/* ==========================================================================
   WADUL - Sistem desain (komponen bersama halaman publik dan admin)
   Dimuat setelah Tailwind CDN:  <link rel="stylesheet" href="/assets/ui.css">

   Isi:
     1. Token (variabel CSS)         5. Kolom isian
     2. Dasar + fokus                6. Chip dan pilihan
     3. Tombol                       7. Panel/sheet, toast, skeleton
     4. Kartu, lencana, status       8. Langkah penanganan, tabel responsif
   Warna status SELALU memakai ikon + teks (tidak mengandalkan warna saja).
   Rasio kontras teks dihitung terhadap latar komponennya (>= 4.5:1).
   ========================================================================== */

/* ---------- 1. Token ---------- */
:root {
  --hijau: #166534;
  --hijau-dark: #14532d;
  --hijau-50: #f0fdf4;
  --hijau-100: #dcfce7;
  --kuning: #facc15;
  --ink: #10241a;
  --ink-soft: #41524a;
  --ink-mute: #566860;
  --garis: #dfe5de;
  --garis-kuat: #b9c7bc;
  --kertas: #f4f6f3;
  --merah: #b91c1c;
  --r-md: .75rem;
  --r-lg: 1rem;
  --ring: 0 0 0 3px rgba(22, 101, 52, .28);
  --shadow-card: 0 1px 2px rgba(16, 36, 26, .06), 0 0 0 1px rgba(16, 36, 26, .06);
  --shadow-pop: 0 18px 40px -10px rgba(16, 36, 26, .35);
}

/* ---------- 2. Dasar + fokus ---------- */
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif; line-height: 1.6; }
:focus-visible { outline: 3px solid var(--hijau); outline-offset: 2px; }
.on-dark :focus-visible, .on-dark:focus-visible { outline-color: var(--kuning); }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.u-skip {
  position: absolute; left: .75rem; top: -4rem; z-index: 100; padding: .6rem 1rem; border-radius: var(--r-md);
  background: var(--hijau-dark); color: #fff; font-weight: 700; transition: top .15s;
}
.u-skip:focus { top: .75rem; }

/* ---------- 3. Tombol ---------- */
.u-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.75rem; padding: .5rem 1.1rem; border: 1.5px solid transparent; border-radius: var(--r-md);
  font-size: .9375rem; font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.u-btn:active:not(:disabled) { transform: scale(.98); }
