/* daCLOUD — livello "Vivo" e rifiniture del tema
   I fogli di questa cartella si caricano in ordine (numero iniziale): l'ordine conta, i successivi
   rifiniscono i precedenti. */

/* =====================================================================
   1.99.0 — livello "Vivo"
   Più colore e più movimento sopra il livello "Verde vivo" (1.99.0).
   Il verde resta il protagonista (e segue il colore del marchio); quattro
   colori di contorno fissi (sole, cielo, corallo, uva) vivacizzano pallini,
   cerchi decorativi e icone. Non sono mai usati per il testo corrente.
   Solo aspetto: classi, id e markup invariati.
   ===================================================================== */
:root {
    --sun: #f2a93b;   --sun-soft: #fff1d6;   --sun-ink: #7a4800;
    --sky: #2b8cbe;   --sky-soft: #e2f1fa;   --sky-ink: #1b5f84;
    --coral: #e0677a; --coral-soft: #fde8ec;
    --grape: #8e6cc8; --grape-soft: #f0eafb; --grape-ink: #5b3fa0;
}

/* sfondo: due aloni che si muovono lentamente */
body.app-body::before, body.app-body::after {
    content: '';
    position: fixed;
    z-index: -1;
    border-radius: 50%;
    filter: blur(70px);
    pointer-events: none;
    will-change: transform;
}
body.app-body::before { width: 460px; height: 460px; top: -160px; right: -100px; background: var(--green-200); opacity: .55; animation: blob-a 24s ease-in-out infinite alternate; }
body.app-body::after { width: 380px; height: 380px; bottom: -170px; left: 32%; background: var(--sun-soft); opacity: .9; animation: blob-b 28s ease-in-out infinite alternate; }
@keyframes blob-a { to { transform: translate(-140px, 90px) scale(1.15); } }
@keyframes blob-b { to { transform: translate(160px, -70px) scale(1.1); } }

