/* =====================================================================
   RistoFlow — Design System "Scirocco"
   Stile Apple · minimal · elegante · bianco · glass leggero
   Light + Dark mode · Desktop-first · Tablet · Mobile
   Palette: Bianco · Nero · Grigio · Rosso Scirocco
   ===================================================================== */

/* ----------------------------- TOKENS ----------------------------- */
:root {
  /* Brand */
  --rosso: #E5322D;
  --rosso-600: #CC2A26;
  --rosso-700: #B01F1C;
  --rosso-soft: #FDECEB;

  /* Neutrali (light) */
  --black: #0A0A0B;
  --ink: #111114;
  --ink-2: #3A3A40;
  --ink-3: #6E6E78;
  --ink-4: #9A9AA5;
  --line: #ECECEF;
  --line-2: #E2E2E7;
  --bg: #F7F7F9;
  --surface: #FFFFFF;
  --surface-2: #FCFCFD;
  --glass: rgba(255,255,255,0.65);
  --glass-border: rgba(255,255,255,0.7);

  /* Stati */
  --green: #2BAE66; --green-soft: #E6F6EE;
  --amber: #E5A82E; --amber-soft: #FBF1DD;
  --blue:  #2D7FF9; --blue-soft: #E7F0FE;
  --gray-state: #8A8A94; --gray-soft: #F0F0F2;

  /* Tipografia */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --fs-xs: 11px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px;
  --fs-xl: 20px; --fs-2xl: 26px; --fs-3xl: 34px;

  /* Raggi */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  /* Ombre morbide (Apple-like) */
  --sh-xs: 0 1px 2px rgba(17,17,20,0.04);
  --sh-sm: 0 2px 8px rgba(17,17,20,0.05);
  --sh-md: 0 8px 24px rgba(17,17,20,0.07);
  --sh-lg: 0 18px 50px rgba(17,17,20,0.10);

  /* Spaziatura */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Layout */
  --sidebar-w: 256px;
  --header-h: 68px;

  /* Motion */
  --ease: cubic-bezier(.22,.61,.36,1);
  --t-fast: .16s; --t: .26s; --t-slow: .4s;
}

[data-theme="dark"] {
  --black: #FFFFFF;
  --ink: #F4F4F6;
  --ink-2: #C9C9D2;
  --ink-3: #9A9AA6;
  --ink-4: #6E6E7A;
  --line: #232327;
  --line-2: #2C2C32;
  --bg: #0C0C0E;
  --surface: #161619;
  --surface-2: #1B1B1F;
  --glass: rgba(22,22,25,0.6);
  --glass-border: rgba(255,255,255,0.06);
  --rosso-soft: #2A1614;
  --green-soft: #122A1E; --amber-soft: #2B2412;
  --blue-soft: #122036; --gray-soft: #1E1E22;
  --sh-xs: 0 1px 2px rgba(0,0,0,0.4);
  --sh-sm: 0 2px 10px rgba(0,0,0,0.45);
  --sh-md: 0 10px 30px rgba(0,0,0,0.5);
  --sh-lg: 0 20px 60px rgba(0,0,0,0.6);
}

/* ----------------------------- BASE ----------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
::selection { background: var(--rosso-soft); color: var(--rosso-700); }

/* Scrollbar discreta */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }

/* ----------------------------- LAYOUT ----------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; padding: var(--sp-5) var(--sp-4);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: var(--sp-2);
  transition: transform var(--t) var(--ease), background var(--t) var(--ease);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3) var(--sp-5); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: #fff url("assets/logo-icon.png") center/86% no-repeat;
  border: 1px solid var(--line);
  display: grid; place-items: center; color: transparent; font-weight: 700; font-size: 0;
  box-shadow: var(--sh-sm);
}
[data-theme="dark"] .brand-mark { background-color: #fff; }
.brand-name { font-weight: 650; font-size: var(--fs-lg); letter-spacing: -.2px; }
.brand-name b { color: var(--rosso); }

.nav-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .8px; color: var(--ink-4); padding: var(--sp-4) var(--sp-3) var(--sp-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3); border-radius: var(--r-md);
  color: var(--ink-2); font-weight: 500; font-size: var(--fs-md);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item svg { width: 18px; height: 18px; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--rosso-soft); color: var(--rosso-700); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
[data-theme="dark"] .nav-item.active { color: #FF6B66; }
.nav-badge { margin-left: auto; font-size: var(--fs-xs); background: var(--rosso); color: #fff; padding: 1px 7px; border-radius: 99px; }

.main { display: flex; flex-direction: column; min-width: 0; }

/* Header glass */
.header {
  position: sticky; top: 0; height: var(--header-h); z-index: 30;
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-8);
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.page-title { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.3px; }
.page-sub { color: var(--ink-3); font-size: var(--fs-sm); }
.header-spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-full); padding: 8px 14px; width: 280px;
  color: var(--ink-3); transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search:focus-within { border-color: var(--rosso); box-shadow: 0 0 0 4px var(--rosso-soft); }
