/* =============================================================================
   styles.css — AI Skills for Business & Finance Professionals
   Mobile-first, responsive, accessible LMS styling with light/dark themes.
   ============================================================================= */

/* ---- Theme tokens --------------------------------------------------------- */
:root {
  --bg: #f4f6fb;
  --bg-grad-1: #e8efff;
  --bg-grad-2: #eafaf3;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --ink: #14213a;
  --muted: #5b6678;
  --line: #e2e7f0;
  --brand: #2f5fe0;
  --brand-2: #19b89b;
  --brand-soft: #eaf0ff;
  --accent-soft: #e6f7f2;
  --warn: #b4690e;
  --warn-soft: #fdf2e2;
  --ok: #1a8f5e;
  --danger: #c0392b;
  --shadow: 0 10px 30px rgba(20, 33, 58, 0.08);
  --shadow-lg: 0 22px 50px rgba(20, 33, 58, 0.14);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 44px; /* minimum tap target */
  --maxw: 1180px;
}

[data-theme="dark"] {
  --bg: #0e1422;
  --bg-grad-1: #16203a;
  --bg-grad-2: #0f2230;
  --surface: #161d2e;
  --surface-2: #1c2538;
  --ink: #eef2fb;
  --muted: #a3afc4;
  --line: #2a3450;
  --brand: #6b95ff;
  --brand-2: #3fd6b8;
  --brand-soft: #1c2745;
  --accent-soft: #13302b;
  --warn: #f0b86b;
  --warn-soft: #2c2418;
  --ok: #54d29a;
  --danger: #ff7a6c;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.5);
}

/* ---- Base ----------------------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -5%, var(--bg-grad-1) 0, transparent 38%),
    radial-gradient(circle at 95% 0%, var(--bg-grad-2) 0, transparent 32%),
    var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 { line-height: 1.18; letter-spacing: -0.01em; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
img { max-width: 100%; }

/* Visible focus for keyboard users */
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  border-radius: 0 0 10px 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---- Buttons -------------------------------------------------------------- */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}
button:hover, .btn:hover { filter: brightness(1.05); }
button:active, .btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn-sm { padding: 7px 12px; min-height: 38px; font-size: 13px; }
.btn-block { width: 100%; }

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

/* Top bar (mobile-first) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand .logo {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 18px;
}
.brand .brand-text { min-width: 0; }
.brand .brand-text strong { display: block; font-size: 14px; line-height: 1.1; }
.brand .brand-text span { font-size: 11px; color: var(--muted); }

.icon-btn {
  width: var(--tap); height: var(--tap);
  padding: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line);
  font-size: 18px;
}
.menu-toggle { display: inline-flex; }

/* Sticky progress bar under the top bar */
.sticky-progress {
  position: sticky; top: 59px; z-index: 90;
  height: 5px; background: var(--line);
}
.sticky-progress > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 0.35s ease;
}

/* Layout body: sidebar + main */
.body { display: flex; flex: 1; }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  width: 290px;
  flex: none;
  padding: 16px;
  overflow-y: auto;
}
.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 14px 6px 8px; }
.nav { display: grid; gap: 4px; }
.nav button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
}
.nav button .nav-ico { font-size: 16px; width: 22px; text-align: center; }
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button[aria-current="true"] { background: var(--brand-soft); color: var(--brand); }

/* Main */
.main { flex: 1; min-width: 0; padding: 22px clamp(14px, 4vw, 40px) 60px; max-width: var(--maxw); margin: 0 auto; width: 100%; }

/* Views */
.view { display: none; animation: fadeUp 0.35s ease; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .view, .card, * { animation: none !important; transition: none !important; }
}

.view-head { margin-bottom: 18px; }
.view-head .eyebrow { text-transform: uppercase; letter-spacing: 0.12em; color: var(--brand-2); font-weight: 800; font-size: 12px; }
.view-head h1 { font-size: clamp(24px, 4vw, 38px); margin: 6px 0 8px; }
.view-head p { color: var(--muted); max-width: 70ch; }

