/* ================================================================
   CyberShield by DarkPhish — Dark SaaS Theme
   Palette: Deep Navy + Cyan Accent + Clean Typography
   ================================================================ */

:root {
  --bg:         #060c18;
  --surface:    #0c1424;
  --surface2:   #111e33;
  --surface3:   #1a2942;
  --border:     #1e3050;
  --border2:    #2a4060;

  --cyan:       #00d4ff;
  --cyan-dim:   #00a8cc;
  --cyan-glow:  rgba(0, 212, 255, 0.15);
  --cyan-soft:  rgba(0, 212, 255, 0.08);

  --green:      #00c896;
  --green-soft: rgba(0, 200, 150, 0.12);
  --yellow:     #f5a623;
  --yellow-soft:rgba(245, 166, 35, 0.12);
  --red:        #ff4757;
  --red-soft:   rgba(255, 71, 87, 0.12);
  --blue:       #4a9eff;
  --blue-soft:  rgba(74, 158, 255, 0.12);

  --text:       #dce8f5;
  --text-dim:   #7a94b0;
  --text-muted: #4a6280;

  --font-head:  'Chakra Petch', sans-serif;
  --font-body:  'Outfit', sans-serif;
  --font-mono:  'JetBrains Mono', monospace;

  --radius:     10px;
  --radius-sm:  6px;
  --radius-lg:  16px;
  --sidebar-w:  240px;
  --topbar-h:   0px;

  /* Theme-derived tokens (overridden in light theme below) */
  --on-accent:   #04121f;
  --primary-hover: #00f0ff;
  --banner-grad: linear-gradient(135deg, #0c2040 0%, #0a1a30 100%);
  --avatar-grad: linear-gradient(135deg, var(--cyan-dim), #006880);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,212,255,0.08);
  --shadow-lg:   0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,212,255,0.05);

  color-scheme: dark;
}

/* ─── LIGHT THEME ─────────────────────────────────────────── */
:root[data-theme="light"] {
  --bg:         #f4f7fb;
  --surface:    #ffffff;
  --surface2:   #eef3f9;
  --surface3:   #e2eaf3;
  --border:     #dce5f0;
  --border2:    #c4d4e6;

  --cyan:       #0091b3;
  --cyan-dim:   #00788f;
  --cyan-glow:  rgba(0, 145, 179, 0.16);
  --cyan-soft:  rgba(0, 145, 179, 0.09);

  --green:      #00936e;
  --green-soft: rgba(0, 147, 110, 0.12);
  --yellow:     #b9770f;
  --yellow-soft:rgba(185, 119, 15, 0.13);
  --red:        #d8303f;
  --red-soft:   rgba(216, 48, 63, 0.10);
  --blue:       #2d6fd6;
  --blue-soft:  rgba(45, 111, 214, 0.11);

  --text:       #14202e;
  --text-dim:   #4a6075;
  --text-muted: #7b91a6;

  --on-accent:   #ffffff;
  --primary-hover: #00a8cc;
  --banner-grad: linear-gradient(135deg, #e8f1fb 0%, #d6e6f6 100%);
  --avatar-grad: linear-gradient(135deg, var(--cyan), #00788f);
  --shadow-card: 0 8px 28px rgba(20,40,70,0.10), 0 0 0 1px rgba(0,145,179,0.06);
  --shadow-lg:   0 24px 60px rgba(20,40,70,0.15), 0 0 0 1px rgba(0,145,179,0.05);

  color-scheme: light;
}

/* Smooth theme cross-fade on the major surfaces */
body, .sidebar, .topbar, .stat-card, .course-card, .info-card,
.quiz-header, .question-card, .answer-option, .result-item,
.profile-card, .attempt-card, .admin-table-wrap, .login-card {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* ─── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

/* ─── VIEWS ───────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: flex; }
.hidden { display: none !important; }

/* ─── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

/* ================================================================
   LOGIN
================================================================ */
#view-login {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 40%, rgba(0,212,255,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 70%, rgba(74,158,255,0.04) 0%, transparent 50%);
}

.login-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

.login-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

/* The brand mark. It used to be a monochrome glyph sitting in a tinted box; it is
   now the CyberShield logo itself, so the box is only a sizing frame — no
   background, no border, nothing to crop the shield against. */
.logo-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.logo-icon.sm { width: 32px; height: 32px; }
/* The mark's left half is near-black navy, which all but vanishes against the
   dark surface. A one-pixel light halo restores the shield's silhouette without
   putting a plate behind the logo or touching its colours. */
[data-theme="dark"] .logo-icon img {
  filter: drop-shadow(0 0 1.5px rgba(255,255,255,0.75));
}

.logo-title {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.02em;
  line-height: 1;
}
.logo-by {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-dim);
  line-height: 1.2;
  margin-top: 4px;
}
.logo-by span {
  color: var(--text);
  font-weight: 600;
}

.login-desc {
  color: var(--text-dim);
  font-size: 0.875rem;
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-error {
  background: var(--red-soft);
  border: 1px solid rgba(255,71,87,0.3);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.form-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--cyan-dim);
  box-shadow: 0 0 0 3px var(--cyan-soft);
}
.form-group input::placeholder { color: var(--text-muted); }

/* SSO */
.login-sso-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-sso-divider::before,
.login-sso-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.btn-sso-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}
.btn-sso-microsoft:hover {
  background: var(--surface3);
  border-color: var(--border2);
}

.login-hints {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.hint-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-family: var(--font-mono);
}
.hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.hint-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  flex-shrink: 0;
}
.hint-badge.admin { background: rgba(74,158,255,0.15); color: var(--blue); border: 1px solid rgba(74,158,255,0.3); }
.hint-badge.student { background: rgba(0,200,150,0.12); color: var(--green); border: 1px solid rgba(0,200,150,0.3); }
.mono { font-family: var(--font-mono); color: var(--text-dim); font-size: 0.78rem; }

