/* Aplikasi Masjid Al-Fattah - tema gelap hijau & emas (mengikuti gaya Sumbagut Bridge) */
:root {
    --bg: #0e1412;
    --panel: #15201c;
    --panel-2: #1b2a24;
    --line: #2a3b34;
    --text: #e8efe9;
    --muted: #93a69c;
    --gold: #e0b84b;
    --green: #2ea043;
    --green-2: #3fd18a;
    --red: #ef5350;
    --sidebar-w: 262px;
}

* { box-sizing: border-box; }

html, body { background: var(--bg); }

body {
    margin: 0;
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--green-2); }
a:hover { color: var(--gold); }

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #102019 0%, #0b1511 100%);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; justify-content: space-between;
    overflow-y: auto; z-index: 1040;
    transition: transform .28s ease;
    padding: 14px 14px 18px;
}
.sidebar-brand {
    display: block; text-align: center; text-decoration: none;
    padding: 14px 0 16px; margin-bottom: 10px;
    border-bottom: 2px solid rgba(224, 184, 75, .45);
}
.sidebar-brand i { font-size: 32px; color: var(--gold); }
.sidebar-brand .t1 { display: block; margin-top: 8px; color: var(--gold); font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.sidebar-brand .t2 { display: block; color: var(--green-2); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }

.nav-label {
    color: #6f8a7d; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
    margin: 14px 10px 6px;
}
.side-nav { list-style: none; margin: 0; padding: 0; }
.side-nav li { margin-bottom: 2px; }
.side-nav a {
    display: flex; align-items: center; gap: 10px;
    color: #b5c7bd; text-decoration: none;
    padding: 9px 12px; border-radius: 8px; font-weight: 500;
    transition: background .2s, color .2s, transform .2s;
}
.side-nav a i.ico { width: 20px; text-align: center; color: var(--green-2); }
.side-nav a:hover { background: rgba(224, 184, 75, .08); color: var(--gold); transform: translateX(3px); }
.side-nav a.active {
    background: linear-gradient(90deg, rgba(224, 184, 75, .18), transparent);
    color: #fff; font-weight: 700; box-shadow: inset 3px 0 0 var(--gold);
}
.side-nav a .chev { margin-left: auto; font-size: 11px; transition: transform .25s; }
.side-nav .menu-parent.open > a .chev { transform: rotate(180deg); }
.side-nav .submenu { list-style: none; padding: 2px 0 6px 30px; margin: 0; display: none; }
.side-nav .menu-parent.open > .submenu { display: block; }
.side-nav .submenu a { padding: 6px 10px; font-size: 13.5px; color: #c9d6cf; }
.side-nav .submenu a.active { color: var(--green-2); box-shadow: inset 2px 0 0 var(--green-2); background: transparent; }

.user-card {
    margin-top: 16px; padding: 12px;
    border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px;
    background: rgba(255, 255, 255, .03);
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: #24352e; color: var(--gold); font-weight: 700; font-size: 18px;
    border: 2px solid rgba(224, 184, 75, .5);
}
.is-admin .user-avatar { animation: pulseGold 2.2s infinite; border-color: var(--gold); }
@keyframes pulseGold {
    0% { box-shadow: 0 0 0 0 rgba(224, 184, 75, .45); }
    70% { box-shadow: 0 0 0 7px rgba(224, 184, 75, 0); }
    100% { box-shadow: 0 0 0 0 rgba(224, 184, 75, 0); }
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-badge {
    display: inline-block; font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
    padding: 1px 7px; border-radius: 4px; background: rgba(63, 209, 138, .12); color: var(--green-2);
}
.is-admin .role-badge { background: rgba(224, 184, 75, .15); color: var(--gold); }
.icon-btn {
    width: 34px; height: 34px; border-radius: 8px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); color: #c9d6cf;
    text-decoration: none;
}
.icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.icon-btn.logout { color: var(--red); }
.icon-btn.logout:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ============ MAIN ============ */
.main-content { margin-left: var(--sidebar-w); padding: 26px 28px 70px; min-height: 100vh; }

.page-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 18px;
}
.page-title { margin: 0; color: var(--gold); font-weight: 600; font-size: 22px; letter-spacing: .3px; }
.page-title i { color: var(--green-2); margin-right: 8px; }
.page-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px; margin-bottom: 18px;
}
.panel-title { color: var(--gold); font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.intro { color: var(--muted); font-size: 13.5px; border-left: 3px solid var(--gold); padding: 6px 12px; margin-bottom: 14px; background: rgba(224,184,75,.05); border-radius: 0 8px 8px 0; }

/* Tabel */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; border: 1px solid var(--line); }
.table-app { margin: 0; --bs-table-bg: transparent; font-size: 14px; }
.table-app thead th {
    background: #1f3a2f; color: #dff5e8; font-weight: 600; white-space: nowrap;
    position: sticky; top: 0; z-index: 1; border-bottom: 2px solid var(--gold);
}
.table-app td { vertical-align: middle; border-color: var(--line); }
.table-app tbody tr:hover td { background: rgba(63, 209, 138, .06); }
.table-app tr.row-today td { background: rgba(224, 184, 75, .12) !important; }
.table-app tr.row-saldo td { background: rgba(88, 166, 255, .08); font-weight: 600; }
.table-app tfoot td { font-weight: 700; background: #18271f; border-top: 2px solid var(--gold); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-debet { color: #6ee7a8; }
.text-kredit { color: #ff8a80; }
.text-gold { color: var(--gold) !important; }
.text-green { color: var(--green-2) !important; }
.text-muted2 { color: var(--muted) !important; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px !important; }
.warn-cell { color: #ffb4a8; font-style: italic; }
.aksi { white-space: nowrap; width: 1%; }
.aksi form { display: inline; }

/* Kartu ringkasan */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
    position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent, var(--gold)); }
.stat small { color: var(--muted); display: block; font-size: 12.5px; }
.stat .v { font-size: 20px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.c-green { --accent: var(--green); }
.c-blue { --accent: #58a6ff; }
.c-red { --accent: var(--red); }
.c-purple { --accent: #bc8cff; }

/* Kartu menu cepat */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.qa-card {
    background: linear-gradient(145deg, #172720, #0f1915); border: 1px solid var(--line); border-radius: 12px;
    padding: 18px; text-decoration: none; color: #fff; position: relative; overflow: hidden;
    transition: transform .25s, border-color .25s, box-shadow .25s;
}
.qa-card:hover { transform: translateY(-4px); border-color: var(--accent, var(--gold)); box-shadow: 0 10px 20px rgba(0,0,0,.45); color: #fff; }
.qa-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent, var(--gold)); }
.qa-card .ico { font-size: 26px; color: var(--accent, var(--gold)); margin-bottom: 10px; }
.qa-card .t { font-weight: 700; font-size: 16px; }
.qa-card .d { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Waktu shalat */
.prayer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.prayer {
    background: linear-gradient(145deg, #162019, #0e1512); border: 1px solid var(--line); border-radius: 12px;
    padding: 10px 8px; text-align: center;
}
.prayer .n { color: var(--green-2); font-size: 13px; }
.prayer .w { font-size: 22px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.prayer.next { border-color: var(--gold); box-shadow: 0 0 16px rgba(224, 184, 75, .25); }
.prayer.next .n { color: var(--gold); }

/* Info Jum'at */
.info-grid { display: grid; grid-template-columns: 190px 1fr; gap: 6px 12px; font-size: 16px; }
.info-grid .l { color: var(--gold); }
.info-grid .v { font-weight: 700; color: #fff; }
.fin-grid { display: grid; grid-template-columns: 210px 1fr; gap: 4px 12px; font-size: 16px; }
.fin-grid .l { color: var(--gold); }
.fin-grid .v { font-weight: 700; color: var(--gold); text-align: right; max-width: 220px; font-variant-numeric: tabular-nums; }

/* Form */
.form-control, .form-select { background-color: #0f1915; border-color: #34483f; color: var(--text); }
.form-control:focus, .form-select:focus { background-color: #0f1915; color: #fff; border-color: var(--gold); box-shadow: 0 0 0 .2rem rgba(224, 184, 75, .2); }
.form-label { color: #cfe0d6; font-size: 13.5px; margin-bottom: 4px; }
.form-text { color: var(--muted); }
.btn-gold { background: var(--gold); color: #1b1405; border: none; font-weight: 600; }
.btn-gold:hover { background: #f0c95c; color: #000; }
.btn-success { background: #1b6e35; border-color: #1b6e35; }
.btn-success:hover { background: #24873f; border-color: #24873f; }
.modal-content { background: var(--panel); border: 1px solid var(--line); }
.modal-header { border-bottom-color: var(--line); }
.modal-footer { border-top-color: var(--line); }
.modal-title { color: var(--gold); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar .form-select, .filter-bar .form-control { width: auto; min-width: 110px; }

.alert-flash { border-radius: 10px; }

/* Footer */
.app-footer {
    margin-left: var(--sidebar-w); padding: 10px 28px; border-top: 1px solid var(--line);
    color: #6f8a7d; font-size: 12px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px;
}
.app-footer .arab { color: var(--gold); font-size: 15px; margin-right: 8px; }

/* Mobile */
.mobile-toggle {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 1050;
    width: 42px; height: 42px; border-radius: 10px;
    background: #102019; border: 1px solid var(--line); color: var(--gold); font-size: 20px;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 1030; }

@media (max-width: 991.98px) {
    .mobile-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }
    .main-content { margin-left: 0; padding: 66px 14px 60px; }
    .app-footer { margin-left: 0; padding: 10px 14px; }
    .page-title { font-size: 19px; }
    .prayer-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .prayer .w { font-size: 17px; }
    .prayer .n { font-size: 11.5px; }
    .info-grid, .fin-grid { grid-template-columns: 1fr; gap: 0 0; }
    .info-grid .v, .fin-grid .v { margin-bottom: 8px; text-align: left; }
    .table-app { font-size: 13px; }
}
@media (max-width: 420px) {
    .prayer-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Cetak (Histori Jum'at, Info Jum'at, Laporan) */
@media print {
    body { background: #fff !important; color: #000 !important; font-size: 12px; }
    .sidebar, .mobile-toggle, .sidebar-overlay, .app-footer, .no-print, .page-actions, .aksi, .alert-flash { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .panel, .table-wrap { border: none; background: #fff; padding: 0; }
    .table-app, .table-app td, .table-app th { color: #000 !important; background: #fff !important; border-color: #999 !important; }
    .page-title, .text-gold, .info-grid .l, .info-grid .v, .fin-grid .l, .fin-grid .v { color: #000 !important; }
    .print-only { display: block !important; }
    a { color: #000; text-decoration: none; }
}
.print-only { display: none; }

/* === Judul tabel tetap terlihat saat scroll (digeser oleh app.js, semua ukuran layar) === */
.table-wrap { overflow-x: auto !important; overflow-y: hidden !important; max-height: none !important; }
.table-app thead th { position: relative !important; top: auto !important; z-index: 5; box-shadow: 0 2px 0 var(--gold); }
@media print { .table-app thead th { transform: none !important; } }

/* === Judul halaman + filter tetap di atas saat scroll === */
.page-head { position: sticky; top: 0; z-index: 20; background: var(--bg); margin: -10px -28px 18px; padding: 10px 28px 12px; border-bottom: 1px solid var(--line); }
@media (max-width: 991.98px) { .page-head { margin: -8px -14px 14px; padding: 8px 14px 10px 62px; min-height: 58px; } }
@media print { .page-head { position: static; border: 0; } }
