/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1a2744;
  --navy-light: #243460;
  --gold: #c9a84c;
  --gold-light: #e8c96e;
  --cream: #faf8f3;
  --white: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e0d8;
  --green: #22c55e;
  --green-bg: #f0fdf4;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --sidebar-width: 280px;
  --mobile-header-height: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(26,39,68,0.10);
  --shadow-sm: 0 2px 8px rgba(26,39,68,0.08);
  --transition: 0.2s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

/* ===== Layout ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 28px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.flag { font-size: 2rem; }

.logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.level-badge {
  display: inline-block;
  background: var(--gold);
  color: var(--navy);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.sidebar-progress {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.progress-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
}

.progress-bar-track {
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 10px;
  transition: width 0.5s ease;
  width: 0%;
}

#lesson-list {
  list-style: none;
  padding: 12px 12px;
  flex: 1;
}

.lesson-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 4px;
}

.lesson-list-item:hover {
  background: rgba(255,255,255,0.08);
}

.lesson-list-item.active {
  background: rgba(201,168,76,0.2);
  border: 1px solid rgba(201,168,76,0.3);
}

.lesson-list-icon {
  font-size: 1.1rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.lesson-list-text {
  flex: 1;
  min-width: 0;
}

.lesson-list-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-list-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
}

.lesson-list-status {
  flex-shrink: 0;
  font-size: 0.7rem;
}

.status-check {
  color: var(--gold);
  font-size: 0.9rem;
}

.score-pill {
  background: rgba(201,168,76,0.2);
  color: var(--gold-light);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
}

.sidebar-home-btn {
  margin: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background var(--transition);
}

.sidebar-home-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

/* ===== Mobile Header ===== */
#mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--mobile-header-height);
  background: var(--navy);
  color: #fff;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
  font-weight: 600;
  font-size: 0.95rem;
}

#mobile-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

#sidebar-overlay.visible { display: block; }

/* ===== Main Content ===== */
#content {
  flex: 1;
  padding: 40px;
  max-width: 860px;
  min-height: 100vh;
}

.view { display: block; }
.hidden { display: none !important; }

/* ===== Home View ===== */
.home-hero {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px 40px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.home-hero::after {
  content: '🇫🇷';
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 4rem;
  opacity: 0.15;
}

.home-hero h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  margin-bottom: 10px;
  color: var(--gold);
}

.home-hero p {
  font-size: 1rem;
  color: rgba(255,255,255,0.8);
  max-width: 480px;
  line-height: 1.6;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.lesson-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.lesson-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--gold);
}

.lesson-card.completed {
  border-color: var(--green);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-score {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--navy);
}

.card-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.card-status-badge.completed {
  background: var(--green-bg);
  color: var(--green);
}

.card-status-badge.in-progress {
  background: #fff7ed;
  color: #f97316;
}

.card-status-badge.not-started {
  background: #f3f4f6;
  color: var(--text-muted);
}

/* ===== Lesson View ===== */
.lesson-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
}

.lesson-header-icon {
  font-size: 2.8rem;
  background: var(--navy);
  width: 68px;
  height: 68px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lesson-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--navy);
  margin-bottom: 4px;
}

.lesson-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lesson-section {
  margin-bottom: 36px;
}

.lesson-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Vocab table */
.vocab-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.vocab-table th {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.vocab-table td {
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}

.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table tr:nth-child(even) td { background: #f9f8f5; }

.vocab-french {
  font-weight: 600;
  color: var(--navy);
}

.vocab-pron {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
}

/* Dialogue */
.dialogue {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialogue-line {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.dialogue-speaker {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(201,168,76,0.1);
  border: 1px solid rgba(201,168,76,0.3);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.dialogue-text {
  flex: 1;
}

.dialogue-french {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.9rem;
  line-height: 1.4;
}

.dialogue-english {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
  font-style: italic;
}

/* Grammar box */
.grammar-box {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 28px;
}

.grammar-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  color: var(--gold);
  margin-bottom: 12px;
}

.grammar-explanation {
  font-size: 0.88rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.85);
  margin-bottom: 16px;
}

.grammar-explanation strong { color: var(--gold-light); }
.grammar-explanation em { color: rgba(255,255,255,0.7); }

.grammar-examples {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grammar-example {
  background: rgba(255,255,255,0.07);
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.example-french {
  font-weight: 600;
  font-size: 0.88rem;
  color: #fff;
}

.example-english {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.lesson-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

/* ===== Quiz View ===== */
.quiz-header {
  margin-bottom: 28px;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.quiz-progress-label { color: var(--navy); font-weight: 600; }

.quiz-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 10px;
  transition: width 0.4s ease;
}

.quiz-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
}

.quiz-question {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--navy);
  line-height: 1.5;
  margin-bottom: 28px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: #fff;
  font-size: 0.93rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  width: 100%;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(201,168,76,0.05);
}

.quiz-option .option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition);
}

.quiz-option.correct {
  border-color: var(--green);
  background: var(--green-bg);
  color: #166534;
}

.quiz-option.correct .option-letter {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.quiz-option.incorrect {
  border-color: var(--red);
  background: var(--red-bg);
  color: #991b1b;
}

.quiz-option.incorrect .option-letter {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.quiz-option:disabled { cursor: default; }

.quiz-feedback {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  animation: fadeIn 0.2s ease;
}

.quiz-feedback.correct-fb {
  background: var(--green-bg);
  border: 1px solid #bbf7d0;
}

.quiz-feedback.incorrect-fb {
  background: var(--red-bg);
  border: 1px solid #fecaca;
}

.feedback-icon { font-size: 1.3rem; flex-shrink: 0; }

.feedback-verdict {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.correct-fb .feedback-verdict { color: #166534; }
.incorrect-fb .feedback-verdict { color: #991b1b; }

.feedback-explanation {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== Results View ===== */
.result-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 52px 40px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 480px;
  margin: 0 auto;
}

.result-emoji {
  font-size: 3.5rem;
  margin-bottom: 20px;
}

.result-card h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  color: var(--navy);
  margin-bottom: 20px;
}

.result-score {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.result-score span {
  font-size: 1.5rem;
  color: var(--text-muted);
  font-weight: 400;
}

.result-message {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.6;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}

.btn-primary:hover {
  background: var(--navy-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,39,68,0.25);
}

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 2px solid var(--navy);
}

.btn-outline:hover {
  background: var(--navy);
  color: #fff;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view { animation: fadeIn 0.25s ease; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100%;
    transition: left 0.3s ease;
    z-index: 150;
  }

  #sidebar.open { left: 0; }

  #mobile-header { display: flex; }

  #content {
    padding: 80px 20px 32px;
    margin-left: 0;
  }

  .home-hero { padding: 28px 24px; }
  .home-hero h2 { font-size: 1.6rem; }
  .quiz-card { padding: 24px; }
  .quiz-question { font-size: 1.1rem; }
  .result-card { padding: 36px 24px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .vocab-table { font-size: 0.82rem; }
}
