/* ============================================================
   COMPONENTS.CSS - Cards, Stat, Buttons, Tables, Forms, Badges
   (Bootstrap 5 dipakai via CDN; ini override tema gelap.)
   ============================================================ */

/* ---------- Card ---------- */
.card-app {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-app .card-header {
  background: transparent; border-bottom: 1px solid var(--border-soft);
  padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-app .card-header h5, .card-app .card-header .h5 { margin: 0; font-size: 1rem; font-weight: 700; }
.card-app .card-body { padding: 1.25rem; }
.card-app .card-footer { background: transparent; border-top: 1px solid var(--border-soft); padding: .85rem 1.25rem; }

/* ---------- Stat Card ---------- */
.stat-card { display: flex; align-items: flex-start; gap: 1rem; padding: 1.25rem; }
.stat-card .ic {
  width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center;
}
.stat-card .ic svg { width: 26px; height: 26px; }
.ic-gold   { background: var(--gold-glow); color: var(--gold); }
.ic-green  { background: var(--success-soft); color: var(--success); }
.ic-blue   { background: var(--info-soft); color: var(--info); }
.ic-warn   { background: var(--warning-soft); color: var(--warning); }
.ic-danger { background: var(--danger-soft); color: var(--danger); }
.stat-card > .flex-grow-1 { min-width: 0; }
.stat-card .lbl { color: var(--text-muted); font-size: .82rem; overflow-wrap: break-word; }
.stat-card .val { font-size: 1.7rem; font-weight: 800; color: var(--text-strong); line-height: 1.1; overflow-wrap: anywhere; }
.stat-card .trend { font-size: .76rem; font-weight: 600; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* Stat card & tabel: compact di layar kecil agar tidak terpotong */
@media (max-width: 575.98px) {
  .stat-card { gap: .7rem; padding: .9rem 1rem; }
  .stat-card .ic { width: 40px; height: 40px; border-radius: 11px; }
  .stat-card .ic svg { width: 19px; height: 19px; }
  .stat-card .val { font-size: 1.3rem; }
}
@media (max-width: 767.98px) {
  .table-app { font-size: .82rem; }
  .table-app thead th { white-space: normal; }
  .table-app :not(caption) > * > * { padding: .45rem .5rem; }
}

/* ---------- Buttons (override BS) ---------- */
.btn { border-radius: 10px; font-weight: 600; letter-spacing: .01em; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold-dim));
  border: 0; color: #1c1813;
}
.btn-gold:hover { color: #1c1813; filter: brightness(1.06); box-shadow: var(--shadow-gold); }
.btn-outline-gold { color: var(--gold); border: 1px solid var(--gold-dim); background: transparent; }
.btn-outline-gold:hover { background: var(--gold-glow); color: var(--gold-soft); }
.btn-soft { background: var(--bg-surface-2); color: var(--text-body); border: 1px solid var(--border-color); }
.btn-soft:hover { background: var(--bg-hover); color: var(--text-strong); }

/* ---------- Forms (override BS) ---------- */
.form-control, .form-select {
  background: var(--bg-input); border: 1px solid var(--border-color);
  color: var(--text-body); border-radius: 10px; padding: .6rem .85rem;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-input); color: var(--text-strong);
  border-color: var(--gold); box-shadow: 0 0 0 .2rem var(--gold-glow);
}
.form-control::placeholder { color: var(--text-faint); }

/* ---------- Filter bar: samakan tinggi tombol dengan form control ---------- */
.filter-bar .btn { padding-top: .6rem; padding-bottom: .6rem; }

/* ---------- Entity select disabled (pre-set saat upload dari card) ---------- */
#docEntitySelect:disabled {
  background: var(--gold-glow, rgba(212,175,55,.12)) !important;
  border-color: var(--gold-dim, rgba(212,175,55,.4)) !important;
  color: var(--gold) !important;
  opacity: 1;
}
.form-label { color: var(--text-muted); font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.input-group-text {
  background: var(--bg-surface-2); border: 1px solid var(--border-color); color: var(--text-muted);
}
.form-check-input { background-color: var(--bg-input); border-color: var(--border-color); }
.form-check-input:checked { background-color: var(--gold); border-color: var(--gold); }

/* ---------- Input password reveal toggle ---------- */
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: .65rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--text-faint); cursor: pointer; padding: .2rem;
}
.pw-toggle:hover { color: var(--gold); }