/* ================================================================
   APP SHELL
================================================================ */
#view-app { min-height: 100vh; }
#view-app.active { display: flex; }
/* .hidden (display:none !important) must win over the id rule above when the
   app shell is not shown — e.g. on the login screen. */

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.03em;
  line-height: 1.1;
}
.sidebar-brand .brand-by {
  display: block;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  margin-top: 3px;
}
.sidebar-brand .brand-by span {
  color: var(--text);
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-item.active {
  background: var(--cyan-soft);
  color: var(--cyan);
  border: 1px solid rgba(0,212,255,0.15);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--avatar-grad);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono); }

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  color: var(--text-muted);
  display: flex;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-logout svg { width: 16px; height: 16px; }
.btn-logout:hover { color: var(--red); border-color: var(--red); background: var(--red-soft); }

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  min-height: 100vh;
}

.section { display: none; }
.section.active { display: block; }

/* ─── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-title {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}
.page-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--cyan);
  color: var(--on-accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 20px var(--cyan-glow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-dim);
}
.btn-outline:hover { border-color: var(--cyan-dim); color: var(--cyan); }

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface3); }

.btn-full { width: 100%; justify-content: center; }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; }

/* ─── STATS GRID ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent, var(--cyan));
  opacity: 0.6;
}
.stat-card:hover { border-color: var(--border2); }

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.stat-value {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft, var(--cyan-soft));
  color: var(--accent, var(--cyan));
}
.stat-icon svg { width: 18px; height: 18px; }

/* ─── COURSES GRID ────────────────────────────────────────── */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}
.course-card:hover {
  transform: translateY(-3px);
  border-color: var(--cyan-glow);
  box-shadow: var(--shadow-card);
}

.course-banner {
  height: 80px;
  background: var(--banner-grad);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.course-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.04) 1px, transparent 1px);
  background-size: 20px 20px;
}
.course-banner-icon {
  width: 40px; height: 40px;
  background: rgba(0,212,255,0.12);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--cyan);
  z-index: 1;
}
.course-banner-icon svg { width: 22px; height: 22px; }
.course-badge {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 2;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--cyan);
  background: rgba(0,212,255,0.12);
  border: 1px solid rgba(0,212,255,0.3);
  border-radius: 6px;
}

.course-body { padding: 20px; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.course-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid;
  font-weight: 500;
}
.tag-level { background: var(--blue-soft); color: var(--blue); border-color: rgba(74,158,255,0.2); }
.tag-category { background: var(--cyan-soft); color: var(--cyan-dim); border-color: rgba(0,212,255,0.2); }
.tag-duration { background: var(--surface2); color: var(--text-dim); border-color: var(--border); }

