/* ==========================================================================
   FORM — tampilan formulir pendaftaran (dipakai semua template).
   Warna, font, dan radius mengikuti token di theme.css tiap template.
   ========================================================================== */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Penunjuk langkah ---------- */
.stepper-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.stepper-count { font-size: 0.75rem; font-weight: 600; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.stepper-current { font-size: 0.875rem; font-weight: 600; }
.stepper-bar { height: 0.25rem; margin-top: 0.625rem; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.stepper-bar > span {
  display: block; height: 100%; border-radius: inherit; background: var(--primary);
  transform-origin: left; transform: scaleX(var(--p, 0));
  transition: transform 0.6s var(--ease-out);
}
.stepper-list { display: none; margin-top: 1.25rem; }
.stepper-item {
  position: relative; display: flex; align-items: center; gap: 0.75rem; width: 100%;
  padding: 0.5rem 0; text-align: left; color: var(--muted-foreground);
  transition: color var(--dur-fast) ease;
}
.stepper-item:not(:disabled) { cursor: pointer; }
.stepper-item:disabled { cursor: default; }
.stepper-dot {
  display: grid; place-items: center; flex: none;
  width: 1.75rem; height: 1.75rem; border-radius: 9999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-base) ease, border-color var(--dur-base) ease, color var(--dur-base) ease, transform var(--dur-base) var(--ease-out);
}
.stepper-dot svg { width: 0.875rem; height: 0.875rem; }
.stepper-text { display: grid; min-width: 0; }
.stepper-text strong { font-size: 0.8125rem; font-weight: 600; line-height: 1.25rem; }
.stepper-text small { font-size: 0.75rem; line-height: 1rem; color: var(--muted-foreground); }
.stepper-item.is-done { color: var(--foreground); }
.stepper-item.is-done .stepper-dot { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.stepper-item[aria-current='step'] { color: var(--foreground); }
.stepper-item[aria-current='step'] .stepper-dot { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); transform: scale(1.08); }
@media (hover: hover) { .stepper-item:not(:disabled):hover { color: var(--foreground); } }

@media (min-width: 1024px) {
  .stepper-list { display: grid; }
  /* Vertikal: daftar di sisi kiri dengan garis penghubung */
  [data-orientation='vertical'] .stepper-list li { position: relative; }
  [data-orientation='vertical'] .stepper-list li:not(:last-child)::before {
    content: ''; position: absolute; left: calc(0.875rem - 0.5px); top: 2.375rem; bottom: -0.375rem; width: 1px; background: var(--border);
  }
  [data-orientation='vertical'] .stepper-item { padding: 0.625rem 0; }
  /* Horizontal: sejajar di atas formulir */
  [data-orientation='horizontal'] .stepper-list { grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.5rem; }
  [data-orientation='horizontal'] .stepper-item { flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 0.75rem 0 0; border-top: 2px solid var(--border); transition: border-color var(--dur-base) ease, color var(--dur-fast) ease; }
  [data-orientation='horizontal'] .stepper-item.is-done,
  [data-orientation='horizontal'] .stepper-item[aria-current='step'] { border-top-color: var(--primary); }
  [data-orientation='horizontal'] .stepper-text small { display: none; }
  [data-orientation='horizontal'] .stepper-bar,
  [data-orientation='horizontal'] .stepper-head { display: none; }
  [data-orientation='horizontal'] .stepper-list { margin-top: 0; }
}

/* ---------- Langkah & susunan field ---------- */
.step { scroll-margin-top: calc(var(--nav-h) + 16px); }
.step.is-entering { animation: step-in 0.45s var(--ease-out) both; }
.step.is-entering.is-back { animation-name: step-in-back; }
@keyframes step-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes step-in-back { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: none; } }

.step-title { font-size: 1.5rem; line-height: 1.25; }
.step-title:focus { outline: none; }
.step-desc { margin-top: 0.375rem; font-size: 0.875rem; line-height: 1.5; color: var(--muted-foreground); max-width: 60ch; }
@media (max-width: 639.98px) {
  .step-title { font-size: 1.25rem; }
  .step-desc { font-size: 0.8125rem; }
}

.form-section { margin-top: 1.5rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.form-section > header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.125rem; }
.form-section > header .sec-icon { display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary); }
.form-section > header .sec-icon svg { width: 1.125rem; height: 1.125rem; }
.form-section h3 { font-size: 0.9375rem; line-height: 1.375rem; letter-spacing: 0; }
.form-section header p { font-size: 0.8125rem; line-height: 1.25rem; color: var(--muted-foreground); }
@media (min-width: 640px) { .form-section { padding: 1.5rem; } }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 0.75rem; }
.ff { grid-column: span 2; min-width: 0; }
.ff.m-half { grid-column: span 1; }
@media (min-width: 640px) {
  .form-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.125rem 1rem; }
  .ff, .ff.m-half { grid-column: span 3; }
  .ff.col-6 { grid-column: span 6; }
  .ff.col-2 { grid-column: span 2; }
  .ff.col-4 { grid-column: span 4; }
}
.ff .req { margin-left: 0.125rem; color: var(--danger); }
.ff .opt { margin-left: 0.375rem; font-weight: 400; font-size: 0.75rem; color: var(--muted-foreground); }
.ff:not(.is-required) .req, .ff.is-required .opt { display: none; }

