/* TurboFattura — Page Flow v3 (TF-FLOW-2026-04-29-v3)
 *
 * SOLUZIONE FLUIDITÀ DEFINITIVA:
 * - Sidebar IMMOBILE (anti-flash desktop)
 * - bg-color body uniforme (no flash white)
 * - Main fade-in opacity-only (testo fermo)
 * - Cross-fade out durante navigation (con tf-flow.js)
 * - Loading bar amber 2px al click
 */

/* 1. ANTI-FLASH SIDEBAR */
@media (min-width: 1024px) {
    #ap-sidebar {
        transform: none !important;
        -webkit-transform: none !important;
        transition: none !important;
    }
    #ap-sidebar.transition-transform {
        transition-property: none !important;
    }
}

/* 1c. UNIFORM LOCKED STATE — voci plan-locked (data-locked) come feature-locked */
/* Stessa logica delle voci feature-gated (Report/Conservazione/Team): opacity 0.4 + no-click */
#ap-sidebar a[data-locked="1"] {
    opacity: 0.4 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
}

/* 1b. NUCLEAR ANTI-FLASH: body opacity 0 finché DOMContentLoaded → tf-flow-ready */
/* INSTANT ready (no fade transition) — il fade del body veniva percepito come flash */
html:not(.tf-flow-ready) body {
    opacity: 0;
}
html.tf-flow-ready body {
    opacity: 1;
    /* NO transition: body diventa visibile ISTANTANEAMENTE, niente fade percepibile */
}
/* Fallback safety: dopo 1.5s mostra comunque (per browser senza JS) */
@keyframes tf-flow-body-safety { to { opacity: 1; } }
html:not(.tf-flow-ready) body {
    animation: tf-flow-body-safety 0s linear 1500ms forwards;
}

/* 2. BG-COLOR UNIFORME (no flash white durante navigation) */
html, body {
    background-color: #f8fafc !important; /* slate-50 - identico in tutte le pagine */
}
:root[data-theme="dark"] body,
.cc-root.dark {
    background-color: #0f172a !important;
}

/* 3. MAIN: NO FADE-IN (era percepito come flash) */
/* Body opacity:0→1 instant al tf-flow-ready basta a nascondere i flicker */
@keyframes pageIn { from { opacity: 1; } to { opacity: 1; } }
@keyframes tf-flow-fadein { from { opacity: 1; } to { opacity: 1; } }
main {
    animation: none !important;
    opacity: 1 !important;
}

/* 4. CROSS-FADE OUT al click - DISABILITATO (causa flash percepito) */
main.tf-leaving {
    opacity: 1 !important;
}

/* 5. LOADING BAR amber 2px (top, sopra tutto) */
#tf-flow-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, #f59e0b 0%, #fb923c 100%);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 99999;
    pointer-events: none;
    will-change: transform, opacity;
    opacity: 0;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}
#tf-flow-bar.tf-flow-bar-active {
    opacity: 1;
    transition: transform 8s cubic-bezier(0.1, 0.4, 0.2, 1);
    transform: scaleX(0.92);
}
#tf-flow-bar.tf-flow-bar-done {
    opacity: 0;
    transform: scaleX(1);
    transition: transform 200ms ease-out, opacity 250ms ease-out 100ms;
}

/* 6. OVERRIDE PER-PAGE ANIMATIONS — disabilitate completamente */
/* Tutti gli element pageload-animated diventano statici (no fade, no slide, no scale) */
.text-2xl,
.text-3xl,
#settings-grid,
.imp-section,
.fb-star,
.settings-card,
/* V108: Skip cc-w from override quando smart layout è attivo */
/* nota: gli override seguenti NON includono .cc-w → smart-pulse + sortable funzionano */
.cc-w-head,
.cc-w-body,
.cc-enter,
.kpi-card,
.kpi-value-big,
.kpi-value,
.anim-fade-up,
.anim-count,
.anim-slide-r,
.anim-progress,
[class*="cardEnter"],
[class*="slideIn"],
[class*="fadeIn"],
[class*="cardEntry"] {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
}

/* SVG icone status: solo opacity stable (no shake/wiggle/pop iniziali) */
@keyframes pbShake { 0%, 100% { transform: none; } }
@keyframes pbWiggle { 0%, 100% { transform: none; } }
@keyframes pbPop { from { opacity: 1; } to { opacity: 1; } }
@keyframes pbHourglass { 0%, 100% { transform: none; } }
@keyframes pbPlaneFly { 0%, 100% { transform: none; } }

/* 7. REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    main, main.tf-leaving { animation: none !important; transition: none !important; opacity: 1 !important; }
    #tf-flow-bar { transition: none !important; }
}
