/* --- ÉTATS & OVERLAY DE CHARGEMENT --- */

/* Affiche l'overlay quand le widget a la classe .loading */
.main-widget.loading .loading-overlay {
    display: flex !important;
}

.loading-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-card);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.loading-bar {
    position: absolute;
    top: 0; left: 0; height: 3px; width: 100%;
    background: var(--border);
    overflow: hidden;
}

.loading-bar::after {
    content: "";
    position: absolute;
    top: 0; left: 0; height: 100%; width: 30%;
    background: var(--primary);
    animation: progressLoop 1.5s infinite ease-in-out;
}

.bi-spinner {
    width: 45px; height: 45px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes progressLoop { 0% { left: -30%; } 100% { left: 100%; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Barre de calcul (recalculs sans blocage) ────────────────────────────── */

/* Barre invisible par défaut — toujours dans le DOM, pilotée par CSS */
.calculating-bar {
    position: absolute;
    top: 0; left: 0;
    height: 3px;
    width: 100%;
    overflow: hidden;
    opacity: 0;
    /* Entrée lente 1.5s — donne l'impression d'un délai avant apparition */
    transition: opacity 3s ease;
    z-index: 10;
    pointer-events: none;
}

.calculating-bar::after {
    content: "";
    position: absolute;
    top: 0; left: 0;
    height: 100%; width: 30%;
    background: var(--primary);
    /* transform au lieu de left — tourne sur le compositor thread,
       indépendant du main thread JS → ne se fige jamais pendant les calculs */
    animation: calculatingSlide 1.5s infinite ease-in-out;
    animation-play-state: paused;
    will-change: transform;
}

/* Activation quand .calculating est posé sur .main-widget */
.main-widget.calculating .calculating-bar {
    opacity: 1;
}

.main-widget.calculating .calculating-bar::after {
    animation-play-state: running;
}

@keyframes calculatingSlide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(430%); }
}

/* ── Effet visuel pendant le calcul — contenu uniquement ─────────────────── */

/* Transition lente sur le contenu — même délai apparent que la barre */
.view-content-target {
    transition: filter 3s ease, opacity 3s ease;
}

/* Flou + légère opacité pendant .calculating — souris non bloquée */
.main-widget.calculating .view-content-target {
    filter: blur(1.5px);
    opacity: 0.75;
}