/* ══════════════════════════════════════════════════════
   style.css — Turni App
   Design pulito, professionale, mobile-first
   ══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* inter-regular - greek_greek-ext_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/inter-v20-greek_greek-ext_latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* inter-500 - greek_greek-ext_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/inter-v20-greek_greek-ext_latin-500.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* inter-600 - greek_greek-ext_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  src: url('../fonts/inter-v20-greek_greek-ext_latin-600.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* inter-700 - greek_greek-ext_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/inter-v20-greek_greek-ext_latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* inter-800 - greek_greek-ext_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  src: url('../fonts/inter-v20-greek_greek-ext_latin-800.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* syne-regular - greek_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Syne';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/syne-v24-greek_latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* syne-700 - greek_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Syne';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/syne-v24-greek_latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* syne-800 - greek_latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Syne';
  font-style: normal;
  font-weight: 800;
  src: url('../fonts/syne-v24-greek_latin-800.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

:root {
  --bg:         #f5f6fa;
  --surface:    #ffffff;
  --surface2:   #f0f1f6;
  --primary:    #4f6ef7;
  --primary-d:  #3a57e8;
  --primary-dim:rgba(79,110,247,0.1);
  --green:      #22c55e;
  --green-dim:  rgba(34,197,94,0.1);
  --orange:     #f59e0b;
  --orange-dim: rgba(245,158,11,0.1);
  --red:        #ef4444;
  --red-dim:    rgba(239,68,68,0.1);
  --text:       #1a1d2e;
  --text2:      #6b7280;
  --border:     #eef0f5; /* Un grigio ancora più delicato per le righe interne */
  --radius:     16px;    /* Più rotondo e moderno */
  --shadow:     0 8px 30px rgba(0,0,0,0.04); /* Ombra premium e diffusa */
  --shadow-md:  0 12px 40px rgba(0,0,0,0.06);
  --touch:      44px;
}

