/* ==========================================================
   Pengajian Warga — tema islami: hijau zamrud, emas, krem
   ========================================================== */
:root {
  --hijau-900: #06352a;
  --hijau-800: #0b4d3a;
  --hijau-700: #0f5f47;
  --hijau-600: #147a5b;
  --hijau-100: #e3f1ea;
  --emas: #c9a13b;
  --emas-muda: #e9d49a;
  --emas-pucat: #f8f0d8;

  --bg: #faf7ef;
  --surface: #ffffff;
  --surface-2: #f4efe2;
  --text: #1d2a25;
  --muted: #5d6b64;
  --border: #e6dfcd;
  --primary: var(--hijau-700);
  --primary-text: #ffffff;
  --accent: var(--emas);
  --danger: #b4372f;
  --danger-bg: #fbe9e7;
  --success-bg: #e3f1ea;
  --info-bg: #f8f0d8;
  --shadow: 0 1px 2px rgba(6, 53, 42, .06), 0 6px 20px rgba(6, 53, 42, .06);
  --radius: 14px;

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-arab: "Amiri", "Scheherazade New", "Traditional Arabic", serif;
  --font-hias: "Amiri", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1714;
    --surface: #12211c;
    --surface-2: #182b25;
    --text: #e8efe9;
    --muted: #9fb2a9;
    --border: #24392f;
    --primary: #1f9a72;
    --hijau-100: #173a2f;
    --emas-pucat: #2c2716;
    --danger-bg: #3a1c19;
    --success-bg: #173a2f;
    --info-bg: #2c2716;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
@media (min-width: 720px) { html { font-size: 18px; } }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }

/* ---------- Header ---------- */
.site-header {
  background:
    url("../img/pattern.svg") repeat,
    linear-gradient(135deg, var(--hijau-900), var(--hijau-700));
  color: #fff;
  border-bottom: 3px solid var(--emas);
}
.header-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand img { width: 44px; height: 44px; flex: none; }
.brand-text { min-width: 0; }
.brand-name { font-family: var(--font-hias); font-weight: 700; font-size: 1.25rem; line-height: 1.1; display: block; }
.brand-sub { font-size: .78rem; color: var(--emas-muda); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.header-actions form { margin: 0; }

.nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #e8f3ee; text-decoration: none; padding: 7px 14px; border-radius: 999px;
  white-space: nowrap; font-weight: 600; font-size: .92rem;
}
.nav a:hover { background: rgba(255, 255, 255, .1); }
.nav a.active { background: var(--emas); color: var(--hijau-900); }

/* ---------- Hero (mihrab) ---------- */
.hero { text-align: center; padding: 28px 0 8px; }
.basmalah {
  font-family: var(--font-arab); font-size: 2.1rem; color: var(--emas); line-height: 1.8;
  margin: 0; direction: rtl;
}
.salam { font-family: var(--font-hias); font-size: 1.15rem; color: var(--muted); margin: 0 0 6px; }
.mihrab {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 180px 180px var(--radius) var(--radius);
  padding: 44px 20px 24px; margin: 12px auto 24px; max-width: 680px; box-shadow: var(--shadow);
}
.mihrab::before {
  content: ""; position: absolute; inset: 8px; border: 1px dashed var(--emas-muda);
  border-radius: 172px 172px 10px 10px; pointer-events: none;
}
.mihrab h1 { font-family: var(--font-hias); color: var(--primary); font-size: 1.9rem; }

.ornament { display: flex; align-items: center; gap: 12px; color: var(--accent); margin: 28px 0 16px; }
.ornament::before, .ornament::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--emas), transparent); }
.ornament h2 { margin: 0; font-family: var(--font-hias); color: var(--text); font-size: 1.4rem; text-align: center; }
.ornament .star { font-size: .9rem; }