/* Pilihan berupa pil (jenis kelamin, status sekolah, dst.) */
.pill-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill { position: relative; flex: 1 1 0; min-width: max-content; }
.pill input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pill span {
  display: flex; align-items: center; justify-content: center; gap: 0.375rem; height: 2.75rem; padding: 0 0.875rem;
  border: 1px solid var(--input); border-radius: var(--radius-md); background: var(--surface);
  font-size: 0.875rem; font-weight: 500; white-space: nowrap;
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.pill input:hover + span { border-color: var(--muted-foreground); }
.pill input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.pill input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }
.pill-group[aria-invalid='true'] .pill span { border-color: var(--danger); }

/* Pilihan berupa kartu (jalur pendaftaran) */
.choice-grid { display: grid; gap: 0.75rem; }
@media (min-width: 640px) { .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Tepat tiga pilihan di layar lebar: sejajar tiga kolom supaya tidak ada sel kosong */
@media (min-width: 1280px) { .choice-grid:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.choice { position: relative; display: block; }
.choice input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; }
.choice-body {
  display: flex; gap: 0.875rem; height: 100%; padding: 1rem;
  border: 1px solid var(--input); border-radius: var(--radius-lg); background: var(--surface);
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-base) var(--ease-out);
}
.choice-icon { display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-md); background: var(--muted); color: var(--muted-foreground); transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.choice-icon svg { width: 1.25rem; height: 1.25rem; }
.choice-title { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; font-weight: 600; line-height: 1.375rem; }
.choice-desc { display: block; margin-top: 0.125rem; font-size: 0.8125rem; line-height: 1.25rem; color: var(--muted-foreground); }
.choice-check { margin-left: auto; flex: none; display: grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 9999px; border: 1px solid var(--input); color: transparent; transition: all var(--dur-fast) ease; }
.choice-check svg { width: 0.75rem; height: 0.75rem; }
.choice input:hover + .choice-body { border-color: var(--muted-foreground); }
.choice input:checked + .choice-body { border-color: var(--primary); background: var(--primary-soft); }
.choice input:checked + .choice-body .choice-icon { background: var(--primary); color: var(--primary-foreground); }
.choice input:checked + .choice-body .choice-check { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--ring); outline-offset: 2px; }
.choice-grid[aria-invalid='true'] .choice-body { border-color: var(--danger); }
@media (max-width: 639.98px) { .choice-title { font-size: 0.875rem; } }

/* Kotak centang */
.check { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.625rem 0; cursor: pointer; font-size: 0.875rem; line-height: 1.375rem; }
.check input {
  appearance: none; flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.0625rem;
  border: 1px solid var(--input); border-radius: min(var(--radius-sm), 6px); background: var(--surface); cursor: pointer;
  display: grid; place-items: center; transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.check input::after { content: ''; width: 0.625rem; height: 0.375rem; border-left: 2px solid var(--primary-foreground); border-bottom: 2px solid var(--primary-foreground); transform: rotate(-45deg) scale(0); margin-top: -0.125rem; transition: transform var(--dur-fast) var(--ease-out); }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { transform: rotate(-45deg) scale(1); }
.check input[aria-invalid='true'] { border-color: var(--danger); }

/* Hasil hitung otomatis (rata-rata rapor) */
.output-box { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; height: 2.75rem; padding: 0 0.875rem; border: 1px dashed var(--input); border-radius: var(--radius-md); background: var(--muted); font-size: 0.9375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.output-box small { font-size: 0.75rem; font-weight: 500; color: var(--muted-foreground); }

/* Daftar prestasi (bisa ditambah) */
.repeater-item { position: relative; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); animation: fade-up var(--dur-slow) var(--ease-out) both; }
.repeater-item + .repeater-item { margin-top: 0.75rem; }
.repeater-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; font-size: 0.8125rem; font-weight: 600; }
.repeater-empty { padding: 1.25rem; border: 1px dashed var(--input); border-radius: var(--radius-md); text-align: center; font-size: 0.8125rem; color: var(--muted-foreground); }

