@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ═══════════════════════════════════════
   CLAUDE PER TUTTI — Platform CSS
   Palette: dark warm (Claude-inspired)
   ═══════════════════════════════════════ */

:root {
  --bg-primary: #1a1410;
  --bg-secondary: #211c17;
  --bg-sidebar: #1e1914;
  --bg-card: #2a241e;
  --bg-card-hover: #332c24;
  --text-primary: #f5f0eb;
  --text-secondary: #b8a99a;
  --text-muted: #8a7d72;
  --accent: #d4714e;
  --accent-hover: #e0825f;
  --accent-soft: rgba(212,113,78,0.12);
  --border: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.1);
  --green: #5a9a6a;
  --red: #c4554d;
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --sidebar-w: 300px;
  --nav-h: 56px;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--accent); color: var(--bg-primary); }
a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }

/* ─── NAVBAR ──── */
.nav {
  height: var(--nav-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
}
.nav-logo:hover { color: var(--text-primary); }
.nav-logo .dot {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%; flex-shrink: 0;
}
.nav-links {
  margin-left: auto;
  display: flex; align-items: center; gap: 4px;
}
.nav-link {
  color: var(--text-muted); font-size: .85rem; font-weight: 500;
  padding: 6px 14px; border-radius: 8px; transition: all .15s;
  text-decoration: none;
}
.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-link.active { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.nav-link.logout:hover { color: var(--accent); }

/* ─── LAYOUT ──── */
.layout {
  display: flex; flex: 1;
  min-height: calc(100vh - var(--nav-h));
}

/* ─── SIDEBAR ──── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 20px 0;
  position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

/* Sidebar toggle (mobile) */
.sidebar-toggle-wrap { display: none; padding: 0 16px 8px; }
.sidebar-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-secondary);
  font-family: var(--font-body); font-size: .85rem;
  cursor: pointer; font-weight: 500;
}
.sidebar-toggle:hover { background: var(--bg-card-hover); }

/* Progress bar */
.sidebar-progress {
  margin: 0 20px 16px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.progress-label {
  font-size: .75rem; color: var(--text-muted);
  margin-bottom: 8px; display: flex; justify-content: space-between;
}
.progress-bar {
  height: 3px; background: rgba(255,255,255,0.06);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; transition: width .4s;
}

/* Module buttons */
.sidebar-section { margin-bottom: 2px; }
.sidebar-module-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 20px;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-family: var(--font-body);
  font-size: .82rem; font-weight: 500; text-align: left;
  transition: all .15s;
}
.sidebar-module-btn:hover { background: rgba(255,255,255,0.03); color: var(--text-primary); }
.sidebar-module-btn.open { color: var(--text-primary); }
.sidebar-module-num {
  font-family: var(--font-display); font-size: 1rem;
  color: var(--accent); min-width: 22px;
}
.sidebar-module-title { flex: 1; }
.sidebar-module-count {
  font-size: .7rem; color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  padding: 2px 7px; border-radius: 99px;
}
.sidebar-chevron {
  font-size: .65rem; color: var(--text-muted);
  transition: transform .25s;
}
.sidebar-section.open .sidebar-chevron { transform: rotate(180deg); }

/* Lesson links */
.sidebar-lessons {
  max-height: 0; overflow: hidden;
  transition: max-height .35s cubic-bezier(0.4,0,0.2,1);
}
.sidebar-section.open .sidebar-lessons { max-height: 800px; }
.sidebar-lesson {
  display: block; padding: 7px 20px 7px 52px;
  font-size: .8rem; color: var(--text-muted);
  transition: all .12s; border-left: 2px solid transparent;
  line-height: 1.45; text-decoration: none;
}
.sidebar-lesson:hover {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
}
.sidebar-lesson.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.sidebar-lesson .lesson-num {
  color: var(--text-muted); font-size: .72rem; margin-right: 4px;
}
.sidebar-lesson.active .lesson-num { color: var(--accent); }

/* ─── MAIN ──── */
.main {
  flex: 1; padding: 32px 40px 60px;
  max-width: 900px;
}
.main p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.75;
}
.main p a {
  color: var(--accent);
  border-bottom: 1px solid rgba(212,113,78,0.3);
  padding-bottom: 1px;
}
.main p a:hover { border-bottom-color: var(--accent); }

/* Breadcrumb */
.breadcrumb {
  font-size: .78rem; color: var(--text-muted);
  margin-bottom: 16px; display: flex; align-items: center; gap: 6px;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: .4; }

