/* ============================================
   AgentPass — Dark Theme (Harmonized with Landing)
   ============================================ */

/* --- CSS Variables (Landing Dark Palette) --- */
:root {
  /* Backgrounds */
  --bg: #0a0c09;
  --bg-2: #111410;
  --bg-3: #181c15;
  --bg-card: #15190f;
  --bg-primary: #0f110d;   /* App main background */
  --bg-secondary: #15190f;  /* Card/surface background */
  --bg-tertiary: #1c2016;

  /* Borders */
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.05);
  --border-gold: rgba(212, 168, 67, 0.3);
  --border-focus: #22c55e;

  /* Text */
  --text-primary: #f0ede6;
  --text-secondary: #8a9080;
  --text-muted: #5a6050;
  --text-inverse: #0a0c09;

  /* Green (success/action) */
  --green-900: #0f1a12;
  --green-800: #152218;
  --green-700: #1a2e1f;
  --green-600: #22c55e;
  --green-500: #4ade80;
  --green-400: #86efac;
  --green-100: rgba(34, 197, 94, 0.12);
  --green-50: rgba(34, 197, 94, 0.06);

  /* Gold (accent/achievement) */
  --gold-700: #7a5a12;
  --gold-600: #D4A843;
  --gold-500: #e8c056;
  --gold-400: #f0d080;
  --gold-100: rgba(212, 168, 67, 0.15);
  --gold-50: rgba(212, 168, 67, 0.08);

  /* Blue (FIFA/links) */
  --blue-700: #1d4ed8;
  --blue-600: #3b82f6;
  --blue-500: #60a5fa;
  --blue-100: rgba(59, 130, 246, 0.12);
  --blue-50: rgba(59, 130, 246, 0.06);

  /* Feedback */
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.08);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);
  --error-soft: #f87171;
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6), 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.7), 0 8px 10px rgba(0, 0, 0, 0.5);
  --shadow-green: 0 4px 14px rgba(34, 197, 94, 0.2);
  --shadow-gold: 0 4px 14px rgba(212, 168, 67, 0.2);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* Spacing */
  --sidebar-width: 260px;
  --header-height: 64px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 2rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; letter-spacing: -0.015em; }
h4 { font-size: 1.0625rem; font-weight: 600; }
h5 { font-size: 0.9375rem; font-weight: 600; }

p {
  color: var(--text-secondary);
  line-height: 1.7;
}

.text-muted { color: var(--text-muted); }
.text-green { color: var(--green-600); }
.text-gold { color: var(--gold-600); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--green-600);
  color: #000;
  box-shadow: var(--shadow-sm), var(--shadow-green);
}
.btn-primary:hover {
  background: var(--green-500);
  box-shadow: var(--shadow-md), var(--shadow-green);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-3);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-600), var(--gold-500));
  color: #000;
  box-shadow: var(--shadow-sm), var(--shadow-gold);
}
.btn-gold:hover {
  box-shadow: var(--shadow-md), var(--shadow-gold);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-base);
}

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

.card-elevated {
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.card-green {
  background: var(--green-900);
  border-color: rgba(34, 197, 94, 0.2);
}

.card-gold {
  background: var(--gold-900, var(--gold-50));
  border-color: var(--gold-100);
}

/* --- Forms --- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--error-soft);
  margin-top: 4px;
}

/* --- Badge/Pill --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.5;
}

.badge-green {
  background: var(--green-100);
  color: var(--green-400);
}

.badge-gold {
  background: var(--gold-100);
  color: var(--gold-400);
}

.badge-blue {
  background: var(--blue-100);
  color: var(--blue-500);
}

.badge-red {
  background: var(--error-bg);
  color: var(--error-soft);
}

/* --- Progress Bar --- */
.progress {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--green-600), var(--green-500));
  transition: width var(--transition-slow);
}

.progress-bar-gold {
  background: linear-gradient(90deg, var(--gold-600), var(--gold-500));
}

