/* Optima Elevate styles. Brand colours come from CSS variables so an organization
   can have its own colours (see applyBranding in js/app.mjs). */
:root {
  --primary: #0A2540;
  --accent: #E8623A;
  --accent-hover: #C74E29;
  --bg: #FAF9F6;
  --card: #ffffff;
  --text: #0A2540;
  --muted: #5a6b7d;
  --line: #E5E7EB;
  --ok: #1a7f4b;
  --ok-bg: #eaf7ef;
  --warn: #8a4b00;
  --warn-bg: #fff4ec;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0e1620; --card: #17222f; --text: #e8eef4; --muted: #9db0c2; --line: #2a3a4c; --ok-bg: #123524; --warn-bg: #3a2614; --bad-bg: #3d1716; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0e1620; --card: #17222f; --text: #e8eef4; --muted: #9db0c2; --line: #2a3a4c; --ok-bg: #123524; --warn-bg: #3a2614; --bad-bg: #3d1716; color-scheme: dark; }

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; color: var(--text); }
h1 { font-size: 26px; margin: 8px 0 12px; }
h2 { font-size: 20px; margin: 22px 0 10px; }
h3 { font-size: 17px; margin: 14px 0 8px; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 18px 16px; flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.accent { color: var(--accent); }
.hidden { display: none !important; }

/* top bar */
.topbar { background: var(--primary); color: #fff; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 20px; }
.brand .accent { color: var(--accent); }
.brand img { height: 34px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; }
.nav a, .nav button { color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 7px 11px; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; }
.nav a:hover, .nav a.active, .nav button:hover { background: #fff; color: var(--primary); }
.banner { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--line); padding: 10px 16px; font-size: 14px; }
.banner.error { background: var(--bad-bg); color: var(--bad); }
.footer { color: var(--muted); font-size: 12px; text-align: center; padding: 14px; border-top: 1px solid var(--line); }

/* cards and layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.split { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 820px) { .split { grid-template-columns: 240px 1fr; } }
.stat { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }

/* course cards */
.course-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); }
.course-card:hover { border-color: var(--accent); }
.course-card h3 { margin: 4px 0; }
.pill { display: inline-block; background: var(--line); border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 700; margin-right: 6px; color: var(--text); }
.pill.accent { background: #ffe9de; color: #8a2f00; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
@media (prefers-color-scheme: dark) { .pill.accent { background: #3d2316; color: #ffb89c; } }

/* buttons and forms */
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-hover); filter: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--primary); border: 1px solid var(--line); }
:root[data-theme="dark"] .btn.secondary, .btn.secondary { color: var(--text); }
.btn.small-btn { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: var(--bad); }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 10px 0; }
.help { font-size: 13px; color: var(--muted); margin-top: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 13px; }
.table-wrap { overflow-x: auto; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs button { background: var(--card); border: 1px solid var(--line); color: var(--text); padding: 8px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.progress { background: var(--line); border-radius: 999px; height: 10px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); }

/* lesson view */
.lesson-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .lesson-layout { grid-template-columns: 260px 1fr; } }
.toc a { display: block; padding: 6px 8px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.toc a.active { background: var(--line); font-weight: 700; }
.toc a.done::before { content: "✓ "; color: var(--ok); font-weight: 800; }
.toc .mod { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 12px 8px 4px; letter-spacing: .4px; }
.prose p { margin: 0 0 12px; }
.video { position: relative; padding-top: 56.25%; background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.quiz-q { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.quiz-opt { display: block; width: 100%; text-align: left; margin: 6px 0; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; cursor: pointer; font: inherit; }
.quiz-opt.right { border-color: var(--ok); background: var(--ok-bg); }
.quiz-opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.callout { border-left: 4px solid var(--accent); background: var(--warn-bg); padding: 10px 14px; border-radius: 8px; margin: 14px 0; }
.tutorial-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tutorial-tabs button { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; }
.tutorial-tabs button.active { background: var(--primary); color: #fff; }
.live-item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }

/* toast */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 92vw; z-index: 50; font-size: 14px; }
.toast.error { background: var(--bad); }

@media (max-width: 600px) {
  .container { padding: 14px 16px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
}

/* ---------- Certificates (version 3) ---------- */
.certificate { background: #fff; color: #16202c; border: 6px double var(--cert-accent, #0A2540); border-radius: 14px; padding: 36px 28px; text-align: center; max-width: 760px; margin: 0 auto; }
.certificate .cert-logo { max-height: 70px; max-width: 220px; object-fit: contain; margin-bottom: 8px; }
.certificate .cert-kicker { text-transform: uppercase; letter-spacing: .18em; font-size: 12px; color: var(--cert-accent, #0A2540); font-weight: 700; margin: 4px 0 18px; }
.certificate .cert-name { font-size: 32px; color: var(--cert-accent, #0A2540); margin: 8px 0; }
.certificate .cert-course { font-size: 22px; margin: 6px 0 14px; }
.cert-test { background: #fff4ec; color: #8a4b00; border: 1px solid #E8623A; border-radius: 10px; padding: 10px 14px; font-weight: 700; text-align: center; margin-bottom: 12px; }
@media print {
  body { background: #fff; color: #000; }
  .topbar, .footer, .no-print, .banner, nav { display: none !important; }
  .certificate { border-width: 4px; box-shadow: none; }
}
