<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>@yield('title', 'Admin') — Sistem Zakat Warga</title>
    {{-- DNS prefetch untuk mempercepat resolusi domain --}}
    <link rel="dns-prefetch" href="//fonts.googleapis.com">
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link rel="dns-prefetch" href="//cdn.jsdelivr.net">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    {{-- NProgress CSS (local) --}}
    <link rel="stylesheet" href="{{ asset('css/nprogress.css') }}">
    {{-- Google Fonts: non-blocking via media trick --}}
    <link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap">
    <noscript><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap"></noscript>
    {{-- Bootstrap Icons: non-blocking --}}
    <link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
    <noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css"></noscript>
    {{-- Chart.js HANYA dimuat di halaman yang membutuhkan (via @push) --}}
    <style>
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        :root {
            --green-primary: #1a6b3c;
            --green-light:   #e8f5ee;
            --green-mid:     #2e8b57;
            --green-hover:   #f0faf4;
            --sidebar-w:     220px;
            --topbar-h:      64px;
            --text-dark:     #111827;
            --text-muted:    #6b7280;
            --border-color:  #e5e7eb;
            --bg-page:       #f9fafb;
            --white:         #ffffff;
            --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
            --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
            --radius:        12px;
        }

        body {
            font-family: 'Inter', sans-serif;
            background: var(--bg-page);
            color: var(--text-dark);
            min-height: 100vh;
            display: flex;
        }

        /* ===== SIDEBAR OVERLAY (Mobile) ===== */
        .sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.45);
            z-index: 99;
            opacity: 0;
            transition: opacity .25s ease;
        }
        .sidebar-overlay.active {
            display: block;
            opacity: 1;
        }

        /* ===== SIDEBAR ===== */
        .sidebar {
            width: var(--sidebar-w);
            min-height: 100vh;
            background: var(--white);
            border-right: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            position: fixed;
            top: 0; left: 0; bottom: 0;
            z-index: 100;
            transition: transform .25s ease;
        }

        .sidebar-logo {
            padding: 18px 16px 14px;
            display: flex;
            align-items: center;
            gap: 10px;
            border-bottom: 1px solid var(--border-color);
        }
        .sidebar-logo-icon {
            width: 36px; height: 36px;
            background: var(--green-primary);
            border-radius: 10px;
            display: flex; align-items: center; justify-content: center;
            color: white; font-size: 18px; flex-shrink: 0;
        }
        .sidebar-logo-text { line-height: 1.2; }
        .sidebar-logo-title {
            font-size: 14px; font-weight: 700;
            color: var(--green-primary); letter-spacing: -0.3px;
        }
        .sidebar-logo-sub { font-size: 11px; color: var(--text-muted); }

        .sidebar-nav {
            flex: 1;
            padding: 12px;
            overflow-y: auto;
        }

        .sidebar-section-label {
            font-size: 10px; font-weight: 600; letter-spacing: 0.8px;
            color: var(--text-muted); text-transform: uppercase;
            padding: 8px 8px 4px;
        }

        .nav-item {
            display: flex; align-items: center;
            gap: 10px;
            padding: 9px 12px;
            border-radius: 8px;
            font-size: 13.5px; font-weight: 500;
            color: var(--text-muted);
            text-decoration: none;
            transition: all .15s ease;
            margin-bottom: 2px;
        }
        .nav-item i { font-size: 16px; flex-shrink: 0; }
        .nav-item:hover { background: var(--green-hover); color: var(--green-primary); }
        .nav-item.active {
            background: var(--green-light);
            color: var(--green-primary);
            font-weight: 600;
        }

        .sidebar-footer {
            padding: 12px;
            border-top: 1px solid var(--border-color);
        }
        /* Tombol logout menggunakan form POST (CSRF aman) */
        .sidebar-logout-form { margin: 0; }
        .sidebar-logout {
            display: flex; align-items: center; gap: 10px;
            width: 100%; padding: 9px 12px;
            border-radius: 8px;
            font-size: 13.5px; font-weight: 500;
            color: #ef4444;
            background: none; border: none;
            cursor: pointer;
            transition: background .15s ease;
            text-align: left;
        }
        .sidebar-logout:hover { background: #fef2f2; color: #dc2626; }

        /* ===== MAIN AREA ===== */
        .main-area {
            margin-left: var(--sidebar-w);
            flex: 1;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            min-width: 0;
        }

        /* ===== TOPBAR ===== */
        .topbar {
            height: var(--topbar-h);
            background: var(--white);
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 24px;
            position: sticky; top: 0; z-index: 50;
            gap: 12px;
        }

        .topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

        /* Hamburger Button — tampil di mobile */
        .hamburger-btn {
            display: none;
            align-items: center; justify-content: center;
            width: 36px; height: 36px;
            border: 1px solid var(--border-color);
            background: var(--white);
            border-radius: 8px;
            cursor: pointer; font-size: 18px;
            color: var(--text-dark);
            flex-shrink: 0;
            transition: background .15s;
        }
        .hamburger-btn:hover { background: var(--bg-page); }

        .topbar-title {
            font-size: 15px; font-weight: 600;
            color: var(--text-dark);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }

        .topbar-right {
            display: flex; align-items: center; gap: 12px; flex-shrink: 0;
        }

        .topbar-date {
            display: flex; align-items: center; gap: 7px;
            background: var(--bg-page);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 6px 12px;
            font-size: 12.5px; color: var(--text-muted); font-weight: 500;
            white-space: nowrap;
        }
        .topbar-date i { font-size: 13px; }

        .topbar-icon-btn {
            width: 36px; height: 36px;
            border-radius: 8px;
            border: 1px solid var(--border-color);
            background: var(--white);
            display: flex; align-items: center; justify-content: center;
            color: var(--text-muted); font-size: 16px;
            cursor: pointer; transition: all .15s;
            text-decoration: none; flex-shrink: 0;
        }
        .topbar-icon-btn:hover { background: var(--bg-page); color: var(--text-dark); }

        .topbar-avatar {
            width: 36px; height: 36px;
            border-radius: 50%;
            background: var(--green-primary);
            color: white;
            display: flex; align-items: center; justify-content: center;
            font-size: 13px; font-weight: 700;
            cursor: pointer; flex-shrink: 0;
        }

        .topbar-user { text-align: right; line-height: 1.3; }
        .topbar-user-name { font-size: 13px; font-weight: 600; color: var(--text-dark); }
        .topbar-user-role { font-size: 11px; color: var(--text-muted); }

        /* ===== PAGE CONTENT ===== */
        .page-content {
            padding: 28px;
            flex: 1;
        }

        .page-header {
            display: flex; align-items: flex-start; justify-content: space-between;
            margin-bottom: 24px;
            gap: 12px;
        }
        .page-header-left h1 {
            font-size: 24px; font-weight: 800; color: var(--text-dark);
            letter-spacing: -0.5px; margin-bottom: 4px;
        }
        .page-header-left p { font-size: 13.5px; color: var(--text-muted); margin: 0; }

        /* ===== CARD ===== */
        .card {
            background: var(--white);
            border: 1px solid var(--border-color);
            border-radius: var(--radius);
            box-shadow: var(--shadow-sm);
        }

        /* ===== STAT CARD ===== */
        .stat-card {
            background: var(--white);
            border: 1px solid var(--border-color);
            border-radius: var(--radius);
            padding: 20px;
            box-shadow: var(--shadow-sm);
        }
        .stat-card-label {
            font-size: 11.5px; font-weight: 600;
            color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
            margin-bottom: 8px;
        }
        .stat-card-value {
            font-size: 28px; font-weight: 800;
            color: var(--text-dark); letter-spacing: -0.5px;
        }
        .stat-card-icon {
            width: 40px; height: 40px;
            border-radius: 10px;
            display: flex; align-items: center; justify-content: center;
            font-size: 20px; flex-shrink: 0;
        }
        .stat-card-top {
            display: flex; justify-content: space-between; align-items: flex-start;
            margin-bottom: 12px;
        }

        /* ===== BUTTONS ===== */
        .btn-primary-green {
            display: inline-flex; align-items: center; gap: 6px;
            background: var(--green-primary); color: white;
            border: none; border-radius: 8px;
            padding: 9px 16px;
            font-size: 13.5px; font-weight: 600;
            cursor: pointer; text-decoration: none;
            transition: background .15s;
            white-space: nowrap;
        }
        .btn-primary-green:hover { background: var(--green-mid); color: white; }

        .btn-outline {
            display: inline-flex; align-items: center; gap: 6px;
            background: white; color: var(--text-dark);
            border: 1px solid var(--border-color); border-radius: 8px;
            padding: 8px 14px;
            font-size: 13px; font-weight: 500;
            cursor: pointer; text-decoration: none;
            transition: all .15s; white-space: nowrap;
        }
        .btn-outline:hover { background: var(--bg-page); color: var(--text-dark); }

        .btn-outline-green {
            display: inline-flex; align-items: center; gap: 6px;
            background: white; color: var(--green-primary);
            border: 1px solid var(--green-primary); border-radius: 8px;
            padding: 8px 14px;
            font-size: 13px; font-weight: 600;
            cursor: pointer; text-decoration: none;
            transition: all .15s; white-space: nowrap;
        }
        .btn-outline-green:hover { background: var(--green-light); }

        /* ===== TABLE — Responsif dengan horizontal scroll ===== */
        .table-responsive {
            width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        .data-table {
            width: 100%; border-collapse: collapse;
            min-width: 600px; /* Pastikan tabel tidak terlalu sempit */
        }
        .data-table thead th {
            font-size: 11px; font-weight: 600; text-transform: uppercase;
            letter-spacing: 0.6px; color: var(--text-muted);
            padding: 10px 16px;
            border-bottom: 1px solid var(--border-color);
            background: #fafafa;
            white-space: nowrap;
        }
        .data-table thead th:first-child { border-radius: 0; }
        .data-table tbody td {
            padding: 14px 16px;
            font-size: 13.5px; color: var(--text-dark);
            border-bottom: 1px solid var(--border-color);
            vertical-align: middle;
        }
        .data-table tbody tr:last-child td { border-bottom: none; }
        .data-table tbody tr:hover { background: var(--bg-page); }

        /* ===== AVATAR ===== */
        .avatar-initial {
            width: 34px; height: 34px;
            border-radius: 50%;
            background: var(--green-light);
            color: var(--green-primary);
            display: inline-flex; align-items: center; justify-content: center;
            font-size: 12px; font-weight: 700; flex-shrink: 0;
        }
        .avatar-photo {
            width: 34px; height: 34px;
            border-radius: 50%; object-fit: cover; flex-shrink: 0;
        }

        /* ===== BADGE ===== */
        .badge-pill {
            display: inline-block;
            padding: 3px 10px;
            border-radius: 20px;
            font-size: 12px; font-weight: 600;
        }
        .badge-fakir   { background: #fee2e2; color: #dc2626; }
        .badge-miskin  { background: #fef3c7; color: #d97706; }
        .badge-gharim  { background: #dbeafe; color: #2563eb; }
        .badge-sabil   { background: #d1fae5; color: #059669; }
        .badge-amil-cat { background: #ede9fe; color: #7c3aed; }
        .badge-green   { background: var(--green-light); color: var(--green-primary); }
        .badge-orange  { background: #fff7ed; color: #ea580c; }
        .badge-gray    { background: #f3f4f6; color: #374151; }
        .badge-blue    { background: #eff6ff; color: #2563eb; }
        .badge-red     { background: #fee2e2; color: #ef4444; }

        /* ===== TOGGLE ===== */
        .toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; }
        .toggle-switch input { display: none; }
        .toggle-slider {
            position: absolute; inset: 0;
            background: #d1d5db; border-radius: 24px;
            cursor: pointer; transition: .2s;
        }
        .toggle-slider:before {
            content: ''; position: absolute;
            width: 18px; height: 18px;
            border-radius: 50%; background: white;
            top: 3px; left: 3px; transition: .2s;
            box-shadow: 0 1px 3px rgba(0,0,0,.2);
        }
        .toggle-switch input:checked + .toggle-slider { background: var(--green-primary); }
        .toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

        /* ===== PAGINATION ===== */
        .pagination-wrap {
            display: flex; align-items: center; justify-content: space-between;
            padding: 14px 16px;
            border-top: 1px solid var(--border-color);
            font-size: 13px; color: var(--text-muted);
            flex-wrap: wrap; gap: 8px;
        }
        .pagination-btns { display: flex; gap: 6px; }
        .page-btn {
            width: 32px; height: 32px;
            border-radius: 6px;
            border: 1px solid var(--border-color);
            background: white; color: var(--text-dark);
            font-size: 13px; font-weight: 500;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            text-decoration: none; transition: all .15s;
        }
        .page-btn:hover { background: var(--bg-page); }
        .page-btn.active { background: var(--green-primary); color: white; border-color: var(--green-primary); }
        .page-btn:disabled { opacity: 0.4; cursor: default; }

        /* ===== FORM CONTROLS ===== */
        .form-ctrl {
            width: 100%; padding: 9px 12px;
            border: 1px solid var(--border-color); border-radius: 8px;
            font-size: 13.5px; font-family: 'Inter', sans-serif;
            color: var(--text-dark); background: white;
            transition: border-color .15s;
            appearance: none;
        }
        .form-ctrl:focus {
            outline: none; border-color: var(--green-primary);
            box-shadow: 0 0 0 3px rgba(26,107,60,.1);
        }
        .form-label-styled {
            display: block; font-size: 12.5px; font-weight: 600;
            color: var(--text-dark); margin-bottom: 6px;
        }

        /* ===== ALERT / BANNER ===== */
        .banner-info {
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            border-radius: var(--radius);
            padding: 16px 20px;
            display: flex; align-items: flex-start; gap: 12px;
            margin-bottom: 24px; position: relative;
        }
        .banner-info-icon { color: var(--green-primary); font-size: 18px; flex-shrink: 0; margin-top: 1px; }
        .banner-info-title { font-size: 14px; font-weight: 700; color: var(--green-primary); margin-bottom: 3px; }
        .banner-info-text { font-size: 13px; color: #166534; line-height: 1.5; }
        .banner-close {
            position: absolute; top: 12px; right: 14px;
            background: none; border: none; cursor: pointer;
            color: var(--text-muted); font-size: 16px;
        }
        .banner-close:hover { color: var(--text-dark); }

        /* ===== TABS ===== */
        .tab-list {
            display: flex; gap: 0;
            border-bottom: 2px solid var(--border-color);
            margin-bottom: 20px;
            overflow-x: auto;
        }
        .tab-btn {
            padding: 10px 18px;
            font-size: 14px; font-weight: 500;
            color: var(--text-muted);
            border: none; background: none;
            cursor: pointer;
            border-bottom: 2px solid transparent;
            margin-bottom: -2px;
            transition: all .15s;
            white-space: nowrap;
        }
        .tab-btn.active {
            color: var(--green-primary); font-weight: 600;
            border-bottom-color: var(--green-primary);
        }

        /* ===== SEARCH & FILTER ===== */
        .search-wrap { position: relative; }
        .search-wrap i {
            position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
            color: var(--text-muted); font-size: 15px; pointer-events: none;
        }
        .search-input {
            width: 100%; padding: 9px 12px 9px 36px;
            border: 1px solid var(--border-color); border-radius: 8px;
            font-size: 13.5px; font-family: 'Inter', sans-serif;
            color: var(--text-dark); background: white;
            transition: border-color .15s;
        }
        .search-input:focus {
            outline: none; border-color: var(--green-primary);
            box-shadow: 0 0 0 3px rgba(26,107,60,.1);
        }

        /* ===== FILTER GRID ===== */
        .filter-grid {
            display: grid; gap: 12px;
            grid-template-columns: 1fr 1fr 1fr;
            margin-bottom: 14px;
        }
        .filter-grid-2 { grid-template-columns: 1fr 1fr; }

        /* ===== SELECT DROPDOWN ===== */
        .select-wrap { position: relative; }
        .select-wrap::after {
            content: '\F282';
            font-family: 'Bootstrap-icons';
            position: absolute; right: 12px; top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted); pointer-events: none; font-size: 12px;
        }
        .select-wrap select { padding-right: 32px; }

        /* ===== ACTION BUTTONS ===== */
        .action-dots {
            width: 30px; height: 30px;
            border-radius: 6px;
            border: 1px solid var(--border-color);
            background: white;
            display: flex; align-items: center; justify-content: center;
            cursor: pointer; font-size: 16px; color: var(--text-muted);
            transition: all .15s; position: relative;
        }
        .action-dots:hover { background: var(--bg-page); color: var(--text-dark); }
        .action-icon-btn {
            width: 30px; height: 30px;
            border-radius: 6px;
            border: none; background: none;
            display: inline-flex; align-items: center; justify-content: center;
            cursor: pointer; font-size: 17px;
            transition: all .15s; text-decoration: none;
        }
        .action-icon-btn.edit { color: var(--green-primary); }
        .action-icon-btn.edit:hover { background: var(--green-light); }
        .action-icon-btn.del { color: #ef4444; }
        .action-icon-btn.del:hover { background: #fee2e2; }

        /* ===== DROPDOWN MENU ===== */
        .dropdown-menu-custom {
            position: absolute; right: 0; top: 36px;
            background: white;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            box-shadow: var(--shadow-md);
            min-width: 160px; z-index: 200;
            display: none; overflow: hidden;
        }
        .dropdown-menu-custom.show { display: block; }
        .dropdown-menu-custom a, .dropdown-menu-custom button {
            display: flex; align-items: center; gap: 8px;
            padding: 9px 14px;
            font-size: 13px; color: var(--text-dark);
            text-decoration: none;
            background: none; border: none; width: 100%; text-align: left;
            cursor: pointer; transition: background .1s;
        }
        .dropdown-menu-custom a:hover, .dropdown-menu-custom button:hover { background: var(--bg-page); }
        .dropdown-menu-custom .del-item { color: #ef4444; }
        .dropdown-menu-custom .del-item:hover { background: #fee2e2; }

        /* ===== ALERT SUCCESS ===== */
        .alert-success-custom {
            background: #f0fdf4; border: 1px solid #bbf7d0;
            border-radius: 8px; padding: 12px 16px;
            font-size: 13.5px; color: #166534;
            display: flex; align-items: center; gap: 10px;
            margin-bottom: 20px;
        }

        /* =============================================
           RESPONSIVE — MOBILE FIRST
           ============================================= */

        /* Tablet: ≤ 1024px */
        @media (max-width: 1024px) {
            .filter-grid { grid-template-columns: 1fr 1fr; }
            .topbar-date { display: none; } /* hemat ruang di tablet kecil */
        }

        /* Mobile: ≤ 768px */
        @media (max-width: 768px) {
            /* Sidebar tersembunyi di luar layar */
            .sidebar { transform: translateX(-100%); }
            .sidebar.open { transform: translateX(0); }

            /* Main area penuh */
            .main-area { margin-left: 0; }

            /* Hamburger button tampil */
            .hamburger-btn { display: flex; }

            /* Topbar lebih kompak */
            .topbar { padding: 0 16px; }
            .topbar-title { font-size: 14px; }

            /* Sembunyikan info user di topbar (ada di sidebar) */
            .topbar-user-info { display: none; }

            /* Page content padding lebih kecil */
            .page-content { padding: 16px; }

            /* Page header: stack vertikal */
            .page-header {
                flex-direction: column;
                align-items: stretch;
                gap: 12px;
            }
            .page-header-left h1 { font-size: 20px; }

            /* Filter grid: 1 kolom */
            .filter-grid { grid-template-columns: 1fr; }
            .filter-grid-2 { grid-template-columns: 1fr; }

            /* Pagination: stack */
            .pagination-wrap { flex-direction: column; align-items: flex-start; }
        }

        /* Small Mobile: ≤ 480px */
        @media (max-width: 480px) {
            .topbar-icon-btn.hide-xs { display: none; }
            .page-content { padding: 12px; }
            .page-header-left h1 { font-size: 18px; }
        }

        /* ===== PAGE TRANSITION ===== */
        .page-content {
            transition: opacity 0.15s ease;
        }

        /* ===== NPROGRESS CUSTOM ===== */
        #nprogress .bar {
            background: var(--green-primary) !important;
            height: 3px !important;
        }
        #nprogress .peg {
            box-shadow: 0 0 10px var(--green-primary), 0 0 5px var(--green-primary) !important;
        }
    </style>
    @stack('styles')
</head>
<body>

<!-- ===== SIDEBAR OVERLAY (Mobile) ===== -->
<div class="sidebar-overlay" id="sidebarOverlay" onclick="closeSidebar()"></div>

<!-- ===== SIDEBAR ===== -->
<aside class="sidebar" id="mainSidebar">

    <!-- Logo -->
    <div class="sidebar-logo">
        <div class="sidebar-logo-icon"><i class="bi bi-moon-stars-fill"></i></div>
        <div class="sidebar-logo-text">
            <div class="sidebar-logo-title">Zakat Warga</div>
            <div class="sidebar-logo-sub">Admin Masjid</div>
        </div>
    </div>

    <nav class="sidebar-nav">
        <div class="sidebar-section-label">Menu Utama</div>
        <a href="{{ url('/admin/dashboard') }}"
           class="nav-item {{ request()->is('admin/dashboard') ? 'active' : '' }}">
            <i class="bi bi-grid-1x2-fill"></i> Dashboard
        </a>
        <a href="{{ url('/admin/user') }}"
           class="nav-item {{ request()->is('admin/user*') ? 'active' : '' }}">
            <i class="bi bi-person-lines-fill"></i> Kelola User
        </a>
        <a href="{{ url('/admin/wilayah') }}"
           class="nav-item {{ request()->is('admin/wilayah*') ? 'active' : '' }}">
            <i class="bi bi-map-fill"></i> Kelola Wilayah
        </a>
        <a href="{{ url('/admin/laporan') }}"
           class="nav-item {{ request()->is('admin/laporan*') ? 'active' : '' }}">
            <i class="bi bi-person-vcard-fill"></i> Laporan Mustahik
        </a>
        <a href="{{ url('/admin/rekap-zakat') }}"
           class="nav-item {{ request()->is('admin/rekap-zakat*') ? 'active' : '' }}">
            <i class="bi bi-receipt-cutoff"></i> Rekap Zakat
        </a>
    </nav>

    <div class="sidebar-footer">
        <form method="POST" action="{{ route('logout') }}" class="sidebar-logout-form">
            @csrf
            <button type="submit" class="sidebar-logout">
                <i class="bi bi-box-arrow-right"></i> Keluar
            </button>
        </form>
    </div>
</aside>

<!-- ===== MAIN AREA ===== -->
<div class="main-area">

    <!-- TOPBAR -->
    <header class="topbar">
        <div class="topbar-left">
            <button class="hamburger-btn" id="hamburgerBtn" onclick="openSidebar()" aria-label="Buka menu">
                <i class="bi bi-list"></i>
            </button>
            <div class="topbar-title">
                @yield('topbar_title', 'Dashboard') &mdash; <span style="color: var(--green-primary);">{{ Auth::user()->masjid->nama_masjid ?? 'Masjid' }}</span>
            </div>
        </div>
        <div class="topbar-right">
            <div class="topbar-date">
                <i class="bi bi-calendar3"></i>
                <span id="dateDisplay">—</span>
            </div>
            <div class="topbar-icon-btn hide-xs"><i class="bi bi-bell"></i></div>
            <div class="topbar-icon-btn hide-xs"><i class="bi bi-gear"></i></div>
            <div style="display:flex;align-items:center;gap:8px;" class="topbar-user-info">
                <div class="topbar-user">
                    <div class="topbar-user-name">{{ Auth::user()->nama_user }}</div>
                    <div class="topbar-user-role">{{ ucfirst(str_replace('_', ' ', Auth::user()->int_role)) }}</div>
                </div>
                <div class="topbar-avatar" style="overflow: hidden;"><img src="https://avatar.iran.liara.run/public/boy" alt="Avatar" style="width: 100%; height: 100%; object-fit: cover;"></div>
            </div>
        </div>
    </header>

    <!-- PAGE CONTENT -->
    <main class="page-content">
        @if(session('success'))
            <div class="alert-success-custom">
                <i class="bi bi-check-circle-fill" style="font-size:16px;"></i>
                {{ session('success') }}
            </div>
        @endif

        @yield('content')
        
        {{-- Modals rendered inside so fast-nav can update them --}}
        @yield('modals')
        
        {{-- Page-specific scripts rendered inside so fast-nav can evaluate them --}}
        @stack('scripts')
    </main>
</div>

<script>
// ===== Hamburger Sidebar Toggle =====
function openSidebar() {
    document.getElementById('mainSidebar').classList.add('open');
    document.getElementById('sidebarOverlay').classList.add('active');
    document.body.style.overflow = 'hidden';
}
function closeSidebar() {
    document.getElementById('mainSidebar').classList.remove('open');
    document.getElementById('sidebarOverlay').classList.remove('active');
    document.body.style.overflow = '';
}
// Tutup sidebar saat tekan Escape
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') closeSidebar();
});

// ===== Tanggal Masehi & Hijriah =====
(function() {
    const today = new Date();
    const masehi = today.toLocaleDateString('id-ID', { day: '2-digit', month: 'short', year: 'numeric' });
    const hijriMonths = ['Muharram','Safar','Rabiul Awal','Rabiul Akhir','Jumadil Awal','Jumadil Akhir','Rajab','Syaban','Ramadan','Syawal','Zulkaidah','Zulhijjah'];
    const jd = Math.floor((today.getTime() / 86400000) + 2440587.5);
    const l = jd - 1948440 + 10632;
    const n = Math.floor((l - 1) / 10631);
    const ll = l - 10631 * n + 354;
    const j = Math.floor((10985 - ll) / 5316) * Math.floor((50 * ll) / 17719) + Math.floor(ll / 5670) * Math.floor((43 * ll) / 15238);
    const lll = ll - Math.floor((30 - j) / 15) * Math.floor((17719 * j) / 50) - Math.floor(j / 16) * Math.floor((15238 * j) / 43) + 29;
    const m = Math.floor((24 * lll) / 709);
    const d = lll - Math.floor((709 * m) / 24);
    const y = 30 * n + j - 30;
    const hijriStr = `${d} ${hijriMonths[m - 1] ?? ''} ${y}H`;
    document.getElementById('dateDisplay').textContent = `${masehi} / ${hijriStr}`;
})();
</script>



{{-- NProgress + Fast Navigation (tanpa reload) --}}
<script src="{{ asset('js/nprogress.min.js') }}"></script>
<script>
// NProgress untuk form POST (hapus, simpan, dll)
document.addEventListener('submit', function(e) {
    var form = e.target;
    if (form.method && form.method.toLowerCase() === 'post') {
        if (typeof NProgress !== 'undefined') NProgress.start();
    }
});
</script>
<script src="{{ asset('js/fast-nav.js') }}"></script>
</body>
</html>