/* ---------- Komponen ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.stats .card { padding: 14px 10px; }
.kv { width: 100%; }
.kv td { padding: 6px 0; border: 0; }
.kv td:last-child { text-align: right; font-weight: 800; white-space: nowrap; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.card-gold { border-top: 3px solid var(--emas); }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover { color: var(--primary); }
.card-link { display: block; color: inherit; text-decoration: none; transition: transform .15s, border-color .15s; }
.card-link:hover { transform: translateY(-2px); border-color: var(--emas-muda); }

.stat { text-align: center; }
.stat .num { font-size: 1.6rem; font-weight: 800; color: var(--primary); display: block; line-height: 1.2; }
.stat .lbl { font-size: .85rem; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.mb0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }

.badge {
  display: inline-block; font-size: .74rem; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  background: var(--hijau-100); color: var(--primary); vertical-align: middle; white-space: nowrap;
}
.badge-gold { background: var(--emas-pucat); color: #8a6a17; }
.badge-duka { background: #e9e6e1; color: #3b3a37; }
.badge-sakit { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-batal { background: var(--danger-bg); color: var(--danger); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-gold { color: var(--emas-muda); }
  :root:not([data-theme="light"]) .badge-duka { background: #2c2c2a; color: #d6d3cd; }
}

/* Tanggal kalender */
.jadwal-item { display: flex; gap: 14px; align-items: flex-start; }
.tgl-box {
  flex: none; width: 62px; text-align: center; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--emas-muda); background: var(--surface);
}
.tgl-box .bln { background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; text-transform: uppercase; padding: 2px 0; letter-spacing: .05em; }
.tgl-box .hr { font-size: 1.5rem; font-weight: 800; line-height: 1.3; color: var(--text); }
.tgl-box .nm { font-size: .68rem; color: var(--muted); padding-bottom: 3px; }
.jadwal-body { min-width: 0; flex: 1; }
.jadwal-body h3 { margin-bottom: 4px; }
.meta { list-style: none; padding: 0; margin: 4px 0 0; font-size: .9rem; color: var(--muted); }
.meta li { display: flex; gap: 6px; }
.meta li span:first-child { flex: none; width: 1.3em; text-align: center; }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: .95rem; line-height: 1.2;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; background: var(--primary); color: var(--primary-text); min-height: 44px;
}
.btn:hover { filter: brightness(1.08); }
.btn-gold { background: var(--emas); color: var(--hijau-900); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-light { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .3); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-wa { background: #1f9d55; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; min-height: 36px; border-radius: 8px; }
.btn-block { width: 100%; }
.inline { display: inline; margin: 0; }

/* Form */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.field label, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .92rem; }
.field .help { font-size: .82rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number],
input[type=search], input[type=url], input[type=tel], input[type=month], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 46px;
}
textarea { min-height: 120px; resize: vertical; }
textarea.arab { font-family: var(--font-arab); font-size: 1.5rem; direction: rtl; line-height: 2; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--emas-muda); outline-offset: 1px; border-color: var(--emas); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-card {
  flex: 1; min-width: 140px; display: flex; gap: 10px; align-items: center; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: 12px; cursor: pointer; font-weight: 700;
}
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--hijau-100); }
.radio-card input { accent-color: var(--primary); width: 20px; height: 20px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 16px; }
.filters > * { flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }

/* Tab */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); text-decoration: none;
  color: var(--text); font-weight: 600; font-size: .9rem; background: var(--surface);
}
.tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Tabel */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.masuk { color: var(--hijau-600); font-weight: 700; }
.keluar { color: var(--danger); font-weight: 700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .masuk { color: #4cc79b; } }

/* Progres program amal */
.progress { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--hijau-600), var(--emas)); border-radius: 999px; }

/* Notifikasi */
.flash { padding: 12px 16px; border-radius: 10px; margin: 16px 0 0; font-weight: 600; border-left: 4px solid var(--primary); background: var(--success-bg); }
.flash-error { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.alert-info { padding: 14px 16px; border-radius: 12px; background: var(--info-bg); border: 1px solid var(--emas-muda); }

/* Empty state */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .icon { font-size: 2rem; color: var(--emas); display: block; }

/* Bacaan */
.arab {
  font-family: var(--font-arab); direction: rtl; text-align: right; font-size: 2.1rem; line-height: 2.2;
  color: var(--text);
}
.latin { font-style: italic; color: var(--primary); }
.bacaan-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow); position: relative; }
.bacaan-box::before, .bacaan-box::after { content: "۞"; position: absolute; top: 8px; color: var(--emas); font-size: 1.1rem; }
.bacaan-box::before { left: 12px; }
.bacaan-box::after { right: 12px; }

/* Video */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Pagination */
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; margin: 20px 0; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; background: var(--surface); }
.pager .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Admin */
.admin-nav {
  position: relative; display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.nav-top {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; cursor: pointer;
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: .92rem; color: var(--text);
  border: 1px solid var(--border); background: var(--surface); list-style: none; user-select: none; min-height: 40px;
}
.nav-top::-webkit-details-marker { display: none; }
.nav-top:hover { border-color: var(--emas-muda); }
.nav-top.active { background: var(--emas-pucat); border-color: var(--emas); }
.nav-top .caret { font-size: .7rem; color: var(--muted); transition: transform .15s; }
.nav-group { position: relative; }
.nav-group[open] > .nav-top { border-color: var(--emas); box-shadow: 0 0 0 3px var(--emas-pucat); }
.nav-group[open] .caret { transform: rotate(180deg); }
.nav-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 220px;
  display: grid; gap: 2px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-top: 3px solid var(--emas); border-radius: 12px; box-shadow: 0 10px 30px rgba(6, 53, 42, .15);
}
.nav-menu a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: .92rem; }
.nav-menu a:hover { background: var(--surface-2); }
.nav-menu a.active { background: var(--hijau-100); color: var(--primary); }
@media (max-width: 560px) {
  .nav-top { padding: 7px 11px; font-size: .88rem; }
  /* Di HP, panel melebar selebar menu agar tidak keluar layar */
  .nav-group { position: static; }
  .nav-menu { left: 0; right: 0; top: auto; margin-top: 6px; }
}
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin: 20px 0 16px; }
.page-head h1 { margin: 0; font-size: 1.5rem; }
.absen-list { list-style: none; margin: 0; padding: 0; }
.absen-list li { border-bottom: 1px solid var(--border); }
.absen-list li:last-child { border-bottom: 0; }
.absen-list label { display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; }
.absen-list label:has(input:checked) { background: var(--hijau-100); }
.absen-list input { width: 24px; height: 24px; accent-color: var(--primary); flex: none; }
.sticky-bar {
  position: sticky; bottom: 0; background: var(--surface); border-top: 2px solid var(--emas);
  padding: 12px 16px; margin: 16px -16px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between;
}

