/* ==========================================================================
   N Capital — animazioni e interazioni del gestionale
   - entrata morbida di intestazioni, riquadri, statistiche e righe delle tabelle
   - comparsa allo scorrimento (classi nc-pre / nc-in messe dallo script)
   - riquadri che si sollevano al passaggio, luce che segue il mouse, pulsanti "che si premono"
   - barra di avanzamento dello scorrimento e pulsante "torna su"
   Chi ha chiesto meno movimento al sistema (prefers-reduced-motion) vede tutto fermo.
   ========================================================================== */

:root {
  --nc-ease: cubic-bezier(.16, 1, .3, 1);
  --livewire-progress-bar-color: #2f6bf0;
}

@keyframes nc-rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes nc-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes nc-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: no-preference) {
  /* ---------- entrata della pagina ---------- */
  .fi-header { animation: nc-fade-up .6s var(--nc-ease) both; }
  .fi-breadcrumbs { animation: nc-fade .5s ease both; }

  .fi-main .fi-section,
  .fi-main .fi-ta-ctn,
  .fi-main .fi-wi-stats-overview-stat,
  .fi-main .fi-wi-chart,
  .fi-main .nc-hero,
  .fi-main .nc-col,
  .fi-main .fi-tabs { animation: nc-rise .7s var(--nc-ease) both; }

  /* a cascata: un elemento dopo l'altro */
  .fi-main .fi-wi-stats-overview-stat:nth-child(2), .fi-main .nc-col:nth-child(2) { animation-delay: .06s; }
  .fi-main .fi-wi-stats-overview-stat:nth-child(3), .fi-main .nc-col:nth-child(3) { animation-delay: .12s; }
  .fi-main .fi-wi-stats-overview-stat:nth-child(4), .fi-main .nc-col:nth-child(4) { animation-delay: .18s; }
  .fi-main .fi-wi-stats-overview-stat:nth-child(5), .fi-main .nc-col:nth-child(5) { animation-delay: .24s; }
  .fi-main .fi-wi-stats-overview-stat:nth-child(6), .fi-main .nc-col:nth-child(6) { animation-delay: .30s; }
  .fi-main .nc-col:nth-child(n+7) { animation-delay: .36s; }
  .fi-main .fi-section + .fi-section { animation-delay: .08s; }
  /* riquadri dentro altri riquadri: si muove solo quello esterno */
  .fi-main .fi-section .fi-section, .fi-main .fi-section .fi-ta-ctn, .fi-modal .fi-section, .fi-modal .fi-ta-ctn { animation: none; }

  /* righe delle tabelle: compaiono in sequenza (anche dopo ricerca, filtri e cambio pagina) */
  .fi-ta-row { animation: nc-fade-up .45s var(--nc-ease) both; }
  .fi-ta-row:nth-child(2) { animation-delay: .03s; } .fi-ta-row:nth-child(3) { animation-delay: .06s; }
  .fi-ta-row:nth-child(4) { animation-delay: .09s; } .fi-ta-row:nth-child(5) { animation-delay: .12s; }
  .fi-ta-row:nth-child(6) { animation-delay: .15s; } .fi-ta-row:nth-child(7) { animation-delay: .18s; }
  .fi-ta-row:nth-child(8) { animation-delay: .21s; } .fi-ta-row:nth-child(9) { animation-delay: .24s; }
  .fi-ta-row:nth-child(10) { animation-delay: .27s; } .fi-ta-row:nth-child(n+11) { animation-delay: .3s; }

  /* ---------- comparsa allo scorrimento ---------- */
  .nc-pre { animation: none !important; opacity: 0; transform: translateY(32px) scale(.98); filter: blur(6px); }
  .nc-pre.nc-in { opacity: 1; transform: none; filter: none; transition: opacity .9s var(--nc-ease), transform .9s var(--nc-ease), filter .9s var(--nc-ease); transition-delay: var(--nc-d, 0s); }

  /* ---------- riquadri che reagiscono ---------- */
  .fi-wi-stats-overview-stat,
  .nc-card { transition: transform .45s var(--nc-ease), box-shadow .45s var(--nc-ease); }
  html:not(.dark) .fi-wi-stats-overview-stat:hover { box-shadow: 0 2px 4px rgba(10, 26, 74, .04), 0 22px 40px -18px rgba(31, 63, 191, .35); }
  .nc-card:not(.is-dragging):hover { box-shadow: 0 18px 32px -18px rgba(31, 63, 191, .45); }

  /* luce che segue il mouse (variabili --mx/--my messe dallo script) */
  html:not(.dark) .fi-wi-stats-overview-stat.nc-glow,
  html:not(.dark) .fi-section.nc-glow {
    background-image: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(47, 107, 240, .075), transparent 45%);
  }
  .dark .fi-wi-stats-overview-stat.nc-glow,
  .dark .fi-section.nc-glow {
    background-image: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(120, 160, 255, .09), transparent 45%);
  }

  /* pulsanti */
  .fi-btn, .nc-btn, .nc-action, .fi-icon-btn, .fi-tabs-item { transition: transform .25s var(--nc-ease), background-color .2s ease, box-shadow .25s ease, color .2s ease; }
  .fi-btn:active, .nc-btn:active, .nc-action:active, .fi-icon-btn:active, .fi-tabs-item:active { transform: scale(.96); }
  .fi-btn-color-primary:hover { box-shadow: 0 10px 22px -12px rgba(31, 63, 191, .8); transform: translateY(-1px); }

  /* menu laterale: l'icona scivola appena al passaggio */
  .fi-sidebar-item-icon { transition: transform .3s var(--nc-ease); }
  .fi-sidebar-item-button:hover .fi-sidebar-item-icon { transform: translateX(3px) scale(1.06); }

  /* valori delle statistiche che cambiano: piccolo lampo */
  .nc-bump { animation: nc-fade-up .5s var(--nc-ease); }

  /* sezioni aperte/chiuse */
  .fi-section-content-ctn { transition: opacity .3s ease; }

  /* pallino "nuovo" dei badge del menu */
  .fi-sidebar-item .fi-badge { transition: transform .3s var(--nc-ease); }
  .fi-sidebar-item-button:hover .fi-badge { transform: scale(1.1); }
}