/* Module tag */
.module-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(212,113,78,0.15);
  padding: 4px 12px; border-radius: 99px;
  font-size: .75rem; color: var(--accent);
  font-weight: 500; margin-bottom: 12px;
}
.module-tag .mod-dot {
  width: 5px; height: 5px; background: var(--accent);
  border-radius: 50%;
}

/* Page titles */
.page-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.2;
  margin-bottom: 24px; color: var(--text-primary);
}

/* Meta tags row */
.meta-row {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap;
}
.meta-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; color: var(--text-muted);
  background: rgba(255,255,255,0.03);
  padding: 5px 12px; border-radius: 8px;
}

/* Video container */
.video-wrap {
  position: relative; padding-top: 56.25%;
  border-radius: 14px; overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.video-wrap iframe {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; border: 0;
}
.video-fallback {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-muted); font-size: .9rem;
}

/* Action bar (download + prev/next) */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 32px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px;
  font-size: .84rem; font-weight: 500;
  font-family: var(--font-body); cursor: pointer;
  transition: all .18s; border: none;
  text-decoration: none;
}
.btn-slide {
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-slide:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-muted); }
.btn-slide.disabled { pointer-events: none; opacity: .4; cursor: default; }
.btn-nav {
  background: none; color: var(--text-muted);
  border: 1px solid var(--border); text-decoration: none;
  padding: 8px 14px; border-radius: 8px; font-size: .8rem;
}
.btn-nav:hover { color: var(--text-secondary); border-color: var(--border-light); }
.btn-nav.primary {
  background: var(--accent); color: var(--bg-primary);
  border-color: var(--accent);
}
.btn-nav.primary:hover { background: var(--accent-hover); color: var(--bg-primary); }
.nav-btns { display: flex; gap: 8px; }

/* Description block */
.description-block {
  border-top: 1px solid var(--border);
  padding-top: 28px;
}
.desc-label {
  font-size: .72rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--accent);
  font-weight: 600; margin-bottom: 10px;
}
.desc-text {
  font-size: .95rem; color: var(--text-secondary);
  line-height: 1.75; max-width: 700px;
}

/* ─── LEZIONI LIST PAGE ──── */
.module-block { margin-bottom: 32px; }
.module-block-header {
  font-family: var(--font-display); font-weight: 400;
  font-size: 1.4rem; color: var(--text-primary);
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 12px;
}
.module-block-header .mod-num {
  color: var(--accent); font-size: 1rem;
}
.module-block-header .mod-count {
  font-family: var(--font-body); font-size: .78rem;
  color: var(--text-muted); font-weight: 400;
}
.lesson-card {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; border-radius: 10px;
  transition: all .15s; text-decoration: none;
  color: var(--text-primary);
  border: 1px solid transparent;
}
.lesson-card:hover {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}
.lesson-card .lc-num {
  font-family: var(--font-display); font-size: 1.1rem;
  color: var(--accent); min-width: 36px;
}
.lesson-card .lc-title {
  font-size: .92rem; font-weight: 500;
}
.lesson-card .lc-arrow {
  margin-left: auto; color: var(--text-muted);
  font-size: .8rem; opacity: 0; transition: opacity .15s;
}
.lesson-card:hover .lc-arrow { opacity: 1; }

/* ─── MATERIALI PAGE ──── */
.materiali-section { margin-bottom: 36px; }
.materiali-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: 1.25rem; color: var(--text-primary);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.materiali-list { list-style: none; }
.materiali-list li { margin-bottom: 6px; }
.materiali-list li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: .9rem;
  transition: all .15s; text-decoration: none;
}
.materiali-list li a:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}
.materiali-list li a .m-icon { font-size: 1.1rem; flex-shrink: 0; }

