/* =======================================================
   SITPA - Modern Islamic Dashboard
   ======================================================= */
:root {
  --primary: #1a9c5b;
  --primary-dark: #147a47;
  --primary-light: #e7f6ee;
  --primary-rgb: 26, 156, 91;
  --sidebar-width: 260px;
  --sidebar-collapsed: 78px;
  --topbar-height: 64px;
  --footer-height: 48px;
  --radius: 14px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow: 0 6px 24px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.14);
  --font: 'Plus Jakarta Sans','Segoe UI',system-ui,sans-serif;
}

* { font-family: var(--font); }
body {
  background: #f4f7f6;
  color: #2b2f33;
  overflow-x: hidden;
  transition: background .3s;
}

/* ---------- DARK MODE ---------- */
[data-bs-theme="dark"] body { background: #14181d; color: #d6dde3; }
[data-bs-theme="dark"] { --primary-light: rgba(var(--primary-rgb),.15); }
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .app-topbar,
[data-bs-theme="dark"] .stat-card,
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .modal-content { background: #1d232a; color: #d6dde3; }
[data-bs-theme="dark"] .table { --bs-table-color: #d6dde3; }
[data-bs-theme="dark"] .text-muted { color: #8b969f !important; }
[data-bs-theme="dark"] .border, [data-bs-theme="dark"] .card { border-color: #2c343d !important; }

/* ---------- SIDEBAR ---------- */
.app-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark), var(--primary));
  color: #fff; z-index: 1040;
  display: flex; flex-direction: column;
  transition: width .28s cubic-bezier(.4,0,.2,1), transform .28s;
  box-shadow: 4px 0 24px rgba(0,0,0,.12);
}
.sidebar-brand {
  height: var(--topbar-height); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid rgba(255,255,255,.12);
  overflow: hidden; white-space: nowrap;
}
.sidebar-brand .logo-box {
  min-width: 40px; width: 40px; height: 40px; border-radius: 11px;
  background: rgba(255,255,255,.18); display: flex; align-items: center;
  justify-content: center; font-size: 20px; overflow:hidden;
}
.sidebar-brand .logo-box img { width:100%; height:100%; object-fit:cover; }
.sidebar-brand .brand-text { font-weight: 800; font-size: 18px; line-height: 1.1; }
.sidebar-brand .brand-text small { font-weight: 400; font-size: 10.5px; opacity: .8; display:block; }

.sidebar-menu { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar-menu::-webkit-scrollbar { width: 5px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
.menu-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px;
  opacity: .55; padding: 14px 14px 6px; white-space: nowrap;
}
.sidebar-menu a {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 14px; margin-bottom: 3px; border-radius: 11px;
  color: rgba(255,255,255,.85); text-decoration: none; font-size: 14.5px;
  font-weight: 500; white-space: nowrap; transition: all .2s; position: relative;
}
.sidebar-menu a i { min-width: 22px; font-size: 16px; text-align: center; }
.sidebar-menu a:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-menu a.active { background: #fff; color: var(--primary-dark); font-weight: 700; box-shadow: var(--shadow-sm); }
.sidebar-menu a .badge { margin-left: auto; }

/* Collapsed */
body.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed); }
body.sidebar-collapsed .app-sidebar .brand-text,
body.sidebar-collapsed .app-sidebar .menu-label,
body.sidebar-collapsed .app-sidebar .link-text,
body.sidebar-collapsed .app-sidebar a .badge { display: none; }
body.sidebar-collapsed .app-sidebar a { justify-content: center; padding: 12px; }
body.sidebar-collapsed .app-sidebar .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-collapsed .app-content { margin-left: var(--sidebar-collapsed); }
body.sidebar-collapsed .app-topbar { left: var(--sidebar-collapsed); }

/* ---------- CONTENT ---------- */
.app-content { margin-left: var(--sidebar-width); transition: margin .28s; min-height: 100vh; padding-top: var(--topbar-height); }
.app-topbar {
  position: fixed; top: 0; right: 0; left: var(--sidebar-width);
  height: var(--topbar-height); background: #fff; z-index: 1030;
  display: flex; align-items: center; gap: 12px; padding: 0 22px;
  border-bottom: 2px solid rgba(0,0,0,.08);
  box-shadow: 0 4px 14px rgba(0,0,0,.1); transition: left .28s;
}
[data-bs-theme="dark"] .app-topbar { border-bottom-color: #2c343d; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.topbar-toggle {
  border: 0; background: var(--primary-light); color: var(--primary);
  width: 42px; height: 42px; border-radius: 11px; font-size: 17px; cursor: pointer;
  transition: all .2s;
}
.topbar-toggle:hover { background: var(--primary); color: #fff; }
.page-content { padding: 26px; padding-bottom: calc(26px + var(--footer-height)); }

/* Footer halaman - freeze/sticky di bawah viewport, mengikuti pola topbar */
.app-footer {
  position: fixed; left: var(--sidebar-width); right: 0; bottom: 0;
  height: var(--footer-height); background: #fff; z-index: 1020;
  display: flex; align-items: center; justify-content: center;
  border-top: 2px solid rgba(0,0,0,.08);
  box-shadow: 0 -4px 14px rgba(0,0,0,.1);
  transition: left .28s; margin: 0 !important;
}
[data-bs-theme="dark"] .app-footer { background: #1d232a; border-top-color: #2c343d; box-shadow: 0 -4px 14px rgba(0,0,0,.35); }
body.sidebar-collapsed .app-footer { left: var(--sidebar-collapsed); }

.topbar-icon-btn {
  border: 0; background: transparent; width: 42px; height: 42px; border-radius: 11px;
  color: inherit; font-size: 17px; cursor: pointer; position: relative; transition: all .2s;
}
.topbar-icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.topbar-icon-btn .dot { position:absolute; top:9px; right:10px; width:8px; height:8px; background:#e74c3c; border-radius:50%; border:2px solid #fff; }

/* ---------- CARDS ---------- */
.card { border: 1px solid rgba(0,0,0,.05); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header {
  background: transparent; border-bottom: 1px solid rgba(0,0,0,.06);
  font-weight: 700; padding: 16px 20px; display:flex; align-items:center; gap:10px;
}
[data-bs-theme="dark"] .card-header { border-color:#2c343d; }

/* Stat cards */
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 16px;
  border: 1px solid rgba(0,0,0,.05); transition: transform .2s, box-shadow .2s;
  position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.stat-card .icon {
  min-width: 58px; width: 58px; height: 58px; border-radius: 15px;
  display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff;
}
.stat-card .num { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-card .label { color: #8a949c; font-size: 13px; margin-top: 4px; }
.stat-card::after {
  content:''; position:absolute; right:-30px; top:-30px; width:100px; height:100px;
  border-radius:50%; background:currentColor; opacity:.05;
}

/* Gradient helpers */
.bg-grad-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.bg-grad-blue { background: linear-gradient(135deg,#3b82f6,#2563eb); }
.bg-grad-orange { background: linear-gradient(135deg,#f59e0b,#d97706); }
.bg-grad-red { background: linear-gradient(135deg,#ef4444,#dc2626); }
.bg-grad-purple { background: linear-gradient(135deg,#8b5cf6,#7c3aed); }
.bg-grad-teal { background: linear-gradient(135deg,#14b8a6,#0d9488); }

/* ---------- BUTTONS ---------- */
.btn { border-radius: 10px; font-weight: 600; padding: 8px 16px; transition: all .2s; }
.btn i { pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-soft-primary { background: var(--primary-light); color: var(--primary); border:0; }
.btn-soft-primary:hover { background: var(--primary); color:#fff; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- TABLES / DataTables ---------- */
.table > thead { background: var(--primary); }
/* Bootstrap memberi setiap th background-color var(--bs-table-bg) (putih) yang
   menutupi warna thead — jadi set langsung di th agar mengikuti tema aktif.
   position:sticky membuat header freeze mengikuti scroll browser/halaman biasa
   (tanpa scrollbar internal) - top disesuaikan dengan tinggi topbar fixed. */
.table > thead th,
.table > thead > tr > th {
  background-color: var(--primary) !important;
  color: #fff !important; font-weight: 600; border: 0;
  white-space: nowrap; vertical-align: middle;
  /* !important perlu karena dataTables.bootstrap5.min.css punya aturan
     "table.dataTable thead th { position: relative; }" berspesifisitas lebih tinggi */
  position: sticky !important; top: var(--topbar-height); z-index: 5;
}
.table > tbody td { vertical-align: middle; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; border-radius:8px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--primary-light) !important; border-color: var(--primary) !important; color: var(--primary) !important; border-radius:8px; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select { border-radius: 8px; border: 1px solid #ddd; padding: 6px 10px; }
[data-bs-theme="dark"] .dataTables_wrapper { color:#d6dde3; }
[data-bs-theme="dark"] .dataTables_filter input,[data-bs-theme="dark"] .dataTables_length select { background:#14181d; color:#d6dde3; border-color:#2c343d; }
.table-avatar { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; }
/* Bootstrap men-set overflow-x:auto pada .table-responsive. Menurut spec CSS, selama
   salah satu sumbu overflow bukan 'visible', browser MEMAKSA sumbu lainnya jadi
   scroll container juga (tidak bisa dilawan dengan overflow-y:visible saja) - ini
   membuat position:sticky pada thead nyangkut ke div ini, bukan ke scroll halaman.
   Matikan juga overflow-x supaya tabel tidak pernah punya scroll container sendiri;
   scroll horizontal (jika perlu) akan ditangani oleh scrollbar browser/halaman. */
.table-responsive { overflow-x: visible; overflow-y: visible; }
/* Bootstrap5 pagination (DataTables) ikut tema */
.page-link { color: var(--primary); }
.page-link:hover { color: var(--primary-dark); background: var(--primary-light); }
.page-item.active .page-link { background-color: var(--primary) !important; border-color: var(--primary) !important; color:#fff !important; }
.page-link:focus { box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb),.2); }
/* Komponen Bootstrap lain ikut tema hijau */
.nav-pills .nav-link { color: var(--primary); border-radius: 10px; font-weight: 600; }
.nav-pills .nav-link.active { background: var(--primary); color: #fff; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb),.15); }
.form-switch .form-check-input:checked { background-color: var(--primary); }
a.text-decoration-none:hover { color: var(--primary-dark); }
.spinner-border.text-primary, .text-primary { color: var(--primary) !important; }

/* ---------- FORMS ---------- */
.form-control, .form-select { border-radius: 10px; padding: 10px 14px; border: 1px solid #dde3e6; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb),.15); }
[data-bs-theme="dark"] .form-control,[data-bs-theme="dark"] .form-select { background:#14181d; color:#d6dde3; border-color:#2c343d; }
.form-label { font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.input-group-text { border-radius: 10px; background: var(--primary-light); color: var(--primary); border-color:#dde3e6; }

/* ---------- MODAL ---------- */
.modal-content { border: 0; border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { background: var(--primary); color: #fff; padding: 16px 22px; border:0; }
/* Pastikan isi modal selalu muat di layar & bisa di-scroll (header/footer tetap
   terlihat) — berlaku untuk semua modal, termasuk yang tanpa modal-dialog-scrollable. */
.modal-body { max-height: calc(100vh - 190px); overflow-y: auto; }
.modal-header .btn-close { filter: invert(1) brightness(2); }
.modal-title { font-weight: 700; }

/* ---------- PAGE HEADER ---------- */
.page-header { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:14px; margin-bottom:22px; }
.page-header h4 { font-weight: 800; margin: 0; }
.page-header .breadcrumb { margin: 4px 0 0; font-size: 13px; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

/* Avatar */
.avatar { border-radius: 12px; object-fit: cover; }
.avatar-sm { width: 38px; height: 38px; }
.avatar-md { width: 52px; height: 52px; }
.avatar-lg { width: 96px; height: 96px; }
.avatar-xl { width: 120px; height: 120px; }

/* Badges soft */
.badge { font-weight: 600; padding: 5px 10px; border-radius: 7px; }

/* ---------- LOGIN ---------- */
.login-wrap { min-height: 100vh; display: flex; }
.login-hero {
  flex: 1; background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 60px;
  position: relative; overflow: hidden;
}
.login-hero::before, .login-hero::after {
  content:''; position:absolute; border-radius:50%; background:rgba(255,255,255,.08);
}
.login-hero::before { width:320px; height:320px; top:-80px; right:-80px; }
.login-hero::after { width:220px; height:220px; bottom:-60px; left:-40px; }
.login-form-side { width: 480px; max-width: 100%; display: flex; align-items: center; justify-content: center; padding: 40px; background:#fff; }
[data-bs-theme="dark"] .login-form-side { background:#1d232a; }

/* Timeline (histori progress) */
.timeline { position: relative; padding-left: 34px; }
.timeline::before { content:''; position:absolute; left:11px; top:6px; bottom:6px; width:2px; background:var(--primary-light); }
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-item::before {
  content:''; position:absolute; left:-28px; top:3px; width:16px; height:16px;
  border-radius:50%; background:#fff; border:3px solid var(--primary);
}
.timeline-item .tl-date { font-size:12px; color:#8a949c; }

/* Progress iqro pills */
.jilid-pill { display:inline-flex; align-items:center; justify-content:center; width:38px; height:38px; border-radius:10px; font-weight:700; border:2px solid var(--primary-light); color:#9aa4ab; }
.jilid-pill.done { background: var(--primary); color:#fff; border-color:var(--primary); }
.jilid-pill.current { border-color: var(--primary); color: var(--primary); }

/* Utility */
.cursor-pointer { cursor: pointer; }
.text-primary { color: var(--primary) !important; }
.hover-shadow:hover { box-shadow: var(--shadow); }
a { color: var(--primary); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .app-sidebar { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,.3); }
  .app-content { margin-left: 0 !important; }
  .app-topbar { left: 0 !important; }
  .app-footer { left: 0 !important; }
  body.sidebar-collapsed .app-sidebar { width: var(--sidebar-width); }
  body.sidebar-collapsed .app-sidebar .brand-text,
  body.sidebar-collapsed .app-sidebar .menu-label,
  body.sidebar-collapsed .app-sidebar .link-text { display: inline; }
  body.sidebar-collapsed .app-sidebar a { justify-content: flex-start; padding: 11px 14px; }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1039; display: none; }
  body.sidebar-open .sidebar-overlay { display: block; }
  .page-content { padding: 16px; padding-bottom: calc(16px + var(--footer-height)); }
}

/* Loader */
.spinner-overlay { position: fixed; inset:0; background: rgba(255,255,255,.6); z-index:9999; display:none; align-items:center; justify-content:center; }
[data-bs-theme="dark"] .spinner-overlay { background: rgba(0,0,0,.5); }
.spinner-overlay.show { display: flex; }