/* ---------- righe delle tabelle: evidenziazione al passaggio ---------- */
.fi-ta-row { transition: background-color .2s ease; }
.fi-ta-row > td:first-child { transition: box-shadow .25s ease; }
.fi-ta-row:hover > td:first-child { box-shadow: inset 3px 0 0 var(--nc-brand, #1f3fbf); }
html:not(.dark) .fi-ta-row:hover { background-color: rgba(47, 107, 240, .035); }

/* ---------- barra superiore: ombra quando si scorre ---------- */
.fi-topbar > nav { transition: box-shadow .3s ease; }
html.nc-scrolled:not(.dark) .fi-topbar > nav { box-shadow: 0 10px 30px -18px rgba(10, 26, 74, .35); }

/* ---------- barra di avanzamento dello scorrimento ---------- */
#nc-scroll-bar {
  position: fixed; left: 0; top: 0; z-index: 60; height: 3px; width: 100%;
  background: linear-gradient(90deg, #1f3fbf, #2f6bf0 45%, #0fb487);
  transform-origin: 0 50%; transform: scaleX(0); pointer-events: none;
  opacity: 0; transition: opacity .3s ease;
}
html.nc-scrolled #nc-scroll-bar { opacity: 1; }

/* ---------- torna su ---------- */
#nc-to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #1f3fbf, #0fb487);
  box-shadow: 0 14px 28px -12px rgba(31, 63, 191, .7);
  opacity: 0; transform: translateY(16px) scale(.8); pointer-events: none;
  transition: opacity .35s var(--nc-ease, ease), transform .35s var(--nc-ease, ease);
}
#nc-to-top.on { opacity: 1; transform: none; pointer-events: auto; }
#nc-to-top:hover { transform: translateY(-3px); }
#nc-to-top svg { width: 20px; height: 20px; }
@media (max-width: 1023px) { #nc-to-top { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); } }

/* barra di caricamento tra una pagina e l'altra */
#nprogress .bar { height: 3px !important; background: linear-gradient(90deg, #1f3fbf, #2f6bf0 45%, #0fb487) !important; }
#nprogress .peg { box-shadow: 0 0 12px #2f6bf0, 0 0 6px #0fb487 !important; }

@media print {
  .nc-pre { opacity: 1 !important; transform: none !important; }
  #nc-scroll-bar, #nc-to-top { display: none !important; }
}