html, body {
  min-height: 100vh;
  display: flex;             /* Trasforma il body in un contenitore flessibile */
  flex-direction: column;    /* Impila gli elementi verticalmente */
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* ── LAYOUT ── */
.container {
  flex: 1;                   /* Dichiara che questo blocco deve occupare tutto lo spazio vuoto, spingendo il footer in basso */
  width: 100%;               
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── NAV ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  padding: 0 1rem;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.navbar-brand {
  font-family: 'Syne', sans-serif; /* Applica il font della landing page */
  font-size: 1.3rem; 
  font-weight: 800;
  color: var(--primary); 
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.navbar-brand span { font-size: 1.3rem; }
.navbar-right { display: flex; align-items: center; gap: 12px; }
.navbar-user {
  font-size: 0.82rem; color: var(--text2); font-weight: 500;
}
.btn-logout {
  font-size: 0.78rem; font-weight: 500; color: var(--text2);
  background: none; border: 1px solid var(--border);
  padding: 0.35rem 0.85rem; border-radius: 6px;
  cursor: pointer; transition: all 0.15s;
}
.btn-logout:hover { background: var(--bg); color: var(--red); border-color: var(--red); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--touch); padding: 0 1.25rem;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  touch-action: manipulation; white-space: nowrap;
  text-decoration: none;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-outline  { background: none; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-dim); }
.btn-danger   { background: var(--red-dim); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-sm { height: 34px; padding: 0 0.85rem; font-size: 0.78rem; border-radius: 6px; }
.btn-full { width: 100%; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* ── FORM ── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; margin-bottom: 0.4rem;
  font-size: 0.82rem; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-input, .form-select {
  width: 100%; height: var(--touch);
  padding: 0 0.9rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 0.95rem;
  outline: none; transition: border-color 0.15s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-input::placeholder { color: #b0b5c0; }
.form-error { font-size: 0.78rem; color: var(--red); margin-top: 0.3rem; display: none; }
.form-error.show { display: block; }

/* ── BADGE ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.3px;
  padding: 2px 8px; border-radius: 20px;
}
.badge-green   { background: var(--green-dim);  color: #16a34a; }
.badge-orange  { background: var(--orange-dim); color: #d97706; }
.badge-primary { background: var(--primary-dim);color: var(--primary); }
.badge-red     { background: var(--red-dim);    color: var(--red); }

/* ── AUTH PAGE ── */
.auth-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f6fa 100%);
}
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2rem;
}
.auth-logo {
  text-align: center; margin-bottom: 1.75rem;
}
.auth-logo-icon {
  font-size: 2.5rem; display: block; margin-bottom: 0.5rem;
}
.auth-logo h1 { font-size: 1.4rem; color: var(--text); }
.auth-logo p  { font-size: 0.85rem; color: var(--text2); margin-top: 0.25rem; }
.auth-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1; padding: 0.6rem; text-align: center;
  font-size: 0.85rem; font-weight: 600; color: var(--text2);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all 0.15s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-panel { display: none; }
.auth-panel.active { display: block; }
.auth-switch {
  text-align: center; margin-top: 1rem;
  font-size: 0.82rem; color: var(--text2);
}
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ── DASHBOARD LAYOUT ── */
.page-header {
  padding: 1.25rem 0 1rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
}
.page-header h1 { font-size: 1.3rem; }

.card {
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.02);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.stats-row {
  display: flex;
  justify-content: center; /* Centra i 3 quadrati in mezzo alla pagina */
  align-items: center;
  gap: 1.5rem;             /* Spazio tra un quadrato e l'altro */
  margin-bottom: 2rem;
}

.stat-card {
  width: 140px;            /* Larghezza fissa */
  height: 140px;           /* Altezza fissa = Quadrato perfetto */
  border: none;
  border-radius: var(--radius); 
  padding: 1.25rem;
  display: flex; 
  flex-direction: column; 
  justify-content: center; /* Centra il testo verticalmente */
  align-items: center;     /* Centra il testo orizzontalmente */
  text-align: center;
  transition: transform 0.2s ease;
}
.stat-card:hover { transform: translateY(-3px); }

.stat-card .stat-label { 
  font-size: 0.72rem; 
  font-weight: 700; 
  color: var(--text2); 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
}
.stat-card .stat-value { 
  font-size: 2.2rem;       /* Numero bello grande in mezzo al quadrato */
  font-weight: 800; 
  line-height: 1; 
  margin-top: 5px;
}

/* Colori dei quadrati */
.stat-card.primary { background: var(--primary-dim); }
.stat-card.primary .stat-value { color: var(--primary); }

.stat-card.green   { background: var(--green-dim); }
.stat-card.green .stat-value { color: var(--green); }

.stat-card.orange  { background: var(--orange-dim); }
.stat-card.orange .stat-value { color: var(--orange); }

/* Bottoni ‹ › */
/* ── NAVIGAZIONE SETTIMANA (Date e Pulsanti AI centrati) ── */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: nowrap; /* Desktop: tutto su una riga */
}
/* Desktop: il bottone Oggi con margin-left:auto spinge i 3 bottoni a destra */
.week-nav button[style*="margin-left"] {
  margin-left: auto !important;
}
.week-nav .week-label {
  font-weight: 600; 
  font-size: 0.9rem;
  text-align: center; 
  min-width: 130px;
  flex: none; /* Rimuove l'espansione invisibile che teneva separati i bottoni */
}
.week-nav button:first-child,
.week-nav button:nth-child(3) {
  width: 44px;           /* Aumentata la larghezza per renderli quadrati perfetti */
  height: 44px;          /* Aumentata l'altezza per pareggiarli agli altri pulsanti */
  font-size: 1.6rem;     /* Freccia più grande e proporzionata */
  border-radius: 10px;   /* Angoli leggermente più morbidi in linea col nuovo design */
  flex-shrink: 0;
}
/* ── CALENDARIO TURNI ── */
.calendario {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto; /* Abilita lo scroll orizzontale su mobile */
  -webkit-overflow-scrolling: touch; /* Rende lo scroll fluido su iPhone */
  margin-bottom: 1.5rem;
}
.cal-header {
  display: grid; grid-template-columns: 100px repeat(7, 1fr);
  background: var(--surface2); border-bottom: 1px solid var(--border);
  min-width: 750px; /* Forza una larghezza minima per evitare lo schiacciamento */
}
.cal-row {
  display: grid; grid-template-columns: 100px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
  min-width: 750px; /* Stessa larghezza dell'header */
}
.cal-header-cell {
  padding: 0.6rem 0.5rem; text-align: center;
  font-size: 0.72rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.cal-header-cell.oggi { color: var(--primary); }

.cal-row:last-child { border-bottom: none; }
.cal-dipendente {
  padding: 0.5rem; display: flex; align-items: flex-start;
  gap: 6px; border-right: 1px solid var(--border);
  background: var(--surface2);
  /* NUOVO: Blocca la colonna a sinistra */
  position: sticky;
  left: 0;
  z-index: 10;
}

/* NUOVO: Blocca anche la cella vuota in alto a sinistra */
.cal-header-cell:first-child {
  position: sticky;
  left: 0;
  z-index: 11;
  background: var(--surface2);
  border-right: 1px solid var(--border);
}
.cal-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: #fff;
}
.cal-nome { font-size: 0.72rem; font-weight: 600; line-height: 1.3; word-break: break-word; }
.cal-cell {
  padding: 4px; border-right: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
  position: relative; min-height: 60px;
  min-width: 0;      /* permette alla colonna di restare a 1fr invece di allargarsi col contenuto */
  overflow: hidden;  /* il testo lungo viene tagliato dalla cella, non sfora il calendario */
}
.cal-cell:last-child { border-right: none; }
.cal-cell:hover { background: var(--primary-dim); }
.cal-cell.oggi-col { background: rgba(79,110,247,0.03); }

.turno-chip {
  background: var(--primary-dim); border: 1px solid var(--primary);
  border-radius: 5px; padding: 2px 5px; margin-bottom: 2px;
  cursor: pointer; transition: all 0.15s;
  min-width: 0; overflow: hidden; /* tiene il contenuto dentro la cella */
}
.turno-chip .tc-ore { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turno-chip:hover { background: var(--primary); color: #fff; }
.turno-chip .tc-ore  { font-size: 0.68rem; font-weight: 700; color: var(--primary); }
.turno-chip:hover .tc-ore { color: #fff; }
.turno-chip .tc-ruolo { font-size: 0.6rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turno-chip:hover .tc-ruolo { color: rgba(255,255,255,0.85); }
.turno-chip.confermato { background: var(--green-dim); border-color: var(--green); }
.turno-chip.confermato .tc-ore { color: var(--green); }
.turno-chip.confermato:hover { background: var(--green); }

/* ── LISTA TURNI (vista dipendente) ── */
.turni-list { display: flex; flex-direction: column; gap: 10px; }
.turno-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow);
}
.turno-data-box {
  flex-shrink: 0; text-align: center; width: 52px;
  background: var(--primary-dim); border-radius: 8px; padding: 6px 4px;
}
.turno-data-box .giorno-num { font-size: 1.3rem; font-weight: 700; color: var(--primary); line-height: 1; }
.turno-data-box .giorno-nome { font-size: 0.62rem; font-weight: 700; color: var(--primary); text-transform: uppercase; }
.turno-info { flex: 1; min-width: 0; } /* min-width:0 permette al testo di andare a capo invece di allargare la card */
.turno-ore  { font-weight: 700; font-size: 1rem; }
.turno-ruolo { font-size: 0.8rem; color: var(--text2); overflow-wrap: break-word; word-break: break-word; }
.turno-note  { font-size: 0.75rem; color: var(--text2); font-style: italic; margin-top: 2px; overflow-wrap: break-word; word-break: break-word; }
.turno-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── TEAM ── */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 1rem;
  display: flex; align-items: center; gap: 12px;
}
.team-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; font-weight: 700; color: #fff;
}
.team-info { flex: 1; }
.team-nome  { font-weight: 600; font-size: 0.95rem; }
.team-email { font-size: 0.78rem; color: var(--text2); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
  display: none;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
.modal-box {
  background: var(--surface); border-radius: 14px;
  padding: 1.5rem; width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 1.05rem; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: var(--surface2);
  cursor: pointer; font-size: 1rem; display: flex;
  align-items: center; justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--red-dim); color: var(--red); }
.modal-footer { margin-top: 1.25rem; display: flex; gap: 8px; justify-content: flex-end; }

/* ── CODICE INVITO ── */
.invito-box {
  background: var(--primary-dim); border: 1.5px dashed var(--primary);
  border-radius: var(--radius); padding: 1rem;
  text-align: center; margin-bottom: 1.5rem;
}
.invito-label { font-size: 0.72rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; }
.invito-code  { font-size: 2rem; font-weight: 800; letter-spacing: 8px; color: var(--primary); margin: 4px 0; }
.invito-sub   { font-size: 0.78rem; color: var(--text2); }

/* ── RICHIESTE ── */
.richiesta-row {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius); padding: 0.9rem 1rem;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.richiesta-info { flex: 1; }
.richiesta-nome { font-weight: 600; font-size: 0.9rem; }
.richiesta-det  { font-size: 0.78rem; color: var(--text2); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1d2e; color: #fff;
  padding: 0.65rem 1.25rem; border-radius: 8px;
  font-size: 0.85rem; font-weight: 500;
  opacity: 0; transition: all 0.3s; z-index: 300;
  white-space: nowrap; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── EMPTY STATE ── */
.empty {
  text-align: center; padding: 2.5rem 1rem; color: var(--text2);
}
.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; opacity: 0.5; }
.empty p    { font-size: 0.88rem; }

/* ── TABS (Barra principale centrata) ── */
.tabs {
  display: flex;
  justify-content: center;    /* Centra i bottoni al suo interno */
  width: fit-content;         /* Fa restringere il box alla dimensione esatta dei bottoni */
  max-width: 100%;
  margin: 0 auto 1.5rem auto; /* Centra l'intero blocco in mezzo allo schermo */
  background: var(--surface2);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.tab {
  padding: 0.6rem 1.25rem; 
  font-size: 0.88rem; 
  font-weight: 600; 
  color: var(--text2);
  cursor: pointer; 
  border-radius: 8px; 
  border-bottom: none; 
  transition: all 0.2s ease; 
}
.tab:hover { color: var(--text); }
.tab.active { 
  background: var(--surface); 
  color: var(--primary); 
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
}

/* ── BANNER COOKIE ── */
.cookie-banner {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1000;
  background: #1a1d2e;
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom)); /* Evita la barra inferiore di iOS */
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.cookie-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.cookie-text {
  flex: 1;
  font-size: 0.82rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.85);
  margin: 0;
}

.cookie-text a {
  color: #60a5fa;
  text-decoration: underline;
  font-weight: 600;
  margin: 0 0.2rem;
}

.cookie-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

/* Modifica per smartphone */
@media (max-width: 640px) {
  .cookie-container {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
  .cookie-btn {
    width: 100%;
    padding: 0.8rem;
  }
}

/* ── ANIMAZIONI ── */
@keyframes fadeIn  { from { opacity: 0; }              to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  /* Box statistiche */
 .stats-row { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 0.5rem; 
    margin-bottom: 1.5rem;
  }
  .stat-card { 
    width: auto; 
    height: auto; 
    aspect-ratio: 1 / 1; /* Mantiene la forma quadrata proporzionalmente */
    padding: 0.5rem; 
  }
  .stat-card .stat-label { font-size: 0.55rem; }
  .stat-card .stat-value { font-size: 1.5rem; }

  /* Intestazione */
  .page-header           { flex-direction: column; align-items: flex-start; padding-bottom: 0.5rem; gap: 1rem; }
  h1                     { font-size: 1.3rem; }

  /* Navigazione settimane: riga 1 = frecce+data, riga 2 = 3 bottoni */
.week-nav {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100%;
  }
  
  /* Trucco CSS: elemento fantasma per forzare l'andata a capo DOPO le frecce */
  .week-nav::after {
    content: "";
    flex-basis: 100%;
    order: 3;
  }
  
  /* Riga 1: Freccia SX, Data, Freccia DX */
  .week-nav button:first-child { order: 1; flex: 0 0 44px !important; }
  .week-nav .week-label        { order: 2; flex: 1 1 0 !important; text-align: center; }
  .week-nav button:nth-child(3){ order: 2; flex: 0 0 44px !important; }
  
  /* Riga 2: I tre bottoni si dividono lo spazio esattamente al 33% */
  .week-btn {
    order: 4 !important;
    flex: 1 1 0 !important; /* Si prendono 1 frazione di spazio ciascuno */
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 2px !important; /* Margini ridotti al minimo per farli entrare */
    font-size: 0.75rem !important; /* Font leggermente più piccolo */
    justify-content: center !important;
  }
    /* Forza l'andata a capo: frecce+label occupano tutta la prima riga */
  .week-nav button:first-child { order: 1; }
  .week-nav .week-label        { order: 2; }
  .week-nav button:nth-child(3){ order: 3; }
  .week-btn                    { order: 4; }

  /* Sezione "Codice invito": su mobile i 3 bottoni vanno a capo invece di strabordare */
  .invito-actions {
    flex-wrap: wrap;
  }
  .invito-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0 !important; /* azzera il margin-left:auto inline che spingeva "Rigenera" fuori dallo schermo */
  }

/* Tab menu navigabili con swipe (RIPARATO) */
  .tabs { 
    display: flex !important;          /* Forza il flex standard per bloccare la larghezza allo schermo */
    width: 100%; 
    max-width: 100%;                   /* Impedisce fisicamente di strabordare */
    overflow-x: auto;                  /* Attiva lo scorrimento orizzontale */
    white-space: nowrap; 
    flex-wrap: nowrap;                 /* Impedisce alle tab di andare a capo */
    -webkit-overflow-scrolling: touch; /* Rende lo scorrimento fluidissimo su iPhone/iOS */
    padding: 6px 4px;                  /* Spazio protettivo per non tagliare l'ombra della pillola attiva */
    border-radius: 12px;
  }
  
  .tabs::-webkit-scrollbar { 
    display: none;                     /* Nasconde la barra di scorrimento visiva per un look pulito */
  }
  
  .tab { 
    padding: 0.6rem 1rem; 
    flex-shrink: 0;
  }
  /* Guida nascosta su mobile, nome utente nascosto */
  .btn-guida-desktop { display: none !important; }
/* ── 1. FIX NAVBAR (Evita tagli e risolve i click bloccati) ── */
  .navbar {
    padding: 0 0.5rem;
  }
  
  .navbar-brand {
    font-size: 1.1rem;
    min-width: 0;
    max-width: 50%; /* abbastanza largo da mostrare "TurniApp" per intero, senza coprire i bottoni (navbar-right è flex-shrink:0) */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .navbar-brand span {
    display: none; 
  }
  
  .navbar-right {
    gap: 4px;
    flex-shrink: 0;
    position: relative; 
    z-index: 50; /* IMPORTANTE: porta i bottoni in primo piano */
  }
  
  .btn-logout {
    padding: 0.35rem 0.5rem; 
    font-size: 0.75rem;
  }
  
  .navbar-user { 
    display: none !important; 
  }

  #lang-switcher {
    position: relative;
    z-index: 60; /* IMPORTANTE: mette il selettore in primissimo piano */
  }
  
  #lang-switcher * {
    cursor: pointer !important; /* Obbliga iOS/Android a riconoscere il tocco */
  }
  /* Preferenze: testo lungo va a capo */
  .team-row { flex-wrap: wrap; align-items: flex-start; }
  .team-info { min-width: 0; flex: 1 1 0; overflow: hidden; }
  .team-info div { white-space: normal !important; overflow-wrap: break-word !important; word-break: break-word !important; max-width: 100% !important; }
  .team-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; align-items: flex-end; }
  /* ── TABELLA PIÙ PICCOLA SOLO SU MOBILE ── */
  .cal-header, .cal-row {
    min-width: 520px; /* Scalata rispetto ai 750px originali */
    grid-template-columns: 75px repeat(7, 1fr); /* Colonna nomi stretta a 75px */
  }
  .cal-header-cell {
    padding: 0.4rem 0.2rem; font-size: 0.62rem;
  }
  .cal-dipendente {
    padding: 0.35rem; gap: 2px;
    flex-direction: column; align-items: center; text-align: center;
  }
  .cal-avatar {
    width: 22px; height: 22px; font-size: 0.55rem; margin-bottom: 2px;
  }
  .cal-nome { font-size: 0.62rem; }
  .cal-cell {
    min-height: 48px; padding: 2px;
  }
  .turno-chip { padding: 2px; margin-bottom: 1px; }
  .turno-chip .tc-ore { font-size: 0.55rem; }
  .turno-chip .tc-ruolo { font-size: 0.5rem; }
}

@media (max-width: 480px) {
  /* Nessuna regola aggiuntiva necessaria per i bottoni, ora sono gestiti tutti al 100% dal blocco 640px */
}
