/* ══════════════════════════════════════════════════════════════
   Learning English Academy — design system
   Minimal, premium, lots of white space. Light + dark themes.
   ══════════════════════════════════════════════════════════════ */

:root {
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;

  --bg:          #f7f8fa;
  --surface:     #ffffff;
  --surface-2:   #f2f4f7;
  --border:      #e7eaf0;
  --border-soft: #f0f2f6;

  --text:        #101828;
  --text-2:      #475467;
  --text-3:      #98a2b3;

  --accent:      #4f46e5;
  --accent-soft: #eef2ff;
  --accent-text: #4338ca;

  --success:      #067647;
  --success-soft: #ecfdf3;
  --warning:      #b54708;
  --warning-soft: #fffaeb;
  --danger:       #b42318;
  --danger-soft:  #fef3f2;
  --info:         #026aa2;
  --info-soft:    #f0f9ff;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px -8px rgba(16,24,40,.14);
  --sidebar-w: 264px;
}

[data-theme="dark"] {
  --bg:          #0c111d;
  --surface:     #161b26;
  --surface-2:   #1f242f;
  --border:      #2a3038;
  --border-soft: #22262e;
  --text:        #f2f4f7;
  --text-2:      #b8c0cc;
  --text-3:      #667085;
  --accent:      #6366f1;
  --accent-soft: #1e2340;
  --accent-text: #a5b4fc;
  --success:      #4ade80;
  --success-soft: #10241a;
  --warning:      #fbbf24;
  --warning-soft: #2a2213;
  --danger:       #f87171;
  --danger-soft:  #2c1616;
  --info:         #38bdf8;
  --info-soft:    #0e2233;
  --shadow:    0 1px 2px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 32px -8px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: var(--font); }

/* ── Language switcher (public pages) ── */
.lang-switch {
  position: fixed; top: 18px; right: 18px; z-index: 60;
  display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 5px; box-shadow: var(--shadow);
}
.lang-switch button {
  border: none; background: none; color: var(--text-2); font-family: var(--font);
  font-size: .74rem; font-weight: 600; padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.lang-switch button:hover { background: var(--surface-2); }
.lang-switch button.active { background: var(--accent); color: #fff; }

/* ── Boot splash ── */
.boot-splash { display: flex; align-items: center; justify-content: center; height: 100vh; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App layout ── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  padding: 22px 14px; position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: .5px; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: .92rem; line-height: 1.25; }
.brand-sub  { font-size: .68rem; color: var(--text-3); font-weight: 500; letter-spacing: .6px; text-transform: uppercase; }

.nav-group-label {
  font-size: .66rem; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-3); padding: 16px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: .9rem; cursor: pointer; border: none;
  background: none; width: 100%; text-align: left; margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item .icon { width: 19px; text-align: center; font-size: 1rem; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff; border-radius: 20px;
  font-size: .66rem; font-weight: 700; padding: 1px 7px;
}
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border-soft); padding-top: 12px; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2);
  color: var(--text-2); font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-chip .name { font-size: .84rem; font-weight: 600; }
.user-chip .role { font-size: .7rem; color: var(--text-3); text-transform: capitalize; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-weight: 700; font-size: 1.02rem; }
.topbar-spacer { flex: 1; }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-2);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center; position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--danger);
}
.hamburger { display: none; }

.content { padding: 30px 32px 60px; max-width: 1200px; }
.content.narrow { max-width: 860px; }

/* ── Typography helpers ── */
.h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.h2 { font-size: 1.12rem; font-weight: 700; }
.h3 { font-size: .95rem; font-weight: 700; }
.muted  { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small  { font-size: .82rem; }
.tiny   { font-size: .72rem; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border-soft);
}
.card-body { padding: 22px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stat { padding: 18px 20px; }
.stat .label { font-size: .74rem; font-weight: 600; color: var(--text-3); letter-spacing: .4px; text-transform: uppercase; }
.stat .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.stat .hint  { font-size: .75rem; color: var(--text-3); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: .875rem;
  padding: 9px 16px; cursor: pointer; border: 1px solid transparent;
  transition: filter .15s ease, background .15s ease; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: 12px 26px; font-size: .95rem; }
.btn-block { width: 100%; }

/* ── Forms ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 13px; color: var(--text);
  font-family: var(--font); font-size: .9rem; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 88px; }
.row { display: flex; gap: 14px; } .row > * { flex: 1; min-width: 0; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-2); cursor: pointer; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; padding: 3px 10px; white-space: nowrap;
}
.badge-accent  { background: var(--accent-soft);  color: var(--accent-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-muted   { background: var(--surface-2);    color: var(--text-2); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  text-align: left; font-size: .72rem; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-3);
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }

/* ── Progress bars ── */
.progress { height: 8px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 20px; transition: width .5s ease; }
.progress.success > div { background: var(--success); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,13,20,.55); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px;
  backdrop-filter: blur(2px); animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: slideUp .2s ease; max-height: 86vh;
  display: flex; flex-direction: column; border: 1px solid var(--border);
}
.modal.wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border-soft); }
.modal-head .h2 { font-size: 1.02rem; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border-soft); }
.modal-x { background: none; border: none; color: var(--text-3); font-size: 1.15rem; cursor: pointer; padding: 4px; }
@keyframes fadeIn  { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0; } }

