/* =====================================================================
   MODE GELAP — seluruh halaman frontend
   Aktif lewat kelas body.dark-mode (tombol bulan di header; tersimpan di
   localStorage). Dimuat paling akhir. Sebagian komponen memakai warna
   dengan !important (gov-theme.css, Bootstrap .bg-white/.text-muted) atau
   gaya inline, jadi di sini juga dipakai !important seperlunya.
   Daftar komponen disusun dari audit otomatis (latar terang / teks gelap
   tak terbaca) di setiap halaman.
   ===================================================================== */
body.dark-mode {
  --dm-bg: #14171c;
  --dm-surface: #1c2027;
  --dm-surface-2: #232831;
  --dm-line: #2e3440;
  --dm-ink: #e7eaf0;
  --dm-ink-2: #b8c0cc;
  --dm-muted: #8b95a5;
  --dm-link: #9fc0ff;
  --dm-input: #171a20;
  --dm-tint: rgba(159, 192, 255, .12);

  /* variabel komponen yang sudah ada */
  --gov-ink: var(--dm-ink);
  --gov-muted: var(--dm-muted);
  --gov-line: var(--dm-line);
  --gov-surface: var(--dm-surface);
  --gov-bg: var(--dm-bg);
  --gov-navy-ink: var(--dm-ink);
  --ux-ink: var(--dm-ink);
  --ux-muted: var(--dm-muted);
  --ux-line: var(--dm-line);

  color: var(--dm-ink);
  background: var(--dm-bg) !important;
  color-scheme: dark;
}
body.dark-mode .berita-index-wrapper {
  --brt-ink: var(--dm-ink);
  --brt-muted: var(--dm-muted);
  --brt-line: var(--dm-line);
  --brt-navy: var(--dm-link);
}
body.dark-mode .gal-page {
  --gal-ink: var(--dm-ink);
  --gal-muted: var(--dm-muted);
  --gal-line: var(--dm-line);
  --gal-navy: var(--dm-link);
}

/* ---------- Kerangka & teks umum ---------- */
body.dark-mode main,
body.dark-mode .banner-section { background-color: var(--dm-bg); }
body.dark-mode main :is(h1, h2, h3, h4, h5, h6) { color: var(--dm-ink); }
body.dark-mode main p,
body.dark-mode main li,
body.dark-mode main td,
body.dark-mode main dd { color: inherit; }
body.dark-mode .text-dark,
body.dark-mode .text-body,
body.dark-mode .text-black { color: var(--dm-ink) !important; }
body.dark-mode .text-muted,
body.dark-mode .text-secondary { color: var(--dm-muted) !important; }
body.dark-mode main a:not([class]) { color: var(--dm-link); }
body.dark-mode hr { border-color: var(--dm-line); opacity: 1; }

/* Permukaan (kartu, panel, wrapper berlatar terang) */
body.dark-mode .bg-white,
body.dark-mode .bg-light,
body.dark-mode .card,
body.dark-mode .card-header,
body.dark-mode .card-footer,
body.dark-mode .list-group-item,
body.dark-mode .modal-content,
body.dark-mode .alert-light {
  color: var(--dm-ink);
  background-color: var(--dm-surface) !important;
  border-color: var(--dm-line) !important;
}
body.dark-mode .card { box-shadow: 0 4px 18px rgba(0, 0, 0, .35) !important; }

/* Wrapper halaman dengan latar inline #f8fafc / gradien terang */
body.dark-mode .dokumen-index-wrapper,
body.dark-mode .dokumen-view-wrapper,
body.dark-mode .berita-index-wrapper,
body.dark-mode .berita-view-wrapper,
body.dark-mode .gal-page,
body.dark-mode .site-about,
body.dark-mode .kontak-page,
body.dark-mode .page-hero,
body.dark-mode .jdih-latest.berita-terbaru {
  background: var(--dm-bg) !important;
}

/* Form */
body.dark-mode main .form-control,
body.dark-mode main .form-select,
body.dark-mode .jdih-control,
body.dark-mode .dokumen-search-input,
body.dark-mode .berita-search-form__input,
body.dark-mode .brt-field__control,
body.dark-mode .contact-form .form-control {
  color: var(--dm-ink) !important;
  background-color: var(--dm-input) !important;
  border-color: var(--dm-line) !important;
}
body.dark-mode main .form-control::placeholder,
body.dark-mode .jdih-control::placeholder { color: var(--dm-muted); }
body.dark-mode main .form-control:focus,
body.dark-mode main .form-select:focus,
body.dark-mode .jdih-control:focus {
  border-color: var(--dm-link) !important;
  box-shadow: 0 0 0 3px rgba(159, 192, 255, .18) !important;
}
body.dark-mode select option { color: var(--dm-ink); background: var(--dm-surface); }
body.dark-mode .jdih-input-icon i { color: var(--dm-muted); }