.course-title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.course-desc {
  font-size: 0.835rem;
  color: var(--text-dim);
  line-height: 1.55;
  flex: 1;
}

.course-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-not_started { background: var(--surface2); color: var(--text-muted); }
.status-in_progress { background: var(--yellow-soft); color: var(--yellow); }
.status-completed   { background: var(--green-soft);  color: var(--green);  }

.score-display {
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 700;
}

/* ─── SECTION TITLE ROW ───────────────────────────────────── */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title-row h3 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.link-action {
  font-size: 0.82rem;
  color: var(--cyan-dim);
  cursor: pointer;
  transition: color 0.15s;
}
.link-action:hover { color: var(--cyan); }

/* ─── BACK BUTTON ─────────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 24px;
  transition: color 0.15s;
}
.back-btn svg { width: 16px; height: 16px; }
.back-btn:hover { color: var(--cyan); }

/* ================================================================
   COURSE DETAIL
================================================================ */
.course-detail-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
  margin-bottom: 32px;
}
.course-detail-title {
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 10px;
}
.course-detail-desc { color: var(--text-dim); line-height: 1.6; margin-bottom: 16px; }
.course-detail-meta { display: flex; gap: 10px; flex-wrap: wrap; }

.course-detail-actions { display: flex; flex-direction: column; gap: 10px; min-width: 180px; }

.content-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .course-detail-header { grid-template-columns: 1fr; }
}

