/* ============================================================
   English for Work & Life — Focus & Purpose Academy
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy-deep: #0e1a30;
  --navy: #16233f;
  --navy-soft: #24345a;
  --gold: #c79a3c;
  --gold-light: #e3c476;
  --ivory: #f7f2e6;
  --ivory-dim: #ece4d1;
  --ink: #1c2230;
  --slate: #5c6478;
  --line: rgba(22, 35, 63, 0.12);
  --good: #3f7d5c;
  --warn: #b5542f;
  --radius-card: 14px;
  --radius-pill: 999px;
  --shadow-soft: 0 10px 30px rgba(14, 26, 48, 0.10);
  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */

#app {
  display: flex;
  flex: 1;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--navy-deep);
  color: var(--ivory);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 22px 6px;
  border-bottom: 1px solid rgba(247, 242, 230, 0.12);
  margin-bottom: 18px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--gold-light), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--navy-deep);
  font-size: 17px;
  flex-shrink: 0;
}

.brand-text .brand-name {
  font-family: var(--font-display);
  font-size: 15.5px;
  line-height: 1.15;
  font-weight: 600;
}

.brand-text .brand-sub {
  font-size: 10.5px;
  color: var(--gold-light);
  letter-spacing: 0.02em;
}

nav.mainnav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

nav.mainnav button {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: rgba(247, 242, 230, 0.72);
  text-align: left;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

nav.mainnav button .navicon { font-size: 16px; width: 18px; text-align: center; }

nav.mainnav button:hover {
  background: rgba(247, 242, 230, 0.07);
  color: var(--ivory);
}

nav.mainnav button.active {
  background: rgba(199, 154, 60, 0.16);
  color: var(--gold-light);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(247, 242, 230, 0.12);
  font-size: 11px;
  color: rgba(247, 242, 230, 0.5);
  line-height: 1.5;
}

/* ---------- Main content ---------- */

.main {
  flex: 1;
  min-width: 0;
  padding: 30px 34px 90px 34px;
}

.topbar-mobile {
  display: none;
}

.view { max-width: 980px; margin: 0 auto; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.view-header h1 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: var(--navy);
}

.view-header p {
  margin: 0;
  color: var(--slate);
  font-size: 14px;
}

/* ---------- Dashboard ---------- */

.hello-banner {
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-soft) 100%);
  border-radius: 18px;
  padding: 26px 28px;
  color: var(--ivory);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.hello-banner::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(199,154,60,0.28), transparent 70%);
}

.hello-banner .eyebrow {
  color: var(--gold-light);
  font-size: 12.5px;
  margin-bottom: 6px;
}

.hello-banner h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 8px 0;
  font-weight: 600;
  position: relative;
}

.hello-banner p {
  margin: 0;
  color: rgba(247,242,230,0.82);
  font-size: 14px;
  max-width: 520px;
  position: relative;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 16px;
  box-shadow: var(--shadow-soft);
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--navy);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--slate);
  margin-top: 3px;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--ivory-dim);
  overflow: hidden;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

.dash-columns {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
}

.panel h3 {
  font-family: var(--font-display);
  font-size: 16.5px;
  margin: 0 0 12px 0;
  color: var(--navy);
}

.next-lesson-card {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.next-lesson-card .badge-month {
  flex-shrink: 0;
  width: 46px; height: 46px;
  border-radius: 10px;
  background: var(--ivory-dim);
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}

.next-lesson-card .nl-title { font-weight: 600; font-size: 14.5px; }
.next-lesson-card .nl-sub { font-size: 12px; color: var(--slate); margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--navy); color: var(--ivory); }
.btn-primary:hover { opacity: 0.92; }

.btn-gold { background: var(--gold); color: var(--navy-deep); }
.btn-gold:hover { opacity: 0.92; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--navy);
  color: var(--navy);
}
.btn-outline:hover { background: rgba(22,35,63,0.06); }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--slate);
}
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }

.btn-sm { padding: 6px 13px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.pillar-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.pillar-chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}
.pillar-Survival { background: #e4efe6; color: var(--good); }
.pillar-Workplace { background: #eee3cf; color: #8a5c17; }
.pillar-Telecom { background: #e2e8f5; color: #33487a; }

/* ---------- Course / month accordion ---------- */

.month-block { margin-bottom: 20px; }

.month-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--navy);
  color: var(--ivory);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}

.month-head h3 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}
.month-head .mh-sub { font-size: 12px; color: var(--gold-light); margin-top: 2px; }
.month-head .chevron { transition: transform .2s ease; font-size: 14px; }
.month-head.open .chevron { transform: rotate(180deg); }

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding-top: 14px;
}

.lesson-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lesson-card:hover { border-color: var(--gold); }
.lesson-card:active { transform: scale(0.99); }

.lesson-card .lc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}

.lesson-num {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--slate);
}

.lesson-card h4 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
}

.check-badge {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: transparent;
}
.check-badge.done {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

/* ---------- Lesson detail ---------- */

.lesson-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.lesson-nav-btns { display: flex; gap: 8px; }

.section-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.section-block h3 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 12px 0;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-block .sec-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--ivory-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

.vocab-list { display: flex; flex-direction: column; gap: 8px; }

.vocab-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  flex-wrap: wrap;
}

.vocab-en { font-weight: 600; min-width: 130px; }
.vocab-pt { color: var(--slate); font-size: 13px; font-style: italic; flex: 1; min-width: 130px; }
.vocab-ex { width: 100%; font-size: 12.5px; color: var(--slate); margin-top: 2px; padding-left: 2px; }

.listen-btn {
  border: 1.5px solid var(--gold);
  background: rgba(199,154,60,0.10);
  color: #8a5c17;
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.listen-btn:hover { background: rgba(199,154,60,0.2); }
.listen-btn.playing { background: var(--gold); color: var(--navy-deep); }

.expr-list, .quiz-list { display: flex; flex-direction: column; gap: 10px; }
.expr-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--ivory);
  border-radius: 10px;
  flex-wrap: wrap;
}
.expr-en { font-weight: 500; }
.expr-pt { color: var(--slate); font-size: 12.5px; font-style: italic; }

.dialogue-list { display: flex; flex-direction: column; gap: 10px; }
.dialogue-line {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 88%;
}
.dialogue-line.speaker-B { align-self: flex-end; flex-direction: row-reverse; max-width: 88%; }

.dl-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy);
  color: var(--ivory);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.speaker-B .dl-avatar { background: var(--gold); color: var(--navy-deep); }

