/* ════════════════════════════════════════════════════════════
   base.css — Design System v5 · Dark Editorial Luxury
   Palette: Midnight × Electric Blue × Crimson Red
   ════════════════════════════════════════════════════════════ */

:root {
  /* Backgrounds */
  --night:       #07080f;
  --night-2:     #0d0f1c;
  --night-3:     #131628;
  --night-4:     #1a1f38;
  --night-5:     #222844;

  /* Electric Blue */
  --blue:        #3b7cf4;
  --blue-bright: #5b9bff;
  --blue-glow:   rgba(59,124,244,.35);
  --blue-dim:    rgba(59,124,244,.12);
  --blue-text:   #a8c8ff;

  /* Crimson Red */
  --red:         #e8352b;
  --red-bright:  #ff5247;
  --red-glow:    rgba(232,53,43,.35);
  --red-dim:     rgba(232,53,43,.1);
  --red-text:    #ffb3af;

  /* Text */
  --white:       #ffffff;
  --ink:         #c8d4f0;
  --ink-dim:     #5a6a90;
  --ink-bright:  #e8f0ff;

  /* Accent */
  --gold:        #f0c060;
  --gold-dim:    rgba(240,192,96,.15);

  /* Shadows & glows */
  --shadow-sm:   0 2px 12px rgba(0,0,0,.5);
  --shadow-md:   0 8px 40px rgba(0,0,0,.7);
  --shadow-lg:   0 24px 80px rgba(0,0,0,.9);
  --glow-blue:   0 0 30px rgba(59,124,244,.3);
  --glow-red:    0 0 30px rgba(232,53,43,.25);

  /* Typography */
  --display:     'Bebas Neue', 'Impact', sans-serif;
  --serif:       'DM Serif Display', Georgia, serif;
  --sans:        'DM Sans', system-ui, sans-serif;

  /* Geometry */
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   18px;
  --radius-xl:   28px;

  /* Motion */
  --tr:          .2s cubic-bezier(.4,0,.2,1);
  --tr-spring:   .35s cubic-bezier(.34,1.56,.64,1);

  /* Layout */
  --sidebar-w:   260px;
  --topbar-h:    64px;
  --mobile-nav-h:70px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  /* Previene overflow orizzontale su mobile */
  overflow-x: hidden;
  max-width: 100%;
}
body {
  font-family: var(--sans);
  background: var(--night);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Previene overflow orizzontale su mobile */
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

/* ── Ambient background glow ─────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 10% 5%,  rgba(59,124,244,.08)  0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 92% 92%, rgba(232,53,43,.06)   0%, transparent 55%);
}
body > * { position: relative; z-index: 1; }

/* ── Keyframes ───────────────────────────────────────────── */
@keyframes fadeUp   { from { opacity:0; transform:translateY(14px)} to { opacity:1; transform:none} }
@keyframes fadeIn   { from { opacity:0; transform:translateY(8px) } to { opacity:1; transform:none} }
@keyframes modalIn  { from { opacity:0; transform:scale(.93) translateY(16px)} to { opacity:1; transform:none} }
@keyframes sheetUp  { from { transform:translateY(100%) } to { transform:translateY(0) } }
@keyframes spin     { to   { transform:rotate(360deg) } }
@keyframes shimmer  { 0% { background-position:-200% 0 } 100% { background-position:200% 0 } }
@keyframes nav-pop  { 0% { transform:scale(.7) translateY(6px); opacity:0 } 60% { transform:scale(1.1) } 100% { transform:scale(1); opacity:1 } }

/* ── App shell visibility ────────────────────────────────── */
#auth-page { display:none; }
#app-shell { display:none; }
#auth-page.visible { display:flex; min-height:100vh; }
#app-shell.visible { display:flex; min-height:100vh; }

/* ── Pages ───────────────────────────────────────────────── */
.page { display:none; }
.page.active { display:block; animation:fadeUp .3s var(--tr); }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display:flex; align-items:flex-end; justify-content:space-between;
  margin-bottom:2rem; padding-bottom:1.4rem;
  border-bottom:1px solid var(--night-3);
  position:relative;
}
.page-header::after {
  content:''; position:absolute; bottom:-1px; left:0;
  width:56px; height:2px;
  background:linear-gradient(90deg, var(--blue), var(--red));
  border-radius:1px;
}
.page-header h2 {
  font-family:var(--display);
  font-size:2.8rem; letter-spacing:.06em; line-height:1;
  color:var(--white);
  text-shadow:0 0 40px rgba(59,124,244,.2);
}
.page-header p { color:var(--ink-dim); font-size:.82rem; margin-top:.4rem; font-weight:300; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width:32px; height:32px;
  border:2px solid var(--night-3);
  border-top-color:var(--blue);
  border-radius:50%;
  animation:spin .7s linear infinite;
  margin:3rem auto;
  box-shadow:0 0 12px var(--blue-glow);
}

/* ── Empty state ─────────────────────────────────────────── */
.empty { text-align:center; padding:5rem 2rem; color:var(--ink-dim); }
.empty-icon {
  width:72px; height:72px; border-radius:50%;
  background:var(--night-3); border:1px solid var(--night-4);
  display:flex; align-items:center; justify-content:center;
  margin:0 auto 1.4rem;
}
.empty-icon svg { opacity:.35; }
.empty h3 { font-family:var(--serif); font-size:1.4rem; color:var(--ink); margin-bottom:.5rem; }
.empty p { font-size:.875rem; font-weight:300; }

/* ── Toast ───────────────────────────────────────────────── */
#toast {
  position:fixed; bottom:1.8rem; right:1.8rem;
  background:var(--night-2);
  color:var(--ink-bright);
  padding:.9rem 1.4rem .9rem 1rem;
  border-radius:var(--radius);
  font-size:.875rem; font-weight:500;
  z-index:9999;
  transform:translateY(100px) scale(.95); opacity:0;
  transition:all .3s cubic-bezier(.34,1.4,.64,1);
  border:1px solid var(--night-4);
  border-left:3px solid var(--blue);
  box-shadow:var(--shadow-lg), var(--glow-blue);
  max-width:340px;
  display:flex; align-items:center; gap:.75rem;
  backdrop-filter:blur(24px);
}
#toast::before {
  content:'✓';
  width:22px; height:22px; border-radius:50%;
  background:var(--blue-dim); color:var(--blue-bright);
  font-size:.75rem; font-weight:700;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
#toast.show { transform:translateY(0) scale(1); opacity:1; }
#toast.err  { border-left-color:var(--red); box-shadow:var(--shadow-lg),var(--glow-red); }
#toast.err::before { background:var(--red-dim); color:var(--red-bright); content:'✕'; }

@media(max-width:768px) {
  #toast { bottom:calc(var(--mobile-nav-h) + .8rem); right:.8rem; left:.8rem; max-width:none; }
}

/* ── Fix overflow orizzontale mobile ─────────────────────── */
@media(max-width:768px) {
  html, body { overflow-x:hidden; max-width:100vw; }
  #main, #content, .page { overflow-x:hidden; max-width:100%; }
  .page-header { flex-wrap:wrap; gap:.6rem; }
  .page-header h2 { font-size:2rem; }
  .page-header > div:last-child { flex-shrink:0; }
  .form-grid  { grid-template-columns:1fr !important; }
  .detail-grid { grid-template-columns:1fr !important; }
}