/* Footer */
.site-footer {
  margin-top: 48px; background: url("../img/pattern.svg") repeat, var(--hijau-900);
  color: #cfe2d9; text-align: center; padding: 28px 0 22px; border-top: 3px solid var(--emas);
}
.site-footer .arab { text-align: center; color: var(--emas-muda); font-size: 1.6rem; line-height: 1.9; }
.site-footer p { margin: 4px 0; font-size: .88rem; }
.site-footer a { color: var(--emas-muda); }

/* Login */
.login-wrap { max-width: 420px; margin: 40px auto; }

@media (max-width: 560px) {
  h1 { font-size: 1.45rem; }
  .basmalah { font-size: 1.7rem; }
  .mihrab { border-radius: 120px 120px var(--radius) var(--radius); padding-top: 36px; }
  .mihrab::before { border-radius: 112px 112px 10px 10px; }
  .mihrab h1 { font-size: 1.5rem; }
  .brand-sub { max-width: 52vw; }
  .hide-sm { display: none; }
  th, td { padding: 8px 10px; }
}

@media print {
  .site-header, .site-footer, .admin-nav, .btn, .filters, .tabs, .pager { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; }
}

/* ---------- Setoran bacaan & hafalan ---------- */
.badge-mumtaz { background: var(--primary); color: #fff; }
.badge-ulang { background: #fdecd8; color: #9a4a0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-ulang { background: #3a2a17; color: #f0b27a; } }

.nilai-group { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); }
.nilai-card {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 2px solid var(--border);
  border-radius: 12px; cursor: pointer; background: var(--surface);
}
.nilai-card input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.nilai-card strong { display: block; line-height: 1.2; }
.nilai-card small { color: var(--muted); }
.nilai-card:has(input:checked) { border-color: var(--primary); background: var(--hijau-100); }
.nilai-card.nilai-ulang:has(input:checked) { border-color: #c2650f; background: #fdecd8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nilai-card.nilai-ulang:has(input:checked) { background: #3a2a17; } }

.aspek { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.aspek .ok { color: var(--hijau-600); font-weight: 700; }

.juz-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 128px), 1fr)); }
.juz-item {
  display: flex; flex-direction: column; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); min-width: 0;
}
.juz-no { font-size: .7rem; color: var(--muted); }
.juz-nama { font-weight: 700; font-size: .9rem; line-height: 1.25; overflow-wrap: anywhere; }
.juz-ket { font-size: .74rem; color: var(--muted); }
.juz-hafal { background: var(--hijau-100); border-color: var(--hijau-600); }
.juz-hafal .juz-ket { color: var(--hijau-600); font-weight: 700; }
.juz-sebagian { background: var(--emas-pucat); border-color: var(--emas); }
.juz-belum { opacity: .75; }
@media print {
  .juz-item { break-inside: avoid; }
  .juz-hafal, .juz-sebagian { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Murid & kelas TPA ---------- */
.tingkat-steps { display: flex; flex-wrap: wrap; gap: 4px; }
.tingkat-steps .step {
  flex: 1 1 auto; text-align: center; font-size: .78rem; font-weight: 700; padding: 6px 8px;
  border-radius: 8px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.tingkat-steps .step.done { background: var(--hijau-100); color: var(--hijau-600); border-color: var(--hijau-100); }
.tingkat-steps .step.current { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--emas-muda); }

.kv-table th { background: none; text-transform: none; letter-spacing: 0; font-size: .85rem; width: 38%; padding-left: 0; }
.kv-table td { padding-right: 0; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--emas-muda); }
.timeline li { position: relative; padding: 0 0 12px 8px; }
.timeline li::before {
  content: ""; position: absolute; left: -23px; top: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--emas);
}
.timeline li:first-child::before { background: var(--primary); border-color: var(--primary); }

.link-btn { background: none; border: 0; padding: 0 0 0 6px; color: var(--muted); cursor: pointer; font: inherit; font-size: .78rem; text-decoration: underline; }
.link-btn:hover { color: var(--danger); }

.juz-compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 104px), 1fr)); gap: 6px; }
.juz-compact .juz-item { flex-direction: row; justify-content: space-between; align-items: center; padding: 6px 8px; gap: 4px; }
.juz-compact .juz-nama { font-size: .8rem; }