/* ---------- Table (override BS) ---------- */
.table-app {
  --bs-table-color: var(--text-body);
  --bs-table-bg: transparent;
  --bs-table-accent-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-striped-color: var(--text-body);
  --bs-table-active-bg: var(--bg-hover);
  --bs-table-active-color: var(--text-strong);
  --bs-table-hover-bg: var(--bg-hover);
  --bs-table-hover-color: var(--text-strong);
  color: var(--text-body); border-color: var(--border-soft);
}
.table-app thead th {
  background: var(--bg-surface-2); color: var(--text-muted);
  font-weight: 700; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
.table-app tbody tr,
.table-app tbody td,
.table-app tbody th { background-color: transparent; }
.table-app tbody td { border-color: var(--border-soft); vertical-align: middle; }
.table-app tbody tr:hover { background: var(--bg-hover); }
.table-app a { color: var(--text-strong); font-weight: 600; }

/* ---------- DataTables wrapper (tema gelap) ---------- */
.dataTables_wrapper { color: var(--text-muted); }
/* Cegah wadah tabel meluber dari card: HANYA kolom yang berisi tabel yang
   menyusut & menggulir horizontal. Baris length/filter & info/paginate
   tetap wrap normal (nowrap global membuatnya keluar card di mobile). */
.dataTables_wrapper .row > .col-sm-12:has(> table) {
  min-width: 0; max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: var(--text-muted); }
.dataTables_wrapper select,
.dataTables_wrapper input[type="search"] {
  background: var(--bg-input) !important; color: var(--text-strong) !important;
  border: 1px solid var(--border-color) !important; border-radius: var(--radius-sm) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  background: var(--bg-surface-2) !important; color: var(--text-body) !important;
  border: 1px solid var(--border-color) !important; border-radius: var(--radius-sm) !important;
  margin: 0 2px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  background: var(--bg-surface) !important; color: var(--text-faint) !important; border-color: var(--border-soft) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--bg-hover) !important; color: var(--gold) !important; border-color: var(--border-color) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--gold) !important; color: #1a160f !important; border-color: var(--gold) !important;
}
.dataTables_wrapper .dataTables_processing { background: var(--bg-surface-2) !important; color: var(--text-body) !important; border: 1px solid var(--border-color) !important; border-radius: var(--radius-sm) !important; }

/* Pagination: jaga tetap di dalam card — tombol halaman wrap ke baris baru
   saat tidak muat (mobile / banyak halaman), bukan meluber keluar kolom. */
.dataTables_wrapper .row > [class*="col-"] { min-width: 0; }
.dataTables_wrapper .dataTables_paginate {
  display: flex; flex-wrap: wrap; justify-content: flex-end;
}
.dataTables_wrapper .dataTables_paginate .pagination {
  flex-wrap: wrap; margin: 0; row-gap: .25rem;
}

/* Mobile: "Tampil [select]" & "Cari:" sejajar satu baris (tidak menumpuk),
   teks "Tampil" disembunyikan agar ringkas, select tetap terlihat. */
@media (max-width: 767.98px) {
  .dataTables_wrapper .row > .col-sm-12.col-md-6 {
    flex: 0 0 auto; width: auto;
  }
  .dataTables_wrapper .row > .col-md-6:has(> .dataTables_filter) {
    margin-left: auto;
  }
  .dataTables_wrapper .dataTables_filter { text-align: right; }
  .dataTables_wrapper .dataTables_filter input { max-width: 150px; }
  .dataTables_wrapper .dataTables_length label { font-size: 0; }
  .dataTables_wrapper .dataTables_length label select { font-size: .8rem; }
}