/* Tabel */
body.dark-mode main .table { --bs-table-bg: transparent; --bs-table-color: var(--dm-ink); color: var(--dm-ink); border-color: var(--dm-line); }
body.dark-mode main .table > :not(caption) > * > * { color: var(--dm-ink); background-color: transparent; border-color: var(--dm-line); }
body.dark-mode main .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(255, 255, 255, .03); }

/* Pagination */
body.dark-mode .page-link,
body.dark-mode .pagination .page-item > span {
  color: var(--dm-ink-2);
  background-color: var(--dm-surface) !important;
  border-color: var(--dm-line) !important;
}
body.dark-mode .page-item.active .page-link { color: #fff; background-color: #2a5298 !important; border-color: #2a5298 !important; }

/* Badge terang Bootstrap */
body.dark-mode .badge.bg-light { color: var(--dm-ink-2) !important; background-color: var(--dm-surface-2) !important; }

/* ---------- Beranda ---------- */
body.dark-mode .statistics,
body.dark-mode .statistics .stat-card { background-color: var(--dm-bg); }
body.dark-mode .statistics .stat-card { background: var(--dm-surface) !important; }
body.dark-mode .jd-card__icon { color: var(--dm-link); background: var(--dm-tint); }
body.dark-mode .peraturan-terbaru .doc-card__title a,
body.dark-mode .putusan-terbaru .put-card__title a { color: var(--dm-ink) !important; }
body.dark-mode .peraturan-terbaru .doc-card__title a:hover,
body.dark-mode .putusan-terbaru .put-card__title a:hover { color: var(--dm-link) !important; }

body.dark-mode .doc-stats {
  --ds-surface: var(--dm-surface);
  --ds-plane: var(--dm-bg);
  --ds-ink: var(--dm-ink);
  --ds-ink-2: var(--dm-ink-2);
  --ds-muted: var(--dm-muted);
  --ds-line: var(--dm-line);
  --ds-grid: #262b34;
  --ds-series-soft: #2b3f5c;
}
body.dark-mode .ds-tile,
body.dark-mode .ds-card,
body.dark-mode .ds-tab,
body.dark-mode .ds-table > summary,
body.dark-mode .ds-table-wrap { background-color: var(--dm-surface) !important; border-color: var(--dm-line) !important; }
body.dark-mode .ds-tab[aria-pressed="true"] { color: #fff; background-color: #3987e5 !important; border-color: #3987e5 !important; }
body.dark-mode .ds-meter { background: #2b3f5c !important; }

/* Kartu berita (beranda + /berita) */
body.dark-mode .nws-card { background: var(--dm-surface) !important; border-color: var(--dm-line) !important; }
body.dark-mode .nws-card__media { background: linear-gradient(135deg, #1f2a3d, #2a2520) !important; }
body.dark-mode .nws-card__date { color: var(--dm-ink); background: rgba(20, 23, 28, .9); }
body.dark-mode .nws-card:hover .nws-card__date { color: #fff; background: #2a5298; }

/* Header pencarian beranda tetap di atas latar biru; tombol terang dipertahankan. */

/* ---------- Daftar dokumen ---------- */
body.dark-mode .dokumen-search-card,
body.dark-mode .dokumen-search-card__header,
body.dark-mode .results-container,
body.dark-mode .search-result-item {
  color: var(--dm-ink);
  background: var(--dm-surface) !important;
  border-color: var(--dm-line) !important;
  box-shadow: none !important;
}
body.dark-mode .search-result-item:hover { border-color: #3a4558 !important; background: var(--dm-surface-2) !important; }
body.dark-mode .search-result-title a { color: var(--dm-ink) !important; }
body.dark-mode .search-result-title a:hover { color: var(--dm-link) !important; }
body.dark-mode .btn-doc-action { color: var(--dm-ink-2) !important; background: var(--dm-surface-2) !important; border-color: var(--dm-line) !important; }
body.dark-mode .btn-doc-action:hover { color: #fff !important; background: #2a5298 !important; border-color: #2a5298 !important; }
body.dark-mode .dokumen-search-label,
body.dark-mode .dokumen-search-section__heading { color: var(--dm-ink-2); }
body.dark-mode .dokumen-search-section { border-color: var(--dm-line); }
body.dark-mode .results-summary { border-color: var(--dm-line) !important; }

/* ---------- Detail dokumen ---------- */
body.dark-mode .dokumen-view-card,
body.dark-mode .dokumen-view-sidebar-panel,
body.dark-mode .dokumen-view-empty {
  color: var(--dm-ink);
  background: var(--dm-surface) !important;
  border-color: var(--dm-line) !important;
  box-shadow: none !important;
}

/* ---------- Berita ---------- */
body.dark-mode .brt-filter,
body.dark-mode .brt-head__count,
body.dark-mode .brt-chip,
body.dark-mode .berita-article,
body.dark-mode .berita-sidebar__panel,
body.dark-mode .brt-share {
  color: var(--dm-ink);
  background: var(--dm-surface) !important;
  border-color: var(--dm-line) !important;
}
body.dark-mode .brt-chip.is-active,
body.dark-mode .brt-chip[aria-pressed="true"] { color: #fff; background: #2a5298 !important; border-color: #2a5298 !important; }
body.dark-mode .berita-article__hero { background: var(--dm-surface-2) !important; }

/* ---------- Galeri ---------- */
body.dark-mode .gal-toolbar,
body.dark-mode .gal-card { background: var(--dm-surface) !important; border-color: var(--dm-line) !important; }
body.dark-mode .gal-card__media { background: var(--dm-surface-2) !important; }
body.dark-mode .gal-tab:not(.is-active) { color: var(--dm-ink-2); }
body.dark-mode .gal-tab:not(.is-active):hover { background: var(--dm-tint); }

/* ---------- Kontak ---------- */
body.dark-mode .contact-chip { color: var(--dm-link); background: var(--dm-tint); }
body.dark-mode .contact-maplink { color: var(--dm-link); }
body.dark-mode .contact-social li a { color: var(--dm-ink-2); background: var(--dm-surface-2); border-color: var(--dm-line); }

/* ---------- Halaman statis (Tentang Kami, SOP, dst.) ---------- */
body.dark-mode .main-content-card {
  color: var(--dm-ink);
  background: var(--dm-surface) !important;
  border-color: var(--dm-line) !important;
  box-shadow: none !important;
}

/* ---------- Halaman statistik ---------- */
body.dark-mode .alert-light { color: var(--dm-ink-2) !important; }

/* ---------- Teks yang tak terbaca di atas permukaan gelap (hasil audit) ---------- */
body.dark-mode .nws-card__title a,
body.dark-mode .nws-card__cta { color: var(--dm-ink) !important; }
body.dark-mode .nws-card__title a:hover,
body.dark-mode .nws-card:hover .nws-card__cta { color: var(--dm-link) !important; }

body.dark-mode .doc-list-stats__item,
body.dark-mode .doc-list-stats__item span { color: var(--dm-muted) !important; }
body.dark-mode .meta-badge,
body.dark-mode .meta-badge a { color: var(--dm-link) !important; }
body.dark-mode .search-result-meta__year { color: var(--dm-muted); }
body.dark-mode .dokumen-search-card__title { color: var(--dm-ink) !important; }
body.dark-mode .dokumen-search-reset { color: var(--dm-ink-2) !important; background: var(--dm-surface-2) !important; border-color: var(--dm-line) !important; }

body.dark-mode .dokumen-view-title,
body.dark-mode .dokumen-view-section-title,
body.dark-mode .dokumen-view-subsection-title,
body.dark-mode .dokumen-view-sidebar-title,
body.dark-mode .dokumen-view-value,
body.dark-mode .dokumen-view-card td,
body.dark-mode .lampiran-link__name { color: var(--dm-ink) !important; }
body.dark-mode .dokumen-view-label { color: var(--dm-muted) !important; }
body.dark-mode .dokumen-view-type-badge { color: var(--dm-link) !important; background: var(--dm-tint) !important; }
body.dark-mode .dokumen-view-card .border-bottom,
body.dark-mode .dokumen-view-card tr { border-color: var(--dm-line) !important; }

body.dark-mode .berita-article__date,
body.dark-mode .berita-article__back { color: var(--dm-ink-2) !important; }
body.dark-mode .berita-article__back:hover { color: var(--dm-link) !important; }

/* Isi dari editor (berita, profil): warna inline hitam diabaikan */
body.dark-mode .berita-article__content [style*="color"],
body.dark-mode .content-wrapper [style*="color"],
body.dark-mode .main-content-card [style*="color"] { color: inherit !important; }
body.dark-mode .berita-article__content [style*="background"],
body.dark-mode .content-wrapper [style*="background"] { background: transparent !important; }
body.dark-mode .content-wrapper,
body.dark-mode .content-wrapper p,
body.dark-mode .content-wrapper li,
body.dark-mode .content-wrapper strong { color: var(--dm-ink) !important; }

body.dark-mode main .text-primary { color: var(--dm-link) !important; }

/* Halaman error */
body.dark-mode .error-page { background: var(--dm-bg); }
body.dark-mode .error-section { background: transparent !important; }
body.dark-mode .btn-secondary-error { color: var(--dm-ink) !important; border-color: var(--dm-ink-2) !important; }
body.dark-mode .dokumen-view-card .text-muted,
body.dark-mode .dokumen-view-card td.text-muted,
body.dark-mode .dokumen-view-wrapper .text-muted { color: var(--dm-muted) !important; filter: brightness(1.25); }
body.dark-mode .dokumen-view-annotation { color: var(--dm-ink) !important; background: var(--dm-surface-2) !important; border-color: var(--dm-line) !important; }
body.dark-mode .berita-article__content span,
body.dark-mode .berita-article__content font { color: inherit !important; }
body.dark-mode .berita-article__title { color: var(--dm-ink) !important; }
body.dark-mode .berita-article__content,
body.dark-mode .berita-article__content :is(p, li, td, blockquote, h2, h3, h4) { color: var(--dm-ink) !important; }
