/* ============================================
   AgentPass — Premium Light Theme Design System
   ============================================ */

/* --- CSS Variables --- */
:root {
  /* Base */
  --white: #FFFFFF;
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8F9FA;
  --bg-tertiary: #F1F3F5;
  --bg-hover: #E9ECEF;

  /* Borders */
  --border: #E2E8F0;
  --border-light: #F1F3F5;
  --border-focus: #1B2A4A;

  /* Text */
  --text-primary: #1A1A2E;
  --text-secondary: #4A5568;
  --text-muted: #94A3B8;
  --text-inverse: #FFFFFF;

  /* Navy (Primary Brand) */
  --green-900: #0F1A2E;
  --green-800: #152236;
  --green-700: #1B2A4A;
  --green-600: #243356;
  --green-500: #2D3D66;
  --green-400: #3D5175;
  --green-100: #D4DCF0;
  --green-50: #EEF2FA;

  /* Grass Green (Accent / Success) */
  --grass-green: #16A34A;
  --grass-light: #DCFCE7;

  /* Gold (Achievement — Vibrant) */
  --gold-700: #8B6914;
  --gold-600: #B8922E;
  --gold-500: #D4A843;
  --gold-400: #E8C056;
  --gold-100: #F5E6BE;
  --gold-50: #FDF6E8;

  /* Blue (FIFA) */
  --blue-700: #1D4ED8;
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-100: #DBEAFE;
  --blue-50: #EFF6FF;

  /* Feedback */
  --success: #16A34A;
  --success-bg: #F0FDF4;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --error-soft: #F87171;
  --warning: #D97706;
  --warning-bg: #FFFBEB;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-green: 0 4px 14px rgba(27, 42, 74, 0.18);
  --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-secondary);
  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-700); }
.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-700);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm), var(--shadow-green);
}
.btn-primary:hover {
  background: var(--green-800);
  box-shadow: var(--shadow-md), var(--shadow-green);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--green-600);
  color: var(--green-700);
}

.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-500), var(--gold-600));
  color: #1A1A2E;
  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-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-base);
}

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

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

.card-green {
  background: var(--green-50);
  border-color: var(--green-100);
}

.card-gold {
  background: 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-primary);
  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(27, 42, 74, 0.1);
}

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

.form-error {
  font-size: 0.8125rem;
  color: var(--error);
  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-800);
}

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

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

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

/* --- 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-400));
}

/* --- Stat Cards --- */
.stat-card {
  background: var(--bg-primary);
  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-50); }
.stat-icon-gold { background: var(--gold-50); }
.stat-icon-blue { background: var(--blue-50); }

.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(--success); }
.stat-change.down { color: var(--error); }

/* ============================================
   App Layout — Sidebar + Main
   ============================================ */

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  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-light);
}

.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-tertiary);
  color: var(--text-primary);
}

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

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

.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-light);
}

.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-tertiary);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--green-100), var(--green-50));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--green-700);
  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-primary);
  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;
}

.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(--green-800) 0%, var(--green-700) 50%, var(--green-600) 100%);
  border-radius: var(--radius-xl);
  padding: 32px 36px;
  color: white;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

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

.welcome-card h2 {
  color: white;
  font-size: 1.375rem;
  margin-bottom: 6px;
}

.welcome-card p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9375rem;
}

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

.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;
}

/* 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;
}

.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-700);
  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(--grass-green);
  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;
}

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

.subject-card.selected {
  border-color: var(--green-600);
  background: var(--green-50);
  box-shadow: 0 0 0 3px rgba(27, 42, 74, 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-tertiary);
  border-radius: var(--radius-full);
}

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

.question-card {
  background: var(--bg-primary);
  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;
}

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

.answer-letter {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  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-700);
}

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

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

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

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

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

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

.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-700);
  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-600);
  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-50);
  color: var(--green-700);
  border: 4px solid var(--green-500);
}

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

.results-message {
  font-size: 1.25rem;
  font-weight: 700;
  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-primary);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.flashcard-back {
  background: var(--green-50);
  border: 2px solid var(--green-200, var(--green-100));
  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: linear-gradient(135deg, var(--green-100), var(--green-50));
  color: var(--green-700);
}

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

.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-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.chat-message.user .chat-bubble {
  background: var(--green-700);
  color: white;
}

.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);
}

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

.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-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  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;
}

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

.auth-card {
  background: var(--bg-primary);
  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(--green-700);
  border-bottom-color: var(--green-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(--green-700);
  font-weight: 600;
}

/* ============================================
   Landing Page
   ============================================ */

.landing-body {
  background: var(--bg-primary);
}

/* Landing Nav */
.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  transition: all var(--transition-base);
}