/* ---------- Badges ---------- */
.badge-app { font-weight: 600; padding: .35em .65em; border-radius: 7px; font-size: .72rem; letter-spacing: .02em; }
.bg-soft-success { background: var(--success-soft); color: var(--success); }
.bg-soft-info    { background: var(--info-soft); color: var(--info); }
.bg-soft-warning { background: var(--warning-soft); color: var(--warning); }
.bg-soft-danger  { background: var(--danger-soft); color: var(--danger); }
.bg-soft-gold    { background: var(--gold-glow); color: var(--gold); }
.bg-soft-muted   { background: rgba(165,154,130,.15); color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert-app { border-radius: var(--radius); border: 1px solid var(--border-color); background: var(--bg-surface); }
.alert-app.alert-success { background: var(--success-soft); border-color: rgba(46,204,113,.3); color: #b9f5d4; }
.alert-app.alert-danger  { background: var(--danger-soft); border-color: rgba(232,85,62,.3); color: #ffc8bd; }
.alert-app.alert-info    { background: var(--info-soft); border-color: rgba(59,158,255,.3); color: #bfe0ff; }
.alert-app.alert-warning { background: var(--warning-soft); border-color: rgba(244,183,64,.3); color: #ffe2a8; }

/* ---------- Divider ---------- */
.divider { height: 1px; background: var(--border-soft); margin: 1.1rem 0; border: 0; }

/* ---------- Bulk import (paste Excel) ---------- */
.bulk-cols { columns: 3; column-gap: 1.25rem; font-size: .78rem; color: var(--text-muted); padding-left: 1.2rem; }
.bulk-cols li { break-inside: avoid; margin-bottom: .15rem; line-height: 1.4; }
@media (max-width: 767.98px) { .bulk-cols { columns: 2; } }
@media (max-width: 575.98px) { .bulk-cols { columns: 1; } }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state svg { width: 56px; height: 56px; color: var(--text-faint); margin-bottom: .8rem; }

/* ---------- Misc ---------- */
.link-muted { color: var(--text-muted); }
.link-muted:hover { color: var(--gold); }
.dot-status { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .35rem; }
.dot-on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot-off { background: var(--text-faint); }
.kbd {
  font-family: var(--font-sans); font-size: .72rem; padding: .15rem .4rem;
  background: var(--bg-surface-3); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-muted);
}

/* ---------- Notification panel ---------- */
.notif-panel {
  width: 330px; max-width: 88vw; padding: 0; overflow: hidden;
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius);
}
.notif-head {
  padding: .8rem 1rem; font-weight: 700; color: var(--text-strong);
  border-bottom: 1px solid var(--border-soft); background: var(--bg-surface-2);
}
.notif-body { max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex; gap: .7rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border-soft);
  color: var(--text-body); text-decoration: none; transition: background var(--transition);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item .ic {
  width: 36px; height: 36px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: var(--gold-glow); color: var(--gold);
}
.notif-item .ic svg { width: 18px; height: 18px; }
.notif-item .tx { font-size: .85rem; line-height: 1.35; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-faint); }

/* ============================================================
   CARD GRID (Dark Modern — SPPG/Yayasan Management)
   ============================================================ */
.spg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 1199.98px) { .spg-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 767.98px)  { .spg-grid { grid-template-columns: 1fr; } }

.spg-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1rem;
  display: flex; flex-direction: column; gap: .75rem;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  position: relative; overflow: hidden;
}
.spg-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-dim));
  opacity: .6; transition: opacity .2s;
}
.spg-card:hover {
  border-color: var(--gold-dim);
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  transform: translateY(-2px);
}
.spg-card:hover::before { opacity: 1; }
.spg-card-top { display: flex; align-items: center; gap: .65rem; }
.spg-card-logo {
  width: 44px; height: 44px; flex: none; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--bg-surface-2); border: 1px solid var(--border-color);
}
.spg-card-logo img { width: 100%; height: 100%; object-fit: cover; }
.spg-card-logo svg { width: 20px; height: 20px; color: var(--gold); }
.spg-card-title { flex: 1; min-width: 0; }
.spg-card-title h6 { margin: 0; font-size: .9rem; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spg-card-title .sub { font-size: .72rem; color: var(--text-muted); }
.spg-card-body { display: flex; flex-direction: column; gap: .35rem; }
.spg-card-row { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--text-body); }
.spg-card-row svg { width: 13px; height: 13px; color: var(--gold); flex: none; }
.spg-card-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spg-card-foot { border-top: 1px solid var(--border-soft); padding-top: .6rem; display: flex; flex-direction: column; gap: .4rem; }
.spg-card-badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.spg-progress-wrap { display: flex; align-items: center; gap: .5rem; }
.spg-progress { flex: 1; height: 6px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.spg-progress-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--gold), var(--gold-dim)); transition: width .6s; }
.spg-progress-pct { font-size: .72rem; font-weight: 700; color: var(--gold); flex: none; width: 32px; text-align: right; }
.spg-progress-bar-doc { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.spg-card-act { position: absolute; top: .6rem; right: .6rem; opacity: 0; transition: opacity .2s; }
.spg-card:hover .spg-card-act { opacity: 1; }
.spg-card-act a { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--bg-surface-2); color: var(--gold); text-decoration: none; border: 1px solid var(--border-color); }
.spg-card-act a:hover { background: var(--gold-glow); }

