/* Design tokens mirror apps/flutter/lib/core/theme/{app_colors,spacing}.dart
   (same set apps/landing uses) so this surface feels like the same product. */
:root {
  --primary: #2456e5;
  --primary-strong: #2456e5;
  --primary-dark: #1c44c2;
  --primary-muted: #e8edfc;
  --success: #166e4a;
  --success-muted: #e5f4ed;
  --warning: #9c6208;
  --warning-muted: #fbf1de;
  --danger: #cc3b3b;
  --danger-muted: #fbe9e9;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #14161a;
  --text-muted: #5b616e;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 26, 0.04), 0 8px 24px rgba(20, 22, 26, 0.04);
  /* Wider than apps/landing's --container (1160px) on purpose — this is a
     task-focused form flow, not a marketing page, so content stays at a
     comfortable reading/form width. The nav/footer chrome share this same
     width rather than spanning full-bleed, so the page doesn't look like a
     narrow form dropped into an oversized shell. */
  --container: 620px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1013;
  --surface: #17191d;
  --border: #3a3e46;
  --text: #f3f4f6;
  --text-muted: #a3a9b3;
  --primary-muted: #1b2540;
  --primary: #6c9bff;
  --success: #34c285;
  --success-muted: #143726;
  --warning: #e0a030;
  --warning-muted: #3a2c0f;
  --danger: #f16565;
  --danger-muted: #3a1c1c;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1013;
    --surface: #17191d;
    --border: #3a3e46;
    --text: #f3f4f6;
    --text-muted: #a3a9b3;
    --primary-muted: #1b2540;
    --primary: #6c9bff;
    --success: #34c285;
    --success-muted: #143726;
    --warning: #e0a030;
    --warning-muted: #3a2c0f;
    --danger: #f16565;
    --danger-muted: #3a1c1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; display: block; }

main {
  flex: 1;
  padding-block: 32px 48px;
  padding-inline: 16px;
}

.wrap {
  max-width: var(--container);
  margin: 0 auto;
}

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

/* ---- Site chrome (nav + footer) — matches apps/landing's brand/nav/
   theme-toggle so this feels like the same product, not a bare form
   generated on its own. ---- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: block;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px;
  cursor: pointer;
}

.theme-toggle button {
  border: none;
  background: transparent;
  color: inherit;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.theme-toggle button[aria-pressed="true"] {
  background: var(--primary-strong);
  color: white;
}

.theme-toggle button svg { width: 15px; height: 15px; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 16px;
}

.site-footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 12.5px;
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover { color: var(--text); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-muted);
  color: var(--primary);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* ---- A school's logo, or a generic fallback icon when none is set or the
   image fails to load — same fallback behavior as the Flutter app's
   SchoolLogoAvatar (see app.js schoolAvatarEl). ---- */
.school-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-muted);
  color: var(--primary);
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.school-avatar svg { width: 55%; height: 55%; }

.school-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.school-avatar.sm { width: 40px; height: 40px; border-radius: 8px; }

.school-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.school-header h1 {
  font-size: 17px;
  margin: 0;
}

.school-header p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

