/* ==========================================================================
   Sales Life Platform — Foglio di stile globale
   Palette derivata dalla presentazione "Sales Life Modulo 1":
     #0A1628 navy scurissimo (sfondo dominante)
     #152B47 navy scuro (superfici / card)
     #1E3A5F navy medio (bordi, hover)
     #2B5499 blu acceso (azioni primarie, accenti)
     #8AA3C0 azzurro tenue (testo secondario)
     #64748B grigio ardesia (testo attenuato)
     #E5EBF4 azzurro chiarissimo (testo principale su scuro)
     #F4F6FA quasi bianco (titoli, contrasti forti)
     #FFFFFF bianco
   ========================================================================== */

:root {
  --navy-950: #0A1628;
  --navy-800: #152B47;
  --navy-600: #1E3A5F;
  --blue-500: #2B5499;
  --blue-300: #8AA3C0;
  --slate-400: #64748B;
  --ice-100: #E5EBF4;
  --ice-50: #F4F6FA;
  --white: #FFFFFF;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(4, 10, 20, 0.45);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--navy-950);
  color: var(--ice-100);
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3, h4 { color: var(--ice-50); line-height: 1.25; }

a { color: var(--blue-300); }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--blue-500);
  color: var(--white);
  font: 600 14px var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  text-decoration: none;
}
.btn:hover { background: #33619f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  border-color: var(--navy-600);
  color: var(--ice-100);
}
.btn-outline:hover { background: var(--navy-600); border-color: var(--navy-600); }
.btn-danger { background: transparent; border-color: var(--navy-600); color: var(--blue-300); }
.btn-danger:hover { background: var(--navy-600); color: var(--ice-50); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Form ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--blue-300); margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  background: var(--navy-950);
  color: var(--ice-50);
  font: 400 14px var(--font);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--blue-500);
  outline-offset: 1px;
  border-color: var(--blue-500);
}
input::placeholder, textarea::placeholder { color: var(--slate-400); }
.field { margin-bottom: 16px; }

/* ---------- Card ---------- */
.card {
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  padding: 20px;
}

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-free { background: rgba(43, 84, 153, .25); color: var(--blue-300); }
.badge-booked { background: var(--blue-500); color: var(--white); }
.badge-muted { background: var(--navy-600); color: var(--blue-300); }

/* ==========================================================================
   Pagina di accesso (login / registrazione)
   ========================================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(43, 84, 153, .28), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(30, 58, 95, .5), transparent 60%),
    var(--navy-950);
}
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand .logo { font-size: 30px; font-weight: 800; letter-spacing: .04em; color: var(--ice-50); }
.auth-brand .logo span { color: var(--blue-300); }
.auth-brand p { color: var(--blue-300); margin-top: 6px; font-size: 14px; }
.auth-card { padding: 28px; box-shadow: var(--shadow); }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.auth-tabs button {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--blue-300);
  font: 600 14px var(--font);
  cursor: pointer;
}
.auth-tabs button.active { background: var(--blue-500); border-color: var(--blue-500); color: var(--white); }
.auth-error {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(43, 84, 153, .18);
  border: 1px solid var(--blue-500);
  color: var(--ice-50);
  font-size: 13px;
}
.auth-hint { margin-top: 18px; text-align: center; color: var(--slate-400); font-size: 12.5px; }

/* ==========================================================================
   Layout applicazione: sidebar + contenuto
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--navy-800);
  border-right: 1px solid var(--navy-600);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--ice-50);
  padding: 0 10px 18px;
}
.sidebar .logo span { color: var(--blue-300); }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--blue-300);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.nav-link:hover { background: var(--navy-600); color: var(--ice-50); }
.nav-link.active { background: var(--blue-500); color: var(--white); }
.nav-link .ico { width: 20px; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .user-box {
  border-top: 1px solid var(--navy-600);
  padding: 14px 10px 4px;
  font-size: 13px;
}
.sidebar .user-box .u-name { color: var(--ice-50); font-weight: 700; }
.sidebar .user-box .u-role { color: var(--slate-400); font-size: 12px; margin-bottom: 10px; }

.main { flex: 1; padding: 30px 34px 60px; min-width: 0; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 26px; margin-bottom: 4px; }
.page-head p { color: var(--blue-300); font-size: 14px; }

.section { display: none; }
.section.active { display: block; }

/* ---------- Topbar mobile ---------- */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--navy-800);
  border-bottom: 1px solid var(--navy-600);
}
/* Il logo della topbar è il pulsante che apre il menu */
.topbar .logo-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  font-family: var(--font);
}
.topbar .logo { font-size: 17px; font-weight: 800; color: var(--ice-50); letter-spacing: .04em; }
.topbar .logo span { color: var(--blue-300); }
.topbar .logo-caret {
  color: var(--blue-300);
  font-size: 13px;
  transition: transform .2s;
}
.topbar .logo-btn.open .logo-caret { transform: rotate(180deg); }