/* Video Container */
.video-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}
.video-label {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.video-label svg { width: 14px; height: 14px; color: var(--cyan); }
.video-placeholder {
  aspect-ratio: 16/9;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.video-placeholder svg { width: 40px; height: 40px; color: var(--border2); }
.video-placeholder iframe {
  width: 100%; height: 100%;
  border: none;
}
.video-frame {
  aspect-ratio: 16/9;
  width: 100%;
}
.video-frame iframe { width: 100%; height: 100%; border: none; display: block; }

/* ── Custom video player (self-hosted MP4) ── */
.cvp {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  overflow: hidden;
}
.cvp:fullscreen { aspect-ratio: auto; }
.cvp-video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; cursor: pointer; }
/* Big centered play button (shown while paused) */
.cvp-big {
  position: absolute; inset: 0; margin: auto;
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); color: #fff; border: none; cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.cvp-big svg { width: 34px; height: 34px; margin-left: 3px; }
.cvp-big:hover { transform: scale(1.06); background: rgba(0,0,0,0.7); }
.cvp-big.cvp-hidden { opacity: 0; pointer-events: none; }
/* Control bar */
.cvp-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0));
  opacity: 0; transition: opacity .18s;
}
.cvp:hover .cvp-bar, .cvp:focus-within .cvp-bar { opacity: 1; }
.cvp-btn {
  background: none; border: none; color: #fff; cursor: pointer;
  padding: 4px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.cvp-btn:hover { background: rgba(255,255,255,0.15); }
.cvp-btn svg { width: 20px; height: 20px; }
.cvp-cc { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; padding: 3px 6px; opacity: 0.7; }
.cvp-cc.active { opacity: 1; background: rgba(255,255,255,0.22); }
.cvp-time { color: #fff; font-family: var(--font-mono); font-size: 0.74rem; white-space: nowrap; }
.cvp-seek {
  flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,0.3); border-radius: 3px; cursor: pointer;
}
.cvp-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%; background: var(--cyan, #3bd6d6); border: none;
}
.cvp-seek::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--cyan, #3bd6d6); border: none; }
/* Volume: a compact slider that expands on hover/focus, next to the mute button */
.cvp-vol { display: flex; align-items: center; }
.cvp-volume {
  width: 0; opacity: 0; -webkit-appearance: none; appearance: none;
  height: 4px; background: rgba(255,255,255,0.3); border-radius: 3px; cursor: pointer;
  transition: width .15s, opacity .15s; margin-left: 2px;
}
.cvp-vol:hover .cvp-volume, .cvp-vol:focus-within .cvp-volume { width: 66px; opacity: 1; }
.cvp-volume::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: none; }
.cvp-volume::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: #fff; border: none; }
/* Subtitles cue styling */
.cvp-video::cue { background: rgba(0,0,0,0.7); color: #fff; }

/* ── Segmented control (video source toggle) ── */
.seg { display: inline-flex; gap: 4px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 12px; }
.seg-btn { background: none; border: none; color: var(--text-muted); padding: 5px 12px; font-size: 0.82rem; border-radius: var(--radius-sm); cursor: pointer; }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

/* ── Course status badge (admin list) ── */
.status-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.status-badge-published { background: rgba(34,197,94,0.15); color: var(--green, #22c55e); }
.status-badge-draft { background: rgba(234,179,8,0.16); color: var(--yellow, #d99a00); }

/* ── Video upload row ── */
.upload-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; flex-wrap: wrap; }
.upload-progress { height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.upload-progress-fill { height: 100%; width: 0; background: var(--cyan, #3bd6d6); transition: width .15s; }
.ce-video-preview .cvp { border-radius: var(--radius); border: 1px solid var(--border); }

/* Course content / Markdown */
.course-content-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.course-content-box h2 {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 12px;
  margin-top: 24px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.course-content-box h2:first-child { margin-top: 0; }
.course-content-box h3 {
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 18px;
  margin-bottom: 8px;
}
.course-content-box p {
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.course-content-box ul, .course-content-box ol {
  padding-left: 20px;
  margin-bottom: 14px;
}
.course-content-box li {
  color: var(--text-dim);
  line-height: 1.7;
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.course-content-box strong { color: var(--text); font-weight: 600; }
.course-content-box code {
  font-family: var(--font-mono);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.82em;
  color: var(--cyan-dim);
}
.course-content-box blockquote {
  border-left: 3px solid var(--cyan-dim);
  padding: 12px 16px;
  background: var(--cyan-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 16px 0;
}
.course-content-box blockquote p {
  margin: 0;
  color: var(--text);
  font-style: italic;
}
.course-content-box hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.course-content-box table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.85rem;
}
.course-content-box th {
  background: var(--surface2);
  padding: 8px 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
}
.course-content-box td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.course-content-box tr:hover td { background: var(--surface2); }

/* Sidebar info panel */
.info-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.info-card h4 {
  font-family: var(--font-head);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-dim); }
.info-row-value { color: var(--text); font-weight: 500; }

/* ================================================================
   QUIZ
================================================================ */
.quiz-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.quiz-title {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.quiz-progress-text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
}

.progress-bar-track {
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  border-radius: 2px;
  transition: width 0.4s ease;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 20px;
}
.question-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 24px;
}

.answers-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.answer-option:hover {
  border-color: var(--cyan-dim);
  background: var(--cyan-soft);
}
.answer-option.selected {
  border-color: var(--cyan);
  background: var(--cyan-soft);
  box-shadow: 0 0 0 1px rgba(0,212,255,0.2);
}
.answer-letter {
  width: 26px; height: 26px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
}
.answer-option.selected .answer-letter {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--on-accent);
}
.answer-text {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
  padding-top: 2px;
}
.answer-option.selected .answer-text { color: var(--text); }

.quiz-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

/* ================================================================
   RESULTS
================================================================ */
.results-header {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 28px;
}
.score-ring-container {
  display: inline-block;
  position: relative;
  margin-bottom: 24px;
}
.score-ring {
  width: 140px; height: 140px;
}
.score-circle-bg { fill: none; stroke: var(--surface3); stroke-width: 8; }
.score-circle-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transform-origin: center;
  transform: rotate(-90deg);
  transition: stroke-dashoffset 1s ease;
}
.score-text-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.score-pct {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  display: block;
}
.score-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.results-title {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.results-subtitle { color: var(--text-dim); font-size: 0.9rem; }

.results-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 700px;
  margin: 0 auto;
}

.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.result-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.result-icon svg { width: 14px; height: 14px; }
.result-correct .result-icon { background: var(--green-soft); color: var(--green); }
.result-wrong .result-icon { background: var(--red-soft); color: var(--red); }
.result-correct { border-color: rgba(0,200,150,0.2); }
.result-wrong { border-color: rgba(255,71,87,0.2); }

.result-q { font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 6px; line-height: 1.4; }
.result-answer-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.result-answer-label { font-size: 0.72rem; font-family: var(--font-mono); color: var(--text-muted); }
.result-answer-text { font-size: 0.82rem; }
.result-answer-text.wrong-ans { color: var(--red); text-decoration: line-through; }
.result-answer-text.right-ans { color: var(--green); }

.results-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

/* ================================================================
   PROFILE
================================================================ */
.profile-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 800px) { .profile-grid { grid-template-columns: 1fr; } }

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
}
.profile-avatar-lg {
  width: 72px; height: 72px;
  background: var(--avatar-grad);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 16px;
}
.profile-name {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.profile-email { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; }
.profile-dept { font-size: 0.8rem; color: var(--cyan-dim); font-family: var(--font-mono); margin-bottom: 20px; }

.profile-stats {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.profile-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.profile-stat-row:last-child { border-bottom: none; }
.profile-stat-label { color: var(--text-dim); }
.profile-stat-value { color: var(--text); font-weight: 600; }

.attempts-list { display: flex; flex-direction: column; gap: 16px; }

.attempt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.attempt-card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.attempt-card-header:hover { background: var(--surface2); }
.attempt-course-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.attempt-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.attempt-date { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }

.attempt-body {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  display: none;
}
.attempt-body.open { display: block; }

.mini-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.83rem;
}
.mini-result:last-child { border-bottom: none; }
.mini-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mini-icon svg { width: 10px; height: 10px; }
.mini-correct .mini-icon { background: var(--green-soft); color: var(--green); }
.mini-wrong .mini-icon { background: var(--red-soft); color: var(--red); }
.mini-q { color: var(--text-dim); flex: 1; }
.mini-a { color: var(--text); font-weight: 500; }
.mini-ca { color: var(--green); font-size: 0.78rem; }

/* ================================================================
   ADMIN
================================================================ */
.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.admin-table-header {
  padding: 16px 20px;
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  transition: background 0.1s;
  cursor: pointer;
}
.data-table tbody tr:hover td { background: var(--surface2); }

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 20px;
}
.score-high   { background: var(--green-soft); color: var(--green); }
.score-mid    { background: var(--yellow-soft); color: var(--yellow); }
.score-low    { background: var(--red-soft);   color: var(--red); }
.score-none   { background: var(--surface3); color: var(--text-muted); }

/* ── Admin user detail ── */
.admin-user-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.admin-user-title {
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}
.admin-user-sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ================================================================
   EMPTY STATE
================================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; }

/* ================================================================
   LOADING
================================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 12px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   TOPBAR (mobile only)
================================================================ */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  z-index: 90;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .sidebar-brand { font-size: 1rem; }
.topbar .sidebar-brand .brand-by { display: none; }
.topbar .logo-icon.sm { width: 28px; height: 28px; }
.hamburger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.hamburger svg { width: 20px; height: 20px; }
.topbar-spacer { flex: 1; }

.scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

/* ================================================================
   THEME + LANGUAGE CONTROLS
================================================================ */
.ui-controls { display: inline-flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--cyan); border-color: var(--cyan-dim); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .icon-sun { display: none; }
:root[data-theme="light"] .icon-btn .icon-sun { display: block; }
:root[data-theme="light"] .icon-btn .icon-moon { display: none; }

.lang-switch {
  display: inline-flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lang-switch button {
  background: none; border: none;
  padding: 7px 11px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: all 0.15s;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.active { background: var(--cyan-soft); color: var(--cyan); }

.login-topbar {
  position: absolute;
  top: 20px; right: 24px;
  z-index: 2;
}
.sidebar-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* ─── ORG SWITCHER (system admin) ─────────────────────────── */
.org-switcher {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.org-switcher-cap {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.org-switcher-field { position: relative; display: flex; align-items: center; }
.org-switcher-ico {
  position: absolute; left: 11px;
  width: 15px; height: 15px;
  color: var(--cyan);
  pointer-events: none;
}
.org-switcher-select {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 9px 30px 9px 34px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.org-switcher-select:hover { border-color: var(--cyan-dim); }
.org-switcher-select:focus {
  outline: none;
  border-color: var(--cyan-dim);
  box-shadow: 0 0 0 3px var(--cyan-soft);
}
.org-switcher-chevron {
  position: absolute; right: 11px;
  width: 14px; height: 14px;
  color: var(--text-dim);
  pointer-events: none;
}
/* The native option list can't be fully themed cross-browser; at least keep it
   on the app's dark surface where the browser honours it. */
.org-switcher-select option { background: var(--surface); color: var(--text); }

/* ================================================================
   TOASTS
================================================================ */
.toast-stack {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.45;
  animation: toast-in 0.25s ease;
}
.toast.toast-success { border-left-color: var(--green); }
.toast.toast-error   { border-left-color: var(--red); }
.toast.toast-out { animation: toast-out 0.25s ease forwards; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-success svg { color: var(--green); }
.toast-error svg   { color: var(--red); }
.toast-info svg    { color: var(--cyan); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ================================================================
   CONFIRM DIALOG (modal)
================================================================ */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: toast-in 0.18s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 440px; width: 100%;
  padding: 24px;
}
.modal h3 { font-family: var(--font-head); font-size: 1.05rem; color: var(--text); margin-bottom: 10px; }
.modal p { color: var(--text-dim); font-size: 0.9rem; line-height: 1.6; white-space: pre-line; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ================================================================
   ACCESSIBILITY
================================================================ */
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }
  .topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    width: 280px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; padding-top: calc(var(--topbar-h) + 16px); }
  .editor-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; }
  .content-grid { grid-template-columns: 1fr; }
  .course-detail-header { grid-template-columns: 1fr; }
  .course-detail-actions { min-width: 0; }
  .page-header { flex-wrap: wrap; gap: 12px; }
  .admin-table-wrap { overflow-x: auto; }
  .admin-table-wrap .data-table { min-width: 640px; }
  .results-header { padding: 24px 12px; }
}

/* ================================================================
   EDITOR DE FORMACIONES (panel admin)
================================================================ */
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid transparent;
}
.btn-danger:hover { background: var(--red); color: #fff; }

.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm, 8px);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--cyan-dim);
  box-shadow: 0 0 0 3px var(--cyan-soft);
}
.input::placeholder { color: var(--text-muted); }
textarea.input { resize: vertical; line-height: 1.5; }
textarea.input.mono { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text); }
select.input { cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field > span {
  font-size: 0.74rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.field-narrow { max-width: 130px; }
.field-hint { font-size: 0.74rem; color: var(--text-muted); text-transform: none; letter-spacing: 0; font-weight: 400; }
.field-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

.editor-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  align-items: start;
}
.ce-video-preview { margin-top: 14px; }
.ce-video-preview .video-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

.ce-error {
  background: var(--red-soft);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm, 8px);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.qe-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.qe-question-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.qe-qnum {
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--cyan);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.qe-answers { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.qe-answer { display: flex; align-items: center; gap: 10px; }
.qe-answer .qe-atext { flex: 1; }
.qe-correct-label {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm, 8px); cursor: pointer;
}
.qe-correct-label:has(.qe-correct:checked) { border-color: var(--green); background: var(--green-soft); }
.qe-correct { accent-color: var(--green); cursor: pointer; }

.editor-footer {
  display: flex; align-items: center; gap: 12px;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Notificaciones por email ── */
.notif-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 18px;
}
.notif-card .notif-h { margin: 0 0 6px; font-size: 1rem; }
.notif-hint { margin: 0 0 14px; color: var(--text-dim); font-size: 0.85rem; line-height: 1.5; }
.notif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}
.notif-checks {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  margin: 16px 0 4px; font-size: 0.86rem;
}
.notif-checks label { display: flex; align-items: center; gap: 7px; }
.notif-days { display: flex; align-items: center; gap: 7px; }
.notif-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}
.notif-status {
  font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 20px;
}
.notif-status.is-on  { background: var(--green-soft); color: var(--green); }
.notif-status.is-off { background: var(--surface3); color: var(--text-dim); }
.notif-userpicker-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.notif-userpicker-bar .input { flex: 1; }
.notif-userlist {
  max-height: 260px; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px;
}
.notif-userrow {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; font-size: 0.86rem; cursor: pointer;
}
.notif-userrow:hover { background: var(--surface3); }
.notif-username { font-weight: 600; }
.notif-usermail { color: var(--text-dim); font-size: 0.78rem; }
.notif-usercount { margin-top: 8px; font-size: 0.8rem; color: var(--text-dim); }

/* ── Apariencia de los correos (pestaña de la tarjeta de correo) ── */
.eb-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 22px;
  align-items: start;
}
.eb-col { min-width: 0; }
.eb-preview-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap;
}
/* El .seg trae su propio margen inferior; dentro de la cabecera estorba. */
.eb-preview-head .seg { margin-bottom: 0; }
.eb-subject { margin: 4px 0 8px; font-size: 0.8rem; color: var(--text-dim); }
.eb-subject strong { color: var(--text); font-weight: 600; }
.eb-frame {
  display: block; width: 100%; height: 520px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.eb-text {
  margin: 0; padding: 14px; max-height: 520px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface3); font: 13px/1.5 var(--font-mono);
}
.eb-error { color: var(--red); }
/* Aviso de validación bajo su propio campo: el formulario no se vuelve a montar
   al escribir, así que este párrafo vive siempre en el DOM y solo se muestra. */
