/* =====================================================================
   ระบบจัดสอบผู้บริหารสถานศึกษา — Design tokens
   โทน: น้ำเงิน (navy/blue) - ขาว (paper) - ดำ (ink) ทันสมัย สะอาดตา
   ===================================================================== */
:root {
  --ink: #0b1220;
  --ink-soft: #33415c;
  --muted: #64748b;
  --navy: #0c2d57;
  --navy-deep: #081d3a;
  --blue: #2563eb;
  --blue-light: #3b82f6;
  --sky: #eaf1fd;
  --sky-line: #d7e6fb;
  --paper: #f5f8fc;
  --white: #ffffff;
  --line: #e3e8f0;
  --success: #0f8a5f;
  --success-bg: #e5f6ee;
  --danger: #d5303f;
  --danger-bg: #fceaec;
  --gold: #b9840c;
  --gold-bg: #fbf1dc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(12, 45, 87, .06);
  --shadow-md: 0 6px 20px rgba(12, 45, 87, .08);
  --shadow-lg: 0 16px 40px rgba(12, 45, 87, .14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--navy); text-decoration: underline; }
h1, h2, h3, h4 { color: var(--navy-deep); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }

::selection { background: var(--sky-line); color: var(--navy-deep); }

/* ---------- ลายเซ็นของระบบ: แถบไล่สีบางด้านบนสุดทุกหน้า ---------- */
body::before {
  content: "";
  display: block;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--navy-deep) 0%, var(--blue) 55%, var(--blue-light) 100%);
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--navy-deep);
  background-image: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy) 100%);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar a { color: rgba(255,255,255,.92); text-decoration: none; }
.topbar a:hover { color: #fff; text-decoration: none; }
.topbar .brand {
  font-weight: 800;
  font-size: 1.12rem;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -.01em;
}
.topbar .brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; box-shadow: 0 2px 8px rgba(37,99,235,.5);
  flex-shrink: 0;
}
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  padding: 8px 14px; border-radius: 999px; font-size: .92rem; font-weight: 500;
  transition: background .15s ease;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); }