/* ---- Cards ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 26px);
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 8px; font-size: 22px; }
.card h3 { margin: 18px 0 8px; font-size: 16px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ---- Hero (dashboard) ----------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: clamp(22px, 4vw, 40px);
  background: linear-gradient(135deg, var(--brand-soft), var(--accent-soft));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}
.hero h1 { font-size: clamp(26px, 5vw, 44px); margin: 0 0 12px; }
.hero p { color: var(--muted); max-width: 65ch; font-size: 16px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pill { background: var(--surface); border: 1px solid var(--line); color: var(--muted); padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat .num { font-size: 30px; font-weight: 800; color: var(--brand); }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Progress ring */
.ring-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring { --pct: 0; width: 116px; height: 116px; flex: none; }
.ring circle { fill: none; stroke-width: 12; }
.ring .track { stroke: var(--line); }
.ring .meter { stroke: url(#ringgrad); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.6s ease; }
.ring-label { text-align: center; }
.ring-label .big { font-size: 26px; font-weight: 800; }
.ring-label .small { color: var(--muted); font-size: 13px; }

.next-box {
  background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 16px; margin-top: 16px;
}
.next-box .small-label { font-size: 12px; font-weight: 800; color: var(--brand-2); text-transform: uppercase; letter-spacing: 0.08em; }
.motivate { color: var(--muted); font-style: italic; margin-top: 10px; }

/* ---- Learning path / phase cards ------------------------------------------ */
.phase-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); cursor: pointer; text-align: left;
  color: var(--ink); display: flex; flex-direction: column; gap: 8px; width: 100%;
}
.phase-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.phase-card .ph-ico { font-size: 26px; }
.phase-card .ph-name { font-weight: 700; font-size: 15px; }
.phase-card .ph-meta { color: var(--muted); font-size: 12.5px; }
.phase-card .mini-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: auto; }
.phase-card .mini-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* ---- Lessons -------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.search-input, .filter-select {
  font: inherit; padding: 11px 14px; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
}
.search-input { flex: 1; min-width: 200px; }

.lesson {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.lesson-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px clamp(14px, 3vw, 22px); cursor: pointer; width: 100%;
  background: transparent; color: var(--ink); text-align: left; border-radius: 0;
}
.lesson-head:hover { background: var(--surface-2); }
.lesson-head .l-id {
  flex: none; font-weight: 800; font-size: 12px; color: var(--brand);
  background: var(--brand-soft); border-radius: 8px; padding: 6px 9px; min-width: 44px; text-align: center;
}
.lesson-head .l-main { flex: 1; min-width: 0; }
.lesson-head .l-title { font-weight: 700; font-size: 15.5px; }
.lesson-head .l-goal { color: var(--muted); font-size: 13px; margin-top: 2px; }
.lesson-head .l-chevron { transition: transform 0.25s ease; color: var(--muted); font-size: 14px; }
.lesson[open] .l-chevron, .lesson.open .l-chevron { transform: rotate(180deg); }
.l-status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.lesson.done .l-status-dot { background: var(--ok); }

.lesson-body { padding: 0 clamp(14px, 3vw, 22px) 20px; display: none; }
.lesson.open .lesson-body { display: block; animation: fadeUp 0.3s ease; }

.block { margin-top: 16px; }
.block .label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand-2); margin-bottom: 6px; }
.analogy { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-style: italic; }
.tasklist { margin: 0; padding-left: 20px; }
.tasklist li { margin: 5px 0; }