/* --- Stat Cards --- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon-green { background: var(--green-100); color: var(--green-600); }
.stat-icon-gold { background: var(--gold-100); color: var(--gold-600); }
.stat-icon-blue { background: var(--blue-100); color: var(--blue-500); }

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
}

.stat-change.up { color: var(--green-600); }
.stat-change.down { color: var(--error); }

/* ============================================
   App Layout — Sidebar + Main (Dark)
   ============================================ */

.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: block;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-section {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-2);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--green-100);
  color: var(--green-400);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--green-500);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav-item:hover .nav-icon {
  color: var(--text-secondary);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--bg-2);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--gold-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gold-600);
  flex-shrink: 0;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-email {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* Main Content */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.app-header {
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-content {
  padding: 32px;
  max-width: 1200px;
}

/* --- View Sections (SPA) --- */
.view {
  display: none;
  animation: fadeIn var(--transition-base) ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Dashboard View
   ============================================ */

.welcome-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-3) 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: 32px 36px;
  color: var(--text-primary);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.welcome-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-600), transparent);
}

.welcome-card::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(212, 168, 67, 0.06) 0%, transparent 70%);
  border-radius: 50%;
}

.welcome-card h2 {
  color: var(--text-primary);
  font-size: 1.375rem;
  margin-bottom: 6px;
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.welcome-streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 6px 14px;
  background: var(--gold-100);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gold-400);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
}

/* Subject Progress */
.subject-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.subject-item:last-child { border-bottom: none; }

.subject-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: var(--bg-3);
}

.subject-info {
  flex: 1;
  min-width: 0;
}

.subject-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.subject-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.subject-progress {
  width: 100px;
}

.subject-pct {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--green-600);
  text-align: right;
  margin-bottom: 4px;
}

/* Recent Activity */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-600);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.activity-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.activity-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   Quiz View
   ============================================ */