/* ---------- Layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.container.narrow { max-width: 480px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
label { display: block; font-weight: 600; margin-bottom: 7px; font-size: .9rem; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); font-size: .98rem; font-family: inherit;
  background: var(--white); color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--sky);
}
input[type=file] { padding: 9px 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 11px 22px; border-radius: var(--radius-sm); border: none;
  background: var(--blue); color: #fff; cursor: pointer; font-size: .95rem;
  font-family: inherit; font-weight: 600; text-align: center;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  box-shadow: 0 1px 2px rgba(37,99,235,.25);
}
.btn:hover { background: var(--navy); text-decoration: none; box-shadow: 0 4px 12px rgba(12,45,87,.25); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #64748b; box-shadow: none; }
.btn.secondary:hover { background: #475569; }
.btn.success { background: var(--success); box-shadow: 0 1px 2px rgba(15,138,95,.25); }
.btn.success:hover { background: #0b6e4b; }
.btn.danger { background: var(--danger); box-shadow: 0 1px 2px rgba(213,48,63,.25); }
.btn.danger:hover { background: #b3242f; }
.btn.outline { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); box-shadow: none; }
.btn.outline:hover { background: var(--sky); color: var(--navy); }
.btn.small { padding: 6px 14px; font-size: .84rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: .91rem; }
th { background: var(--sky); color: var(--navy-deep); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafcfe; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .76rem; font-weight: 700; letter-spacing: .01em; }
.badge.green { background: var(--success-bg); color: var(--success); }
.badge.red { background: var(--danger-bg); color: var(--danger); }
.badge.gray { background: #eef1f5; color: var(--muted); }
.badge.gold { background: var(--gold-bg); color: var(--gold); }

/* ---------- Alerts ---------- */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .93rem; border: 1px solid transparent; }
.alert.error { background: var(--danger-bg); color: var(--danger); border-color: #f4c3c9; }
.alert.success { background: var(--success-bg); color: var(--success); border-color: #bfe6d3; }
.alert.info { background: var(--sky); color: var(--navy); border-color: var(--sky-line); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.tabs a { padding: 11px 18px; border-radius: 10px 10px 0 0; color: var(--muted); font-weight: 600; font-size: .92rem; }
.tabs a:hover { color: var(--navy); text-decoration: none; background: var(--sky); }
.tabs a.active { color: var(--blue); background: #fff; border: 2px solid var(--line); border-bottom-color: #fff; margin-bottom: -2px; }

.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; }
.flex.between { justify-content: space-between; }
.flex.gap { gap: 10px; }

code {
  background: var(--sky); border: 1px solid var(--sky-line); border-radius: 6px;
  padding: 2px 7px; font-size: .88em; color: var(--navy-deep);
}
hr { border: none; border-top: 1px solid var(--line); margin: 22px 0; }

/* ---------- Landing hero ---------- */
.hero-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 44px 36px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.hero-mark {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 18px;
  background: linear-gradient(135deg, var(--navy-deep), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; box-shadow: 0 8px 24px rgba(12,45,87,.28);
}
.hero-card h1 { font-size: 1.55rem; margin: 0 0 6px; }

/* ---------- Stat tiles ---------- */
.stat-tile { text-align: center; }
.stat-tile .label { color: var(--muted); font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.stat-tile .value { font-size: 2rem; font-weight: 800; color: var(--navy-deep); }
.stat-tile .value.success { color: var(--success); }
.stat-tile .value.gold { color: var(--gold); }

/* ---------- Exam taking screen ---------- */
.exam-layout { display: grid; grid-template-columns: 1fr 270px; gap: 22px; }
@media (max-width: 900px) { .exam-layout { grid-template-columns: 1fr; } }
.exam-timer {
  position: sticky; top: 84px; color: #fff;
  background: linear-gradient(135deg, var(--navy-deep), var(--blue));
  padding: 16px; border-radius: var(--radius); text-align: center; margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.exam-timer .time { font-size: 1.9rem; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.exam-timer.warn { background: linear-gradient(135deg, #7a1a24, var(--danger)); animation: pulseWarn 1.4s ease-in-out infinite; }
@keyframes pulseWarn { 0%, 100% { box-shadow: 0 0 0 0 rgba(213,48,63,.4); } 50% { box-shadow: 0 0 0 10px rgba(213,48,63,0); } }

.question-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.question-nav button {
  aspect-ratio: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 8px;
  cursor: pointer; font-weight: 700; font-size: .85rem; color: var(--ink-soft);
  transition: all .12s ease;
}
.question-nav button:hover { border-color: var(--blue); color: var(--blue); }
.question-nav button.answered { background: var(--success); color: #fff; border-color: var(--success); }
.question-nav button.current { outline: 3px solid var(--gold); outline-offset: 1px; }

.choice-option {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; cursor: pointer;
  transition: all .12s ease;
}
.choice-option:hover { background: var(--sky); border-color: var(--sky-line); }
.choice-option.selected { border-color: var(--blue); background: var(--sky); box-shadow: 0 0 0 3px var(--sky); }
.choice-option.correct { border-color: var(--success); background: var(--success-bg); }
.choice-option.incorrect { border-color: var(--danger); background: var(--danger-bg); }
.choice-option input { margin-top: 3px; accent-color: var(--blue); }

.score-circle {
  width: 168px; height: 168px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; flex-direction: column; margin: 0 auto 18px; border: 10px solid var(--line);
  background: var(--white); box-shadow: var(--shadow-sm);
}
.score-circle.pass { border-color: var(--success); }
.score-circle.fail { border-color: var(--danger); }
.score-circle .pct { font-size: 2.3rem; font-weight: 800; color: var(--navy-deep); }