.landing-nav.scrolled {
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.nav-brand .brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.nav-links a:hover {
  color: var(--green-700);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Landing Hero */
.landing-hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 24px 80px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(27, 42, 74, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(245, 158, 11, 0.03) 0%, transparent 50%),
    var(--bg-primary);
}

.hero-inner {
  max-width: 720px;
}

.hero-badge-landing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--green-50);
  border: 1px solid var(--green-100);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--green-700);
  margin-bottom: 32px;
}

.hero-badge-landing .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-500);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.landing-hero h1 {
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.landing-hero h1 .gradient-text {
  background: linear-gradient(135deg, var(--green-700) 0%, var(--gold-500) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-hero .hero-desc {
  font-size: clamp(1rem, 2vw, 1.1875rem);
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto 36px;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 56px;
}

.hero-stats-bar {
  display: flex;
  justify-content: center;
  gap: 48px;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.hero-stat-value.green { color: var(--green-700); }
.hero-stat-value.gold { color: var(--gold-600); }

.hero-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Landing Sections */
.landing-section {
  padding: 100px 24px;
}

.landing-section.alt {
  background: var(--bg-secondary);
}

.landing-container {
  max-width: 1080px;
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 56px;
}

.section-header h2 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.section-header p {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}

/* Problem Section */
.problem-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
}

.problem-content h2 {
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  line-height: 1.15;
}

.problem-content p {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 12px;
}

.problem-content strong {
  color: var(--gold-600);
  font-weight: 700;
}

.fail-stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 36px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.fail-number {
  font-size: 6rem;
  font-weight: 800;
  background: linear-gradient(180deg, #EF4444 0%, #FCA5A5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.fail-label {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  margin-top: 8px;
  font-weight: 600;
}

.fail-source {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* Features Grid */
.features-grid-landing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card-landing {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: all var(--transition-base);
}

.feature-card-landing:hover {
  border-color: var(--green-400);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.feature-card-landing.featured {
  grid-column: span 3;
  background: linear-gradient(135deg, var(--green-50) 0%, var(--gold-50) 100%);
  border-color: var(--green-100);
  padding: 36px 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: center;
}

.feature-emoji {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--green-50);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 16px;
}

.feature-card-landing h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.feature-card-landing p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.feature-card-landing .highlight {
  color: var(--green-700);
  font-weight: 600;
}

/* Comparison Table */
.comparison-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
}

.comparison-table-landing {
  width: 100%;
  border-collapse: collapse;
}

.comparison-table-landing th,
.comparison-table-landing td {
  padding: 16px 24px;
  text-align: left;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border-light);
}

.comparison-table-landing thead th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.comparison-table-landing thead th:last-child {
  color: var(--green-700);
  background: var(--green-50);
}

.comparison-table-landing td:first-child {
  font-weight: 600;
  color: var(--text-primary);
}

.comparison-table-landing td:nth-child(2) {
  color: var(--text-muted);
}

.comparison-table-landing td:last-child {
  color: var(--green-700);
  font-weight: 700;
}

.comparison-table-landing tbody tr:last-child td {
  border-bottom: none;
}

.comparison-table-landing tbody tr:hover {
  background: var(--bg-secondary);
}

/* CTA Section */
.cta-section {
  text-align: center;
  padding: 100px 24px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(27, 42, 74, 0.04) 0%, transparent 60%),
    var(--bg-primary);
}

.cta-section h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
  max-width: 600px;
  margin: 0 auto 16px;
  line-height: 1.15;
}

.cta-section p {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 460px;
  margin: 0 auto 32px;
}

/* Landing Footer */
.landing-footer {
  padding: 40px 24px;
  text-align: center;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.landing-footer .footer-brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.landing-footer .footer-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================
   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.3);
  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;
  }

  .features-grid-landing {
    grid-template-columns: repeat(2, 1fr);
  }

  .feature-card-landing.featured {
    grid-column: span 2;
  }
}

@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;
  }

  .problem-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .features-grid-landing {
    grid-template-columns: 1fr;
  }

  .feature-card-landing.featured {
    grid-column: span 1;
    grid-template-columns: 1fr;
  }

  .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;
  }

  .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;
  }

  .fail-number {
    font-size: 4rem;
  }

  .landing-nav {
    padding: 12px 16px;
  }

  .landing-hero h1 {
    font-size: 2rem;
  }
}

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

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

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

/* ============================================
   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(--text-primary);
  color: white;
  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-700); }
.toast.error { background: var(--error); }

/* 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;
}

.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;
}

.update-banner .banner-note {
  opacity: 0.85;
}

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

/* Warning (stale > 6 months): orange */
.update-banner.warning {
  background: var(--warning-bg);
  border-color: #FDE68A;
  color: #92400E;
}

/* 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-secondary);
  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;
}

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

.admin-matiere-row .admin-btn {
  background: var(--green-700);
  color: white;
  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-800);
}

.admin-date-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  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: white;
  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;
  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;
}

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

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

.admin-date-modal .btn-cancel {
  background: var(--bg-secondary);
  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-700);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
