/* JEXA Academy staff portal: sign-in, password reset and dashboards. */
:root {
  --navy-950: #070f1c;
  --navy-900: #0b1a2e;
  --navy-800: #12243d;
  --navy-700: #1b3352;
  --navy-600: #2a4568;
  --gold-500: #c9a24a;
  --gold-400: #d8b766;
  --gold-300: #e6cd92;
  --gold-100: #f5ecd6;
  --ivory: #f6f1e7;
  --paper: #fbf9f4;
  --ink: #18212f;
  --ink-2: #4a5568;
  --ink-3: #6b7486;
  --line: #e4dfd3;
  --danger: #a23a2e;
  --danger-bg: #fbeceb;
  --warn: #8a5a12;
  --warn-bg: #fdf3e1;
  --ok: #2f6b4a;
  --ok-bg: #e9f4ee;
  --radius: 14px;
  --shadow: 0 24px 60px -24px rgba(7, 15, 28, .45), 0 2px 6px rgba(7, 15, 28, .08);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--paper); line-height: 1.5; }
a { color: inherit; }
button, input { font: inherit; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--gold-500); color: var(--navy-950); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px;
  font-family: var(--serif); font-weight: 700; font-size: 26px; color: var(--navy-950);
  background: linear-gradient(140deg, var(--gold-300), var(--gold-500) 55%, #a8822f);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 6px 18px -6px rgba(201,162,74,.6);
}
.brand-text { font-family: var(--serif); font-size: 24px; letter-spacing: .02em; line-height: 1.05; display: flex; flex-direction: column; }
.brand-text strong { letter-spacing: .14em; font-weight: 700; }
.brand-text small { font-family: var(--sans); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-400); margin-top: 4px; }
.brand-center { justify-content: center; margin-bottom: 18px; }
.brand-center .brand-text { flex-direction: row; gap: 6px; align-items: baseline; color: var(--navy-900); }