/* View toggle */
.view-toggle { display: inline-flex; background: var(--bg-input); border-radius: 8px; padding: 2px; gap: 2px; }
.view-toggle button {
  border: 0; background: transparent; color: var(--text-muted); padding: .25rem .6rem;
  border-radius: 6px; font-size: .8rem; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: .3rem;
}
.view-toggle button svg { width: 15px; height: 15px; }
.view-toggle button.active { background: var(--gold); color: #1c1813; font-weight: 600; }

/* ---------- Verifikasi Dokumen ---------- */
.ver-stat { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .1s; user-select: none; }
.ver-stat:hover { border-color: var(--gold-dim); box-shadow: var(--shadow-gold); }
.ver-stat:active { transform: translateY(1px); }
.ver-stat.active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-glow); }
.ver-stat-ic { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; }
.ver-stat-ic svg { width: 22px; height: 22px; }
.ver-stat-num { font-size: 1.5rem; font-weight: 800; color: var(--text-strong); line-height: 1.1; }
.ver-stat-lbl { font-size: .78rem; }
.ver-source.active { background: var(--gold); color: #1c1813; border-color: var(--gold); }

.ver-doc { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; }
.ver-doc-logo { width: 40px; height: 40px; border-radius: 10px; flex: none; overflow: hidden; display: grid; place-items: center; background: var(--bg-input); border: 1px solid var(--border-soft); }
.ver-doc-logo svg { width: 20px; height: 20px; color: var(--gold); }
.ver-doc-logo img { width: 100%; height: 100%; object-fit: cover; }
.ver-doc-body { flex: 1; min-width: 0; }
.ver-doc-title { font-weight: 700; color: var(--text-strong); font-size: .9rem; }
.ver-doc-sub { font-size: .76rem; color: var(--text-muted); }
.ver-doc-note { font-size: .76rem; color: var(--danger); margin-top: .15rem; }
.ver-doc-act { display: flex; gap: .35rem; flex: none; }

/* ---------- Penerima Manfaat (legend dots & map tooltips) ---------- */
.dot-blue, .dot-gold, .dot-purple { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot-blue { background: #3b9eff; }
.dot-gold { background: var(--gold); }
.dot-purple { background: #9b59b6; }
.leaflet-tooltip.pm-tip-blue { background: #3b9eff; color: #fff; border: 0; box-shadow: 0 2px 6px rgba(0,0,0,.4); font-weight: 600; font-size: .72rem; }
.leaflet-tooltip.pm-tip-blue::before { border-top-color: #3b9eff; }
.leaflet-tooltip.pm-tip-gold { background: var(--gold); color: #1c1813; border: 0; box-shadow: 0 2px 6px rgba(0,0,0,.4); font-weight: 600; font-size: .72rem; }
.leaflet-tooltip.pm-tip-gold::before { border-top-color: var(--gold); }
.leaflet-tooltip.pm-tip-purple { background: #9b59b6; color: #fff; border: 0; box-shadow: 0 2px 6px rgba(0,0,0,.4); font-weight: 600; font-size: .72rem; }
.leaflet-tooltip.pm-tip-purple::before { border-top-color: #9b59b6; }
.ic-purple { background: rgba(155,89,182,.18); color: #9b59b6; }

/* ---------- Modal & Dropdown (theme-aware via token) ----------
   Nilai sama dengan inline style yang dipakai modal existing
   (background:var(--bg-surface);border:1px solid var(--border-color))
   sehingga tema gelap tidak berubah, dan modal tanpa inline style
   ikut mengikuti tema. */
.modal-content { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); color: var(--text-body); }
.modal-header { border-bottom-color: var(--border-soft); }
.modal-footer { border-top-color: var(--border-soft); }
.modal-title { color: var(--text-strong); }
.dropdown-menu { background: var(--bg-surface); border: 1px solid var(--border-color); box-shadow: var(--shadow); }
.dropdown-item { color: var(--text-body); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-hover); color: var(--text-strong); }
.dropdown-divider { border-color: var(--border-soft); }
.dropdown-header { color: var(--text-faint); }

/* ---------- SweetAlert2 mengikuti tema ---------- */
.swal2-popup { background: var(--bg-surface); color: var(--text-body); border-radius: var(--radius-lg); }
.swal2-title { color: var(--text-strong); }
.swal2-html-container { color: var(--text-muted); }
.swal2-toast { background: var(--bg-surface-2); color: var(--text-body); box-shadow: var(--shadow); }

/* ---------- Theme switcher (centang mode aktif di dropdown profil) ---------- */
.theme-check { opacity: 0; transition: opacity var(--transition); }
.theme-check.on { opacity: 1; color: var(--gold); }

/* ---------- Print ----------
   Layout plain (halaman cetak: laporan, dsb.) tidak memuat layout.css,
   sehingga override warna teks hitam saat cetak diletakkan di sini agar
   teks tidak samar (cream #e8e0cc) di atas kertas putih. */
@media print {
  body { background: #fff !important; color: #000 !important; }
  h1, h2, h3, h4, h5, h6 { color: #000 !important; }
  .text-muted-2 { color: #666 !important; }
  .card-app { border: 1px solid #ccc !important; box-shadow: none !important; }
  #btnPrint { display: none !important; }
  @page { margin: 1cm; }
}

/* ---------- Berita Acara (thumbnail foto kegiatan) ---------- */
.ba-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-soft); cursor: zoom-in; transition: transform var(--transition); }
.ba-thumb:hover { transform: scale(1.06); }
