/* EduLink — Shared Design System */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --card: #ffffff;
  --muted: #f1f5f9;
  --muted-fg: #64748b;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --primary: #3b82f6;
  --primary-fg: #ffffff;
  --primary-light: #eff6ff;
  --destructive: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  /* Sidebar */
  --sidebar: #0f172a;
  --sidebar-fg: #f8fafc;
  --sidebar-accent: #1e293b;
  --sidebar-border: #1e293b;
  --sidebar-muted: #94a3b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Be Vietnam Pro', sans-serif; background: var(--bg); color: var(--fg); line-height: 1.5; font-size: 14px; }

/* ── Sidebar Layout ── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; min-height: 100vh; background: var(--sidebar); color: var(--sidebar-fg); display: flex; flex-direction: column; flex-shrink: 0; transition: width .22s ease; position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; overflow: hidden; }
.sidebar-header { padding: 16px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sidebar-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 14px; flex-shrink: 0; }
.sidebar-brand { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; transition: opacity .15s; }
.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; overflow-x: hidden; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--sidebar-muted); transition: all .15s; text-decoration: none; white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: var(--sidebar-accent); color: var(--sidebar-fg); }
.nav-item.active { background: var(--sidebar-accent); color: var(--sidebar-fg); }
.nav-item svg { flex-shrink: 0; width: 16px; height: 16px; }
/* Section group label (Tổng quan / Học tập / Cài đặt) */
.nav-cap { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 12px 4px; opacity: .6; white-space: nowrap; overflow: hidden; }
.nav-cap:first-child { padding-top: 8px; }
.nav-group-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--sidebar-muted); padding: 8px 12px 4px; }
.nav-sub { padding-left: 28px; }
.nav-sub .nav-item { font-size: 12.5px; font-weight: 400; }
.sidebar-footer { padding: 8px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0; }
.sidebar-rail { position: absolute; right: -4px; top: 0; bottom: 0; width: 4px; cursor: ew-resize; opacity: 0; transition: opacity .15s; }
.sidebar-rail:hover { opacity: 1; background: var(--primary); }