.eb-field-error { margin: 6px 0 0; font-size: 0.78rem; line-height: 1.4; color: var(--red); }
.input.is-invalid { border-color: var(--red); }
.eb-logo-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.eb-logo-thumb {
  height: 34px; width: auto; max-width: 150px;
  padding: 4px; background: #fff;
  border: 1px solid var(--border); border-radius: 6px;
}
.eb-color-row { display: flex; gap: 8px; align-items: center; }
/* El selector de color hereda el ancho de los inputs globales y se comería la
   fila, dejando el campo hexadecimal en unos pocos píxeles: se fija a una muestra. */
.eb-color-row input[type="color"] {
  flex: 0 0 46px; width: 46px; height: 38px; padding: 2px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface3); cursor: pointer;
}
.eb-color-row .input { flex: 1 1 auto; min-width: 0; }
.eb-code { font: 13px/1.5 var(--font-mono); resize: vertical; }
.eb-html-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 6px;
}
.eb-section {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
}
/* La explicación bajo el interruptor pasó al icono de ayuda, y era ella la que
   separaba esta fila del campo siguiente. */
.eb-section .notif-checks { margin-bottom: 16px; }
/* <details> aporta abrir/cerrar y Escape sin JavaScript. */
.eb-varmenu { position: relative; }
.eb-varmenu > summary { list-style: none; cursor: pointer; display: inline-block; }
.eb-varmenu > summary::-webkit-details-marker { display: none; }
.eb-varlist {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50;
  min-width: 300px; max-height: 320px; overflow-y: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lg);
}
.eb-varitem {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left; padding: 7px 10px;
  background: none; border: none; border-radius: 6px;
  cursor: pointer; color: var(--text);
}
.eb-varitem:hover { background: var(--surface3); }
.eb-varitem code { font: 600 0.78rem var(--font-mono); }
.eb-varitem span { font-size: 0.76rem; color: var(--text-dim); }

/* Icono de ayuda por campo: la explicación aparece al pasar el ratón o al
   enfocarlo con el teclado, en vez de ocupar una línea bajo cada campo. */
.eb-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; margin-left: 6px; vertical-align: middle;
  border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-dim); background: var(--surface3);
  font: 700 9px/1 var(--font-sans, inherit); font-style: italic;
  text-transform: none; letter-spacing: 0; cursor: help; flex: none;
}
.eb-info:hover, .eb-info:focus-visible { color: var(--text); border-color: var(--text-dim); }
.eb-info::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  z-index: 60; width: max-content; max-width: 260px; padding: 8px 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
  font: 400 0.76rem/1.45 inherit; font-style: normal;
  text-align: left; white-space: normal; text-transform: none; letter-spacing: 0;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s;
}
.eb-info:hover::after, .eb-info:focus-visible::after { opacity: 1; visibility: visible; }
/* El posicionamiento del globo cuelga del icono, no de la etiqueta. */
.eb-info { position: relative; }

@media (max-width: 900px) {
  /* Por debajo de esto las dos columnas dejan la previa demasiado estrecha
     para juzgar el correo. */
  .eb-grid { grid-template-columns: 1fr; }
  .eb-frame { height: 420px; }
}