.search input { border: none; outline: none; background: none; color: var(--ink); width: 100%; font-size: var(--fs-md); }
.icon-btn {
  width: 42px; height: 42px; border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--ink-2);
  border: 1px solid var(--line); background: var(--surface);
  transition: background var(--t-fast), transform var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.nav-item { min-height: 42px; }
.avatar { width: 38px; height: 38px; border-radius: var(--r-full); background: linear-gradient(135deg,#3A3A40,#0A0A0B); color:#fff; display:grid; place-items:center; font-weight:600; font-size: var(--fs-sm); }

.content { padding: var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-6); }

/* ----------------------------- COMPONENTI ----------------------------- */

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-xs);
  transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease), border-color var(--t);
}
.card.hover:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.card-pad { padding: var(--sp-6); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.2px; }

/* Griglie */
.grid { display: grid; gap: var(--sp-5); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.col-2 { grid-column: span 2; }

/* Stat card */
.stat { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-6); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; }
.stat-icon.red { background: var(--rosso-soft); color: var(--rosso); }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-label { color: var(--ink-3); font-size: var(--fs-sm); font-weight: 500; }
.stat-value { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -1px; line-height: 1; }
.trend { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; padding: 2px 8px; border-radius: var(--r-full); }
.trend.up { color: var(--green); background: var(--green-soft); }
.trend.down { color: var(--rosso); background: var(--rosso-soft); }

/* Badge / stati */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; padding: 4px 10px; border-radius: var(--r-full); }
.badge::before { content:""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.amber { color: var(--amber); background: var(--amber-soft); }
.badge.red   { color: var(--rosso); background: var(--rosso-soft); }
.badge.blue  { color: var(--blue); background: var(--blue-soft); }
.badge.gray  { color: var(--gray-state); background: var(--gray-soft); }

/* Bottoni */
.btn { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 600; font-size: var(--fs-md); padding: 10px 16px; min-height: 42px; border-radius: var(--r-md); transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast); -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--rosso); color: #fff; box-shadow: var(--sh-sm); }
.btn-primary:hover { background: var(--rosso-600); box-shadow: var(--sh-md); }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: var(--fs-sm); }

/* Tabelle professionali */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.tbl th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .6px; color: var(--ink-4); font-weight: 600; padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--line); }
table.tbl td { padding: 14px var(--sp-5); border-bottom: 1px solid var(--line); color: var(--ink-2); }
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.cell-strong { color: var(--ink); font-weight: 600; }
.cell-people { display: flex; align-items: center; gap: var(--sp-3); }
.mini-avatar { width: 32px; height: 32px; border-radius: 99px; background: var(--gray-soft); color: var(--ink-2); display: grid; place-items: center; font-weight: 600; font-size: var(--fs-sm); }

/* Input */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r-md); padding: 11px 14px; font-size: var(--fs-md); color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--rosso); box-shadow: 0 0 0 4px var(--rosso-soft); background: var(--surface); }

/* Segmented control (vista giorno/settimana/mese) */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; }
.segmented button { padding: 7px 16px; border-radius: 9px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); transition: all var(--t-fast); }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-xs); }
[data-theme="dark"] .segmented button.active { background: var(--line-2); }

/* Toggle dark mode */
.switch { position: relative; width: 48px; height: 26px; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; transition: background var(--t); }
/* icone sole (light) e luna (dark) sulla traccia, per capire la modalità */
.switch .slider::after { position:absolute; top:50%; transform:translateY(-50%); right:6px; content:"☾"; font-size:11px; color:var(--ink-4); line-height:1; }
.switch input:checked + .slider::after { left:7px; right:auto; content:"☀"; color:rgba(255,255,255,.85); }
.switch .slider::before { content:"☀"; display:grid; place-items:center; font-size:11px; color:#E5A82E; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 99px; box-shadow: var(--sh-sm); transition: transform var(--t) var(--ease); z-index:1; }
.switch input:checked + .slider { background: var(--rosso); }
.switch input:checked + .slider::before { transform: translateX(22px); content:"☾"; color:#3A3A40; }

/* Animazioni d'ingresso */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: rise var(--t-slow) var(--ease) both; }
.rise:nth-child(2){ animation-delay:.04s } .rise:nth-child(3){ animation-delay:.08s } .rise:nth-child(4){ animation-delay:.12s }

/* Utility */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.between { justify-content: space-between; }
.muted { color: var(--ink-3); }
.hide-mobile { display: initial; }
.menu-toggle { display: none; }

/* ----------------------------- RESPONSIVE ----------------------------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; width: 256px; transform: translateX(-100%); box-shadow: var(--sh-lg); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .header { padding: 0 var(--sp-5); }
  .search { display: none; }
  .content { padding: var(--sp-5); }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .col-2 { grid-column: auto; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); z-index: 35; opacity: 0; pointer-events: none; transition: opacity var(--t); }
  .scrim.show { opacity: 1; pointer-events: auto; }
}
@media (min-width: 861px) { .scrim { display: none; } }
