/* Gold Mandate Programme — bank-grade deep navy + gold, light & dark. */

:root {
  --navy-950: #060d1c;
  --navy-900: #0e1f3d;
  --navy-800: #142c53;
  --navy-700: #1c3a68;
  --navy-600: #29507f;
  --gold-600: #b8901f;
  --gold-500: #d4af37;
  --gold-400: #e3c565;
  --gold-100: #f6ecca;

  --bg: #f6f7fa;
  --bg-elevated: #ffffff;
  --bg-sunken: #eceef3;
  --text: #101826;
  --text-muted: #55607a;
  --border: #dde1ea;
  --accent: var(--navy-900);
  --accent-contrast: #ffffff;
  --gold: var(--gold-500);
  --gold-contrast: #201400;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --success: #1e7a4c;
  --success-bg: #e7f6ee;
  --shadow: 0 1px 2px rgba(16, 24, 38, 0.06), 0 8px 24px -12px rgba(16, 24, 38, 0.18);
  --radius: 12px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1220;
    --bg-elevated: #101c30;
    --bg-sunken: #0c1626;
    --text: #eef1f7;
    --text-muted: #9aa6c0;
    --border: #243352;
    --accent: var(--gold-500);
    --accent-contrast: #1a1200;
    --gold: var(--gold-500);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.6);
    --danger-bg: #3a1613;
    --success-bg: #10301f;
  }
}

:root[data-theme="dark"] {
  --bg: #0a1220;
  --bg-elevated: #101c30;
  --bg-sunken: #0c1626;
  --text: #eef1f7;
  --text-muted: #9aa6c0;
  --border: #243352;
  --accent: var(--gold-500);
  --accent-contrast: #1a1200;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.6);
  --danger-bg: #3a1613;
  --success-bg: #10301f;
}

:root[data-theme="light"] {
  --bg: #f6f7fa;
  --bg-elevated: #ffffff;
  --bg-sunken: #eceef3;
  --text: #101826;
  --text-muted: #55607a;
  --border: #dde1ea;
  --accent: var(--navy-900);
  --accent-contrast: #ffffff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; color: var(--text); line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: inherit; }
.muted { color: var(--text-muted); font-size: 0.92rem; }
code { background: var(--bg-sunken); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.9em; }
input, textarea, select, button { font-family: inherit; font-size: 1rem; color: var(--text); }

/* ---- App shell layout ------------------------------------------------ */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr auto;
  grid-template-areas:
    "header header"
    "nav main"
    "footer footer";
  min-height: 100vh;
}
.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--navy-900);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; font-family: var(--font-serif); }
.brand-mark { color: var(--gold-500); font-size: 1.3rem; }
.brand-text { font-weight: 700; letter-spacing: 0.01em; }
.header-spacer { flex: 1; }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
#nav-toggle { display: none; }

