/* =========================================================
   theme.css - CV Sumber Air
   Token tema, komponen dasar (kartu, input, tombol, tabel, filter),
   bilah tab mobile, dan mode gelap.
   Warna brand/aksen berasal dari variabel --b-* / --a-* (tema di Pengaturan).
   ========================================================= */

:root {
  /* Tema bawaan "Biru Navy" - ditimpa <style> di base.html sesuai Pengaturan */
  --b-50: 239 246 255; --b-100: 219 234 254; --b-200: 191 219 254; --b-300: 147 197 253;
  --b-400: 96 165 250; --b-500: 59 130 246; --b-600: 37 99 235; --b-700: 29 78 216;
  --b-800: 30 64 175; --b-900: 30 58 138; --b-950: 23 37 84;
  --a-50: 255 251 235; --a-100: 254 243 199; --a-200: 253 230 138; --a-300: 252 211 77;
  --a-400: 251 191 36; --a-500: 245 158 11; --a-600: 217 119 6; --a-700: 180 83 9;

  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef1f6;
  --border: #e4e8ef;
  --border-strong: #d3d9e3;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --text-muted: #94a3b8;
  --text-faint: #cbd5e1;
  --accent-text: rgb(var(--b-700));
  --ok: #059669;
  --warn: #d97706;
  --bad: #e11d48;
  --card-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -16px rgba(16, 24, 40, .18);

  --header-h: 60px;
  --tabbar-h: 60px;
  --tabbar-bg: rgba(255, 255, 255, .97);
  --tabbar-garis: rgba(15, 23, 42, .09);
  --tab-aktif-bg: rgb(var(--b-500) / .12);
}

html.dark {
  color-scheme: dark;
  --bg: #070b13;
  --surface: #0f1622;
  --surface-2: #141d2b;
  --surface-3: #1b2636;
  --border: rgba(148, 170, 205, .14);
  --border-strong: rgba(148, 170, 205, .24);
  --text: #e7edf6;
  --text-2: #b6c2d3;
  --text-3: #93a1b5;
  --text-muted: #748296;
  --text-faint: #4a5567;
  --accent-text: rgb(var(--b-300));
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --tabbar-bg: rgba(12, 18, 28, .96);
  --tabbar-garis: rgba(148, 170, 205, .14);
  --tab-aktif-bg: rgb(var(--b-400) / .18);
}

/* ---------- Dasar ---------- */
html { background-color: var(--bg); }
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
[x-cloak] { display: none !important; }
.angka { font-variant-numeric: tabular-nums; }

.press { transition: transform .12s ease; }
.press:active { transform: scale(.97); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .22s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.toast-in { animation: toastIn .3s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: translateY(0); } }

.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
#app-table.htmx-request { opacity: .55; transition: opacity .15s; }

/* ---------- Gradasi brand ---------- */
.brand-gradient {
  background: linear-gradient(170deg, rgb(var(--b-950)) 0%, rgb(var(--b-900)) 55%, rgb(var(--b-800)) 100%);
}
.aksen-gradient { background: linear-gradient(140deg, rgb(var(--b-700)), rgb(var(--b-500))); }
.tombol-utama { background: linear-gradient(120deg, rgb(var(--b-800)), rgb(var(--b-600))); }
.garis-aksen { background: linear-gradient(90deg, rgb(var(--a-400)), rgb(var(--a-600))); }

/* =========================================================
   KOMPONEN
   ========================================================= */