h2 {
  font-size: 20px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field {
  margin-bottom: 16px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

/* ---- Buttons — same class names/styling as apps/landing's .btn system. ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary { background: var(--primary-strong); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text-muted); }

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-block { width: 100%; }

.error-box {
  background: var(--danger-muted);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.result-row:last-child { border-bottom: none; }
.result-row span:first-child { color: var(--text-muted); }
.result-row span:last-child { font-weight: 600; text-align: right; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-submitted, .badge-verified { background: var(--warning-muted); color: var(--warning); }
.badge-accepted, .badge-enrolled { background: var(--success-muted); color: var(--success); }
.badge-rejected { background: var(--danger-muted); color: var(--danger); }

.reg-number {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--primary);
  background: var(--primary-muted);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 16px 0;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.actions .btn { flex: 1; }

.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--primary);
  margin: 28px 0 4px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-title:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.section-hint {
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 0 0 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 480px) {
  .field-row, .field-row.cols-3 { grid-template-columns: 1fr; }
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
  min-height: 64px;
}

textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex: 1;
  justify-content: center;
}

.radio-group input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

.radio-group input:checked + span,
.radio-group label:has(input:checked) {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-muted);
}

.field.required label::after {
  content: " *";
  color: var(--danger);
}

/* ---- File-upload (lampiran) widgets — each wraps a hidden <input type
   file>, shows a compress-in-progress state, then a thumbnail + size once
   the client-side WebP compression (see app.js compressImage) finishes. ---- */
.upload-field {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.upload-field .upload-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.upload-field .upload-label span.name {
  font-size: 13px;
  font-weight: 600;
}

.upload-field .upload-label span.optional-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  display: none;
}

.upload-thumb.visible { display: block; }

.upload-pick {
  flex: 1;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.upload-pick.has-file {
  color: var(--success);
  border-style: solid;
  border-color: var(--success);
  background: var(--success-muted);
}

.upload-pick.compressing {
  color: var(--warning);
  border-color: var(--warning);
  background: var(--warning-muted);
}

.upload-remove {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
  background: var(--danger-muted);
  color: var(--danger);
  display: none;
}

.upload-remove.visible { display: block; }

/* ---- Multi-step wizard (apply.html) ---- */
.step-indicator {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 24px;
}

.step-indicator .step {
  flex: 1;
  text-align: center;
  position: relative;
  font-size: 11px;
  color: var(--text-muted);
}

.step-indicator .step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.step-indicator .step.done:not(:last-child)::after { background: var(--primary); }

.step-indicator .dot {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  margin: 0 auto 6px;
  position: relative;
  z-index: 1;
}

/* Solid fill + white text for both "current" and "done" — same high-
   contrast treatment, so the active step's number is never harder to read
   than a completed one. A halo ring (not a muted/outline fill) is what
   tells "current" apart from "done" instead. */
.step-indicator .step.current .dot {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 3px var(--primary-muted);
}

.step-indicator .step.done .dot {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.step-indicator .label {
  display: block;
  max-width: 74px;
  margin: 0 auto;
}

.reg-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--primary-muted);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 18px;
}

.reg-banner strong { font-size: 14px; letter-spacing: 0.5px; }

.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.wizard-nav .btn-outline { flex: 0 0 auto; }
.wizard-nav button[type="submit"] { flex: 1; }

.choice-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-card h3 {
  margin: 0;
  font-size: 15px;
}

.choice-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  flex: 1;
}

/* Shown in place of the "Daftar Baru" card when a school's PPDB is closed
   or not yet open (school.html) or in place of the whole wizard when
   landing on apply.html directly while closed — see app.js
   ppdbClosedMessage(). */
.notice-card {
  border: 1px solid var(--warning);
  background: var(--warning-muted);
  border-radius: var(--radius-sm);
  padding: 18px;
}

.notice-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--warning);
}

.notice-card p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  margin: 20px 0;
}

.divider-or::before, .divider-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- School search (index.html) ---- */
.school-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.school-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}

.school-list-item:hover, .school-list-item:focus-visible {
  border-color: var(--primary);
}

.school-list-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.school-list-item-info strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-list-item-info .badge-level {
  font-size: 11px;
  color: var(--text-muted);
}

.school-list-item .chevron {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Progress/result tracker shown on school.html after a successful lookup
   for a non-draft (already-submitted) registration. */
.tracker {
  display: flex;
  justify-content: space-between;
  margin: 20px 0 4px;
}

.tracker .stage {
  flex: 1;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  position: relative;
}

.tracker .stage:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.tracker .stage.done:not(:last-child)::after { background: var(--success); }
.tracker .stage.rejected:not(:last-child)::after { background: var(--danger); }

.tracker .stage .dot {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text-muted);
  margin: 0 auto 6px;
  position: relative;
  z-index: 1;
  font-size: 14px;
}

/* Solid fill + white text/icon, not a muted tint — same reasoning as the
   step-indicator above: a colored glyph on a muted background is much
   harder to read at this size than white-on-solid. */
.tracker .stage.done .dot { border-color: var(--success); background: var(--success); color: #fff; }
.tracker .stage.current .dot { border-color: var(--warning); background: var(--warning); color: #fff; }
.tracker .stage.rejected .dot { border-color: var(--danger); background: var(--danger); color: #fff; }

/* ---- Skeleton loading — a shape-preview of what's coming, not a bare
   spinner (same convention as the Flutter app's SkeletonBox/SkeletonShimmer:
   apps/flutter/lib/shared/widgets/app_skeleton.dart). Used while school.html
   and apply.html wait on their one initial fetch, so the page reveals its
   final state in a single paint instead of content popping in/out as pieces
   resolve at different times. ---- */
@keyframes skeleton-sweep {
  0% { background-position: -150% 0; }
  100% { background-position: 150% 0; }
}

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--border) 25%, color-mix(in srgb, var(--border) 40%, var(--surface)) 50%, var(--border) 75%);
  background-size: 250% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.skeleton-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.skeleton-avatar { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; }

.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.skeleton-line { height: 12px; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-100 { width: 100%; }

.skeleton-title { height: 20px; width: 55%; margin-bottom: 10px; }
.skeleton-field { height: 42px; margin-bottom: 16px; }
.skeleton-button { height: 46px; }

[hidden] { display: none !important; }

@media print {
  body { background: #fff; }
  main { padding: 0; }
  .no-print { display: none !important; }
  .card { box-shadow: none; border: none; }
}
