/* ============================================================
 * Form Pengajuan KTA Terintegrasi BNI — Ikatan Arsitek Indonesia
 * Tema menyatu dengan aapdc.iai.or.id: Hanken Grotesk,
 * maroon #8B1538, bersih. Mobile-first, tanpa dependensi eksternal.
 * ============================================================ */

/* Font self-hosted, sama dengan aapdc/lms (Hanken Grotesk 100-900). */
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/hanken-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/hanken-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Palet aapdc.iai.or.id */
  --maroon:       #8B1538;
  --maroon-dark:  #6B1227;
  --maroon-deep:  #4A0C1D;
  --maroon-light: #C12755;
  --maroon-tint:  #FDF2F6;
  --maroon-tint2: #F9E3EA;
  --accent:       #A91B3C;

  /* Alias komponen lama → palet maroon */
  --navy-900: var(--maroon-deep);
  --navy-700: var(--maroon);
  --navy-600: var(--maroon);
  --orange: var(--maroon);
  --orange-dark: var(--maroon-dark);

  --bg: #F9FAFB;
  --card: #ffffff;
  --ink: #1F2937;
  --ink-soft: #4B5563;
  --line: #E5E7EB;
  --line-strong: #D1D5DB;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 22px rgba(31, 41, 55, .10), 0 2px 6px rgba(31, 41, 55, .06);
  --focus-ring: 0 0 0 3px rgba(139, 21, 56, .14);
  --font: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* atribut hidden harus selalu menang atas gaya tampilan apa pun */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  background: #ffffff;
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
}

/* ---------- Header (gaya aapdc: putih sticky, logo + teks maroon) ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  padding: 14px 16px;
}
.brand {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo { display: inline-flex; flex: none; height: 44px; width: auto; }
.brand-logo img { height: 44px; width: auto; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.3rem; font-weight: 700; letter-spacing: .5px; line-height: 1.15; color: var(--maroon); }
.brand-text span { font-size: .8rem; color: var(--ink-soft); }

/* ---------- Layout ---------- */
.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 14px calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Stepper ---------- */
.stepper {
  list-style: none;
  display: flex;
  gap: 4px;
  padding: 0;
  margin: 0 0 14px;
  counter-reset: step;
}
.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: .68rem;
  color: var(--ink-soft);
  text-align: center;
  position: relative;
}
.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .78rem;
  background: #fff;
  border: 2px solid var(--line-strong);
  color: var(--ink-soft);
  transition: all .25s ease;
}
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 13px;
  left: calc(50% + 18px);
  width: calc(100% - 36px);
  height: 2px;
  background: var(--line-strong);
}
.step.is-active .step-dot {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(139, 21, 56, .14);
}
.step.is-active .step-label { color: var(--navy-700); font-weight: 600; }
.step.is-done .step-dot {
  background: var(--navy-700);
  border-color: var(--navy-700);
  color: #fff;
}

@media (max-width: 480px) {
  .step-label { display: none; }
  .step.is-active .step-label { display: block; font-size: .62rem; }
}

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px 18px;
  border: 1px solid rgba(219, 227, 236, .7);
}

.screen-title {
  margin: 0 0 6px;
  font-size: 1.28rem;
  color: var(--navy-700);
}
.screen-title small { font-size: .8rem; color: var(--ink-soft); font-weight: 500; }

.notice {
  background: var(--maroon-tint);
  border: 1px solid var(--maroon-tint2);
  border-radius: var(--radius-sm);
  color: var(--maroon-dark);
  font-size: .86rem;
  padding: 10px 12px;
  margin: 0 0 16px;
}