.app-nav {
  grid-area: nav;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: sticky;
  top: 60px;
  align-self: start;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.main-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-link:hover { background: var(--bg-sunken); color: var(--text); }
.nav-link.active { background: var(--navy-900); color: var(--gold-400); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nav-link.active { background: var(--gold-500); color: var(--gold-contrast); }
}
:root[data-theme="dark"] .nav-link.active { background: var(--gold-500); color: var(--gold-contrast); }

.app-main { grid-area: main; padding: 28px 32px 48px; max-width: 980px; width: 100%; }
.app-footer {
  grid-area: footer;
  padding: 14px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
.nav-scrim { display: none; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "header" "main" "footer"; }
  #nav-toggle { display: inline-flex; }
  .app-nav {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
    box-shadow: var(--shadow);
  }
  .app-shell.nav-open .app-nav { transform: translateX(0); }
  .app-shell.nav-open .nav-scrim {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(6, 13, 28, 0.45);
    z-index: 25;
  }
  .app-main { padding: 20px 16px 40px; }
}

/* ---- Breadcrumb -------------------------------------------------------- */
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 14px; }
.breadcrumb a.crumb { color: var(--text-muted); text-decoration: none; }
.breadcrumb a.crumb:hover { text-decoration: underline; }
.crumb-current { color: var(--text); font-weight: 600; }
.crumb-sep { margin: 0 6px; opacity: 0.5; }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  background: var(--bg-sunken);
  color: var(--text);
}
.btn-small { padding: 7px 14px; font-size: 0.85rem; }
.btn-primary { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.btn-primary:hover { background: var(--navy-800); }
:root[data-theme="dark"] .btn-primary { background: var(--gold-500); color: var(--gold-contrast); border-color: var(--gold-500); }
:root[data-theme="dark"] .btn-primary:hover { background: var(--gold-400); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-sunken); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---- Dashboard ----------------------------------------------------------- */
.stub-banner {
  background: var(--gold-100);
  border: 1px solid var(--gold-500);
  color: #4a3a05;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 20px;
}
:root[data-theme="dark"] .stub-banner { background: #26200a; color: var(--gold-100); border-color: var(--gold-600); }

.dash-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  color: #fff;
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}
.dash-hero-text h1 { color: #fff; }
.dash-hero-text .muted { color: #c3cee6; }
.dash-hero-ring { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.dash-hero-ring .muted { color: #c3cee6; font-size: 0.8rem; }
.ring-svg { width: 100px; height: 100px; }
.ring-track { stroke: rgba(255, 255, 255, 0.18); }
.ring-progress { stroke: var(--gold-500); stroke-linecap: round; transition: stroke-dashoffset 0.4s ease; }
.ring-text { fill: #fff; font-size: 20px; font-weight: 700; font-family: var(--font-serif); }

.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 700px) { .dash-stats { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 1.6rem; font-weight: 700; font-family: var(--font-serif); color: var(--accent); }
.stat-label { color: var(--text-muted); font-size: 0.82rem; }

.dash-chart-card, .module-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.chart-svg { width: 100%; height: auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-text { fill: var(--text-muted); font-size: 10px; }
.chart-empty-text { fill: var(--text-muted); font-size: 13px; }
.chart-area { fill: color-mix(in srgb, var(--gold-500) 18%, transparent); stroke: none; }
.chart-line { fill: none; stroke: var(--gold-600); stroke-width: 2.5; }
:root[data-theme="dark"] .chart-line { stroke: var(--gold-400); }
.chart-pass-line { stroke: var(--success); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart-dot-pass { fill: var(--success); }
.chart-dot-fail { fill: var(--danger); }

.module-list { display: flex; flex-direction: column; gap: 16px; }
.module-card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.module-card-pct { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); }
.bar-svg { width: 90px; height: 10px; }
.bar-track { fill: var(--bg-sunken); }
.bar-fill { fill: var(--gold-600); }
:root[data-theme="dark"] .bar-fill { fill: var(--gold-500); }

.lesson-row-list { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.lesson-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.lesson-row:hover { background: var(--bg-sunken); }
.lesson-row-check { width: 18px; color: var(--success); font-weight: 700; }
.lesson-row-title { flex: 1; }
.lesson-row-dur { color: var(--text-muted); font-size: 0.82rem; }
.lesson-row-done .lesson-row-title { color: var(--text-muted); }

/* ---- Lesson view --------------------------------------------------------- */
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; color: var(--gold-600); font-weight: 700; margin: 0 0 6px; }
:root[data-theme="dark"] .eyebrow { color: var(--gold-400); }
.lesson-head { margin-bottom: 12px; }
.objectives-list, .takeaways-list { padding-left: 1.2em; }
.lesson-section { margin: 24px 0; }
.markdown-body p { margin: 0 0 1em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.4em; }
.markdown-body blockquote { border-left: 3px solid var(--gold-500); margin: 0 0 1em; padding: 2px 0 2px 14px; color: var(--text-muted); }

.callout {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}
.callout-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; }
.callout-body { font-size: 0.92rem; }
.callout-tip { border-color: #8fb7e0; background: color-mix(in srgb, #8fb7e0 14%, var(--bg-elevated)); }
.callout-example { border-color: #9ac7a8; background: color-mix(in srgb, #9ac7a8 14%, var(--bg-elevated)); }
.callout-warning { border-color: var(--danger); background: var(--danger-bg); }
.callout-law { border-color: #6b5bd6; background: color-mix(in srgb, #6b5bd6 14%, var(--bg-elevated)); }
.callout-saudi { border-color: var(--gold-500); background: color-mix(in srgb, var(--gold-500) 16%, var(--bg-elevated)); }

.kc-question, .test-question { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 12px 0; }
.kc-prompt { margin: 0 0 8px; }
.kc-options { display: flex; flex-direction: column; gap: 6px; }
.option-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.option-row:hover { background: var(--bg-sunken); }
.kc-feedback { margin-top: 10px; padding: 10px; border-radius: 8px; font-size: 0.9rem; }
.kc-feedback-correct { background: var(--success-bg); color: var(--success); }
.kc-feedback-incorrect { background: var(--danger-bg); color: var(--danger); }
.lesson-actions, .test-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- Test / exam results ---------------------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; background: var(--bg-sunken); }
.badge-pass { background: var(--success-bg); color: var(--success); }
.badge-fail { background: var(--danger-bg); color: var(--danger); }
.result-banner { border-radius: var(--radius); padding: 18px; margin-top: 16px; }
.result-pass { background: var(--success-bg); }
.result-fail { background: var(--danger-bg); }

/* ---- Flashcards --------------------------------------------------------- */
.flashcard-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 20px 0; }
.flashcard {
  width: 100%;
  max-width: 520px;
  min-height: 220px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
}
.flashcard-face { width: 100%; }
.flashcard-front { background: linear-gradient(160deg, var(--bg-elevated), var(--bg-sunken)); }
.flashcard-hint { margin-top: 14px; font-size: 0.8rem; }
.flashcard-ratings { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.flashcard-ratings[hidden] { display: none; }
.rating-again { background: var(--danger-bg); color: var(--danger); }
.rating-hard { background: #fdf1dc; color: #8a5a00; }
.rating-good { background: var(--success-bg); color: var(--success); }
.rating-easy { background: color-mix(in srgb, var(--gold-500) 22%, var(--bg-elevated)); color: var(--gold-600); }

/* ---- Scenarios ----------------------------------------------------------- */
.artifact-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.artifact-card { border: 1px dashed var(--border); border-radius: 10px; padding: 14px; background: var(--bg-sunken); }
.artifact-kind { text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }

/* ---- Capstone --------------------------------------------------------- */
.checklist, .checklist-static { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; list-style: none; padding: 0; }
.check-row { display: flex; align-items: flex-start; gap: 8px; }
.req-done { color: var(--success); }
.req-pending { color: var(--text-muted); }
.field-label { display: block; font-size: 0.85rem; font-weight: 600; margin: 10px 0 4px; }
textarea, input[type="text"], input[type="search"], input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}
.search-input { margin: 12px 0; }
.capstone-final-actions { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }

/* ---- Certificate --------------------------------------------------------- */
.certificate-sheet { margin-top: 24px; }
.certificate-border {
  border: 3px solid var(--gold-500);
  outline: 1px solid var(--navy-900);
  outline-offset: -8px;
  border-radius: 6px;
  padding: 56px 40px;
  text-align: center;
  background: var(--bg-elevated);
  position: relative;
}
.certificate-eyebrow { text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold-600); font-weight: 700; font-size: 0.8rem; }
.certificate-title { font-size: 2rem; margin: 8px 0 20px; }
.certificate-body { max-width: 520px; margin: 0 auto 24px; }
.certificate-name { font-family: var(--font-serif); font-size: 1.6rem; border-bottom: 2px solid var(--gold-500); display: inline-block; padding: 0 20px 6px; }
.certificate-meta { margin-top: 20px; color: var(--text-muted); font-size: 0.85rem; }
.certificate-seal { position: absolute; bottom: 24px; right: 32px; color: var(--gold-500); font-size: 1.6rem; }

/* ---- Ask the course ---------------------------------------------------- */
.ask-results { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ask-result-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-elevated);
}
.ask-result-card:hover { border-color: var(--gold-500); }
.ask-result-kind { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold-600); font-weight: 700; }
:root[data-theme="dark"] .ask-result-kind { color: var(--gold-400); }

/* ---- Glossary ------------------------------------------------------------- */
.glossary-list { display: flex; flex-direction: column; gap: 10px; }
.glossary-item { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.glossary-item dt { font-weight: 700; }
.glossary-item dd { margin: 4px 0 0; color: var(--text-muted); }

/* ---- Templates ---------------------------------------------------------- */
.template-preview { border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-top: 16px; background: var(--bg-sunken); }

/* ---- Empty state ----------------------------------------------------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ---- Header: language switcher + greeting ------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.header-greeting { color: var(--gold-400); font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.lang-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.85rem;
}
.lang-select option { color: #101826; }

/* ---- Language-fallback content banner ----------------------------------- */
.lang-fallback-banner {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ---- Onboarding overlay ------------------------------------------------- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
}
.onboarding-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  max-height: 90vh;
  overflow-y: auto;
}
.onboarding-card select { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); }
.field-error { color: var(--danger); font-size: 0.85rem; margin: 4px 0 0; }

/* ---- Worked examples / case studies -------------------------------------- */
.worked-example, .case-study {
  border: 1px solid var(--gold-500);
  border-radius: var(--radius);
  padding: 16px 20px;
  background: color-mix(in srgb, var(--gold-500) 8%, var(--bg-elevated));
}
.worked-example-tag, .case-study-tag {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gold-600);
  background: var(--gold-100);
  border-radius: 999px;
  padding: 2px 10px;
  margin-right: 8px;
  vertical-align: middle;
}
:root[data-theme="dark"] .worked-example-tag, :root[data-theme="dark"] .case-study-tag { color: var(--gold-contrast); background: var(--gold-500); }
.case-study-arena { margin-top: -8px; }
.callout-arena { border-color: #4f9e8f; background: color-mix(in srgb, #4f9e8f 14%, var(--bg-elevated)); }

/* ---- World Arenas -------------------------------------------------------- */
.arena-card .markdown-body { margin-top: 10px; }

/* ---- Deal Simulator ------------------------------------------------------ */
.badge-ai { background: color-mix(in srgb, var(--gold-500) 25%, var(--bg-elevated)); color: var(--gold-600); margin-bottom: 8px; }
:root[data-theme="dark"] .badge-ai { color: var(--gold-400); }
.badge-practice { background: var(--bg-sunken); color: var(--text-muted); margin-bottom: 8px; }
.sim-offline-note { font-style: italic; }

/* ---- RTL readiness (future Arabic drop-in) ------------------------------- */
[dir="rtl"] .app-shell { grid-template-areas: "header header" "nav main" "footer footer"; }
[dir="rtl"] .app-nav { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .crumb-sep { transform: scaleX(-1); display: inline-block; }
[dir="rtl"] .lesson-row-check { transform: scaleX(-1); }
@media (max-width: 860px) {
  [dir="rtl"] .app-nav { left: auto; right: 0; transform: translateX(100%); }
  [dir="rtl"] .app-shell.nav-open .app-nav { transform: translateX(0); }
}

/* ---- Print (capstone export + certificate) ---------------------------- */
@media print {
  .app-header, .app-nav, .app-footer, .nav-scrim, .no-print, .test-actions, .lesson-actions { display: none !important; }
  .app-shell { display: block; }
  .app-main { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
  .certificate-border { border-color: #b8901f; outline-color: #0e1f3d; }
}