/* ---------- auth pages ---------- */
body.auth { min-height: 100vh; background: var(--navy-950); }
.auth-split { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-hero { display: none; }
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(201,162,74,.16), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(42,69,104,.6), transparent 60%),
    var(--navy-900);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--paper); border-radius: 20px; padding: 36px 28px 28px;
  box-shadow: var(--shadow); border: 1px solid rgba(201,162,74,.28); position: relative;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; border-radius: 20px 20px 0 0;
  background: linear-gradient(90deg, transparent, var(--gold-500), transparent);
}
.auth-mobile-brand { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-mobile-brand .brand-text { color: var(--navy-900); flex-direction: row; gap: 6px; align-items: baseline; }
.portal-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--navy-700); background: var(--gold-100); border: 1px solid var(--gold-300);
  padding: 4px 10px; border-radius: 999px;
}
.auth-title { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.1; margin: 14px 0 6px; color: var(--navy-900); }
.auth-sub { margin: 0 0 24px; color: var(--ink-2); font-size: 15px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--navy-800); margin-bottom: 6px; }
.input-wrap { position: relative; }
.field input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(201,162,74,.18); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.input-wrap input { padding-right: 52px; }
.toggle-pw {
  position: absolute; right: 4px; top: 4px; height: 40px; width: 44px; border: 0; background: transparent; border-radius: 8px;
  color: var(--ink-3); cursor: pointer; display: grid; place-items: center;
}
.toggle-pw:hover { color: var(--navy-800); background: var(--ivory); }
.toggle-pw svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 20px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--navy-700); font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--gold-400); }
.link-btn:hover { color: var(--navy-950); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 50px; border-radius: 10px;
  border: 0; font-weight: 600; font-size: 15px; letter-spacing: .02em; cursor: pointer; text-decoration: none; transition: transform .05s, filter .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { cursor: progress; filter: saturate(.6) brightness(.95); }
.btn-gold { color: var(--navy-950); background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); box-shadow: 0 10px 22px -12px rgba(201,162,74,.9), inset 0 1px 0 rgba(255,255,255,.4); }
.btn-gold:hover { filter: brightness(1.04); }
.btn-ghost { background: transparent; color: var(--navy-800); border: 1px solid var(--line); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(7,15,28,.25); border-top-color: var(--navy-950); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 18px; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #f0cfcb; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f1ddb4; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #cfe5d8; }
.auth-foot { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; font-size: 13px; color: var(--ink-3); }
.auth-foot a { color: var(--navy-700); }
.fine { font-size: 12px; color: var(--ink-3); text-align: center; margin: 14px 0 0; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

@media (min-width: 960px) {
  .auth-split { grid-template-columns: 1.05fr 1fr; }
  .auth-hero {
    display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px; color: var(--ivory); position: relative; overflow: hidden;
    background:
      radial-gradient(700px 420px at 0% 0%, rgba(201,162,74,.22), transparent 60%),
      linear-gradient(160deg, var(--navy-800), var(--navy-950));
    border-right: 1px solid rgba(201,162,74,.22);
  }
  .auth-hero::after {
    content: ""; position: absolute; right: -160px; bottom: -160px; width: 520px; height: 520px; border-radius: 50%;
    border: 1px solid rgba(201,162,74,.25); box-shadow: 0 0 0 40px rgba(201,162,74,.04), 0 0 0 90px rgba(201,162,74,.03);
  }
  .auth-hero .brand-text { color: var(--ivory); }
  .hero-copy h2 { font-family: var(--serif); font-weight: 500; font-size: 52px; line-height: 1.05; margin: 0 0 18px; max-width: 12ch; }
  .hero-copy h2 em { color: var(--gold-400); font-style: italic; }
  .hero-copy p { color: rgba(246,241,231,.72); max-width: 42ch; font-size: 16px; }
  .hero-foot { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: rgba(246,241,231,.5); }
  .auth-split .auth-wrap { background: var(--ivory); }
  .auth-split .auth-card { box-shadow: 0 30px 80px -40px rgba(7,15,28,.35); }
  .auth-mobile-brand { display: none; }
}

/* ---------- dashboard ---------- */
body.dash { background: var(--ivory); }
.dash-layout { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 40; display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px; color: var(--ivory); background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  border-right: 1px solid rgba(201,162,74,.18); transform: translateX(-100%); transition: transform .22s ease;
}
.sidebar.open { transform: none; box-shadow: var(--shadow); }
.sidebar .brand { padding: 0 8px 18px; margin-bottom: 8px; border-bottom: 1px solid rgba(201,162,74,.16); }
.sidebar .brand-text { color: var(--ivory); font-size: 22px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a, .nav-logout {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none;
  color: rgba(246,241,231,.78); font-size: 14px; font-weight: 500; border: 0; background: transparent; cursor: pointer; width: 100%; text-align: left;
}
.sidebar nav a:hover, .nav-logout:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: linear-gradient(90deg, rgba(201,162,74,.22), rgba(201,162,74,.05)); color: var(--gold-300); box-shadow: inset 3px 0 0 var(--gold-500); }
.sidebar svg, .menu-btn svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-logout { margin-top: 8px; border-top: 1px solid rgba(201,162,74,.16); border-radius: 0; padding-top: 16px; }
.scrim { position: fixed; inset: 0; background: rgba(7,15,28,.5); z-index: 30; }
.dash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 64px;
  background: rgba(251,249,244,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-family: var(--serif); font-weight: 600; font-size: 26px; margin: 0; color: var(--navy-900); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--navy-900); display: grid; place-items: center; cursor: pointer; }
.who { display: flex; align-items: center; gap: 10px; }
.who-name { display: none; font-size: 14px; font-weight: 500; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--navy-950); background: linear-gradient(140deg, var(--gold-300), var(--gold-500)); }
.role-badge { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; }
.role-admin { background: var(--navy-900); color: var(--gold-300); }
.role-trainer { background: var(--gold-100); color: var(--navy-800); border: 1px solid var(--gold-300); }
main { padding: 20px 16px 48px; max-width: 1200px; width: 100%; }
main:focus { outline: none; }
.welcome { background: linear-gradient(135deg, var(--navy-800), var(--navy-950)); color: var(--ivory); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; position: relative; overflow: hidden; }
.welcome::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; border: 1px solid rgba(201,162,74,.3); }
.welcome h2 { font-family: var(--serif); font-weight: 600; font-size: 32px; margin: 2px 0 6px; }
.welcome p { margin: 0; color: rgba(246,241,231,.75); }
.eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-400) !important; margin: 0; }
.intro { color: var(--ink-2); margin: 0 0 16px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); }
.empty-mark { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--gold-100); color: var(--gold-500); font-size: 20px; margin-bottom: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 12px 8px; border-bottom: 1px solid #f0ece2; vertical-align: middle; }
.table-scroll { overflow-x: auto; }
.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.status-on { background: var(--ok-bg); color: var(--ok); }
.status-off { background: var(--danger-bg); color: var(--danger); }
.btn-sm { width: auto; height: 34px; padding: 0 12px; font-size: 13px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 18px; }
.form-grid .btn { align-self: end; }
.panel h3 { font-family: var(--serif); font-size: 22px; margin: 0 0 12px; color: var(--navy-900); }

