/* ══════════════════════════════════════════════════════════════
   English Learning — Main Stylesheet
   Dark mode, glassmorphism, smooth animations
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-base:        #0d0f1a;
  --bg-surface:     #141728;
  --bg-card:        #1a1f35;
  --bg-card-hover:  #1e2440;
  --bg-glass:       rgba(26, 31, 53, 0.7);

  --accent-blue:    #4f8ef7;
  --accent-purple:  #8b5cf6;
  --accent-green:   #22d3a0;
  --accent-orange:  #f97316;
  --accent-pink:    #ec4899;
  --accent-yellow:  #fbbf24;

  --text-primary:   #e8eaf6;
  --text-secondary: #8892b0;
  --text-muted:     #4a5568;

  --border:         rgba(255, 255, 255, 0.07);
  --border-active:  rgba(79, 142, 247, 0.4);

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-glow-blue:   0 0 24px rgba(79, 142, 247, 0.25);
  --shadow-glow-purple: 0 0 24px rgba(139, 92, 246, 0.25);
  --shadow-glow-green:  0 0 24px rgba(34, 211, 160, 0.25);
  --shadow-card:        0 8px 32px rgba(0, 0, 0, 0.4);

  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Animated background mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(79, 142, 247, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 80%, rgba(139, 92, 246, 0.07) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 50% 40%, rgba(34, 211, 160, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Layout ────────────────────────────────────────────────── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── Navigation ────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
  position: sticky;
  top: 0;
  background: rgba(13, 15, 26, 0.85);
  backdrop-filter: blur(16px);
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.navbar-brand .logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow-blue);
}

.navbar-brand .brand-name {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.navbar-links a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.navbar-links a:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.navbar-links a.active {
  color: var(--accent-blue);
  background: rgba(79, 142, 247, 0.1);
}

/* ─── Page Header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
  background: linear-gradient(90deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

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

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ─── Stat Cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  transition: all var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow-blue);
  border-color: var(--border-active);
}

.stat-icon {
  font-size: 28px;
  margin-bottom: 10px;
  display: block;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-blue  .stat-value { color: var(--accent-blue); }
.stat-green .stat-value { color: var(--accent-green); }
.stat-purple .stat-value { color: var(--accent-purple); }
.stat-orange .stat-value { color: var(--accent-orange); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #fff;
  box-shadow: 0 4px 16px rgba(79, 142, 247, 0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(79, 142, 247, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green), #059669);
  color: #fff;
  box-shadow: 0 4px 16px rgba(34, 211, 160, 0.3);
}
.btn-success:hover:not(:disabled) { transform: translateY(-2px); }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { transform: translateY(-2px); }

.btn-warning {
  background: linear-gradient(135deg, var(--accent-yellow), #d97706);
  color: #000;
}
.btn-warning:hover:not(:disabled) { transform: translateY(-2px); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(79, 142, 247, 0.08);
}

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

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

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

/* ─── Badge / Pill ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-blue   { background: rgba(79,142,247,0.15); color: var(--accent-blue); }
.badge-green  { background: rgba(34,211,160,0.15); color: var(--accent-green); }
.badge-purple { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.badge-orange { background: rgba(249,115,22,0.15); color: var(--accent-orange); }

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress-wrap {
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.green {
  background: linear-gradient(90deg, var(--accent-green), #059669);
}

/* ─── Flashcard ──────────────────────────────────────────────── */
.flashcard-scene {
  perspective: 1000px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  height: 280px;
}

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

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

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

.flashcard-front {
  background: linear-gradient(135deg, #1a2040, #1e2845);
  border: 1px solid rgba(79, 142, 247, 0.3);
  box-shadow: var(--shadow-glow-blue), var(--shadow-card);
}

.flashcard-back {
  background: linear-gradient(135deg, #1a2840, #1e3828);
  border: 1px solid rgba(34, 211, 160, 0.3);
  box-shadow: var(--shadow-glow-green), var(--shadow-card);
  transform: rotateY(180deg);
}

.card-word {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.card-ipa {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  color: var(--accent-blue);
  margin-bottom: 8px;
}

.card-tip {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

.card-meaning {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-green);
  margin-bottom: 12px;
}

.card-hint {
  font-size: 13px;
  color: var(--text-muted);
  position: absolute;
  bottom: 16px;
}

.flashcard-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ─── Input / Textarea ───────────────────────────────────────── */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition);
}

.input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.1);
}

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