.dl-bubble {
  background: var(--ivory);
  border-radius: 14px;
  padding: 9px 13px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.speaker-B .dl-bubble { background: #eee3cf; }

.speaking-q-list { display: flex; flex-direction: column; gap: 12px; }
.speaking-q {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.speaking-q .sq-text { font-weight: 500; margin-bottom: 10px; }
.sq-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rec-indicator {
  font-size: 12px; color: var(--warn); font-weight: 600;
  display: none; align-items: center; gap: 6px;
}
.rec-indicator.active { display: inline-flex; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.25} }

.recognized-text {
  margin-top: 10px;
  font-size: 12.5px;
  background: var(--ivory);
  border-radius: 8px;
  padding: 8px 10px;
  display: none;
}
.recognized-text.show { display: block; }
.recognized-text .rt-label { color: var(--slate); }
.recognized-text .rt-feedback { font-weight: 700; margin-top: 4px; }
.rt-feedback.ok { color: var(--good); }
.rt-feedback.retry { color: var(--warn); }

.audio-controls { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

.roleplay-box {
  border: 1.5px dashed var(--gold);
  border-radius: 12px;
  padding: 16px;
  background: rgba(199,154,60,0.06);
}
.roleplay-box h4 { margin: 0 0 6px 0; font-family: var(--font-display); font-size: 15px; }

.quiz-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.quiz-q { font-weight: 500; margin-bottom: 10px; }
.quiz-options { display: flex; flex-direction: column; gap: 7px; }
.quiz-opt {
  border: 1.5px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13.5px;
  background: #fff;
  text-align: left;
}
.quiz-opt:hover { border-color: var(--navy); }
.quiz-opt.correct { border-color: var(--good); background: #eaf5ee; }
.quiz-opt.wrong { border-color: var(--warn); background: #fbebe4; }
.quiz-opt[disabled] { cursor: default; }

.quiz-score-banner {
  display: none;
  background: var(--navy);
  color: var(--ivory);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 8px;
  font-weight: 600;
  align-items: center;
  justify-content: space-between;
}
.quiz-score-banner.show { display: flex; }

.review-box, .homework-box {
  background: var(--ivory);
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
}

.complete-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Vocabulary flashcards ---------- */

.vocab-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

select, input[type="text"] {
  border: 1.5px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: var(--font-body);
  background: #fff;
  color: var(--ink);
}

.flash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.flashcard {
  perspective: 1000px;
  height: 140px;
}
.flashcard-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  width: 100%; height: 100%;
  backface-visibility: hidden;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.flash-front { background: #fff; }
.flash-back { background: var(--navy); color: var(--ivory); transform: rotateY(180deg); }
.flash-word { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin-bottom: 6px; }
.flash-hint { font-size: 11px; color: var(--slate); }
.flash-ex { font-size: 12px; margin-top: 8px; color: rgba(247,242,230,0.85); }
.flash-back .listen-btn { border-color: var(--gold-light); color: var(--gold-light); background: rgba(255,255,255,0.08); margin-top: 8px; align-self: flex-start; }

/* ---------- Progress view ---------- */

.progress-month-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.progress-month-row:last-child { border-bottom: none; }
.pm-label { width: 90px; font-weight: 600; font-size: 13.5px; flex-shrink: 0; }
.pm-track { flex: 1; }
.pm-pct { width: 46px; text-align: right; font-size: 13px; color: var(--slate); flex-shrink: 0; }

.badge-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  border: 1.5px solid var(--line);
  color: var(--slate);
}
.badge.earned { border-color: var(--gold); color: #8a5c17; background: rgba(199,154,60,0.08); }

/* ---------- Assessments ---------- */

.assessment-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  margin-bottom: 14px;
  background: #fff;
  flex-wrap: wrap;
}
.assessment-card h3 { font-family: var(--font-display); margin: 0 0 4px 0; font-size: 16px; }
.assessment-card p { margin: 0; color: var(--slate); font-size: 13px; }
.lock-note { font-size: 12px; color: var(--warn); margin-top: 4px; }

/* ---------- Settings row (voice) ---------- */

.voice-settings {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.voice-settings label { font-size: 12.5px; color: var(--slate); margin-right: 4px; }
.speed-toggle { display: flex; gap: 4px; }
.speed-toggle button {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  font-size: 12px;
}
.speed-toggle button.active { background: var(--navy); color: var(--ivory); border-color: var(--navy); }

.empty-note {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 16px;
  color: var(--slate);
  font-size: 13.5px;
}

/* ---------- Mobile bottom nav ---------- */

.bottom-nav {
  display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sidebar { display: none; }

  .topbar-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--navy-deep);
    color: var(--ivory);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .main { padding: 16px 14px 90px 14px; }

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

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--navy-deep);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0));
    justify-content: space-around;
    z-index: 30;
    border-top: 1px solid rgba(247,242,230,0.1);
  }

  .bottom-nav button {
    background: none;
    border: none;
    color: rgba(247,242,230,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 9.5px;
    padding: 4px 6px;
    flex: 1;
  }
  .bottom-nav button .navicon { font-size: 17px; }
  .bottom-nav button.active { color: var(--gold-light); }

  .dialogue-line, .dialogue-line.speaker-B { max-width: 96%; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .view-header h1 { font-size: 22px; }
  .hello-banner { padding: 20px; }
  .hello-banner h2 { font-size: 20px; }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy-deep);
  color: var(--ivory);
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  .toast { bottom: 74px; }
}