/* Unggah berkas */
.drop {
  position: relative; display: flex; align-items: center; gap: 0.875rem; padding: 0.875rem;
  border: 1px dashed var(--input); border-radius: var(--radius-md); background: var(--surface);
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.drop input[type='file'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-icon { display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-md); background: var(--muted); color: var(--muted-foreground); }
.drop-icon svg { width: 1.125rem; height: 1.125rem; }
.drop-text { min-width: 0; flex: 1; }
.drop-text strong { display: block; font-size: 0.8125rem; font-weight: 600; line-height: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-text small { display: block; font-size: 0.75rem; line-height: 1rem; color: var(--muted-foreground); }
.drop:hover, .drop.is-drag { border-color: var(--primary); background: var(--primary-soft); }
.drop:focus-within { outline: 2px solid var(--ring); outline-offset: 2px; }
.drop.has-file { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.drop.has-file .drop-icon { background: var(--success); color: #fff; }
.drop[aria-invalid='true'] { border-color: var(--danger); }
.drop-remove { position: relative; z-index: 1; display: none; }
.drop.has-file .drop-remove { display: inline-grid; }

/* ---------- Tombol navigasi langkah ---------- */
.form-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1.5rem; }
.form-nav .btn-next { margin-left: auto; }
@media (max-width: 639.98px) {
  .form-nav { position: sticky; bottom: 0; z-index: 20; margin-inline: calc(var(--gutter) * -1); padding: 0.75rem var(--gutter) max(0.75rem, env(safe-area-inset-bottom)); background: var(--background); border-top: 1px solid var(--border); }
  .form-nav .btn { flex: 1; }
}

/* ---------- Tinjauan ---------- */
.review-card { margin-top: 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.review-card > header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.875rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--muted); }
.review-card > header h3 { font-size: 0.875rem; letter-spacing: 0; }
.review-list { display: grid; gap: 0.75rem 1.5rem; padding: 1.125rem 1.25rem; }
@media (min-width: 640px) { .review-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.review-list dt { font-size: 0.75rem; line-height: 1rem; color: var(--muted-foreground); }
.review-list dd { margin-top: 0.125rem; font-size: 0.875rem; line-height: 1.375rem; font-weight: 500; overflow-wrap: anywhere; }
.review-list .wide { grid-column: 1 / -1; }

.notice { display: flex; gap: 0.75rem; padding: 0.875rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted); font-size: 0.8125rem; line-height: 1.25rem; }
.notice svg { width: 1rem; height: 1rem; flex: none; margin-top: 0.125rem; }
.notice-danger { border-color: transparent; background: var(--danger-soft); color: var(--danger); }
.notice-primary { border-color: transparent; background: var(--primary-soft); }
.notice-primary svg { color: var(--primary); }

/* ---------- Halaman berhasil ---------- */
.success { text-align: center; animation: fade-up 0.6s var(--ease-out) both; }
.success:focus { outline: none; }
.success-mark { width: 4.5rem; height: 4.5rem; margin-inline: auto; }
.success-mark circle { fill: var(--success-soft); stroke: var(--success); stroke-width: 2; stroke-dasharray: 190; stroke-dashoffset: 190; animation: draw 0.7s var(--ease-out) 0.15s forwards; }
.success-mark path { fill: none; stroke: var(--success); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.45s var(--ease-out) 0.7s forwards; }
.ticket { margin: 1.5rem auto 0; max-width: 34rem; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.ticket-no { padding: 1.25rem; text-align: center; border-bottom: 1px dashed var(--input); background: var(--muted); }
.ticket-no span { display: block; font-size: 0.75rem; color: var(--muted-foreground); }
.ticket-no strong { display: block; margin-top: 0.25rem; font-family: var(--font-mono); font-size: 1.375rem; letter-spacing: 0.06em; }
.ticket dl { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; padding: 1.125rem 1.25rem; font-size: 0.875rem; }
.ticket dt { color: var(--muted-foreground); }
.ticket dd { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* ---------- Toast & dialog ---------- */
.toast-wrap { position: fixed; z-index: 60; left: 50%; bottom: max(1rem, calc(env(safe-area-inset-bottom) + 0.5rem)); transform: translateX(-50%); display: grid; gap: 0.5rem; width: max-content; max-width: calc(100vw - 2rem); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.875rem; border-radius: var(--radius-md); background: var(--foreground); color: var(--background); font-size: 0.8125rem; font-weight: 500; animation: fade-up var(--dur-slow) var(--ease-out) both; }
.toast svg { width: 1rem; height: 1rem; flex: none; }
.toast.is-leaving { animation: fade-in var(--dur-base) var(--ease-in) reverse both; }
@media (max-width: 639.98px) { .toast-wrap { bottom: calc(5rem + env(safe-area-inset-bottom)); } }

dialog.dialog { width: min(26rem, calc(100vw - 2rem)); padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--surface-foreground); }
dialog.dialog::backdrop { background: color-mix(in srgb, black 55%, transparent); } /* peredup: selalu gelap, di tema terang maupun gelap */
dialog.dialog[open] { animation: fade-up var(--dur-slow) var(--ease-out) both; }
dialog.dialog h2 { font-size: 1.125rem; line-height: 1.5rem; }
dialog.dialog p { margin-top: 0.5rem; font-size: 0.875rem; line-height: 1.375rem; color: var(--muted-foreground); }
dialog.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
@media (max-width: 639.98px) {
  dialog.dialog { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: 1.25rem 1.25rem max(1.25rem, env(safe-area-inset-bottom)); }
  dialog.dialog .dialog-actions { flex-direction: column-reverse; }
}

/* ---------- Cetak bukti pendaftaran ---------- */
@media print {
  body { background: #fff !important; color: #000 !important; }
  header, footer, aside, .no-print, .toast-wrap, #ppdb-stepper { display: none !important; }
  .success { animation: none; }
  .success-mark circle, .success-mark path { animation: none; stroke-dashoffset: 0; }
  .ticket { border-color: #000; max-width: none; }
}