/* Quiz Setup */
.quiz-setup {
  max-width: 600px;
  margin: 0 auto;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.subject-card {
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  background: var(--bg-card);
}

.subject-card:hover {
  border-color: var(--green-600);
  background: var(--green-50);
}

.subject-card.selected {
  border-color: var(--green-600);
  background: var(--green-100);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.subject-card .subject-emoji {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.subject-card .subject-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.subject-card .subject-count {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Quiz Active */
.quiz-active {
  max-width: 720px;
  margin: 0 auto;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.quiz-progress-info {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.quiz-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 14px;
  background: var(--bg-3);
  border-radius: var(--radius-full);
}

.quiz-progress-bar {
  margin-bottom: 32px;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.question-text {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Answer Options */
.answer-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-card);
}

.answer-option:hover {
  border-color: var(--green-600);
  background: var(--green-50);
}

.answer-letter {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.answer-option:hover .answer-letter {
  background: var(--green-100);
  color: var(--green-600);
}

.answer-option.selected {
  border-color: var(--green-600);
  background: var(--green-900);
}

.answer-option.selected .answer-letter {
  background: var(--green-600);
  color: #000;
}

.answer-option.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.answer-option.correct .answer-letter {
  background: var(--success);
  color: #000;
}

.answer-option.incorrect {
  border-color: var(--error-soft);
  background: var(--error-bg);
}

.answer-option.incorrect .answer-letter {
  background: var(--error-soft);
  color: #000;
}

.answer-option.disabled {
  pointer-events: none;
  opacity: 0.7;
}

/* Explanation Box */
.explanation-box {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 20px;
  animation: slideUp var(--transition-base) ease;
}

.explanation-box h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--blue-500);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.explanation-box p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.explanation-ref {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue-500);
  padding: 3px 10px;
  background: var(--blue-100);
  border-radius: var(--radius-full);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Results View
   ============================================ */

.results-hero {
  text-align: center;
  padding: 40px 0;
  margin-bottom: 32px;
}

.results-score {
  width: 140px;
  height: 140px;
  margin: 0 auto 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 800;
  position: relative;
}

.results-score.pass {
  background: var(--green-900);
  color: var(--green-600);
  border: 4px solid var(--green-600);
}

.results-score.fail {
  background: var(--error-bg);
  color: var(--error-soft);
  border: 4px solid var(--error-soft);
}

.results-message {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.results-detail {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.results-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

/* ============================================
   Flashcards View
   ============================================ */

.flashcard-container {
  max-width: 560px;
  margin: 0 auto;
  perspective: 1200px;
}

.flashcard {
  width: 100%;
  min-height: 280px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.flashcard-front {
  background: var(--bg-card);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.flashcard-back {
  background: var(--green-900);
  border: 2px solid rgba(34, 197, 94, 0.2);
  box-shadow: var(--shadow-lg);
  transform: rotateY(180deg);
}

.flashcard-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.flashcard-text {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-primary);
}

.flashcard-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

.flashcard-counter {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 0;
}

/* ============================================
   AI Chat View
   ============================================ */

.chat-container {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - 96px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: slideUp var(--transition-base) ease;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.chat-avatar.ai {
  background: var(--green-100);
  color: var(--green-500);
}

.chat-avatar.human {
  background: var(--blue-100);
  color: var(--blue-500);
}

.chat-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.chat-message.assistant .chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.chat-message.user .chat-bubble {
  background: var(--green-600);
  color: #000;
}

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 16px 0;
  border-top: 1px solid var(--border-light);
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.9375rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  transition: border-color var(--transition-fast);
  color: var(--text-primary);
  background: var(--bg-3);
}

.chat-input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.08);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}

.chat-suggestion {
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-suggestion:hover {
  border-color: var(--green-600);
  background: var(--green-50);
  color: var(--green-400);
}

/* ============================================
   Auth Pages
   ============================================ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo .logo-mark {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: block;
  margin: 0 auto 12px;
}

.auth-logo h1 {
  font-size: 1.375rem;
  color: var(--text-primary);
}

.auth-logo p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-light);
}

.auth-tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
}

.auth-tab.active {
  color: var(--gold-400);
  border-bottom-color: var(--gold-600);
}

.auth-tab:hover:not(.active) {
  color: var(--text-secondary);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: fadeIn var(--transition-base) ease;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--gold-400);
  font-weight: 600;
}

/* ============================================
   Pricing Page (shared styles)
   ============================================ */

.pricing-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 0;
}

/* ============================================
   Cas Réels — Dark Theme
   ============================================ */

/* Theme filter pills */
.cas-theme-btn {
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.cas-theme-btn:hover {
  border-color: var(--green-600);
  color: var(--green-400);
  background: var(--green-50);
}
.cas-theme-btn.active {
  background: var(--green-600);
  border-color: var(--green-600);
  color: #000;
}

/* Cas list grid */
.cas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* Individual cas card */
.cas-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}
.cas-card:hover {
  border-color: var(--green-600);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.cas-card.cas-completed {
  border-color: var(--green-600);
  background: var(--success-bg);
}
.cas-card.cas-wrong {
  border-color: var(--error-soft);
  background: var(--error-bg);
}

.cas-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.cas-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

.cas-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.cas-card-preview {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cas-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cas-status-dot.done-correct { background: var(--green-600); }
.cas-status-dot.done-wrong   { background: var(--error-soft); }
.cas-status-dot.todo         { background: var(--border); }

/* Difficulty dots */
.diff-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.diff-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}
.diff-dot.filled { background: var(--gold-500); }

/* Scenario text block */
#casDetailScenario {
  background: var(--bg-2);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text-primary);
  border-left: 3px solid var(--gold-600);
  white-space: pre-wrap;
}

/* Clickable article references */
.article-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--blue-100);
  border: 1px solid var(--blue-100);
  color: var(--blue-500);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: default;
}

/* Stats bar at top of list */
.cas-stats-bar {
  display: flex;
  gap: 16px;
  background: var(--bg-2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.cas-stats-bar strong { color: var(--green-400); font-size: 1rem; }

/* ============================================
   Utility Classes
   ============================================ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  animation: slideUp var(--transition-base) ease;
}

.toast.success {
  background: var(--green-900);
  border-color: var(--green-600);
  color: var(--green-400);
}
.toast.error {
  background: var(--error-bg);
  border-color: var(--error-soft);
  color: var(--error-soft);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.125rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

/* ===== Update Banner ===== */
.update-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.45;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.update-banner .banner-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.update-banner .banner-text {
  flex: 1;
}

.update-banner .banner-label {
  font-weight: 600;
  color: var(--text-primary);
}

.update-banner .banner-note {
  opacity: 0.85;
  color: var(--text-secondary);
}

/* Default: neutral/info style */
.update-banner.info {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text-secondary);
}

/* Warning (stale > 6 months): orange */
.update-banner.warning {
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning);
}

/* Admin section */
.admin-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.admin-section h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.admin-matiere-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-2);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.admin-matiere-row .matiere-emoji {
  font-size: 1.25rem;
}

.admin-matiere-row .matiere-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.admin-matiere-row .matiere-date {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.admin-matiere-row .admin-btn {
  background: var(--green-600);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.admin-matiere-row .admin-btn:hover {
  background: var(--green-500);
}

.admin-date-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.admin-date-modal.hidden {
  display: none;
}

.admin-date-modal .modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}

.admin-date-modal h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.admin-date-modal label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.admin-date-modal input,
.admin-date-modal textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.75px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  margin-bottom: 12px;
  box-sizing: border-box;
  color: var(--text-primary);
  background: var(--bg-3);
}

.admin-date-modal input:focus,
.admin-date-modal textarea:focus {
  outline: none;
  border-color: var(--green-600);
}

.admin-date-modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.admin-date-modal .btn-cancel {
  background: var(--bg-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.admin-date-modal .btn-save {
  background: var(--green-600);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

/* ============================================
   Responsive
   ============================================ */

/* Mobile menu toggle */
.mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
}

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

.sidebar-overlay.active {
  display: block;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: flex;
  }

  .app-main {
    margin-left: 0;
  }

  .app-content {
    padding: 20px 16px;
  }

  .app-header {
    padding: 0 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .subject-grid {
    grid-template-columns: 1fr;
  }

  .results-breakdown {
    grid-template-columns: 1fr;
  }

  .question-card {
    padding: 24px;
  }

  .quiz-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .hero-stats-bar {
    gap: 24px;
    flex-wrap: wrap;
  }

  .hero-cta {
    flex-direction: column;
  }

  .nav-links {
    display: none;
  }

  .comparison-table-landing th,
  .comparison-table-landing td {
    padding: 12px 14px;
    font-size: 0.8125rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats-bar {
    flex-direction: column;
    gap: 16px;
  }

  .chat-message {
    max-width: 95%;
  }
}

@media (max-width: 600px) {
  .cas-grid { grid-template-columns: 1fr; }
  .cas-theme-btn { font-size: 0.75rem; padding: 5px 10px; }
}

/* Notes layout — stack columns on mobile */
@media (max-width: 768px) {
  #notesLayout {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  #notesLayout > div:first-child {
    max-height: 220px;
  }
  #notesEditor {
    min-height: 400px;
  }
}

/* ── Fiches de révision (quiz wrong-answer card) ─────────────────────────── */

/* Card container */
#revisionCardContent {
  background: var(--bg-card);
  border: 1.5px solid rgba(220,50,50,0.25);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

/* Pedagogical content typography */
.fiche-revision-body h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.fiche-revision-body h4:first-child { margin-top: 0; }

.fiche-revision-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 10px;
}

.fiche-revision-body ul {
  margin: 8px 0 12px 0;
  padding-left: 20px;
}
.fiche-revision-body li {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 4px;
}

.fiche-revision-body strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Clickable article refs inside cards */
.fiche-article-ref {
  display: inline;
  color: var(--green-600);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  border-radius: 3px;
  padding: 0 2px;
  transition: background 0.15s;
}
.fiche-article-ref:hover {
  background: rgba(34,197,94,0.1);
}

/* Spin animation for loading indicator */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Language selector */
.lang-selector.open .lang-options {
  display: block !important;
}
.lang-option {
  display: block;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.lang-option:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.lang-option.active {
  color: var(--green-600);
  background: var(--green-50);
}
}