/* Exercise */
.exercise { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; margin-top: 12px; }
.exercise .ex-head { font-weight: 800; color: var(--brand); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.exercise .ex-q { margin: 8px 0 10px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
.answer-box {
  margin-top: 10px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--ink); display: none;
}
.answer-box.show { display: block; animation: fadeUp 0.25s ease; }

/* Prompt + code blocks */
.codeblock {
  position: relative; background: #10182b; color: #e8eefc;
  border-radius: var(--radius-sm); padding: 14px 14px; font-size: 13px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.5;
}
[data-theme="dark"] .codeblock { background: #0a0f1d; border: 1px solid var(--line); }

.mini-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.done-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 14px; min-height: var(--tap); font-weight: 600;
}
.done-toggle input { width: 18px; height: 18px; accent-color: var(--ok); }

/* ---- Workflow graphic ----------------------------------------------------- */
.flow { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.flow-step {
  flex: 1 1 140px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; align-items: center; color: var(--ink);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.flow-step:hover { transform: translateY(-2px); border-color: var(--brand); }
.flow-step[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.flow-step .fs-ico { font-size: 26px; }
.flow-step .fs-label { font-weight: 700; font-size: 13.5px; }
.flow-arrow { align-self: center; color: var(--muted); font-size: 18px; }
.flow-detail {
  margin-top: 16px; padding: 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); display: none;
}
.flow-detail.show { display: block; animation: fadeUp 0.25s ease; }
.flow-detail .fd-eg { margin-top: 8px; color: var(--muted); }

/* ---- Prompt builder ------------------------------------------------------- */
.pb-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.field label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.field .help { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.field textarea, .field input {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); resize: vertical;
}
.field textarea { min-height: 60px; }
.preview {
  margin-top: 16px; background: #10182b; color: #e8eefc; border-radius: var(--radius-sm);
  padding: 16px; white-space: pre-wrap; word-break: break-word; min-height: 80px; line-height: 1.55;
}
[data-theme="dark"] .preview { background: #0a0f1d; border: 1px solid var(--line); }

/* ---- Tool chooser --------------------------------------------------------- */
.chooser-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.chooser-options button {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  justify-content: flex-start; text-align: left; font-weight: 600; padding: 14px;
}
.chooser-options button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.chooser-result { margin-top: 18px; display: none; }
.chooser-result.show { display: block; animation: fadeUp 0.25s ease; }
.tool-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tool-tag { background: var(--accent-soft); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 13px; }

/* ---- Glossary flip cards -------------------------------------------------- */
.glossary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.flip { background: transparent; border: 0; padding: 0; perspective: 1000px; height: 180px; cursor: pointer; }
.flip-inner {
  position: relative; width: 100%; height: 100%; text-align: left;
  transition: transform 0.5s; transform-style: preserve-3d;
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); overflow: auto;
}
.flip-front { background: linear-gradient(135deg, var(--brand-soft), var(--accent-soft)); display: flex; flex-direction: column; justify-content: center; }
.flip-front .term { font-weight: 800; font-size: 18px; }
.flip-front .tap-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
.flip-back { background: var(--surface); transform: rotateY(180deg); }
.flip-back .term { font-weight: 800; font-size: 14px; color: var(--brand); margin-bottom: 6px; }
.flip-back .def { font-size: 13px; }
.flip-back .eg { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---- Portfolio ------------------------------------------------------------ */
.portfolio-list { display: grid; gap: 10px; }
.pf-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; box-shadow: var(--shadow);
}
.pf-item input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ok); flex: none; }
.pf-item.done .pf-label { text-decoration: line-through; color: var(--muted); }
.pf-label { font-weight: 700; }
.pf-hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---- Prompt library ------------------------------------------------------- */
.lib-cat { margin-bottom: 22px; }
.lib-cat h3 { display: flex; align-items: center; gap: 8px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.prompt-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; box-shadow: var(--shadow); }
.prompt-card .pc-title { font-weight: 800; }
.prompt-card .pc-use { color: var(--muted); font-size: 12.5px; margin: 2px 0 10px; }

/* ---- Tables (datasets) ---------------------------------------------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 520px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; white-space: nowrap; }
th { background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }

/* ---- Capstone ------------------------------------------------------------- */
.summary-card { background: linear-gradient(135deg, var(--brand-soft), var(--accent-soft)); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.checklist-final { display: grid; gap: 8px; margin-top: 12px; }
.checklist-final li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; list-style: none; }

/* ---- Toast ---------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0;
  pointer-events: none; transition: all 0.3s ease; z-index: 300;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Backdrop for mobile sidebar ----------------------------------------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(10, 16, 30, 0.45);
  z-index: 95; display: none;
}
.backdrop.show { display: block; }

/* ---- Footer --------------------------------------------------------------- */
.foot { color: var(--muted); font-size: 12.5px; text-align: center; padding: 24px 16px; }

/* =============================================================================
   Responsive: desktop sidebar, mobile drawer
   ============================================================================= */
@media (max-width: 880px) {
  .pb-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sticky-progress { top: 59px; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    width: 80%; max-width: 320px;
    transform: translateX(-105%); transition: transform 0.28s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
}

@media (min-width: 881px) {
  .menu-toggle { display: none; }
  .backdrop { display: none !important; }
  .sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); }
}

/* Larger screens: more columns where it helps */
@media (min-width: 1100px) {
  .learning-path-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Print ---------------------------------------------------------------- */
@media print {
  .topbar, .sidebar, .sticky-progress, .toolbar, .mini-actions, .icon-btn, .backdrop, .foot { display: none !important; }
  .view { display: block !important; }
  .lesson-body { display: block !important; }
  .answer-box { display: block !important; }
  body { background: #fff; }
}