/* ==========================================================================
   Sezione Video corso
   ========================================================================== */
.module-block { margin-bottom: 28px; }
.module-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.module-head .module-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-300);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.module-head h2 { font-size: 19px; }

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.lesson-card {
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.lesson-card:hover { border-color: var(--blue-500); transform: translateY(-2px); }
.lesson-card.playing { border-color: var(--blue-500); background: var(--navy-600); }
.lesson-card .l-play {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--blue-500);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  margin-bottom: 12px;
}
.lesson-card .l-title { font-weight: 700; color: var(--ice-50); font-size: 14.5px; }
.lesson-card .l-meta { color: var(--slate-400); font-size: 12.5px; margin-top: 4px; }
.lesson-card .l-desc { color: var(--blue-300); font-size: 13px; margin-top: 6px; }
.lesson-card.hidden-lesson { opacity: .55; }

/* Barra di avanzamento del modulo */
.module-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -6px 0 14px;
}
.progress-bar {
  flex: 1;
  max-width: 320px;
  height: 8px;
  border-radius: 999px;
  background: var(--navy-600);
  overflow: hidden;
}
.progress-bar > div {
  height: 100%;
  background: var(--blue-500);
  border-radius: 999px;
  transition: width .3s;
}
.progress-label { font-size: 12.5px; color: var(--blue-300); white-space: nowrap; }

/* Modulo bloccato (sblocco progressivo) */
.module-block.locked .lesson-grid { opacity: .45; pointer-events: none; }
.lock-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  background: var(--navy-800);
  color: var(--blue-300);
  font-size: 13px;
  font-weight: 600;
}

/* Lezione completata */
.lesson-card.completed { border-color: var(--blue-500); }
.lesson-card .l-check {
  margin-top: 10px;
  width: 100%;
}
.badge-done { background: var(--blue-500); color: var(--white); }
.badge-pending { background: rgba(43, 84, 153, .25); color: var(--blue-300); }

/* Player */
.player-wrap { margin-bottom: 26px; display: none; }
.player-wrap.open { display: block; }
.player-box {
  background: #000;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  overflow: hidden;
}
.player-box video { width: 100%; max-height: 62vh; display: block; background: #000; }
.player-info { padding: 14px 18px; background: var(--navy-800); }
.player-info h3 { font-size: 16px; }
.player-info p { color: var(--blue-300); font-size: 13px; margin-top: 3px; }

/* Materiali collegati al modulo */
.module-materials {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -4px 0 14px;
}
.material-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--navy-600);
  border-radius: 999px;
  background: var(--navy-800);
  color: var(--ice-100);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.material-chip:hover { border-color: var(--blue-500); }

/* Riquadro quiz del modulo */
.quiz-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  background: var(--navy-800);
}
.quiz-box .q-title { font-weight: 700; color: var(--ice-50); font-size: 14.5px; }
.quiz-box .q-meta { color: var(--blue-300); font-size: 13px; }

/* Domande del quiz (modale cliente) */
.quiz-question { margin-bottom: 18px; }
.quiz-question .qq-text { font-weight: 700; color: var(--ice-50); margin-bottom: 8px; font-size: 14.5px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 14px;
}
.quiz-option:hover { border-color: var(--blue-500); }
.quiz-option input { width: auto; }
.quiz-option.opt-correct { border-color: var(--blue-500); background: rgba(43, 84, 153, .25); }
.quiz-option.opt-wrong { opacity: .55; text-decoration: line-through; }
.quiz-result {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--blue-500);
  background: rgba(43, 84, 153, .18);
  margin-bottom: 16px;
  font-weight: 600;
  color: var(--ice-50);
}
.modal.modal-lg { max-width: 640px; max-height: 85vh; overflow-y: auto; }

/* Editor quiz (formatore) */
.qe-question {
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
  background: var(--navy-950);
}
.qe-option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.qe-option-row input[type="radio"] { width: auto; flex-shrink: 0; }

/* Appunti sotto il player */
.player-notes { padding: 14px 18px; background: var(--navy-800); border-top: 1px solid var(--navy-600); }
.player-notes label { margin-bottom: 8px; }
.player-notes .notes-status { font-size: 12px; color: var(--slate-400); margin-top: 6px; }