/* ---------- admin: courses ---------- */
.field textarea, .field select {
  width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.field select { height: 48px; padding-top: 0; padding-bottom: 0; }
.field textarea { resize: vertical; line-height: 1.5; }
.field textarea:focus, .field select:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(201,162,74,.18); }
.field input[disabled] { background: var(--paper); color: var(--ink-3); }
.panel h4 { font-size: 15px; margin: 20px 0 10px; color: var(--navy-800); }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.select-sm { height: 34px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 0 10px; font: inherit; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 14px; color: var(--navy-700); }
.course-cell { display: flex; gap: 12px; align-items: center; min-width: 220px; }
.course-cell small { display: block; }
.course-link { font-weight: 600; color: var(--navy-900); text-decoration: none; }
.course-link:hover { text-decoration: underline; text-decoration-color: var(--gold-400); }
.course-thumb { width: 56px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: var(--gold-100); }
.course-thumb-empty { display: grid; place-items: center; color: var(--gold-500); }
.tag { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px; background: var(--navy-900); color: var(--gold-300); vertical-align: middle; }
.status-draft { background: #eef0f4; color: var(--ink-2); }
.status-published { background: var(--ok-bg); color: var(--ok); }
.status-unpublished { background: var(--warn-bg); color: var(--warn); }
.status-archived { background: var(--danger-bg); color: var(--danger); }
.editor-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.editor-head h3 { margin: 0; }
.editor-head .status, .editor-head .tag { font-family: var(--sans); vertical-align: middle; }
.editor-card { display: block; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 4px 0 18px; }
.tabs [role=tab] { border: 0; background: none; padding: 10px 14px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-3);
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs [role=tab][aria-selected="true"] { color: var(--navy-900); border-bottom-color: var(--gold-500); }
.tab-panel { min-height: 120px; }
.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
.info-box { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-top: 4px; }
.info-box .hint { margin: 4px 0 0; }
.plain-list { margin: 8px 0 0; padding-left: 18px; }
.thumb-preview { display: block; max-width: 280px; max-height: 160px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); margin: -6px 0 16px; }
.module-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--paper); }
.module-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.lesson-list { list-style: none; margin: 0 0 10px; padding: 0; }
.lesson-row { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: center; justify-content: flex-end; border-top: 1px dashed var(--line); padding: 10px 0; }
.lesson-fields { display: grid; grid-template-columns: 1fr 88px; gap: 10px; flex: 1 1 100%; min-width: 0; }
.lesson-fields .field { margin-bottom: 10px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--navy-800); font-size: 14px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger { color: var(--danger); }
.check-list { display: grid; gap: 8px; margin-bottom: 12px; }
.check-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--gold-500); }
.save-bar { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 14px 0 4px; margin-top: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0), #fff 30%); border-top: 1px solid var(--line); }

@media (min-width: 720px) {
  .lesson-row { flex-wrap: nowrap; padding-bottom: 0; }
  .lesson-fields { flex: 1 1 auto; }
  .grid-2 { grid-template-columns: repeat(3, 1fr); }
  .grid-2:has(> .field:nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 720px) {
  .who-name { display: inline; }
  .form-grid { grid-template-columns: 1.2fr 1.2fr 1fr auto; }
  main { padding: 28px 28px 56px; }
}
@media (min-width: 1024px) {
  .sidebar { transform: none; position: sticky; top: 0; height: 100vh; }
  .scrim { display: none !important; }
  .menu-btn { display: none; }
  .topbar { padding: 14px 28px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 1.5s !important; } }
