/**
 * ISORS Manager — animazioni
 * Movimenti brevi e morbidi. Chi ha attivato "riduci movimento" nel sistema
 * operativo non li vede (blocco in fondo al file).
 */

:root {
    --curva-uscita: cubic-bezier(.2, .8, .2, 1);
    --curva-molla: cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes sali       { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes appari     { from { opacity: 0; } to { opacity: 1; } }
@keyframes ingrandisci{ from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes scorri-sx  { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes luccichio  { from { background-position: -460px 0; } to { background-position: 460px 0; } }
@keyframes campanella {
    0%, 100% { transform: rotate(0); }
    15% { transform: rotate(16deg); } 30% { transform: rotate(-14deg); }
    45% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(3deg); }
}
@keyframes pulsa      { 0% { box-shadow: 0 0 0 0 rgba(196,50,74,.45); } 70% { box-shadow: 0 0 0 8px rgba(196,50,74,0); } 100% { box-shadow: 0 0 0 0 rgba(196,50,74,0); } }
@keyframes onda       { to { transform: scale(2.6); opacity: 0; } }
@keyframes carica     { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes galleggia  { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes gradiente  { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* ── Ingresso della pagina ─────────────────────────────────── */
.contenuto > *:not(.modal):not(script):not(style) { animation: sali .5s var(--curva-uscita) both; }
.contenuto > *:nth-child(2) { animation-delay: .04s; }
.contenuto > *:nth-child(3) { animation-delay: .08s; }
.contenuto > *:nth-child(n+4) { animation-delay: .12s; }

/* Elementi in sequenza: interfaccia.js imposta --i su schede e righe */
.anim-sequenza { animation: ingrandisci .45s var(--curva-uscita) both; animation-delay: calc(var(--i, 0) * 45ms + 80ms); }
.anim-riga { animation: scorri-sx .35s var(--curva-uscita) both; animation-delay: calc(var(--i, 0) * 22ms); }

/* Comparsa allo scorrimento */
.anim-scorri { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--curva-uscita), transform .6s var(--curva-uscita); }
.anim-scorri.visibile { opacity: 1; transform: none; }

/* ── Barra superiore e menu ────────────────────────────────── */
.sidebar .nav-link.active::before { animation: appari .3s ease both; }
.nav-conteggio, .topbar-badge { animation: pulsa 2s ease-out 1s 2; }

/* Menu a tendina: si aprono con una piccola caduta */
.dropdown-menu.show { animation: ingrandisci .18s var(--curva-uscita); transform-origin: top right; }

/* ── Barra di caricamento in cima ──────────────────────────── */
.barra-caricamento {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000;
    pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .3s;
}
.barra-caricamento::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, var(--blu-500), var(--accento), transparent);
}
.barra-caricamento.attiva { opacity: 1; }
.barra-caricamento.attiva::after { animation: carica 1.1s ease-in-out infinite; }

/* ── Effetto onda sui pulsanti ─────────────────────────────── */
.onda {
    position: absolute; border-radius: 50%; pointer-events: none;
    width: 40px; height: 40px; margin: -20px 0 0 -20px;
    background: currentColor; opacity: .25; transform: scale(0);
    animation: onda .55s ease-out forwards;
}

/* ── Finestre modali ───────────────────────────────────────── */
.modal.fade .modal-dialog { transform: translateY(18px) scale(.97) !important; opacity: 0; transition: transform .28s var(--curva-uscita), opacity .22s ease !important; }
.modal.show .modal-dialog { transform: none !important; opacity: 1; }
.modal-backdrop.fade { transition: opacity .25s ease; }

/* ── Segnaposto durante il caricamento ─────────────────────── */
.scheletro, .contenuto td.text-center.text-muted:only-child:has(.spinner-border) {
    background: linear-gradient(90deg, var(--superficie-2) 0px, var(--linea) 160px, var(--superficie-2) 320px);
    background-size: 920px 100%;
    animation: luccichio 1.3s linear infinite;
    border-radius: 8px;
}
.spinner-border { border-width: .18em; animation-duration: .9s; }

/* ── Avvisi e notifiche ────────────────────────────────────── */
.contenuto .alert { animation: ingrandisci .35s var(--curva-uscita) both; }
.toast.show, .toast.showing { animation: ingrandisci .3s var(--curva-uscita); }

/* ── Numeri e icone ────────────────────────────────────────── */
.contenuto .stats-icon-box { transition: transform .3s var(--curva-molla); }
.contenuto a:hover .stats-icon-box, .contenuto .stats-card:hover .stats-icon-box { transform: scale(1.08) rotate(-4deg); }
.contenuto .form-check-input { transition: background-color .15s, border-color .15s, transform .15s var(--curva-molla); }
.contenuto .form-check-input:checked { transform: scale(1.06); }

/* Linguette: indicatore che scivola */
.contenuto .nav-tabs .nav-link { position: relative; }
.tab-pane.fade.show { animation: sali .35s var(--curva-uscita); }

/* Intestazione della dashboard */
.eroe { background-size: 160% 160%; animation: gradiente 16s ease infinite, sali .55s var(--curva-uscita) both; }
.eroe::after { animation: galleggia 9s ease-in-out infinite; }

/* Menu a scomparsa: le voci entrano una dopo l'altra */
.menu-aperto .sidebar .nav-item { animation: scorri-sx .35s var(--curva-uscita) both; animation-delay: calc(var(--i, 0) * 25ms + 60ms); }

/* ── Riduci movimento ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
    .anim-scorri { opacity: 1; transform: none; }
}