.kartu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
}
.kartu-judul { font-size: 14px; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
.kartu-sub { font-size: 11.5px; font-weight: 500; color: var(--text-muted); }

.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.inp {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  font-size: 13.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.inp { height: auto; padding: 10px 14px; line-height: 1.5; }
select.inp { padding-right: 32px; }
.inp:focus { border-color: rgb(var(--b-500)); box-shadow: 0 0 0 3px rgb(var(--b-500) / .15); }
.inp.galat { border-color: #fda4af; }
.inp[readonly], .inp:disabled { background: var(--surface-2); color: var(--text-3); }
.inp::placeholder { color: var(--text-muted); }
@media (min-width: 768px) {
  .inp { height: 40px; font-size: 13px; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 11px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .6; pointer-events: none; }
.btn-utama { background: rgb(var(--b-700)); color: #fff; }
.btn-utama:hover { background: rgb(var(--b-800)); }
.btn-garis { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-garis:hover { background: var(--surface-2); }
.btn-bahaya { background: #fff1f2; color: #e11d48; border-color: #ffe4e6; }
.btn-bahaya:hover { background: #ffe4e6; }
.btn-sukses { background: #059669; color: #fff; }
.btn-sukses:hover { background: #047857; }
.btn-ikon {
  width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); color: var(--text-3); background: var(--surface); font-size: 11px;
  transition: background-color .15s;
}
.btn-ikon:hover { background: var(--surface-2); }

/* ---------- Toolbar daftar: cari + filter + aksi dalam satu baris ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; }
.cari { position: relative; flex: 1 1 auto; min-width: 0; }
.cari > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 12.5px; color: var(--text-muted); }
.cari > input { padding-left: 36px; }
.f-item { display: block; }
.f-label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.f-tanggal { display: flex; align-items: center; gap: 6px; }
.f-tanggal .inp { min-width: 0; }

.filter-jangkar { position: relative; flex: none; }
.filter-jumlah {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 10.5px; font-weight: 800;
  background: rgb(var(--b-600)); color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.filter-wadah {
  background: var(--surface); visibility: hidden;
  box-shadow: 0 -14px 44px rgba(16, 24, 40, .22);
}
.filter-wadah.buka { visibility: visible; }
.filter-isi { display: grid; gap: 14px; }
.f-item .inp, .f-tanggal .inp { width: 100%; }

@media (max-width: 767px) {
  .toolbar .btn { height: 44px; padding: 0 14px; }
  .filter-wadah {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
    border-radius: 24px 24px 0 0;
    padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + 16px);
    max-height: 82vh; overflow-y: auto;
    transform: translateY(105%); transition: transform .28s cubic-bezier(.22, 1, .36, 1), visibility .28s;
  }
  .filter-wadah.buka { transform: translateY(0); }
}
@media (min-width: 768px) {
  .cari { max-width: 420px; }
  /* Desktop: panel filter melayang di bawah tombol Filter agar tabel tetap luas. */
  .filter-wadah {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 35; width: 460px;
    padding: 16px; border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 18px 40px -12px rgba(16, 24, 40, .28);
    opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s, visibility .15s;
  }
  .filter-wadah.buka { opacity: 1; transform: none; }
  .filter-isi { grid-template-columns: 1fr 1fr; }
  .filter-isi > .f-item:has(.f-tanggal) { grid-column: 1 / -1; }
}

/* ---------- Tabel data ---------- */
.tabel { width: 100%; font-size: 12.5px; border-collapse: separate; border-spacing: 0; }
.tabel thead th {
  background: var(--surface-2); color: var(--text-3);
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.tabel td.kanan, .tabel td.angka { white-space: nowrap; }
.tabel tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.tabel tbody tr:last-child td { border-bottom: 0; }
.tabel tbody tr:hover td { background: var(--surface-2); }
.tabel tfoot td { padding: 10px 14px; font-weight: 800; background: rgb(var(--a-50)); color: var(--text); border-top: 1px solid var(--border); }
.tabel .kanan { text-align: right; }
.tabel .tengah { text-align: center; }
.tabel .utama { font-weight: 700; color: var(--text); }
.tabel th a { display: inline-flex; align-items: center; gap: 6px; }
.tabel th a:hover, .tabel th a.aktif { color: var(--accent-text); }

/* Kartu daftar mobile */
.item-hp {
  display: block; padding: 13px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px;
}
.item-hp:active { background: var(--surface-2); }

/* ---------- Bilah tab bawah (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--tabbar-bg); border-top: 1px solid var(--tabbar-garis);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar { -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
}
.tabbar-isi { display: flex; align-items: stretch; height: var(--tabbar-h); }
.tab-item {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 7px 2px 6px; color: var(--text-muted); transition: color .18s ease;
}
.tab-ikon {
  width: 48px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: 999px; font-size: 16px; transition: background-color .2s ease, transform .16s ease;
}
.tab-label { font-size: 10px; font-weight: 700; line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-item:active .tab-ikon { transform: scale(.9); }
.tab-item.aktif { color: var(--accent-text); }
.tab-item.aktif .tab-ikon { background: var(--tab-aktif-bg); }
.tab-aksi .tab-ikon {
  width: 46px; height: 30px; color: #fff; border-radius: 12px;
  background: linear-gradient(140deg, rgb(var(--b-700)), rgb(var(--b-500)));
  box-shadow: 0 4px 12px -3px rgb(var(--b-600) / .55);
}
.tab-aksi .fa-plus { transition: transform .28s cubic-bezier(.22, 1, .36, 1); }

main.pb-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 18px); }
@media (min-width: 768px) { main.pb-tabbar { padding-bottom: 24px; } }

/* ---------- Lembar bawah (bottom sheet) & modal ---------- */
.sheet-pegangan { width: 40px; height: 5px; border-radius: 999px; background: var(--border-strong); margin: 0 auto; }

/* ---------- Grafik batang dashboard ----------
   Warna data tetap (tidak ikut tema) agar selalu lolos uji buta warna:
   terang #2563eb / #ea580c, gelap #3b82f6 / #ea580c (validate_palette).
   Batang pengeluaran diberi tekstur garis miring sebagai penanda kedua. */
:root { --grafik-1: #2563eb; --grafik-2: #ea580c; }
html.dark { --grafik-1: #3b82f6; --grafik-2: #ea580c; }
.batang { transition: height .5s cubic-bezier(.22, 1, .36, 1); border-radius: 4px 4px 0 0; }
.grafik-tekstur { background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .3) 0 2px, transparent 2px 6px); }

/* ---------- Transisi ganti tema ---------- */
html.tema-anim, html.tema-anim *, html.tema-anim *::before, html.tema-anim *::after {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease !important;
}

/* =========================================================
   MODE GELAP - override kelas Tailwind terang
   Dibungkus @media screen agar hasil cetak tetap terang.
   ========================================================= */
@media screen {
  .dark .bg-white { background-color: var(--surface); }
  .dark .bg-slate-50, .dark .bg-gray-50 { background-color: var(--surface-2); }
  .dark .bg-slate-100, .dark .bg-gray-100 { background-color: var(--surface-3); }
  .dark .bg-slate-200 { background-color: var(--surface-3); }
  .dark .bg-slate-200\/70 { background-color: rgba(27, 38, 54, .8); }
  .dark .bg-white\/80 { background-color: rgba(15, 22, 34, .86); }
  .dark .bg-white\/90 { background-color: rgba(15, 22, 34, .92); }

  .dark .text-slate-900, .dark .text-slate-800 { color: var(--text); }
  .dark .text-slate-700, .dark .text-slate-600 { color: var(--text-2); }
  .dark .text-slate-500 { color: var(--text-3); }
  .dark .text-slate-400 { color: var(--text-muted); }
  .dark .text-slate-300 { color: var(--text-faint); }

  .dark .text-brand-600, .dark .text-brand-700, .dark .text-brand-800 { color: var(--accent-text); }
  .dark .text-blue-600, .dark .text-blue-700, .dark .text-sky-600, .dark .text-sky-700 { color: #7cc0ff; }
  .dark .text-emerald-600, .dark .text-emerald-700, .dark .text-green-700 { color: var(--ok); }
  .dark .text-amber-600, .dark .text-amber-700, .dark .text-aksen-600, .dark .text-aksen-700 { color: var(--warn); }
  .dark .text-rose-600, .dark .text-rose-700, .dark .text-red-600 { color: var(--bad); }
  .dark .text-violet-600, .dark .text-violet-700 { color: #b49cff; }

  .dark .bg-brand-50 { background-color: rgb(var(--b-500) / .16); }
  .dark .bg-brand-100 { background-color: rgb(var(--b-500) / .24); }
  .dark .bg-aksen-50, .dark .bg-aksen-100 { background-color: rgb(var(--a-500) / .16); }
  .dark .bg-blue-50, .dark .bg-blue-100, .dark .bg-sky-50, .dark .bg-sky-100 { background-color: rgba(56, 189, 248, .15); }
  .dark .bg-emerald-50, .dark .bg-emerald-100, .dark .bg-green-100 { background-color: rgba(16, 185, 129, .16); }
  .dark .bg-amber-50, .dark .bg-amber-100 { background-color: rgba(245, 158, 11, .16); }
  .dark .bg-rose-50, .dark .bg-rose-100, .dark .bg-red-100 { background-color: rgba(244, 63, 94, .16); }
  .dark .bg-violet-50, .dark .bg-violet-100 { background-color: rgba(139, 92, 246, .16); }

  .dark .border-slate-100, .dark .border-slate-200 { border-color: var(--border); }
  .dark .border-slate-300 { border-color: var(--border-strong); }
  .dark .border-brand-100, .dark .border-brand-200 { border-color: rgb(var(--b-400) / .3); }
  .dark .border-rose-100, .dark .border-rose-200 { border-color: rgba(244, 63, 94, .3); }
  .dark .border-amber-100, .dark .border-amber-200 { border-color: rgba(245, 158, 11, .3); }
  .dark .border-emerald-100, .dark .border-emerald-200 { border-color: rgba(16, 185, 129, .3); }
  .dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border); }

  .dark .hover\:bg-slate-50:hover, .dark .active\:bg-slate-50:active { background-color: var(--surface-2); }
  .dark .hover\:bg-slate-100:hover { background-color: var(--surface-3); }
  .dark .hover\:bg-rose-50:hover { background-color: rgba(244, 63, 94, .14); }

  .dark .peer:checked ~ .peer-checked\:bg-white { background-color: var(--surface-3); }
  .dark .peer:checked ~ .peer-checked\:text-slate-900 { color: var(--text); }

  .dark .btn-bahaya { background: rgba(244, 63, 94, .14); border-color: rgba(244, 63, 94, .25); color: var(--bad); }
  .dark .tabel tfoot td { background: rgb(var(--a-500) / .12); }
  .dark ::file-selector-button { background-color: var(--surface-3); color: var(--text-2); }
}

/* ---------- Halaman cetak ---------- */
@media print {
  .no-print, nav, aside, header, footer, .htmx-indicator { display: none !important; }
  body { background: #fff !important; }
  main { padding: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
  html.tema-anim, html.tema-anim * { transition: none !important; }
  .fade-in, .toast-in { animation: none !important; }
}

/* ===== Tombol i & Panel Informasi Menu ===== */
.u-info-buka {
  flex: none; width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: rgb(var(--b-600)); font-size: 16px;
  cursor: pointer; transition: all .15s ease;
}
.u-info-buka:hover {
  background: var(--surface-2); border-color: var(--border-strong);
  color: rgb(var(--b-700));
}
.u-info-panel { position: fixed; inset: 0; z-index: 92; }
.u-info-latar { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.u-info-kertas {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: -12px 0 34px rgba(16, 24, 40, .18);
}
.u-info-kepala {
  flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.u-info-kepala > i { color: rgb(var(--b-600)); font-size: 18px; flex: none; }
.u-info-kepala h2 { flex: 1; min-width: 0; margin: 0; color: var(--text); font-size: 15.5px; font-weight: 800; letter-spacing: -.02em; }
.u-info-kepala button {
  flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 8px; color: var(--text-muted); font-size: 15px; cursor: pointer;
  transition: all .15s ease;
}
.u-info-kepala button:hover { background: var(--surface-3); color: var(--text); }
.u-info-isi {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom)); color: var(--text); font-size: 13.5px; line-height: 1.6;
}
.u-info-isi h3 {
  margin: 18px 0 6px; color: var(--text-muted); font-size: 11px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase; display: flex; align-items: center; gap: 6px;
}
.u-info-isi h3:first-child { margin-top: 0; }
.u-info-isi p { margin: 0; color: var(--text); }
.u-info-isi ol { margin: 0; padding: 0; list-style: none; counter-reset: langkah; display: flex; flex-direction: column; gap: 9px; }
.u-info-isi ol li { position: relative; counter-increment: langkah; padding: 0 0 0 32px; color: var(--text); }
.u-info-isi ol li::before {
  content: counter(langkah); position: absolute; left: 0; top: 1px; width: 22px; height: 22px;
  border-radius: 999px; background: rgb(var(--b-600)); color: #fff; font-size: 11.5px; font-weight: 700;
  line-height: 22px; text-align: center;
}
.u-info-isi ul {
  margin: 16px 0 0; padding: 12px 14px 12px 32px; list-style: disc;
  background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 12px; color: var(--text);
}
.u-info-isi ul li + li { margin-top: 6px; }
@media (max-width: 768px) {
  .u-info-kertas {
    top: auto; left: 0; width: auto; max-height: 86vh; border-left: 0;
    border-top: 1px solid var(--border); border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 34px rgba(16, 24, 40, .22); overflow: hidden;
  }
}