/* Bacheca annunci */
.announcement {
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.announcement h3 { font-size: 16px; margin-bottom: 4px; }
.announcement .a-date { color: var(--slate-400); font-size: 12.5px; margin-bottom: 8px; }
.announcement .a-body { color: var(--ice-100); font-size: 14px; white-space: pre-wrap; }
.announcement .a-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Scheda cliente (formatore) */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--navy-600); }
.client-detail h2 { font-size: 20px; margin-bottom: 2px; }
.detail-block { margin-top: 20px; }
.detail-block > h3 { font-size: 15px; margin-bottom: 10px; color: var(--blue-300); text-transform: uppercase; letter-spacing: .05em; font-size: 12.5px; }
.detail-lesson {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--navy-600);
  font-size: 13.5px;
  flex-wrap: wrap;
}
.detail-lesson:last-child { border-bottom: none; }
.detail-lesson .dl-note { width: 100%; color: var(--blue-300); font-size: 12.5px; font-style: italic; }

/* ==========================================================================
   Sezione Elaborati
   ========================================================================== */
/* Layout a due colonne: materiali a sinistra, azioni a destra */
.elab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 20px;
  align-items: start;
}

/* Gruppo di materiali per modulo */
.file-group { margin-bottom: 24px; }
.file-group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--navy-600);
}
.file-group-head .fg-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-300);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.file-group-head h3 { font-size: 15px; }
.file-group-head .fg-count { margin-left: auto; color: var(--slate-400); font-size: 12.5px; white-space: nowrap; }

.side-title { font-size: 15px; margin: 22px 0 10px; }

.file-list { display: flex; flex-direction: column; gap: 12px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.file-ico {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--navy-600);
  color: var(--ice-50);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; letter-spacing: .03em;
}
.file-info { flex: 1; min-width: 0; }
.file-info .f-title { font-weight: 700; color: var(--ice-50); font-size: 14.5px; }
.file-info .f-desc { color: var(--blue-300); font-size: 13px; }
.file-info .f-meta { color: var(--slate-400); font-size: 12px; margin-top: 2px; }
.file-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* ==========================================================================
   Calendario
   ========================================================================== */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h3 { font-size: 17px; text-transform: capitalize; }
.cal-nav { display: flex; gap: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--slate-400); padding: 6px 0; text-transform: uppercase; }
.cal-day {
  min-height: 62px;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  background: var(--navy-950);
  padding: 6px;
  font-size: 12.5px;
  color: var(--slate-400);
  cursor: default;
  position: relative;
}
.cal-day.in-month { color: var(--ice-100); }
.cal-day.selectable { cursor: pointer; }
.cal-day.selectable:hover { border-color: var(--blue-500); }
.cal-day.selected { border-color: var(--blue-500); background: var(--navy-600); }
.cal-day.today .d-num { color: var(--white); background: var(--blue-500); }
.cal-day .d-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-weight: 600;
}
.cal-day .d-dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.cal-day .dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-free { background: var(--blue-300); }
.dot-booked { background: var(--blue-500); }
.dot-mine { background: var(--ice-50); }

.slot-panel h3 { font-size: 16px; margin-bottom: 12px; }
.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  background: var(--navy-950);
  font-size: 14px;
  flex-wrap: wrap;
}
.slot-row .s-time { font-weight: 700; color: var(--ice-50); }
.slot-row .s-client { color: var(--blue-300); font-size: 13px; }
.slot-empty { color: var(--slate-400); font-size: 13.5px; padding: 8px 2px; }

.cal-legend { display: flex; gap: 16px; margin-top: 14px; font-size: 12.5px; color: var(--blue-300); flex-wrap: wrap; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Prossime prenotazioni ---------- */
.upcoming-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

/* ==========================================================================
   Dashboard formatore
   ========================================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card .s-value { font-size: 30px; font-weight: 800; color: var(--ice-50); }
.stat-card .s-label { font-size: 13px; color: var(--blue-300); margin-top: 2px; }

/* Tabelle */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  padding: 10px 14px;
  color: var(--slate-400);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--navy-600);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--navy-600); color: var(--ice-100); }
tr:last-child td { border-bottom: none; }

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 20, .7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%;
  max-width: 460px;
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 6px; }
.modal .m-sub { color: var(--blue-300); font-size: 13.5px; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--blue-500);
  color: var(--white);
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.muted { color: var(--slate-400); }
.empty-note { color: var(--slate-400); font-size: 14px; padding: 18px 0; }

/* ==========================================================================
   Responsive — mobile
   ========================================================================== */
@media (max-width: 860px) {
  .topbar { display: flex; }
  .app { flex-direction: column; }
  .elab-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: 260px;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(4, 10, 20, .6);
    z-index: 45;
  }
  .sidebar-backdrop.open { display: block; }
  .main { padding: 20px 16px 50px; }
  .cal-layout { grid-template-columns: 1fr; }
  .file-row { flex-wrap: wrap; }
  .file-actions { width: 100%; }
}