.u-btn:disabled, .u-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.u-btn-primary { background: var(--hijau); color: #fff; }
.u-btn-primary:hover:not(:disabled) { background: var(--hijau-dark); }
.u-btn-accent { background: var(--kuning); color: var(--hijau-dark); }
.u-btn-accent:hover:not(:disabled) { background: #fde047; }
.u-btn-outline { background: #fff; border-color: var(--garis-kuat); color: var(--hijau); }
.u-btn-outline:hover:not(:disabled) { background: var(--hijau-50); border-color: var(--hijau); }
.u-btn-ghost { background: transparent; color: var(--ink-soft); }
.u-btn-ghost:hover:not(:disabled) { background: rgba(16, 36, 26, .07); }
.u-btn-danger { background: var(--merah); color: #fff; }
.u-btn-danger:hover:not(:disabled) { background: #991b1b; }
.u-btn-danger-outline { background: #fff; border-color: #fca5a5; color: var(--merah); }
.u-btn-danger-outline:hover:not(:disabled) { background: #fef2f2; border-color: var(--merah); }
.u-btn-warn-outline { background: #fff; border-color: #fcd34d; color: #92400e; }
.u-btn-warn-outline:hover:not(:disabled) { background: #fffbeb; border-color: #d97706; }
.u-btn-onDark { background: transparent; border-color: rgba(255, 255, 255, .55); color: #fff; }
.u-btn-onDark:hover:not(:disabled) { background: rgba(255, 255, 255, .12); border-color: #fff; }
.u-btn-lg { min-height: 3.25rem; padding: .75rem 1.5rem; font-size: 1rem; }
.u-btn-sm { min-height: 2.75rem; padding: .4rem .85rem; font-size: .875rem; }
.u-btn-block { width: 100%; }
.u-icon-btn {
  display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none;
  border-radius: 999px; color: var(--ink-soft); cursor: pointer; transition: background-color .15s, color .15s;
}
.u-icon-btn:hover { background: rgba(16, 36, 26, .07); }
.u-spin { animation: u-putar 1s linear infinite; }
@keyframes u-putar { to { transform: rotate(360deg); } }

/* ---------- 4. Kartu, lencana, status ---------- */
.u-card { background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.u-card-pad { padding: 1.1rem 1.25rem; }
.u-eyebrow { font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); }

.u-badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; line-height: 1.35; white-space: nowrap;
}
.u-badge svg, .u-badge i { width: .9rem; height: .9rem; flex: none; }
.u-badge-lg { font-size: .875rem; padding: .3rem .8rem; }
.u-badge[data-tone="baru"] { background: #e0f2fe; color: #075985; }
.u-badge[data-tone="diproses"] { background: #fef3c7; color: #92400e; }
.u-badge[data-tone="selesai"] { background: #dcfce7; color: #166534; }
.u-badge[data-tone="ditolak"] { background: #fee2e2; color: #991b1b; }
.u-badge[data-tone="netral"] { background: #e9eee8; color: #34443c; }
.u-badge[data-tone="info"] { background: #ede9fe; color: #5b21b6; }
.u-badge[data-tone="alert"] { background: #fef3c7; color: #92400e; }
.u-badge[data-tone="bahaya"] { background: #fee2e2; color: #991b1b; }
/* Kategori: netral dan berikon supaya tidak bersaing dengan warna status */
.u-pill {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .65rem; border-radius: 999px;
  background: #fff; box-shadow: inset 0 0 0 1.5px var(--garis); color: var(--ink-soft);
  font-size: .75rem; font-weight: 700; line-height: 1.35; white-space: nowrap;
}
.u-pill svg, .u-pill i { width: .85rem; height: .85rem; flex: none; }
.u-tabnum { font-variant-numeric: tabular-nums; }

/* ---------- 5. Kolom isian ---------- */
.u-label { display: block; font-size: .9375rem; font-weight: 700; color: var(--ink); }
.u-opt { font-weight: 500; color: var(--ink-mute); }
.u-help { margin-top: .25rem; font-size: .8125rem; line-height: 1.5; color: var(--ink-mute); }
.u-error { display: flex; align-items: flex-start; gap: .35rem; margin-top: .35rem; font-size: .875rem; font-weight: 600; line-height: 1.45; color: var(--merah); }
.u-error.hidden { display: none; }
.u-field {
  display: block; width: 100%; min-height: 3rem; padding: .65rem .9rem; border-radius: var(--r-md);
  border: 1.5px solid var(--garis-kuat); background: #fff; color: var(--ink); font: inherit; font-size: 1rem; line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
.u-field::placeholder { color: #66766e; opacity: 1; }
.u-field:hover { border-color: #8da192; }
.u-field:focus { outline: none; border-color: var(--hijau); box-shadow: var(--ring); }
.u-field[aria-invalid="true"] { border-color: var(--merah); }
.u-field[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, .25); }
textarea.u-field { min-height: 7.5rem; resize: vertical; }
select.u-field { appearance: auto; }

/* Tombol sakelar (anonim) */
.u-switch { position: relative; display: inline-block; flex: none; width: 3.25rem; height: 2rem; border-radius: 999px; background: #94a39a; transition: background-color .15s; }
.u-switch::after { content: ""; position: absolute; left: .25rem; top: .25rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
input:checked + .u-switch { background: var(--hijau); }
input:checked + .u-switch::after { transform: translateX(1.25rem); }
input:focus-visible + .u-switch { outline: 3px solid var(--hijau); outline-offset: 2px; }

/* ---------- 6. Chip dan pilihan ---------- */
.u-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; flex: none;
  min-height: 2.5rem; padding: 0 1rem; border: 1.5px solid var(--garis-kuat); border-radius: 999px;
  background: #fff; color: var(--ink-soft); font-size: .875rem; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.u-chip:hover { border-color: var(--hijau); color: var(--hijau); }
.u-chip[aria-pressed="true"] { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.u-chip svg, .u-chip i { width: 1rem; height: 1rem; }
/* radio sebagai kartu pilihan (kategori) */
.u-choice { position: relative; cursor: pointer; }
.u-choice > input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.u-choice > span {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 2.75rem; padding: 0 1rem; border: 1.5px solid var(--garis-kuat);
  border-radius: var(--r-md); background: #fff; color: var(--ink-soft); font-size: .9375rem; font-weight: 600;
  transition: background-color .15s, border-color .15s, color .15s;
}
.u-choice > span svg, .u-choice > span i { width: 1.1rem; height: 1.1rem; flex: none; }
.u-choice:hover > span { border-color: var(--hijau); }
.u-choice > input:checked + span { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.u-choice > input:focus-visible + span { outline: 3px solid var(--hijau); outline-offset: 2px; }

/* ---------- 7. Sheet, toast, skeleton ---------- */
.sheet { display: none; }
.sheet.open { display: flex; }
@keyframes u-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes u-naik { from { transform: translateY(100%); } to { transform: none; } }
@keyframes u-muncul { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.sheet-backdrop { animation: u-fade .2s ease-out both; }
.sheet-panel { animation: u-naik .28s cubic-bezier(.22, 1, .36, 1) both; overscroll-behavior: contain; }
.sheet-center .sheet-panel { animation: u-muncul .2s ease-out both; }
@media (min-width: 768px) { .sheet-panel { animation: u-muncul .2s ease-out both; } }
.u-toast {
  position: fixed; left: 50%; bottom: calc(5.5rem + env(safe-area-inset-bottom)); z-index: 70; transform: translateX(-50%);
  max-width: min(92vw, 28rem); padding: .75rem 1.25rem; border-radius: 999px; background: var(--ink); color: #fff;
  font-size: .9375rem; font-weight: 600; text-align: center; box-shadow: var(--shadow-pop); animation: u-fade .15s ease-out both;
}
.u-toast.hidden { display: none; }
.u-skel { border-radius: .5rem; background: linear-gradient(90deg, #e6ece6 25%, #f2f5f2 40%, #e6ece6 65%); background-size: 400% 100%; animation: u-shimmer 1.5s ease infinite; }
@keyframes u-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- 8. Langkah penanganan + tabel responsif ---------- */
.u-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0; padding: 0; list-style: none; }
.u-step { position: relative; display: flex; flex-direction: column; align-items: center; padding: 0 .25rem; text-align: center; }
.u-step::before { content: ""; position: absolute; top: 1rem; left: -50%; width: 100%; height: 3px; background: var(--garis); z-index: 0; }
.u-step:first-child::before { display: none; }
.u-step[data-done="true"]::before, .u-step[data-current="true"]::before { background: var(--hijau); }
.u-step[data-tone="ditolak"][data-current="true"]::before { background: #b91c1c; }
.u-step-dot {
  position: relative; z-index: 1; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: #fff; box-shadow: inset 0 0 0 2.5px var(--garis-kuat); color: var(--ink-mute);
}
.u-step-dot svg, .u-step-dot i { width: 1rem; height: 1rem; }
.u-step[data-done="true"] .u-step-dot { background: var(--hijau); box-shadow: none; color: #fff; }
.u-step[data-current="true"] .u-step-dot { background: #fff; box-shadow: inset 0 0 0 3px var(--hijau), 0 0 0 4px rgba(22, 101, 52, .15); color: var(--hijau); }
.u-step[data-tone="ditolak"][data-current="true"] .u-step-dot { box-shadow: inset 0 0 0 3px #b91c1c, 0 0 0 4px rgba(185, 28, 28, .15); color: #b91c1c; }
.u-step[data-current="true"][data-final="true"] .u-step-dot { background: var(--hijau); box-shadow: 0 0 0 4px rgba(22, 101, 52, .15); color: #fff; }
.u-step-label { margin-top: .4rem; font-size: .8125rem; font-weight: 600; line-height: 1.3; color: var(--ink-mute); }
.u-step[data-done="true"] .u-step-label, .u-step[data-current="true"] .u-step-label { color: var(--ink); font-weight: 800; }
.u-step-sub { font-size: .75rem; color: var(--ink-mute); }

/* Menu admin aktif */
[data-nav][aria-current="page"] { background: rgba(0, 0, 0, .22); color: var(--kuning); }
[data-nav][aria-current="page"] i, [data-nav][aria-current="page"] svg { color: var(--kuning); }

/* Tabel jadi kartu bertumpuk di layar kecil */
@media (max-width: 639px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; }
  .tbl tr { border: 1px solid var(--garis); border-radius: var(--r-md); margin: .75rem; padding: .25rem 0; background: #fff; }
  .tbl tr + tr { border-top-width: 1px; }
  .tbl td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 1rem; text-align: right; }
  .tbl td::before { content: attr(data-label); font-size: .75rem; font-weight: 700; color: var(--ink-mute); text-align: left; }
  .tbl td.cell-isi { display: block; text-align: left; }
  .tbl td.cell-isi::before { display: none; }
  .tbl td[colspan]::before { display: none; }
  .tbl td[colspan] { justify-content: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .u-spin { animation: none !important; }
}
