/* ============================================================
   SKILL2INCOME ACADEMY — LEARNING PLATFORM STYLES
   ============================================================ */

:root {
  --cream: #F7F2E7;
  --white: #FFFFFF;
  --forest: #17422C;
  --forest-deep: #0F2E1E;
  --gold: #C89B3C;
  --gold-light: #E4C77E;
  --ink: #24261F;
  --muted: #6E7566;
  --line: #E7E0CE;
  --success: #3F7D53;
  --success-bg: #EAF3EC;
  --danger: #A23B3B;
}

* { box-sizing: border-box; }
html, body { width: 100%; margin: 0; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: 'Fraunces', serif; color: var(--forest); margin: 0; letter-spacing: -0.01em; }

a { color: inherit; }

button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex: none;
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  transform: translateX(0);
  transition: transform 0.2s ease;
  z-index: 40;
  overflow-y: auto;
}

.sidebar-brand {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--forest);
  padding: 0 12px 24px;
}
.sidebar-brand span { color: var(--gold); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--cream); color: var(--ink); }
.nav-item.active { background: var(--success-bg); color: var(--forest); }

.sidebar-xp-card {
  margin-top: 24px;
  background: var(--cream);
  border-radius: 12px;
  padding: 16px;
}
.sidebar-xp-card .level-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.sidebar-xp-card .level-label { font-weight: 700; color: var(--forest); font-size: 15px; }
.sidebar-xp-card .xp-label { font-weight: 700; color: var(--gold); font-size: 13.5px; }
.xp-bar-track {
  height: 8px;
  background: var(--line);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--forest));
  border-radius: 100px;
}
.xp-to-next { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.streak-line { font-size: 13px; color: var(--ink); font-weight: 600; }

.main-content {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
}
.menu-toggle svg { width: 22px; height: 22px; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--forest);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.logout-btn {
  background: none;
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}
.logout-btn:hover { background: var(--cream); color: var(--ink); }

.page-body { padding: 32px 28px 64px; max-width: 1080px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 39;
}

@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .page-body { padding: 24px 16px 48px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 13px 22px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  border: none;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--forest-deep); }
.btn-gold { background: var(--gold); color: var(--forest-deep); }
.btn-gold:hover { background: var(--gold-light); }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 24px 0 32px;
}
@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.stat-value { font-family: 'Fraunces', serif; font-size: 34px; font-weight: 600; color: var(--forest); }
.stat-value.accent-gold { color: var(--gold); }
.stat-value.accent-success { color: var(--success); }
.stat-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- Course card ---------- */
.course-card {
  display: flex;
  gap: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 14px;
  align-items: center;
}
.course-icon {
  width: 56px; height: 56px;
  border-radius: 10px;
  background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  flex: none;
}
.course-info { flex: 1; min-width: 0; }
.course-title { font-weight: 700; font-size: 16px; color: var(--ink); margin-bottom: 8px; }
.progress-track {
  height: 8px;
  background: var(--line);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill { height: 100%; background: var(--forest); border-radius: 100px; }
.progress-text { font-size: 12.5px; color: var(--muted); }
.course-cta { flex: none; font-weight: 700; font-size: 14px; color: var(--forest); text-decoration: none; white-space: nowrap; }
.course-cta:hover { text-decoration: underline; }

/* ---------- Section headers ---------- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 20px; }
.section-header .view-all { font-size: 13.5px; font-weight: 700; color: var(--forest); text-decoration: none; }

/* ---------- Auth page ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(23,66,44,0.08);
}
.auth-brand {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--forest);
  text-align: center;
  margin-bottom: 6px;
}
.auth-brand span { color: var(--gold); }
.auth-subtitle { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 28px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--cream);
}
.field input:focus { outline: 2px solid var(--gold); outline-offset: 1px; background: var(--white); }

.auth-toggle { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.auth-toggle button { background: none; border: none; color: var(--forest); font-weight: 700; text-decoration: underline; padding: 0; font-size: 13.5px; }

.form-error {
  background: #FBEAEA;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: none;
}
.form-error.visible { display: block; }

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state .display { font-size: 18px; margin-bottom: 8px; color: var(--forest); }

/* ---------- Lesson viewer ---------- */
.lesson-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.lesson-list {
  width: 280px;
  flex: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}
.lesson-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 2px;
}
.lesson-list-item:hover { background: var(--cream); }
.lesson-list-item.active { background: var(--success-bg); color: var(--forest); font-weight: 700; }
.lesson-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line);
  flex: none;
  display: flex; align-items: center; justify-content: center;
}
.lesson-check.done { background: var(--success); border-color: var(--success); }
.lesson-check.done svg { width: 11px; height: 11px; }

.lesson-main { flex: 1; min-width: 0; }
.lesson-content-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
}
.lesson-content-card h1 { font-size: 26px; margin-bottom: 16px; }
.lesson-body { font-size: 16px; color: var(--ink); max-width: 68ch; margin-bottom: 28px; }
.xp-pill {
  display: inline-block;
  background: var(--cream);
  color: var(--gold);
  font-weight: 700;
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 100px;
  margin-bottom: 18px;
}

.quiz-box {
  background: var(--cream);
  border-radius: 10px;
  padding: 20px;
  margin: 24px 0;
}
.quiz-question { font-weight: 700; margin-bottom: 14px; }
.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 14.5px;
}
.quiz-option:hover { border-color: var(--gold); }
.quiz-option.correct { border-color: var(--success); background: var(--success-bg); }
.quiz-option.incorrect { border-color: var(--danger); background: #FBEAEA; }
.quiz-feedback { font-size: 14px; font-weight: 600; margin-top: 8px; }
.quiz-feedback.correct { color: var(--success); }
.quiz-feedback.incorrect { color: var(--danger); }

.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
}

@media (max-width: 880px) {
  .lesson-layout { flex-direction: column; }
  .lesson-list { width: 100%; }
}

/* ---------- Certificates ---------- */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.cert-card {
  background: var(--forest);
  border-radius: 14px;
  padding: 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.cert-card .cert-seal { position: absolute; top: 18px; right: 18px; font-size: 28px; opacity: 0.7; }
.cert-card h3 { color: #fff; font-size: 18px; margin-bottom: 6px; max-width: 80%; }
.cert-card .cert-date { color: var(--gold-light); font-size: 13px; margin-bottom: 18px; }
.cert-card .btn { margin-top: 4px; }

/* ---------- Leaderboard ---------- */
.leader-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.leader-row:last-child { border-bottom: none; }
.leader-rank { font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px; color: var(--muted); width: 28px; }
.leader-row.top-3 .leader-rank { color: var(--gold); }
.leader-name { flex: 1; font-weight: 600; }
.leader-xp { font-weight: 700; color: var(--forest); }
.leader-row.is-you { background: var(--success-bg); border-radius: 8px; }
