<!DOCTYPE html>
<html lang="id">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard - Pendakian</title>

    
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js"></script>
    
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Sora:wght@400;600;700&display=swap" rel="stylesheet">

    
    <?php echo app('Illuminate\Foundation\Vite')(['resources/css/app.css', 'resources/js/app.js']); ?>

    <style>
        /* ── ROOT VARIABLES ── */
        :root {
            --bg-base:      #0d1117;
            --bg-surface:   #161b22;
            --bg-elevated:  #1c2330;
            --bg-card:      #21262d;
            --border:       #30363d;
            --border-light: #3d444d;
            --accent-green:  #3fb950;
            --accent-teal:   #39d0c8;
            --accent-blue:   #58a6ff;
            --accent-amber:  #e3b341;
            --accent-red:    #f85149;
            --accent-purple: #bc8cff;
            --text-primary:   #e6edf3;
            --text-secondary: #8b949e;
            --text-muted:     #6e7681;
            --sidebar-w:    240px;
        }

        /* INTEGRASI MODAL (TAMBAHAN) */
        .modal-backdrop {
            z-index: 1050 !important;
        }
        .modal.show {
            display: block !important;
            background: rgba(0, 0, 0, 0.7);
            z-index: 1060 !important;
        }

        /* ── BASE ── */
        body {
            font-family: 'Plus Jakarta Sans', sans-serif;
            background: var(--bg-base);
            color: var(--text-primary);
            min-height: 100vh;
        }

        /* ── SIDEBAR ── */
        #sidebar {
            width: var(--sidebar-w);
            background: var(--bg-surface);
            border-right: 1px solid var(--border);
            position: fixed;
            top: 0; left: 0;
            height: 100vh;
            z-index: 1040;
            display: flex;
            flex-direction: column;
            transition: transform .3s ease;
        }

        #sidebarOverlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,.6);
            backdrop-filter: blur(2px);
            z-index: 1030;
            opacity: 0;
            transition: opacity .3s ease;
        }
        #sidebarOverlay.active { display: block; opacity: 1; }

        .sidebar-logo {
            padding: 24px 20px 20px;
            border-bottom: 1px solid var(--border);
        }
        .logo-icon {
            width: 36px; height: 36px;
            background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
            border-radius: 10px;
            display: grid; place-items: center;
            font-size: 18px;
        }
        .logo-text {
            font-family: 'Sora', sans-serif;
            font-size: 15px; font-weight: 700;
            color: var(--text-primary);
        }
        .logo-sub {
            font-size: 10px; color: var(--text-muted);
            letter-spacing: 1.5px; text-transform: uppercase;
        }

        /* Sidebar nav items */
        .sidebar-nav { padding: 20px 12px; flex: 1; overflow-y: auto; }
        .nav-section-label {
            font-size: 10px; font-weight: 600;
            letter-spacing: 1.8px; text-transform: uppercase;
            color: var(--text-muted);
            padding: 0 8px; margin: 16px 0 8px;
        }
        .sidebar-link {
            display: flex; align-items: center; gap: 10px;
            padding: 9px 12px; border-radius: 8px;
            font-size: 13.5px; font-weight: 500;
            color: var(--text-secondary);
            text-decoration: none;
            transition: all .18s ease;
            margin-bottom: 2px;
        }
        .sidebar-link:hover { background: var(--bg-elevated); color: var(--text-primary); }
        .sidebar-link.active { background: rgba(57,208,200,.12); color: var(--accent-teal); }
        .sidebar-link .nav-icon { font-size: 16px; width: 20px; text-align: center; }

        .sidebar-footer {
            padding: 16px 12px;
            border-top: 1px solid var(--border);
        }
        .logout-btn {
            display: flex; align-items: center; gap: 10px;
            padding: 9px 12px; border-radius: 8px;
            font-size: 13px; font-weight: 500;
            color: var(--accent-red);
            background: none; border: none; width: 100%;
            font-family: inherit; cursor: pointer;
            transition: background .18s;
        }
        .logout-btn:hover { background: rgba(248,81,73,.1); }

        /* ── MAIN WRAPPER ── */
        #mainWrapper {
            margin-left: var(--sidebar-w);
            min-height: 100vh;
            display: flex; flex-direction: column;
        }

        /* ── TOPBAR ── */
        .topbar {
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border);
            height: 64px;
            position: sticky; top: 0; z-index: 1020;
            padding: 0 28px;
        }
        .user-chip {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 6px 12px 6px 6px;
            cursor: pointer;
            transition: border-color .18s;
        }
        .user-chip:hover { border-color: var(--border-light); }
        .user-avatar {
            width: 30px; height: 30px; border-radius: 8px;
            background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
            display: grid; place-items: center;
            font-size: 12px; font-weight: 700; color: #fff;
        }
        .user-name  { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1; }
        .user-role  { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

        /* PERBAIKAN NOTIFIKASI AGAR PERSIS LOKET */
        .notif-wrap { position: relative; }
        .notif-icon-btn {
            width: 36px; height: 36px; border-radius: 8px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            display: grid; place-items: center;
            color: var(--text-secondary); font-size: 18px;
            transition: all .18s;
            cursor: pointer;
        }
        .notif-icon-btn:hover { border-color: var(--accent-teal); color: var(--accent-teal); }
        .notif-badge {
            position: absolute; top: -5px; right: -5px;
            background: var(--accent-red); color: #fff;
            border-radius: 50%; padding: 2px 5px;
            font-size: 10px; font-weight: 700;
            border: 2px solid var(--bg-surface);
            pointer-events: none;
        }
        .notif-dropdown {
            display: none;
            position: absolute; top: 45px; right: 0;
            width: 300px;
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: 12px; 
            z-index: 9999; /* Z-INDEX TINGGI AGAR TIDAK TERHALANG */
            box-shadow: 0 16px 48px rgba(0,0,0,.7);
            overflow: hidden;
        }
        .notif-dropdown-header {
            padding: 14px;
            background: rgba(248,81,73,.1);
            border-bottom: 1px solid var(--border);
            font-weight: 700; color: var(--accent-red);
            font-size: 13px;
        }
        .notif-dropdown-body { max-height: 350px; overflow-y: auto; }
        .notif-item { padding: 12px; border-bottom: 1px solid var(--bg-card); transition: background .2s; }
        .notif-item:hover { background: var(--bg-elevated); }
        .notif-item-name { color: #fff; font-weight: 600; font-size: 13.5px; }
        .notif-item-sub  { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

        .shake { animation: shake .5s infinite; }
        @keyframes shake { 0%,100%{transform:rotate(0);} 25%{transform:rotate(10deg);} 75%{transform:rotate(-10deg);} }

        /* ── CONTENT AREA ── */
        .content-area { padding: 28px; flex: 1; }
        .page-title {
            font-family: 'Sora', sans-serif;
            font-size: 22px; font-weight: 700; color: var(--text-primary);
        }
        .page-subtitle { font-size: 13px; color: var(--text-muted); }

        /* ── STAT CARDS ── */
        .stat-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 20px;
            position: relative; overflow: hidden;
            transition: border-color .2s, transform .2s;
            cursor: default;
        }
        .stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
        .stat-card::before {
            content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
        }
        .stat-card.green::before { background: var(--accent-green); }
        .stat-card.teal::before  { background: var(--accent-teal); }
        .stat-card.blue::before  { background: var(--accent-blue); }
        .stat-card.amber::before { background: var(--accent-amber); }

        .stat-label {
            font-size: 11.5px; font-weight: 600;
            letter-spacing: .6px; text-transform: uppercase;
            color: var(--text-muted);
        }
        .stat-icon {
            width: 34px; height: 34px; border-radius: 9px;
            display: grid; place-items: center; font-size: 16px;
        }
        .stat-card.green .stat-icon { background: rgba(63,185,80,.15);  color: var(--accent-green); }
        .stat-card.teal  .stat-icon { background: rgba(57,208,200,.15); color: var(--accent-teal); }
        .stat-card.blue  .stat-icon { background: rgba(88,166,255,.15); color: var(--accent-blue); }
        .stat-card.amber .stat-icon { background: rgba(227,179,65,.15); color: var(--accent-amber); }

        .stat-value {
            font-family: 'Sora', sans-serif;
            font-size: 26px; font-weight: 700;
            color: var(--text-primary); line-height: 1; margin-bottom: 6px;
        }

        /* ── CHART CARDS ── */
        .chart-card {
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 22px;
            min-width: 0;
        }
        .chart-title    { font-size: 14px; font-weight: 700; color: var(--text-primary); }
        .chart-subtitle { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
        .chart-badge {
            font-size: 11px; font-weight: 600;
            padding: 3px 9px; border-radius: 20px;
        }
        .chart-badge.teal { background: rgba(57,208,200,.15); color: var(--accent-teal); }
        .chart-badge.blue { background: rgba(88,166,255,.15); color: var(--accent-blue); }
        .chart-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 10px; }
        .chart-wrap { position: relative; height: 250px; min-width: 500px; width: 100%; }

        /* ── TABLE CARD ── */
        .table-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 14px;
            overflow: hidden;
        }
        .table-card-header {
            border-bottom: 1px solid var(--border);
            padding: 20px 22px;
        }
        .table-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
        .table-desc  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

        .search-box {
            display: flex; align-items: center; gap: 8px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: 8px; padding: 7px 12px;
            transition: border-color .18s;
        }
        .search-box:focus-within { border-color: var(--accent-teal); }
        .search-box input {
            background: none; border: none; outline: none;
            font-family: inherit; font-size: 13px;
            color: var(--text-primary); width: 180px;
        }

        /* Override Bootstrap table for dark theme */
        .dark-table {
            width: 100%;
            border-collapse: collapse;
            min-width: 800px;
            color: var(--text-secondary);
        }
        .dark-table thead th {
            background: var(--bg-elevated);
            padding: 11px 22px;
            font-size: 11px; font-weight: 600;
            letter-spacing: 1px; text-transform: uppercase;
            color: var(--text-muted);
            border-bottom: 1px solid var(--border);
            white-space: nowrap; border-top: none;
        }
        .dark-table tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
        .dark-table tbody tr:hover { background: var(--bg-elevated); }
        .dark-table tbody td { padding: 13px 22px; font-size: 13.5px; white-space: nowrap; border: none; }

        .td-name { display: flex; align-items: center; gap: 10px; }
        .avatar-sm {
            width: 30px; height: 30px; border-radius: 8px;
            display: grid; place-items: center;
            font-size: 12px; font-weight: 700;
            flex-shrink: 0; color: #fff;
        }
        .av-2 { background: linear-gradient(135deg, #3fb950, #39d0c8); }
        .av-3 { background: linear-gradient(135deg, #e3b341, #f85149); }

        .name-text   { font-weight: 600; color: var(--text-primary); }
        .badge-origin {
            display: inline-block; padding: 2px 8px; border-radius: 20px;
            font-size: 11px; font-weight: 500;
            background: var(--bg-elevated); color: var(--text-secondary);
            border: 1px solid var(--border);
        }
        .badge-guide {
            display: inline-flex; align-items: center; gap: 5px;
            padding: 3px 9px; border-radius: 20px;
            font-size: 11.5px; font-weight: 600;
            background: rgba(88,166,255,.1); color: var(--accent-blue);
        }

        .table-footer-bar {
            padding: 14px 22px;
            border-top: 1px solid var(--border);
            font-size: 12.5px; color: var(--text-muted);
        }
        .page-btn {
            padding: 4px 10px; border-radius: 6px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            color: var(--text-secondary);
            font-size: 12.5px; cursor: pointer;
            transition: all .15s;
        }
        .page-btn:hover, .page-btn.active {
            background: rgba(57,208,200,.15);
            border-color: var(--accent-teal);
            color: var(--accent-teal);
        }

        /* ── PAGINATION STYLE FIX ── */
        .pagination-wrap { padding: 15px 22px; border-top: 1px solid var(--border); display: flex; justify-content: center; }
        .pagination { gap: 6px; margin: 0; }
        .page-item .page-link { background-color: #1c2330 !important; border: 1px solid var(--border) !important; color: var(--text-secondary) !important; border-radius: 8px !important; font-size: 13px; padding: 6px 14px; transition: 0.2s; }
        .page-item.active .page-link { background-color: var(--accent-teal) !important; border-color: var(--accent-teal) !important; color: var(--bg-base) !important; font-weight: 700; }
        .pagination svg { width: 18px; height: 18px; }

        /* ANIMASI TERLAMBAT */
        .status-danger-blink { 
            display: inline-flex; 
            align-items: center; 
            gap: 5px; 
            background: rgba(248,81,73,.1); 
            border: 1px solid var(--accent-red); 
            color: var(--accent-red); 
            padding: 4px 8px; 
            border-radius: 6px; 
            font-weight: 600;
            animation: danger-pulse 0.8s infinite alternate;
        }

        @keyframes danger-pulse {
            0% { transform: scale(1); opacity: 1; }
            100% { transform: scale(1.05); opacity: 0.7; }
        }

        /* ── RESPONSIVE ── */
        @media (max-width: 768px) {
            #sidebar { transform: translateX(-100%); }
            #sidebar.active { transform: translateX(0); }
            #mainWrapper { margin-left: 0; }
            .topbar { padding: 0 16px; }
            .header-brand { display: none; }
            .content-area { padding: 16px; }
            .user-info { display: none; }
            .notif-dropdown {
                position: fixed; left: 10px; right: 10px; width: auto;
            }
        }
        @media (max-width: 1024px) {
            .header-date { display: none; }
        }
    </style>

    <?php echo $__env->yieldPushContent('styles'); ?>

    <?php echo \Livewire\Mechanisms\FrontendAssets\FrontendAssets::styles(); ?>

</head>

<body>


<div id="sidebarOverlay"></div>


<aside id="sidebar">
    <div class="sidebar-logo">
        <div class="d-flex align-items-center gap-2">
            <div class="logo-icon">⛰️</div>
            <div>
                <div class="logo-text">SummitAdmin</div>
                <div class="logo-sub">Manajemen Pendakian</div>
            </div>
        </div>
    </div>

    <nav class="sidebar-nav">
        <div class="nav-section-label">Core</div>
        <a href="<?php echo e(route('admin.dashboard')); ?>" 
        wire:navigate 
        class="sidebar-link <?php echo e(request()->routeIs('admin.dashboard') ? 'active' : ''); ?>">
            <span class="nav-icon">📊</span> Dashboard
        </a>

        <div class="nav-section-label">Data</div>
        <a href="<?php echo e(route('admin.climbing')); ?>" 
        wire:navigate 
        class="sidebar-link <?php echo e(request()->routeIs('admin.climbing') ? 'active' : ''); ?>">
            <span class="nav-icon">🧗</span> Pendaki
        </a>
        <a href="<?php echo e(route('admin.tiket')); ?>" 
        wire:navigate 
        class="sidebar-link <?php echo e(request()->routeIs('admin.tiket') ? 'active' : ''); ?>">
            <span class="nav-icon">🎫</span> Monitoring Tiket
        </a>
        <a href="<?php echo e(route('admin.guide.index')); ?>" 
        wire:navigate 
        class="sidebar-link <?php echo e(request()->routeIs('admin.guide.index') ? 'active' : ''); ?>">
            <span class="nav-icon">🪖</span> Guide
        </a>
        <a href="<?php echo e(route('admin.group.index')); ?>" 
        wire:navigate 
        class="sidebar-link <?php echo e(request()->routeIs('admin.group.index') ? 'active' : ''); ?>">
            <span class="nav-icon">👥</span> Grup Pendakian
        </a>

        <div class="nav-section-label">Laporan</div>
        <a href="<?php echo e(route('admin.statistik')); ?>" 
        wire:navigate 
        class="sidebar-link <?php echo e(Request::is('admin/statistik') ? 'active' : ''); ?>">
            <span class="nav-icon">📈</span> Statistik
        </a>
        <a href="<?php echo e(route('admin.keuangan')); ?>" 
        wire:navigate 
        class="sidebar-link <?php echo e(Request::is('admin/keuangan') ? 'active' : ''); ?>">
            <span class="nav-icon">💰</span> Keuangan
        </a>
        <a href="<?php echo e(route('admin.ticket-counter.index')); ?>"
        wire:navigate 
        class="sidebar-link <?php echo e(request()->routeIs('admin.ticket-counter.*') ? 'active' : ''); ?>">
            <span class="nav-icon">👮</span>
            <span>Penjaga Tiket</span>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(isset($counters) && $counters->count() > 0): ?>
                <span class="ms-auto badge" style="background:#238636; font-size:10px;">
                    <?php echo e($counters->count()); ?>

                </span>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </a>
        <a href="<?php echo e(route('admin.rekap')); ?>"
        wire:navigate 
        class="sidebar-link <?php echo e(request()->routeIs('admin.rekap') ? 'active' : ''); ?>">
            <span class="nav-icon">📅</span> Rekap Bulanan
        </a>
    </nav>
    <div class="sidebar-footer">
        <form method="POST" action="<?php echo e(route('admin.logout')); ?>">
            <?php echo csrf_field(); ?>
            <button type="submit" class="logout-btn">
                <span>🚪</span> Logout
            </button>
        </form>
    </div>
</aside>


<div id="mainWrapper">

    
    <header class="topbar d-flex align-items-center justify-content-between">
        
        <div class="d-flex align-items-center gap-3">
            <button class="btn p-0 d-md-none" id="mobileToggle" style="color:var(--text-primary); font-size:24px;">☰</button>
            <span class="header-brand fw-bold" style="font-family:'Sora',sans-serif; font-size:16px; color:var(--text-primary);">Admin</span>
        </div>

        
        <div class="d-flex align-items-center gap-3">
            <span class="header-date" style="font-size:12px; color:var(--text-muted);" id="headerDate"></span>

            
            <div class="notif-wrap" id="notifWrap">
                <div class="notif-icon-btn <?php echo e(isset($notifCount) && $notifCount > 0 ? 'shake' : ''); ?>" id="notifBtn">🔔</div>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(isset($notifCount) && $notifCount > 0): ?>
                    <span class="notif-badge"><?php echo e($notifCount); ?></span>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                <div class="notif-dropdown" id="notifDropdown">
                    <div class="notif-dropdown-header d-flex align-items-center gap-2">
                        <span>⚠️</span> Peringatan Keamanan
                    </div>
                    <div class="notif-dropdown-body">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(isset($overdueClimbers) && $overdueClimbers->count() > 0): ?>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $overdueClimbers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $climber): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                <div class="notif-item">
                                    <div class="notif-item-name"><?php echo e($climber->name); ?></div>
                                    <div class="notif-item-sub">Mulai: <?php echo e($climber->created_at->format('d M, H:i')); ?></div>
                                    
                                    <span class="badge bg-danger mt-1" style="font-size: 9px; font-weight: 700;">
                                        Terlambat: <?php echo e(floor($climber->created_at->diffInHours(now()))); ?> Jam
                                    </span>
                                </div>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                        <?php else: ?>
                            <div class="text-center py-4" style="color:var(--text-muted);">
                                <div style="font-size:24px; margin-bottom:10px;">✅</div>
                                <div style="font-size:13px;">Semua pendaki aman.</div>
                            </div>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>
                </div>
            </div>

            
            <div class="user-chip d-flex align-items-center gap-2">
                <div class="user-avatar">A</div>
                <div class="user-info">
                    <div class="user-name"><?php echo e(auth('admin')->user()->name ?? 'Admin'); ?></div>
                    <div class="user-role">Administrator</div>
                </div>
            </div>
        </div>
    </header>

    
    <div class="content-area">

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(Request::routeIs('admin.dashboard')): ?>

            <div class="page-title mb-1">Dashboard</div>
            <div class="page-subtitle mb-4">Selamat datang kembali. Berikut ringkasan aktivitas hari ini.</div>

            
            <div class="row g-3 mb-4" wire:poll.30s>
                <div class="col-12 col-sm-6 col-xl-3">
                    <div class="stat-card green">
                        <div class="d-flex align-items-center justify-content-between mb-3">
                            <span class="stat-label">Domestik Bulan Ini</span>
                            <div class="stat-icon">🧗</div>
                        </div>
                        <div class="stat-value"><?php echo e($totalDomestik ?? 0); ?></div>
                    </div>
                </div>
                <div class="col-12 col-sm-6 col-xl-3">
                    <div class="stat-card teal">
                        <div class="d-flex align-items-center justify-content-between mb-3">
                            <span class="stat-label">Mancanegara Bulan Ini</span>
                            <div class="stat-icon">🎫</div>
                        </div>
                        <div class="stat-value"><?php echo e($totalMancanegara ?? 0); ?></div>
                    </div>
                </div>
                <div class="col-12 col-sm-6 col-xl-3">
                    <div class="stat-card blue">
                        <div class="d-flex align-items-center justify-content-between mb-3">
                            <span class="stat-label">Jumlah Guide</span>
                            <div class="stat-icon">🪖</div>
                        </div>
                        <div class="stat-value"><?php echo e(count($guides ?? [])); ?></div>
                    </div>
                </div>
                <div class="col-12 col-sm-6 col-xl-3">
                    <div class="stat-card amber">
                        <div class="d-flex align-items-center justify-content-between mb-3">
                            <span class="stat-label">Total Penjualan Bulan ini</span>
                            <div class="stat-icon">💰</div>
                        </div>
                        <div class="stat-value" style="font-size:20px;">Rp. <?php echo e(number_format($income ?? 0, 0, ',', '.')); ?></div>
                    </div>
                </div>
            </div>

            
            <div class="row g-3 mb-4">
                <div class="col-12 col-lg-6">
                    <div class="chart-card">
                        <div class="d-flex align-items-center justify-content-between mb-4">
                            <div>
                                <div class="chart-title">Pendaki Harian</div>
                                <div class="chart-subtitle">30 hari terakhir</div>
                            </div>
                            <span class="chart-badge teal">Harian</span>
                        </div>
                        <div class="chart-responsive">
                            <div class="chart-wrap">
                                <canvas id="dailyChart"></canvas>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-12 col-lg-6">
                    <div class="chart-card">
                        <div class="d-flex align-items-center justify-content-between mb-4">
                            <div>
                                <div class="chart-title">Penjualan Bulanan</div>
                                <div class="chart-subtitle">Tahun <?php echo e(date('Y')); ?></div>
                            </div>
                            <span class="chart-badge blue">Bulanan</span>
                        </div>
                        <div class="chart-responsive">
                            <div class="chart-wrap">
                                <canvas id="monthlyChart"></canvas>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            
            <div class="table-card">
                <div class="table-card-header d-flex flex-wrap align-items-center justify-content-between gap-3">
                    <div>
                        <div class="table-title">Daftar Pendaki Terdaftar Hari Ini</div>
                        <div class="table-desc">Semua pendaki yang telah melakukan registrasi hari ini</div>
                    </div>
                    <div class="search-box">
                        <span>🔍</span>
                        <input type="text" id="searchInput" placeholder="Cari pendaki...">
                    </div>
                </div>

                <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('climbing-table');

$__keyOuter = $__key ?? null;

$__key = null;
$__componentSlots = [];

$__key ??= \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::generateKey('lw-987824700-0', $__key);

$__html = app('livewire')->mount($__name, $__params, $__key, $__componentSlots);

echo $__html;

unset($__html);
unset($__key);
$__key = $__keyOuter;
unset($__keyOuter);
unset($__name);
unset($__params);
unset($__componentSlots);
unset($__split);
?>
            </div>

        <?php else: ?>
            <?php echo $__env->yieldContent('content'); ?>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    </div>

</div>


<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>

<script>
// Fungsi Ekspor Global
function exportData(type) {
    const start = document.getElementById('start_date').value;
    const end = document.getElementById('end_date').value;
    
    if(!start || !end) {
        alert('Silakan pilih rentang tanggal terlebih dahulu.');
        return;
    }

    let url = "";
    if(type === 'excel') {
        url = "<?php echo e(route('admin.rekap.excel')); ?>";
    } else {
        url = "<?php echo e(route('admin.rekap.pdf')); ?>";
    }
    
    window.location.href = `${url}?start_date=${start}&end_date=${end}`;
}

// 1. FUNGSI UNTUK MENGGAMBAR CHART
function renderAllCharts() {
    let dailyStatus = Chart.getChart("dailyChart");
    if (dailyStatus) dailyStatus.destroy();
    
    let monthlyStatus = Chart.getChart("monthlyChart");
    if (monthlyStatus) monthlyStatus.destroy();

    if (typeof Chart !== 'undefined') {
        Chart.defaults.color = '#8b949e';
        Chart.defaults.font.family = "'Plus Jakarta Sans', sans-serif";

        <?php if(isset($dailyData) && $dailyData->count() > 0): ?>
        const dailyCtx = document.getElementById('dailyChart');
        if (dailyCtx) {
            new Chart(dailyCtx, {
                type: 'line',
                data: {
                    labels: <?php echo json_encode($dailyData->pluck('date')); ?>,
                    datasets: [{
                        label: 'Jumlah Pendaki',
                        data: <?php echo json_encode($dailyData->pluck('count')); ?>,
                        borderColor: '#39d0c8',
                        backgroundColor: 'rgba(57,208,200,0.08)',
                        borderWidth: 2,
                        pointRadius: 3,
                        pointBackgroundColor: '#39d0c8',
                        tension: 0.45,
                        fill: true,
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: { display: false },
                        tooltip: { callbacks: { label: ctx => 'Jumlah Pendaki: ' + ctx.raw } }
                    },
                    scales: {
                        x: { grid: { color: '#30363d' }, ticks: { font: { size: 10.5 } } },
                        y: { grid: { color: '#30363d' }, beginAtZero: true, ticks: { stepSize: 1 } }
                    }
                }
            });
        }
        <?php endif; ?>

        <?php if(isset($monthlyData) && $monthlyData->count() > 0): ?>
        const monthlyCtx = document.getElementById('monthlyChart');
        if (monthlyCtx) {
            new Chart(monthlyCtx, {
                type: 'bar',
                data: {
                    labels: <?php echo json_encode($monthlyData->pluck('month')); ?>,
                    datasets: [{
                        label: 'Jumlah Pendaki',
                        data: <?php echo json_encode($monthlyData->pluck('total_pendaki')); ?>,
                        backgroundColor: 'rgba(88,166,255,0.7)',
                        borderColor: 'rgba(88,166,255,0.9)',
                        borderWidth: 1,
                        borderRadius: 5,
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: { legend: { display: false } },
                    scales: {
                        x: { grid: { color: '#30363d' }, ticks: { font: { size: 10.5 } } },
                        y: { grid: { color: '#30363d' }, beginAtZero: true }
                    }
                }
            });
        }
        <?php endif; ?>
    }
}

// 2. FUNGSI INISIALISASI REALTIME & EVENT LISTENER (LOGIKA NOTIFIKASI DI SINI)
function initMainRealtime() {
    if (window.Echo) {
        window.Echo.leave('pendakian');
        window.Echo.channel('pendakian')
            .listen('.pendaki.baru', (e) => {
                if (typeof Livewire !== 'undefined') {
                    Livewire.dispatch('refresh-data');
                }
            });
    }

    // SIDEBAR LOGIC
    const mobileToggle = document.getElementById('mobileToggle');
    const sidebar = document.getElementById('sidebar');
    const overlay = document.getElementById('sidebarOverlay');
    if (mobileToggle && sidebar && overlay) {
        mobileToggle.onclick = () => {
            sidebar.classList.add('active'); overlay.classList.add('active');
            document.body.style.overflow = 'hidden';
        };
        overlay.onclick = () => {
            sidebar.classList.remove('active'); overlay.classList.remove('active');
            document.body.style.overflow = 'auto';
        };
    }

    // --- PERBAIKAN LOGIKA NOTIFIKASI AGAR SELALU BISA DIKLIK ---
    const notifBtn = document.getElementById('notifBtn');
    const notifDropdown = document.getElementById('notifDropdown');
    
    if(notifBtn && notifDropdown) {
        // Menggunakan properti .onclick agar listener tidak menumpuk saat navigasi Livewire
        notifBtn.onclick = function(e) {
            e.stopPropagation();
            const isVisible = notifDropdown.style.display === 'block';
            notifDropdown.style.display = isVisible ? 'none' : 'block';
        };

        // Menutup dropdown jika klik di tempat lain
        document.addEventListener('click', function(e) {
            if (!notifDropdown.contains(e.target)) {
                notifDropdown.style.display = 'none';
            }
        });
    }

    // HEADER DATE
    const dateEl = document.getElementById('headerDate');
    if (dateEl) {
        dateEl.textContent = new Date().toLocaleDateString('id-ID', {
            weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'
        });
    }

    // SEARCH TABLE
    const searchInput = document.getElementById('searchInput');
    if (searchInput) {
        searchInput.oninput = function () {
            const q = this.value.toLowerCase();
            document.querySelectorAll('#mainTable tbody tr').forEach(row => {
                row.style.display = row.textContent.toLowerCase().includes(q) ? '' : 'none';
            });
        };
    }

    renderAllCharts();
}

// 3. LOGIKA KUNCI
document.addEventListener('livewire:init', () => {
    Livewire.on('refresh-data', () => {
        setTimeout(() => { renderAllCharts(); }, 150);
    });
});

document.addEventListener('DOMContentLoaded', initMainRealtime);
document.addEventListener('livewire:navigated', initMainRealtime);
</script>

<?php echo $__env->yieldPushContent('scripts'); ?>
<?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('climbing-detail');

$__keyOuter = $__key ?? null;

$__key = null;
$__componentSlots = [];

$__key ??= \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::generateKey('lw-987824700-1', $__key);

$__html = app('livewire')->mount($__name, $__params, $__key, $__componentSlots);

echo $__html;

unset($__html);
unset($__key);
$__key = $__keyOuter;
unset($__keyOuter);
unset($__name);
unset($__params);
unset($__componentSlots);
unset($__split);
?>
<?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('guide-detail');

$__keyOuter = $__key ?? null;

$__key = null;
$__componentSlots = [];

$__key ??= \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::generateKey('lw-987824700-2', $__key);

$__html = app('livewire')->mount($__name, $__params, $__key, $__componentSlots);

echo $__html;

unset($__html);
unset($__key);
$__key = $__keyOuter;
unset($__keyOuter);
unset($__name);
unset($__params);
unset($__componentSlots);
unset($__split);
?>
<?php echo \Livewire\Mechanisms\FrontendAssets\FrontendAssets::scripts(); ?>


</body>
</html><?php /**PATH C:\laragon\www\Pendaki_App-main\resources\views/admin/dashboardAdmin.blade.php ENDPATH**/ ?>