/* ---------- Fields ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 5px;
  color: var(--navy-900);
}
.req { color: var(--danger); }
.helper { font-size: .76rem; color: var(--ink-soft); margin: 5px 0 0; }

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="date"],
input[type="search"],
textarea {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 96px; }

input:focus, textarea:focus {
  border-color: var(--navy-600);
  box-shadow: var(--focus-ring);
  background: #fff;
}

.field.has-error input,
.field.has-error textarea,
.combo.has-error .combo-toggle { border-color: var(--danger); }
.field.has-error input:focus, .field.has-error textarea:focus { box-shadow: 0 0 0 3px rgba(192, 57, 43, .15); }

.error {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 6px;
  font-size: .78rem;
  margin: 6px 0 0;
  padding: 6px 9px;
}
.error::before { content: "⚠"; font-size: .85em; }

.inline-note {
  font-size: .78rem;
  color: var(--ink-soft);
  background: var(--bg);
  border-left: 3px solid var(--orange);
  padding: 7px 10px;
  border-radius: 0 8px 8px 0;
  margin: -6px 0 16px;
}

/* ---------- Combobox kantor cabang ---------- */
.combo-caption {
  font-size: .84rem;
  color: var(--ink-soft);
  margin: 0 0 10px;
  padding: 9px 11px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.combo { position: relative; }
.combo-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  font: inherit;
  font-size: .95rem;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.combo-toggle:focus-visible { outline: none; border-color: var(--navy-600); box-shadow: var(--focus-ring); }
.combo-value.placeholder { color: #93a3b3; }
.combo-value.selected { font-weight: 600; color: var(--navy-700); }
.combo-caret { flex: none; color: var(--ink-soft); transition: transform .18s ease; }
.combo.open .combo-caret { transform: rotate(180deg); }

.combo-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 40px rgba(11, 42, 74, .22);
  overflow: hidden;
}
.combo-search-wrap { padding: 9px; border-bottom: 1px solid var(--line); background: #f7fafd; }
.combo-search { background: #fff; }
.combo-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.combo-opt {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.combo-opt .opt-title { display: block; font-weight: 600; font-size: .88rem; color: var(--navy-900); }
.combo-opt .opt-desc {
  display: block;
  white-space: pre-line;
  font-size: .74rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.combo-opt:hover, .combo-opt.is-highlight { background: var(--maroon-tint); }
.combo-opt[aria-selected="true"] { background: var(--navy-700); }
.combo-opt[aria-selected="true"] .opt-title,
.combo-opt[aria-selected="true"] .opt-desc { color: #fff; }
.combo-empty { padding: 14px 10px; text-align: center; color: var(--ink-soft); font-size: .84rem; }

/* ---------- Summary (konfirmasi) ---------- */
.summary {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.sum-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "dt edit" "dd edit";
  gap: 1px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.sum-row:last-child { border-bottom: 0; }
.sum-row:nth-child(even) { background: #fafcfe; }
.sum-row dt {
  grid-area: dt;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-soft);
}
.sum-row dd {
  grid-area: dd;
  margin: 0;
  font-weight: 700;
  font-size: .92rem;
  color: var(--navy-900);
  overflow-wrap: anywhere;
}
.sum-row dd.pre { white-space: pre-line; font-weight: 600; }
.sum-edit {
  grid-area: edit;
  align-self: center;
  border: 0;
  background: none;
  color: var(--navy-600);
  font: inherit;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 7px;
}
.sum-edit:hover { background: var(--maroon-tint); text-decoration: underline; }

/* ---------- Opt-in ---------- */
.optin { margin-bottom: 12px; }
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  padding: 11px 12px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
}
.check:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.check input {
  flex: none;
  width: 19px;
  height: 19px;
  margin: 1px 0 0;
  accent-color: var(--navy-600);
}

/* ---------- Honeypot ---------- */
.hp-wrap {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* ---------- Actions ---------- */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  position: sticky;
  bottom: 0;
  padding: 12px 0 2px;
  background: linear-gradient(to top, var(--card) 72%, transparent);
}
.btn {
  flex: 1;
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 0;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary {
  background: var(--maroon);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--maroon-dark); }
.btn-primary[disabled] { opacity: .6; cursor: wait; }
.btn-ghost, .btn-secondary {
  background: #fff;
  color: var(--navy-700);
  border: 1.5px solid var(--line-strong);
  flex: 0 0 auto;
}
.btn-ghost:hover, .btn-secondary:hover { background: var(--maroon-tint); }
.screen-done .done-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.screen-done .done-actions .btn { flex: 1 1 160px; }

/* ---------- Selesai ---------- */
.screen-done { text-align: center; padding-top: 8px; }
.done-icon { margin-bottom: 4px; }
.screen-done .notice { text-align: left; }
.receipt {
  text-align: left;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  margin: 6px 0 10px;
  background: #fbfdff;
}
.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: .85rem;
}
.receipt-row:last-child { border-bottom: 0; }
.receipt-row span { color: var(--ink-soft); }
.receipt-row strong { text-align: right; overflow-wrap: anywhere; }
.helper.center { text-align: center; }

.foot-note {
  text-align: center;
  font-size: .74rem;
  color: var(--ink-soft);
  margin: 16px auto 0;
  max-width: 460px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--navy-900);
  color: #fff;
  font-size: .84rem;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .28);
  z-index: 90;
  max-width: min(92vw, 480px);
  text-align: center;
}

/* ---------- Submitting state ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}

/* ---------- Aksesibilitas ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.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;
}