/* ─── LOGIN PAGE ──── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-primary);
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; top: -200px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(212,113,78,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.login-box {
  width: min(400px, 90vw); padding: 40px 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px; position: relative; z-index: 1;
}
.login-brand {
  font-family: var(--font-display);
  font-size: 1.6rem; color: var(--text-primary);
  margin-bottom: 6px; display: flex; align-items: center; gap: 10px;
}
.login-brand .dot {
  width: 8px; height: 8px; background: var(--accent);
  border-radius: 50%;
}
.login-subtitle {
  font-size: .9rem; color: var(--text-secondary);
  margin-bottom: 28px; line-height: 1.6;
}
.login-field {
  width: 100%; padding: 12px 16px;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: 10px; color: var(--text-primary);
  font-family: var(--font-body); font-size: .95rem;
  outline: none; transition: border-color .2s;
}
.login-field:focus { border-color: var(--accent); }
.login-field::placeholder { color: var(--text-muted); }
.login-btn {
  width: 100%; padding: 12px;
  background: var(--accent); color: var(--bg-primary);
  border: none; border-radius: 10px;
  font-family: var(--font-body); font-size: .95rem;
  font-weight: 600; cursor: pointer;
  margin-top: 12px; transition: all .2s;
}
.login-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.login-error {
  background: rgba(196,85,77,0.12);
  border: 1px solid rgba(196,85,77,0.25);
  color: #e8a09c; border-radius: 10px;
  padding: 10px 14px; font-size: .85rem;
  margin: 12px 0 0;
}
.login-note {
  font-size: .78rem; color: var(--text-muted);
  margin-top: 24px; line-height: 1.6;
}
.login-note a { color: var(--accent); }

/* ─── WELCOME PAGE ──── */
.welcome-box {
  max-width: 640px;
}
.welcome-box .page-title { margin-bottom: 16px; }
.welcome-box p { font-size: .95rem; }

/* ─── FOOTER ──── */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: .75rem; color: var(--text-muted);
}

/* ─── RESPONSIVE ──── */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto;
    position: static; border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none; padding: 12px 0;
  }
  .sidebar-toggle-wrap { display: block; }
  .sidebar-modules { display: none; }
  .sidebar.mobile-open .sidebar-modules { display: block; }
  .main { padding: 24px 20px 48px; }
  .action-bar { flex-direction: column; align-items: flex-start; }
  .nav-btns { width: 100%; }
  .nav-btns .btn-nav { flex: 1; text-align: center; justify-content: center; }
}
@media (min-width: 861px) {
  .sidebar-toggle-wrap { display: none !important; }
  .sidebar-modules { display: block !important; }
}
@media (max-width: 480px) {
  .nav { padding: 0 16px; }
  .nav-link { padding: 6px 10px; font-size: .8rem; }
  .main { padding: 20px 16px 40px; }
}

/* =========================================================================
   Lezioni viste + ricerca — aggiunte, usano i colori del tema scuro
   ========================================================================= */

.pd-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 20px 0 28px; padding: 14px;
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px;
}
.pd-search {
  flex: 1 1 240px; padding: 10px 12px; font: inherit; font-size: 15px;
  color: var(--text-primary); background: var(--bg-card);
  border: 1px solid var(--border-light); border-radius: 8px;
}
.pd-search::placeholder { color: var(--text-muted); }
.pd-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.pd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pd-chip {
  padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); background: var(--bg-card);
  border: 1px solid var(--border-light); border-radius: 999px; cursor: pointer;
  transition: all .15s ease;
}
.pd-chip:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-muted); }
.pd-chip.active { background: var(--accent); border-color: var(--accent); color: #1a1410; }

.pd-status { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--text-muted); }
.pd-status:empty { display: none; }

.lesson-card.is-hidden, .module-block.is-hidden { display: none; }

.lc-check {
  display: none; flex: none;
  width: 22px; height: 22px; margin-left: auto;
  border-radius: 50%; background: var(--accent); color: #1a1410;
  font-size: 12px; line-height: 22px; text-align: center; font-weight: 700;
}
.lesson-card.is-done .lc-check { display: block; }
.lesson-card.is-done .lc-arrow { opacity: .35; }

.sidebar-lesson.is-done .lesson-num { color: var(--accent); }
.sidebar-lesson.is-done::after {
  content: '\2713'; margin-left: auto; padding-left: 6px;
  color: var(--accent); font-size: 12px; font-weight: 700;
}
.sidebar-module-count.is-complete { background: var(--accent); color: #1a1410; }

/* Pulsante "Segna come vista": stessi colori di btn-slide, cosi' resta leggibile */
.btn-vista {
  margin-left: 8px; cursor: pointer; font: inherit;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-vista:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-muted); }
.btn-vista.is-done { background: var(--accent); border-color: var(--accent); color: #1a1410; }

.pd-reset-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border);
}
.pd-reset {
  padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); background: var(--bg-card);
  border: 1px solid var(--border-light); border-radius: 8px; cursor: pointer;
}
.pd-reset:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-muted); }
.pd-reset-note { font-size: 12px; color: var(--text-muted); }

@media (max-width: 560px) {
  .pd-toolbar { flex-direction: column; align-items: stretch; }
  .pd-chips { justify-content: space-between; }
  .btn-vista { margin-left: 0; }
}