/* ── Sidebar collapsed state (toggle .collapsed on .app-shell) ── */
.app-shell.collapsed .sidebar { width: 60px; }
.app-shell.collapsed .sidebar-brand { opacity: 0; width: 0; }
.app-shell.collapsed .nav-cap { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.app-shell.collapsed .nav-item span,
.app-shell.collapsed .nav-item > .nav-chevron { opacity: 0; width: 0; overflow: hidden; }
.app-shell.collapsed .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
.app-shell.collapsed .nav-group-content { display: none; }
.app-shell.collapsed .sidebar-header { justify-content: center; }
.app-shell.collapsed .sidebar-footer a { justify-content: center; }

/* Main area */
.main-area { margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; flex: 1; transition: margin-left .22s ease; }
.app-shell.collapsed .main-area { margin-left: 60px; }
.page-header-bar { position: sticky; top: 0; z-index: 20; height: 56px; background: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.page-content { padding: 24px; flex: 1; }

/* ── Student Layout ── */
.student-shell { min-height: 100vh; display: flex; flex-direction: column; }
.student-topnav { position: sticky; top: 0; z-index: 40; height: 56px; background: rgba(255,255,255,.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: none; }
.student-topnav .nav-inner { max-width: 900px; margin: 0 auto; height: 100%; display: flex; align-items: center; gap: 6px; padding: 0 16px; }
.student-main { flex: 1; padding-bottom: 64px; }
.student-bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: rgba(255,255,255,.95); backdrop-filter: blur(8px); border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(5, 1fr); z-index: 40; }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; font-weight: 500; color: var(--muted-fg); text-decoration: none; cursor: pointer; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item svg { width: 20px; height: 20px; }
@media (min-width: 768px) {
  .student-topnav { display: block; }
  .student-main { padding-bottom: 0; }
  .student-bottom-nav { display: none; }
}

/* ── Auth Layout ── */
.auth-shell { min-height: 100vh; background: #f8fafc; display: flex; align-items: center; justify-content: center; padding: 16px; }

/* ── Components ── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card-padded { padding: 20px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; white-space: nowrap; text-decoration: none; font-family: inherit; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-outline { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--muted); }
.btn-destructive { background: var(--destructive); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; }
.btn-full { width: 100%; }
.btn-link { background: none; color: var(--primary); padding: 0; font-size: 12px; }
.btn-link:hover { text-decoration: underline; }

/* Form */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.label { font-size: 13px; font-weight: 500; color: var(--fg); }
.label .req { color: var(--destructive); }
.input { width: 100%; padding: 8px 12px; border: 1px solid var(--input); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--bg); color: var(--fg); transition: border-color .15s; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.input-error { border-color: var(--destructive) !important; }
.error-text { font-size: 12px; color: var(--destructive); }
.textarea { resize: vertical; min-height: 80px; }
.select-wrapper { position: relative; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #f0fdf4; color: #16a34a; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-muted { background: var(--muted); color: var(--muted-fg); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--fg); }
.badge-destructive { background: #fef2f2; color: var(--destructive); }
.badge-purple { background: #f5f3ff; color: #7c3aed; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted-fg); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* Tabs */
.tabs { display: flex; gap: 0; background: var(--muted); padding: 3px; border-radius: 8px; width: fit-content; }
.tab { padding: 5px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted-fg); border: none; background: none; font-family: inherit; transition: all .15s; display: flex; align-items: center; gap: 5px; }
.tab.active { background: var(--bg); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tab-badge { background: var(--muted); color: var(--muted-fg); padding: 1px 6px; border-radius: 999px; font-size: 11px; }
.tab.active .tab-badge { background: var(--border); }

/* Progress */
.progress { height: 6px; background: var(--muted); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--destructive); }

/* Avatar */
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.avatar-xl { width: 80px; height: 80px; font-size: 24px; }

/* Stat card */
.stat-card { display: flex; flex-direction: column; gap: 8px; }
.stat-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.stat-icon.blue { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted-fg); }
.stat-trend { font-size: 11px; color: var(--success); display: flex; align-items: center; gap: 3px; }

/* Alert */
.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.alert-info { background: var(--primary-light); border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* Separator */
.sep { height: 1px; background: var(--border); margin: 12px 0; }
.sep-v { width: 1px; background: var(--border); height: 16px; }

/* Dropdown */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.1); min-width: 160px; z-index: 100; padding: 4px; display: none; }
.dropdown-menu.open { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--fg); text-decoration: none; }
.dropdown-item:hover { background: var(--muted); }
.dropdown-item.danger { color: var(--destructive); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Dialog */
.dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--bg); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.dialog-lg { max-width: 680px; }
.dialog-header { padding: 20px 24px 0; }
.dialog-title { font-size: 16px; font-weight: 600; }
.dialog-desc { font-size: 13px; color: var(--muted-fg); margin-top: 4px; }
.dialog-body { padding: 16px 24px; }
.dialog-footer { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* Sheet */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; }
.sheet { position: fixed; right: 0; top: 0; bottom: 0; width: 380px; background: var(--bg); box-shadow: -4px 0 20px rgba(0,0,0,.1); z-index: 201; display: flex; flex-direction: column; }
.sheet-header { padding: 20px; border-bottom: 1px solid var(--border); }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px; }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 64px 24px; text-align: center; color: var(--muted-fg); }
.empty-state svg { opacity: .3; }
.empty-state-title { font-size: 14px; font-weight: 600; color: var(--fg); }
.empty-state-desc { font-size: 13px; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.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; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.flex-1 { flex: 1; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.p-6 { padding: 24px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }
.text-2xl { font-size: 22px; }
.text-muted { color: var(--muted-fg); }
.text-primary { color: var(--primary); }
.text-success { color: #16a34a; }
.text-warning { color: #d97706; }
.text-danger { color: var(--destructive); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.rounded { border-radius: 6px; }
.rounded-lg { border-radius: 8px; }
.rounded-full { border-radius: 999px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.hidden { display: none; }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.z-10 { z-index: 10; }
.bg-muted { background: var(--muted); }
.bg-primary { background: var(--primary); }
.bg-primary-light { background: var(--primary-light); }
.border { border: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.rounded-t { border-top-left-radius: 8px; border-top-right-radius: 8px; }
.overflow-hidden { overflow: hidden; }
.page-title { font-size: 22px; font-weight: 600; }
.page-sub { font-size: 13px; color: var(--muted-fg); margin-top: 2px; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* Collapsible nav items */
.nav-group { overflow: hidden; }
.nav-group-content { display: none; }
.nav-group.open .nav-group-content { display: block; }
.nav-chevron { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; }
.nav-group.open .nav-chevron { transform: rotate(180deg); }

/* Highlight colors for scores */
.score-high { color: #16a34a; font-weight: 600; }
.score-mid { color: #d97706; font-weight: 600; }
.score-low { color: var(--destructive); font-weight: 600; }

/* Play screen */
.play-shell { min-height: 100vh; display: flex; flex-direction: column; background: #f8fafc; }
.play-header { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); padding: 12px 20px; }
.play-footer { background: var(--bg); border-top: 1px solid var(--border); padding: 12px 20px; }

/* Flashcard */
.flashcard { background: var(--bg); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,.08); overflow: hidden; max-width: 480px; margin: 0 auto; }
.flashcard-top { background: var(--primary-light); padding: 40px 32px; text-align: center; }
.flashcard-word { font-size: 36px; font-weight: 700; color: var(--fg); }
.flashcard-bottom { padding: 24px 32px; text-align: center; }
.flashcard-phonetic { font-size: 14px; color: var(--muted-fg); margin-bottom: 8px; }
.flashcard-meaning { font-size: 22px; font-weight: 600; }

/* MC Options */
.mc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 480px; margin: 0 auto; }
.mc-option { position: relative; padding: 20px 16px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; text-align: center; font-size: 15px; font-weight: 600; transition: all .15s; }
.mc-option .mc-label { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; }
.mc-option:nth-child(1) { background: #dbeafe; } .mc-option:nth-child(1) .mc-label { background: #3b82f6; }
.mc-option:nth-child(2) { background: #fef9c3; } .mc-option:nth-child(2) .mc-label { background: #ca8a04; }
.mc-option:nth-child(3) { background: #dcfce7; } .mc-option:nth-child(3) .mc-label { background: #16a34a; }
.mc-option:nth-child(4) { background: #fce7f3; } .mc-option:nth-child(4) .mc-label { background: #ec4899; }

/* Word chips */
.word-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 16px; }
.word-chip { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 12px; cursor: pointer; background: var(--bg); }
.word-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* VocabDaily streak */
.streak-badge { display: inline-flex; align-items: center; gap: 6px; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 999px; padding: 4px 12px; }
.streak-flame { color: #f59e0b; }
.streak-text { font-size: 13px; font-weight: 600; color: #92400e; }
.week-calendar { display: flex; gap: 8px; justify-content: center; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week-day-label { font-size: 11px; color: var(--muted-fg); }
.week-day-circle { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; background: var(--muted); color: var(--muted-fg); }
.week-day-circle.done { background: var(--primary); color: #fff; }
.week-day-circle.today { box-shadow: 0 0 0 2px var(--primary), 0 0 0 4px #fff; }

/* Collapsible toggle */
.collapsible-toggle { background: none; border: none; display: flex; align-items: center; gap: 8px; width: 100%; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; padding: 8px 0; }
.collapsible-content { display: none; }
.collapsible-content.open { display: block; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--muted) 25%, #e8ecf0 50%, var(--muted) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: -200% 0 } 100% { background-position: 200% 0 } }

/* Misc */
.code { font-family: 'Courier New', monospace; font-size: 12px; background: var(--muted); padding: 2px 6px; border-radius: 4px; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }
