/* =====================================================================
   app.css - Reka bentuk SPRP (Clean Professional Dashboard)
   Tema dikawal melalui atribut <html data-tema="..."> menggunakan pembolehubah CSS.
   ===================================================================== */

/* ---------- Tema: Blue Professional (lalai) ---------- */
:root, [data-tema="blue"] {
  --bg: #f3f6fb;  --surface: #ffffff;  --text: #1b2a41;  --muted: #6b7a90;  --border: #e3e9f2;
  --side-bg: #0b2447;  --side-text: #b9c7e0;  --side-active: #1d4ed8;  --side-hover: rgba(255,255,255,.07);
  --primary: #1d4ed8;  --primary-hover: #1a43b8;  --soft: #e8f0fe;  --top-bg: #ffffff;
  --shadow: 0 1px 3px rgba(16,42,90,.06), 0 4px 14px rgba(16,42,90,.05);
}
[data-tema="green"] {
  --bg: #f2f7f4;  --text: #17302a;  --muted: #62786f;  --border: #dfeae4;
  --side-bg: #0b3d2e;  --side-text: #b7d4c8;  --side-active: #15803d;
  --primary: #15803d;  --primary-hover: #126a33;  --soft: #e3f4e9;
  --shadow: 0 1px 3px rgba(10,60,40,.06), 0 4px 14px rgba(10,60,40,.05);
}
[data-tema="maroon"] {
  --bg: #f8f4f5;  --text: #2e1a20;  --muted: #7d666c;  --border: #eddde1;
  --side-bg: #5a0f1f;  --side-text: #e4c3ca;  --side-active: #9b2146;
  --primary: #8b1e3f;  --primary-hover: #731833;  --soft: #f9e8ec;
  --shadow: 0 1px 3px rgba(90,15,31,.07), 0 4px 14px rgba(90,15,31,.05);
}
[data-tema="light"] {
  --bg: #f5f5f7;  --text: #20242c;  --muted: #707684;  --border: #e6e8ee;
  --side-bg: #ffffff;  --side-text: #4a5262;  --side-active: #2563eb;  --side-hover: #f0f3fa;
  --primary: #2563eb;  --primary-hover: #1e50c7;  --soft: #eef2ff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 3px 10px rgba(0,0,0,.04);
}
[data-tema="dark"] {
  --bg: #0f172a;  --surface: #1e293b;  --text: #e5e7eb;  --muted: #94a3b8;  --border: #2c3a52;
  --side-bg: #0b1220;  --side-text: #9fb0c9;  --side-active: #2f5fd0;
  --primary: #4f86f7;  --primary-hover: #6a9aff;  --soft: #1f3355;  --top-bg: #1e293b;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ---------- Asas ---------- */
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
       font-size: .94rem; line-height: 1.55; }
a { color: var(--primary); }
.text-muted, .form-text { color: var(--muted) !important; }
h1,h2,h3,h4,h5 { font-weight: 650; letter-spacing: -.01em; }
[dir="rtl"], .rtl { direction: rtl; text-align: right; unicode-bidi: plaintext; }

/* Selaraskan komponen Bootstrap dengan pembolehubah tema */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); color: var(--text); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; padding: .9rem 1.15rem; }
.form-control, .form-select { background-color: var(--surface); color: var(--text); border-color: var(--border); border-radius: 9px; padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--primary) 22%, transparent); background-color: var(--surface); color: var(--text); }
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.btn { border-radius: 9px; font-weight: 550; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover); --bs-btn-active-bg: var(--primary-hover); --bs-btn-active-border-color: var(--primary-hover); --bs-btn-color:#fff; }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); --bs-btn-hover-color:#fff; --bs-btn-active-bg: var(--primary); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); }
.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; border-bottom-width: 1px; white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: var(--soft); --bs-table-hover-color: var(--text); }
.modal-content, .dropdown-menu { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; }
.dropdown-item { color: var(--text); } .dropdown-item:hover { background: var(--soft); color: var(--text); }
.modal-header, .modal-footer { border-color: var(--border); }
.btn-close { filter: none; } [data-tema="dark"] .btn-close { filter: invert(1); }
.nav-pills .nav-link.active, .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.page-link { color: var(--primary); background: var(--surface); border-color: var(--border); }
.progress { background: var(--soft); } .progress-bar { background: var(--primary); }
.list-group-item { background: var(--surface); color: var(--text); border-color: var(--border); }
.alert { border-radius: 10px; }

/* ---------- Rangka aplikasi ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; background: var(--side-bg); color: var(--side-text); z-index: 1040;
  display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .25s ease;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); border-right: 1px solid var(--border); }
.sidebar.terbuka { transform: none; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.15rem 1.25rem; color: var(--side-text); text-decoration: none; }
.sidebar-brand .logo { width: 40px; height: 40px; border-radius: 11px; background: var(--side-active); color: #fff; display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.sidebar-brand b { display: block; color: #fff; font-size: 1.05rem; line-height: 1.1; }
[data-tema="light"] .sidebar-brand b { color: var(--text); }
.sidebar-brand small { font-size: .72rem; opacity: .8; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .4rem .8rem 1rem; }
.sidebar-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; opacity: .6; padding: 1rem .65rem .35rem; }
.sidebar-nav a { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 10px; color: var(--side-text);
  text-decoration: none; font-weight: 500; margin-bottom: 2px; transition: background .15s, color .15s; }
.sidebar-nav a i { font-size: 1.1rem; width: 1.3rem; text-align: center; }
.sidebar-nav a:hover { background: var(--side-hover); color: #fff; }
[data-tema="light"] .sidebar-nav a:hover { color: var(--text); }
.sidebar-nav a.aktif { background: var(--side-active); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.sidebar-foot { padding: .9rem 1.1rem; font-size: .75rem; opacity: .65; border-top: 1px solid rgba(255,255,255,.08); }
.tirai { position: fixed; inset: 0; background: rgba(8,16,36,.5); z-index: 1035; display: none; }
.tirai.terbuka { display: block; }

.kandungan { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; background: var(--top-bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; padding-top: calc(.7rem + env(safe-area-inset-top)); }
.topbar .tajuk-halaman { font-weight: 650; font-size: 1.08rem; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-ikon { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; }
.btn-ikon:hover { background: var(--soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.halaman { padding: 1.25rem; flex: 1; max-width: 1480px; width: 100%; margin: 0 auto; padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
.kaki { padding: 1rem 1.25rem; font-size: .8rem; color: var(--muted); text-align: center; }

@media (min-width: 992px) {          /* Desktop & laptop: sidebar tetap */
  .sidebar { transform: none; }
  .kandungan { margin-left: 264px; }
  .btn-menu { display: none; }
  .halaman { padding: 1.6rem 1.9rem; }
}

/* ---------- Kad statistik ---------- */
.stat { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; height: 100%; transition: transform .18s ease, box-shadow .18s ease; }
.stat:hover { transform: translateY(-2px); }
.stat .ikon { width: 50px; height: 50px; border-radius: 13px; background: var(--soft); color: var(--primary); display: grid; place-items: center; font-size: 1.45rem; flex: none; }
.stat .nilai { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .82rem; }
.ikon-hijau { background: #e0f5e9 !important; color: #15803d !important; }
.ikon-kuning { background: #fff4d6 !important; color: #b7791f !important; }
.ikon-merah { background: #fde4e4 !important; color: #c53030 !important; }
[data-tema="dark"] .ikon-hijau { background: #153a2a !important; } [data-tema="dark"] .ikon-kuning { background: #3d3315 !important; } [data-tema="dark"] .ikon-merah { background: #44201f !important; }
.fade-masuk { animation: masuk .35s ease; }   /* tanpa 'both': elak stacking context kekal yang menyekat modal Bootstrap */
@keyframes masuk { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Jadual & kandungan DSKP ---------- */
.jadual-skrol { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sel-teks { min-width: 220px; max-width: 460px; white-space: normal; }
.pilihan-dskp { cursor: pointer; }
.tema-kad { cursor: pointer; border: 2px solid var(--border); border-radius: 12px; padding: .8rem; transition: border-color .15s; text-align: center; }
.tema-kad:hover { border-color: var(--primary); }
.tema-kad.dipilih { border-color: var(--primary); background: var(--soft); }
.tema-warna { display: flex; height: 28px; border-radius: 7px; overflow: hidden; margin-bottom: .5rem; border: 1px solid rgba(0,0,0,.08); }
.tema-warna span { flex: 1; }
.item-rpt { background: var(--soft); border-radius: 12px; padding: .9rem; margin-bottom: .75rem; border: 1px solid var(--border); }
.toast-kontena { position: fixed; right: 1rem; bottom: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; }
.kosong { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.kosong i { font-size: 2.4rem; display: block; margin-bottom: .4rem; opacity: .6; }

/* ---------- Halaman login ---------- */
.login-latar { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem;
  background: linear-gradient(135deg, var(--side-bg) 0%, var(--primary) 100%); }
.login-kad { width: 100%; max-width: 430px; border-radius: 18px; padding: 2rem 1.8rem; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 2rem; margin: 0 auto 1rem; }

/* ---------- Cetakan ---------- */
@media print { .sidebar, .topbar, .kaki, .tidak-cetak { display: none !important; } .kandungan { margin: 0 !important; } .halaman { padding: 0; } .card { box-shadow: none; } }

html {
    font-size: 16px; /* desktop base */
}

@media (max-width: 768px) {
    html { font-size: 13px; /* tablet */ }
}

@media (max-width: 576px) {
    html { font-size: 12px; /* mobile, as requested */ }
}