/* titoli */
.page-head h1 {
    background: linear-gradient(90deg, var(--green-900) 0%, var(--green-600) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.topbar-title span { justify-self: start; padding: 1px 8px; border-radius: 999px; background: var(--green-100); color: var(--green-700); }

/* barra laterale: icone menta, pallino sulla voce aperta */
.sidebar-nav a .nav-icon { color: var(--green-300); transition: color .15s ease, transform .2s var(--ease-out); }
.sidebar-nav a:hover .nav-icon { color: #fff; transform: scale(1.08); }
.sidebar-nav a.active .nav-icon { color: var(--green-600); }
.sidebar-nav a.active::after { content: ''; margin-left: auto; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.sidebar-nav a.active:has(.nav-badge)::after { display: none; }
.nav-rail .sidebar-nav a.active::after { display: none; }

/* indicatori: ogni riquadro ha il suo colore */
.metric-card > span:first-child::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    margin-right: 7px;
    vertical-align: 1px;
    border-radius: 50%;
    background: var(--green-500);
}
.metrics-grid > .metric-card:nth-child(5n+1):not(.accent)::after { background: var(--green-100); }
.metrics-grid > .metric-card:nth-child(5n+2)::after { background: var(--sun-soft); }
.metrics-grid > .metric-card:nth-child(5n+2) > span:first-child::before { background: var(--sun); }
.metrics-grid > .metric-card:nth-child(5n+3)::after { background: var(--sky-soft); }
.metrics-grid > .metric-card:nth-child(5n+3) > span:first-child::before { background: var(--sky); }
.metrics-grid > .metric-card:nth-child(5n+4)::after { background: var(--coral-soft); }
.metrics-grid > .metric-card:nth-child(5n+4) > span:first-child::before { background: var(--coral); }
.metrics-grid > .metric-card:nth-child(5n+5)::after { background: var(--grape-soft); }
.metrics-grid > .metric-card:nth-child(5n+5) > span:first-child::before { background: var(--grape); }
.metric-card.accent > span:first-child::before { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }

/* accento in movimento */
.metric-card.accent, .status-pill.primary {
    background: linear-gradient(120deg, var(--green-700), var(--green-500), var(--green-600), var(--green-700));
    background-size: 300% 300%;
    animation: accent-flow 12s ease-in-out infinite;
}
@keyframes accent-flow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* schede: pallino colorato accanto al titolo */
.card-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.card-head h2::before { content: ''; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.dashboard-widgets > .card:nth-child(5n+2) .card-head h2::before, .settings-cards > .card:nth-child(5n+2) .card-head h2::before { background: var(--sun); box-shadow: 0 0 0 3px var(--sun-soft); }
.dashboard-widgets > .card:nth-child(5n+3) .card-head h2::before, .settings-cards > .card:nth-child(5n+3) .card-head h2::before { background: var(--sky); box-shadow: 0 0 0 3px var(--sky-soft); }
.dashboard-widgets > .card:nth-child(5n+4) .card-head h2::before, .settings-cards > .card:nth-child(5n+4) .card-head h2::before { background: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.dashboard-widgets > .card:nth-child(5n+5) .card-head h2::before, .settings-cards > .card:nth-child(5n+5) .card-head h2::before { background: var(--grape); box-shadow: 0 0 0 3px var(--grape-soft); }

/* pulsante principale: riflesso al passaggio */
.btn-primary { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after {
    /* 1.99.0: il riflesso scorre come sfondo dentro il pulsante, senza uscire dai
       suoi bordi (prima un elemento fuori dal pulsante ne allargava l'area di
       scorrimento e i controlli lo segnalavano come testo tagliato) */
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, .38) 50%, transparent 65%) no-repeat;
    background-size: 300% 100%;
    background-position: 100% 0;
    transition: background-position .7s var(--ease-out);
    pointer-events: none;
}
.btn-primary:hover:not(:disabled)::after { background-position: 0% 0; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 24px -10px var(--green-600), inset 0 1px 0 rgba(255, 255, 255, .18); }

/* periodi: scelta con un piccolo rimbalzo */
.tab.active { animation: tab-pop .28s var(--ease-out); }
@keyframes tab-pop { 0% { transform: scale(.9); } 70% { transform: scale(1.04); } 100% { transform: none; } }
.category-chip.active { animation: tab-pop .28s var(--ease-out); }

/* etichette di stato con pallino */
.status-pill.success::before, .status-pill.warning::before, .status-pill.danger::before,
.status-pill.info::before, .status-pill.teal::before, .status-pill.neutral::before { /* 4.3.1: neutral = tipo/categoria, con pallino come gli altri */
    content: '';
    width: 6px; height: 6px;
    flex: none;
    border-radius: 50%;
    background: currentColor;
}

/* tabelle */
thead th { background: var(--green-50); color: var(--green-800); }
tbody tr:hover td { background: var(--green-50); }
tbody tr.clickable:hover td { background: var(--green-100); }
.main-content, .table-wrap, .modal-body, .sidebar-nav, .notification-list { scrollbar-width: thin; }
.main-content, .table-wrap, .modal-body, .notification-list { scrollbar-color: var(--green-200) transparent; }

/* barre di avanzamento che si riempiono */
.progress-fill { transform-origin: left center; animation: fill-in .9s var(--ease-out) both; }
@keyframes fill-in { from { transform: scaleX(0); } }

/* finestre, notifiche, vuoti */
.modal-head { background: linear-gradient(180deg, var(--green-50), var(--surface)); }
.toast::before {
    display: inline-grid;
    place-items: center;
    width: 18px; height: 18px;
    margin-right: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    font-size: 11px;
    font-weight: 800;
    vertical-align: -3px;
}
.toast.success::before { content: '✓'; }
.toast.error::before, .toast.warning::before { content: '!'; }
.empty-icon { animation: soft-bob 3.2s ease-in-out infinite; }
.notification-item.unread .notification-dot { animation: dot-pulse 2.4s ease-in-out infinite; }
@keyframes dot-pulse { 50% { box-shadow: 0 0 0 6px var(--green-100); } }
.notification-item.warning .notification-dot { box-shadow: 0 0 0 3px var(--sun-soft); }
.notification-item.info .notification-dot { box-shadow: 0 0 0 3px var(--sky-soft); }

/* prezzi e schede prodotto */
.product-price { color: var(--green-700); }
.product-tile:hover:not(:disabled) .product-price { color: var(--green-600); }
.inv-metric:nth-child(4n+2) { background: linear-gradient(160deg, var(--surface) 60%, var(--sun-soft)); }
.inv-metric:nth-child(4n+3) { background: linear-gradient(160deg, var(--surface) 60%, var(--sky-soft)); }
.inv-metric:nth-child(4n+4) { background: linear-gradient(160deg, var(--surface) 60%, var(--grape-soft)); }

/* accesso */
.login-visual::after {
    content: '';
    position: absolute;
    right: 8%; top: 38%;
    width: 280px; height: 280px;
    border-radius: 50%;
    background: var(--sun);
    opacity: .16;
    filter: blur(60px);
    pointer-events: none;
    animation: blob-b 22s ease-in-out infinite alternate;
}
.login-card .portal-switch:nth-of-type(2n) .portal-switch-icon { background: var(--sky-soft); color: var(--sky-ink); }
.login-card .portal-switch:nth-of-type(2n+1) .portal-switch-icon { background: var(--sun-soft); color: var(--sun-ink); }
.demo-chip { background: linear-gradient(90deg, var(--green-100), var(--sun-soft)); }

@media (prefers-reduced-motion: reduce) {
    body.app-body::before, body.app-body::after, .login-visual::after, .metric-card.accent, .status-pill.primary,
    .tab.active, .category-chip.active, .progress-fill, .empty-icon, .notification-item.unread .notification-dot { animation: none !important; }
    .btn-primary::after { display: none; }
}
@media print {
    body.app-body::before, body.app-body::after { display: none !important; }
    .page-head h1 { color: var(--ink) !important; background: none !important; }
}


/* ---------------------------------------------------------------------
   1.99.0 — rifiniture finali
   --------------------------------------------------------------------- */
:root { color-scheme: light; }

/* Sui dispositivi a tocco niente spostamenti "da mouse" che restano appesi */
@media (hover: none) {
    .sidebar-nav a:hover, .product-tile:hover:not(:disabled), .portal-switch:hover,
    [data-nav]:hover, .turnstile-card:hover, .btn:hover:not(:active):not(:disabled) { transform: none; }
    .sidebar-nav a:hover .nav-icon { transform: none; }
    .metric-card:hover::after { transform: none; }
    .btn-primary:hover:not(:disabled)::after { background-position: 100% 0; }
}

/* Schermi piccoli: aloni più leggeri (meno lavoro per la grafica) */
@media (max-width: 900px) {
    body.app-body::before, body.app-body::after { animation: none; filter: blur(50px); opacity: .45; }
    .page-head h1 { font-size: var(--text-4xl); }
}

/* Barra laterale: scorrimento sottile anche su Safari/Chrome */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .2); border-radius: 999px; }
.main-content ::-webkit-scrollbar { height: 8px; width: 8px; }
.main-content ::-webkit-scrollbar-thumb { background: var(--green-200); border-radius: 999px; }

/* Numeri sempre allineati nelle colonne e nei riquadri */
.metric-card > strong, .summary-item strong, .kpi-inline strong, td.num, .num { font-variant-numeric: tabular-nums; }

/* Contrasto elevato di sistema (Windows): niente testo trasparente né decorazioni */
@media (forced-colors: active) {
    .page-head h1 { color: CanvasText; background: none; }
    body.app-body::before, body.app-body::after, .metric-card::after, .card-head h2::before,
    .metric-card > span:first-child::before, .sidebar::after, .login-visual::after { display: none; }
    .btn-primary, .tab.active, .sidebar-nav a.active { forced-color-adjust: none; }
}

/* 1.99.0 — i collegamenti dentro un testo restano sottolineati (il redesign li
   distingueva solo per colore: con poco contrasto rispetto al testo non si
   riconoscono, e il controllo di accessibilità lo segnala). */
p a:not(.btn), li a:not(.btn), .modal-body a:not(.btn), .muted a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }

/* 1.99.0 — telefono: filtri e selettori a tutta larghezza (prima restavano
   larghi al massimo 260 px e lasciavano un vuoto a destra). */
@media (max-width: 560px) {
    .filter-bar > .field-inline { flex: 1 1 100%; max-width: none; }
    .filter-bar > .search-box { flex: 1 1 100%; }
    #dashboardStore { flex: 1 1 100%; width: 100%; max-width: none; }
}