/* ── Toasts ── */
#toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 18px;
  font-size: .86rem; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease; max-width: 360px;
}
.toast.error { background: #b42318; color: #fff; }

/* ── Auth screens (login / apply / verify) ── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 28px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 640px; }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .brand-mark { margin: 0 auto 12px; width: 48px; height: 48px; border-radius: 14px; font-size: 20px; }

/* ── Learning player ── */
.player-layout { display: flex; gap: 24px; align-items: flex-start; }
.player-main { flex: 1; min-width: 0; }
.player-side { width: 320px; flex-shrink: 0; position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; }
video.lesson-video { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 16/9; }
.pdf-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

.outline-chapter { border-bottom: 1px solid var(--border-soft); padding: 10px 0; }
.outline-chapter .ch-title { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: .86rem; padding: 4px 8px; }
.outline-lesson {
  display: flex; align-items: center; gap: 9px; font-size: .84rem; padding: 7px 8px 7px 30px;
  border-radius: 8px; color: var(--text-2); cursor: pointer;
}
.outline-lesson:hover { background: var(--surface-2); }
.outline-lesson.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.outline-lesson.locked { color: var(--text-3); cursor: not-allowed; }
.check-dot {
  width: 17px; height: 17px; border-radius: 50%; flex-shrink: 0; font-size: .62rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); color: transparent;
}
.check-dot.done { background: var(--success); border-color: var(--success); color: #fff; }

/* ── Quiz ── */
.quiz-q { margin-bottom: 26px; }
.quiz-q .q-text { font-weight: 600; margin-bottom: 12px; }
.quiz-opt {
  display: flex; align-items: center; gap: 11px; padding: 12px 15px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: .9rem;
}
.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.quiz-opt.correct  { border-color: var(--success); background: var(--success-soft); }
.quiz-opt.wrong    { border-color: var(--danger);  background: var(--danger-soft); }
.score-ring { font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; }

/* ── Certificate ── */
.certificate {
  background: #fff; color: #1a1a2e; border: 3px double #c9a959; border-radius: 6px;
  padding: 56px 48px; text-align: center; max-width: 820px; margin: 0 auto;
  font-family: Georgia, 'Times New Roman', serif;
}
.certificate .cert-school { font-size: 1rem; letter-spacing: 4px; text-transform: uppercase; color: #8a6d1f; }
.certificate .cert-title  { font-size: 2.1rem; margin: 18px 0 6px; font-weight: 700; }
.certificate .cert-name   { font-size: 1.9rem; font-style: italic; margin: 22px 0; color: #1f2a5a; }
.certificate .cert-line   { width: 320px; border-bottom: 1px solid #999; margin: 0 auto 6px; }
.certificate .cert-meta   { display: flex; justify-content: space-between; margin-top: 44px; font-size: .82rem; align-items: flex-end; }
@media print {
  body * { visibility: hidden; }
  .certificate, .certificate * { visibility: visible; }
  .certificate { position: absolute; left: 0; top: 0; width: 100%; border-width: 3px; }
}

/* ── Content protection ── */
.protected {
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.protected img, .protected video, .protected canvas { -webkit-user-drag: none; pointer-events: auto; }
.media-shell { position: relative; overflow: hidden; border-radius: var(--radius); }
.watermark {
  position: absolute; z-index: 5; pointer-events: none;
  color: rgba(255,255,255,.34); font-size: .78rem; font-weight: 600;
  text-shadow: 0 0 3px rgba(0,0,0,.45); letter-spacing: .4px;
  white-space: nowrap; transform: rotate(-14deg);
  transition: top 1.2s ease, left 1.2s ease;
}
.watermark.dark-wm { color: rgba(30,30,60,.22); text-shadow: none; }
.pdf-canvas-wrap {
  height: 72vh; overflow-y: auto; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-align: center; position: relative;
}
.pdf-canvas-wrap canvas {
  max-width: 100%; margin: 10px auto; display: block;
  box-shadow: 0 2px 10px rgba(0,0,0,.12); background: #fff;
}
/* Lesson material never prints */
@media print {
  .player-main, .player-side, .pdf-canvas-wrap, video.lesson-video { display: none !important; visibility: hidden !important; }
}

/* ── Misc ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .big { font-size: 2.2rem; margin-bottom: 10px; }
.divider { height: 1px; background: var(--border-soft); margin: 18px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt-1{margin-top:6px}.mt-2{margin-top:12px}.mt-3{margin-top:20px}.mt-4{margin-top:30px}
.mb-1{margin-bottom:6px}.mb-2{margin-bottom:12px}.mb-3{margin-bottom:20px}.mb-4{margin-bottom:30px}
.tree-item { display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:8px; }
.tree-item:hover { background: var(--surface-2); }
.tree-item .grow { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.drag-handle { cursor: grab; color: var(--text-3); }

/* ── Responsive (mobile-first behaviours) ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .content { padding: 20px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .player-layout { flex-direction: column; }
  .player-side { width: 100%; position: static; max-height: none; }
  .row { flex-direction: column; gap: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .certificate { padding: 32px 18px; }
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,13,20,.4); z-index: 35;
}
@media (max-width: 900px) { .sidebar.open + .sidebar-backdrop { display: block; } }