/* ─── Select ─────────────────────────────────────────────────── */
.select {
  appearance: none;
  background: var(--bg-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892b0' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  padding-right: 36px;
}

/* ─── Answer Feedback ────────────────────────────────────────── */
.answer-correct {
  color: var(--accent-green);
  font-weight: 700;
  background: rgba(34, 211, 160, 0.1);
  border: 1px solid rgba(34, 211, 160, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.answer-wrong {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.word-correct { color: var(--accent-green); }
.word-wrong { color: #ef4444; text-decoration: underline wavy #ef4444; }

/* ─── Dialogue lines ─────────────────────────────────────────── */
.dialogue-line {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.dialogue-speaker {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-blue);
  white-space: nowrap;
  min-width: 60px;
  padding-top: 2px;
}

.dialogue-speaker.speaker-b { color: var(--accent-purple); }

.dialogue-text {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 15px;
  flex: 1;
  line-height: 1.5;
}

/* ─── Grammar exercise ───────────────────────────────────────── */
.exercise-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 14px;
  transition: border-color var(--transition);
}

.exercise-item.correct { border-color: var(--accent-green); background: rgba(34,211,160,0.05); }
.exercise-item.wrong   { border-color: #ef4444; background: rgba(239,68,68,0.05); }

.exercise-sentence {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.7;
}

.exercise-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  max-width: 200px;
}

.exercise-explanation {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: none;
}

.exercise-item.correct .exercise-explanation,
.exercise-item.wrong   .exercise-explanation { display: block; }

/* ─── Lesson list ────────────────────────────────────────────── */
.lesson-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  margin-bottom: 10px;
}

.lesson-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateX(4px);
}

.lesson-day-badge {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  flex-shrink: 0;
  color: #fff;
}

.lesson-day-badge .day-num {
  font-size: 20px;
  line-height: 1;
}

.lesson-info { flex: 1; }
.lesson-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.lesson-meta  { font-size: 12px; color: var(--text-secondary); }

/* ─── Quick action cards (Dashboard) ────────────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 22px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
  cursor: pointer;
}

.action-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-active);
}

.action-card.blue  { --card-glow: rgba(79,142,247,0.2); }
.action-card.green { --card-glow: rgba(34,211,160,0.2); }
.action-card.purple{ --card-glow: rgba(139,92,246,0.2); }

.action-card:hover { box-shadow: 0 8px 32px var(--card-glow, rgba(79,142,247,0.15)); }

.action-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.blue .action-icon   { background: rgba(79,142,247,0.15); }
.green .action-icon  { background: rgba(34,211,160,0.15); }
.purple .action-icon { background: rgba(139,92,246,0.15); }

.action-title { font-weight: 700; font-size: 15px; }
.action-desc  { font-size: 13px; color: var(--text-secondary); }

/* ─── Loading spinner ────────────────────────────────────────── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

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

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* ─── Toast notifications ────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}

.toast.success { border-color: var(--accent-green); }
.toast.error   { border-color: #ef4444; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ─── Sections ───────────────────────────────────────────────── */
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Divider ────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ─── Streak display ─────────────────────────────────────────── */
.streak-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--accent-orange);
  font-weight: 600;
}

/* ─── Hamburger Menu (mobile) ──────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.hamburger:hover { background: var(--bg-card); }
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hamburger { display: flex; }
  .navbar-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: rgba(13, 15, 26, 0.97);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 16px;
    gap: 4px;
    z-index: 200;
  }
  .navbar-links.open { display: flex; }
  .navbar-links a { padding: 10px 14px; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .flashcard-scene { height: 240px; }
  .card-word { font-size: 28px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}


/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Logout button ──────────────────────────────────────────── */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239,68,68,0.25);
  background: rgba(239,68,68,0.07);
  color: #ef4444;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.btn-logout:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.5);
}

