/* Edulitmus — design tokens
   Palette: deep exam-hall navy + warm amber highlighter accent, paper background.
   Type: Source Serif 4 for headings (textbook authority), Inter for UI/body. */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,500;8..60,600;8..60,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #16233F;
  --primary: #1F3E72;
  --primary-dark: #132949;
  --primary-light: #2E5590;
  --accent: #E2A33B;
  --accent-dark: #C4841C;
  --paper: #F6F3EA;
  --surface: #FFFFFF;
  --border: #E1DACB;
  --muted: #6B7284;
  --success: #2F7D5C;
  --success-bg: #E8F3EC;
  --danger: #C1442D;
  --danger-bg: #FBEAE6;
  --radius: 8px;
  --radius-lg: 14px;
  --max-width: 1080px;
  --shadow-sm: 0 1px 2px rgba(22,35,63,0.06);
  --shadow-md: 0 6px 20px rgba(22,35,63,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; }

h1, h2, h3, h4 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  line-height: 1.22;
  margin: 0 0 0.5em;
  color: var(--ink);
}

h1 { font-size: 2.1rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

p { margin: 0 0 1em; max-width: 68ch; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- Hero ---------- */
.hero {
  padding: 2rem 1.75rem 2.4rem;
  margin: 0 0 2rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 60%, #3E6BAA 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; top: -40px; right: -40px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(226,163,59,0.35) 0%, rgba(226,163,59,0) 70%);
  border-radius: 50%;
}
.hero h1 { color: #fff; max-width: 18ch; font-size: 2.2rem; }
.hero p { color: rgba(255,255,255,0.86); }

/* ---------- Header ---------- */
.site-header {
  background: var(--primary);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  position: relative;
}
.brand {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-logo { height: 28px; width: auto; border-radius: 4px; }
.brand .dot { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 1.4rem; }
.site-nav a { color: #E7ECF6; font-weight: 500; font-size: 0.95rem; }
.site-nav a:hover { color: #fff; text-decoration: none; border-bottom: 2px solid var(--accent); }
.site-nav .btn { color: #fff; }

.nav-toggle {
  display: none;
  background: none; border: none; color: #fff; font-size: 1.5rem;
  cursor: pointer; line-height: 1; padding: 0.2rem 0.4rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--primary-dark); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-dark); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; border-color: currentColor; color: inherit; }
.btn-outline:hover { background: rgba(255,255,255,0.08); }
.btn-dark { background: var(--primary); color: #fff; }
.btn-dark:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 1.25rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
}
.subject-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.subject-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.subject-card h3 { margin-bottom: 0.3rem; }
.subject-card p { color: var(--muted); font-size: 0.92rem; margin-bottom: 0.9rem; }
.subject-card .count { font-size: 0.82rem; color: var(--muted); }

/* ---------- Chips (subject filter) ---------- */
.chip-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.chip {
  padding: 0.4rem 0.9rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--ink);
}
.chip:hover { text-decoration: none; border-color: var(--primary); }
.chip-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.test-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.test-row:last-child { border-bottom: none; }
.test-row .meta { color: var(--muted); font-size: 0.85rem; }

/* ---------- Study materials grid ---------- */
.material-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.material-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; color: var(--ink); box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.material-card:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.material-thumb { width: 100%; height: 110px; object-fit: cover; background: var(--paper); }
.material-pdf-icon { display: flex; align-items: center; justify-content: center; font-size: 2.2rem; }
.material-info { padding: 0.7rem 0.85rem; }
.material-info strong { display: block; font-size: 0.92rem; margin-bottom: 0.15rem; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin: 0.9rem 0 0.3rem; font-size: 0.9rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=file], select, textarea {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,62,114,0.12);
}
textarea { resize: vertical; min-height: 90px; }
.form-narrow { max-width: 420px; margin: 2rem auto; }
.field-hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }

/* ---------- Alerts ---------- */
.alert { padding: 0.85rem 1rem; border-radius: var(--radius); margin-bottom: 1.2rem; font-size: 0.92rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #EFC7BC; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #C4E2D0; }

/* ---------- Tables ---------- */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 480px; }
th, td { text-align: left; padding: 0.65rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

/* ---------- Admin shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 230px;
  background: var(--primary-dark);
  color: #E7ECF6;
  padding: 1.4rem 1rem;
  flex-shrink: 0;
}
.admin-sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.admin-sidebar .brand { color: #fff; margin-bottom: 0; font-size: 1.15rem; }
.admin-sidebar nav { margin-top: 1.4rem; }
.admin-sidebar nav a {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  color: #C9D3E6;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}
.admin-sidebar nav a.nav-sep { margin-top: 0.8rem; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 0.8rem; }
.admin-main { flex: 1; padding: 1.8rem 2rem; max-width: 1100px; min-width: 0; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.4rem; flex-wrap: wrap; gap: 0.6rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow-sm); }
.stat-box .num { font-family: 'Source Serif 4', serif; font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-box .label { color: var(--muted); font-size: 0.85rem; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-live { background: var(--success-bg); color: var(--success); }
.badge-off { background: #EDEDED; color: var(--muted); }
.icon-link { color: var(--muted); font-size: 0.85rem; margin-right: 0.6rem; white-space: nowrap; }
.icon-link.danger { color: var(--danger); }

/* ---------- Test-taking (CBT) screen ---------- */
.cbt-shell { display: flex; flex-direction: column; min-height: 100vh; }
.cbt-topbar {
  background: var(--primary);
  color: #fff;
  padding: 0.7rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.timer { font-family: 'Source Serif 4', serif; font-size: 1.3rem; font-weight: 700; background: rgba(255,255,255,0.14); padding: 0.25rem 0.9rem; border-radius: var(--radius); }
.timer.low { background: var(--danger); }

.cbt-body { display: flex; flex: 1; gap: 1.25rem; padding: 1.25rem; max-width: 1200px; margin: 0 auto; width: 100%; }
.question-panel { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; min-width: 0; }
.question-panel .q-index { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.question-panel .q-text { font-size: 1.08rem; margin-bottom: 1rem; }
.q-figure { display: block; max-width: 100%; max-height: 320px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 1.3rem; }
.option-item {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 0.6rem; cursor: pointer;
}
.option-item:hover { border-color: var(--primary); }
.option-item.selected { border-color: var(--accent); background: #FBF3E3; }
.option-item input { margin-top: 0.2rem; flex-shrink: 0; }

.nav-panel { width: 260px; flex-shrink: 0; }
.nav-panel .panel { padding: 1rem; }
.q-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; margin: 0.8rem 0 1rem; }
.q-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
}
.q-cell.answered { background: var(--success); color: #fff; border-color: var(--success); }
.q-cell.current { outline: 2px solid var(--primary); outline-offset: 1px; }
.q-cell.marked { background: var(--accent); color: var(--primary-dark); border-color: var(--accent); }
.legend { font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.3rem; }
.legend span.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.4rem; vertical-align: -1px; }

.cbt-footer {
  display: flex; justify-content: space-between; padding: 0.85rem 1.25rem;
  background: #fff; border-top: 1px solid var(--border); position: sticky; bottom: 0; flex-wrap: wrap; gap: 0.5rem;
}

/* ---------- Result page ---------- */
.score-hero { text-align: center; padding: 2.2rem 1rem; }
.score-hero .big { font-family: 'Source Serif 4', serif; font-size: 3rem; font-weight: 700; color: var(--primary); }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 1rem; margin-top: 1.5rem; }
.result-grid .stat-box .num { font-size: 1.5rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.6rem 0; color: var(--muted); font-size: 0.85rem; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .cbt-body { flex-direction: column; padding: 0.8rem; }
  .nav-panel { width: 100%; order: -1; }
  .q-grid { grid-template-columns: repeat(8, 1fr); }
  .cbt-footer { position: static; }
  .cbt-footer > div { display: flex; gap: 0.5rem; flex-wrap: wrap; width: 100%; justify-content: center; }

  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; padding: 0.9rem 1rem; }
  .admin-sidebar nav { display: none; margin-top: 0.9rem; }
  .admin-sidebar nav.open { display: block; }
  .admin-sidebar nav a { padding: 0.7rem; }
  .nav-toggle { display: block; }
  .admin-main { padding: 1.2rem 1rem; }

  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--primary-dark); flex-direction: column; align-items: stretch;
    padding: 0.6rem 1.25rem 1rem; gap: 0.2rem; border-bottom: 3px solid var(--accent);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 0.6rem 0; border-bottom: 1px solid rgba(255,255,255,0.08) !important; }
  .site-nav .btn { margin-top: 0.5rem; text-align: center; }

  .hero { padding: 1.6rem 1.25rem 1.9rem; }
  .hero h1 { font-size: 1.7rem; }
  h1 { font-size: 1.6rem; }

  table { min-width: 560px; }
}

@media (min-width: 821px) {
  .admin-sidebar nav { display: block !important; }
}
