<!doctype html>
<html lang="ms">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>System Dashboard</title>

    <link rel="preconnect" href="https://fonts.bunny.net">
    <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

    <style>
        :root{
            --bg:linear-gradient(135deg,#0f172a,#1d4ed8);
            --panel:#ffffff;
            --border:rgba(15,23,42,.15);
            --muted:#6b7280;
            --text:#0f172a;
            --shadow:0 14px 30px rgba(15,23,42,.12);
            --sidebar-w:260px;
            --topbar-h:56px;
            --accent:#2563eb;
            --accent-soft:#dbeafe;
            --accent-strong:#1d4ed8;
        }

        *{box-sizing:border-box}
        html,body{height:100%}
        body{
            margin:0;
            font-family:Figtree,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";
            color:var(--text);
            background:var(--bg);
            background-attachment:fixed;
        }

        .app{
            min-height:100vh;
            display:grid;
            grid-template-columns: var(--sidebar-w) 1fr;
            grid-template-rows: var(--topbar-h) 1fr;
            grid-template-areas:
                "sidebar topbar"
                "sidebar main";
        }

        /* Top bar */
        .topbar{
            grid-area:topbar;
            height:var(--topbar-h);
            background:rgba(15,23,42,.88);
            backdrop-filter:blur(12px);
            border-bottom:1px solid rgba(148,163,184,.45);
            border-left:none;
            display:flex;
            align-items:center;
            justify-content:space-between;
            padding:0 14px;
            box-shadow:var(--shadow);
            position:sticky;
            top:0;
            z-index:10;
        }
        .topbar-left{display:flex;align-items:center;gap:10px;min-width:0}
        .btn-icon{
            width:34px;height:34px;
            display:inline-flex;
            align-items:center;
            justify-content:center;
            border:1px solid rgba(148,163,184,.7);
            background:rgba(15,23,42,.75);
            color:#e5e7eb;
            cursor:pointer;
            border-radius:999px;
            transition:background .18s ease,transform .18s ease,box-shadow .18s ease,border-color .18s ease;
        }
        .btn-icon:hover{
            background:rgba(37,99,235,.9);
            border-color:rgba(191,219,254,1);
            box-shadow:0 10px 25px rgba(15,23,42,.55);
            transform:translateY(-1px);
        }
        .brand{
            display:flex;
            align-items:center;
            gap:10px;
            min-width:0;
        }
        .brand-badge{
            width:160px;height:55px;
            border-radius:999px;
            border:1px solid rgba(191,219,254,1);
            display:grid;
            place-items:center;
            font-weight:800;
            letter-spacing:.4px;
            font-size:12px;
            color:#dbeafe;
            background:radial-gradient(circle at 0 0,#60a5fa,#1d4ed8);
            box-shadow:0 12px 30px rgba(37,99,235,.65);
        }
        .brand-title{
            font-weight:700;
            white-space:nowrap;
            overflow:hidden;
            text-overflow:ellipsis;
            color:#e5e7eb;
        }

       
        /* Main */
        .main{
            grid-area:main;
            padding:18px 18px 24px;
        }
        .page-head{
            border-radius:18px;
            border:1px solid rgba(148,163,184,.5);
            background:linear-gradient(135deg,rgba(248,250,252,.98),rgba(219,234,254,.98));
            padding:16px 18px;
            box-shadow:0 18px 40px rgba(15,23,42,.18);
        }
        .page-head h1{
            margin:0;
            font-size:20px;
        }
        .page-head p{
            margin:6px 0 0;
            color:var(--muted);
            font-size:13px;
        }

        .grid{
            margin-top:14px;
            display:grid;
            gap:14px;
        }
        .stats{
            grid-template-columns: repeat(4, minmax(0, 1fr));
        }
        .panel{
            border-radius:16px;
            border:1px solid rgba(148,163,184,.35);
            background:var(--panel);
            box-shadow:var(--shadow);
            overflow:hidden;
            position:relative;
            transition:transform .16s ease,box-shadow .16s ease, border-color .16s ease;
        }
        .panel::before{
            content:"";
            position:absolute;
            inset:0;
            opacity:0;
            pointer-events:none;
            background:radial-gradient(circle at 0 0,rgba(129,140,248,.4),transparent 55%);
            transition:opacity .18s ease;
        }
        .panel:hover{
            transform:translateY(-3px);
            box-shadow:0 22px 55px rgba(15,23,42,.20);
            border-color:rgba(59,130,246,.7);
        }
        .panel:hover::before{
            opacity:1;
        }
        .panel-body{padding:12px 12px 10px}
        .stat-label{
            font-size:11px;
            color:var(--muted);
            letter-spacing:.3px;
            text-transform:uppercase;
        }
        .stat-value{
            margin-top:6px;
            font-weight:800;
            font-size:22px;
        }

        .two-col{
            grid-template-columns: 2fr 1fr;
            align-items:start;
        }
        .panel-head{
            display:flex;
            align-items:center;
            justify-content:space-between;
            gap:10px;
            padding:10px 12px;
            border-bottom:1px solid var(--border);
        }
        .panel-title{
            font-weight:700;
            font-size:13px;
        }
        .panel-action{
            font-size:12px;
            color:var(--accent-strong);
            text-decoration:none;
            padding:6px 8px;
            border-radius:999px;
            border:1px solid rgba(191,219,254,1);
            background:var(--accent-soft);
            white-space:nowrap;
            display:inline-flex;
            align-items:center;
            gap:4px;
            transition:background .16s ease,border-color .16s ease,transform .12s ease,box-shadow .16s ease;
        }
        .panel-action:hover{
            background:#2563eb;
            color:#eff6ff;
            border-color:#1d4ed8;
            transform:translateY(-1px);
            box-shadow:0 12px 30px rgba(37,99,235,.5);
        }

        .panel-chart{
            padding:10px 12px 14px;
        }
        .chart-wrap{
            height:220px;
        }
        canvas{max-width:100% !important}

        .bottom{
            grid-template-columns: 2fr 1fr;
            align-items:start;
        }
        .stack{
            display:grid;
            gap:14px;
        }

        .list{
            padding:10px 12px 14px;
        }
        .list-item{
            border-radius:12px;
            border:1px dashed rgba(148,163,184,.8);
            padding:10px 10px;
            margin-top:10px;
            background:linear-gradient(135deg,#f9fafb,#eff6ff);
        }
        .list-item:first-child{margin-top:0}
        .li-title{font-weight:700;font-size:13px;margin:0}
        .li-meta{margin:6px 0 0;color:var(--muted);font-size:12px;line-height:1.35}

        .footer{
            margin-top:16px;
            text-align:center;
            color:white;
            font-size:12px;
        }

        /* kecilkan animasi highlight pada klik kad */
        .pulse{
            animation:pulse-card .6s ease-out;
        }
        @keyframes pulse-card{
            0%{transform:translateY(-2px) scale(1); box-shadow:0 22px 55px rgba(37,99,235,.5);}
            50%{transform:translateY(-4px) scale(1.02); box-shadow:0 30px 70px rgba(37,99,235,.55);}
            100%{transform:translateY(-2px) scale(1); box-shadow:0 22px 55px rgba(15,23,42,.20);}
        }

        /* Responsive */
        @media (max-width: 1100px){
            .stats{grid-template-columns: repeat(2, minmax(0, 1fr));}
            .two-col{grid-template-columns: 1fr;}
            .bottom{grid-template-columns: 1fr;}
        }
        @media (max-width: 860px){
            .app{
                grid-template-columns: 1fr;
                grid-template-areas:
                    "topbar"
                    "main";
            }
            .topbar{border-left:1px solid var(--border)}
          
            .backdrop{
                display:none;
                position:fixed;
                inset:0;
                background:rgba(0,0,0,.22);
                z-index:15;
            }
            .backdrop.show{display:block}
        }
    </style>
</head>
<body>
<div class="app" data-app>
    <?php echo $__env->make('partials.sidebar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <header class="topbar" role="banner">
        <div class="topbar-left">
            <button class="btn-icon" type="button" aria-label="Buka menu" data-open-sidebar>
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
                    <path d="M4 6h16M4 12h16M4 18h16" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
                </svg>
            </button>
            <div class="brand" aria-label="Jenama">
                <div class="brand-badge"><img src="<?php echo e(asset('image/logo_kv_sepang.png')); ?>" alt="Logo" style="width:100%;height:100%;"></div>
                <div class="brand-title">System Dashboard</div>
            </div>
        </div>
        <!-- <div style="display:flex;align-items:center;gap:10px">
            <a class="panel-action" href="<?php echo e(url('/welcome')); ?>">Welcome</a>
        </div> -->
    </header>

    <main class="main" role="main">
        <section class="page-head" aria-label="Ringkasan">
            <h1>Dashboard Utama</h1>
            <p>Ringkasan maklumat sistem</p>
        </section>

        <section class="grid stats" aria-label="Kad ringkasan">
                        <div class="panel" data-card-highlight="pelajar">
                    <div class="panel-body">
                        <div class="stat-label">Jumlah Pelajar</div>
                        <div class="stat-value"><?php echo e(number_format($students)); ?></div>
                       </div>
                    </div>

                <div class="panel" data-card-highlight="pensyarah">
                    <div class="panel-body">
                        <div class="stat-label">Jumlah Pensyarah</div>
                        <div class="stat-value"><?php echo e(number_format($teachers)); ?></div>
                    </div>
                </div>
            <div class="panel" data-card-highlight="pentadbiran">
                <div class="panel-body">
                    <div class="stat-label">Pentadbiran</div>
                    <div class="stat-value">24</div>
                </div>
            </div>
            <div class="panel" data-card-highlight="kebolehpasaran">
                <div class="panel-body">
                    <div class="stat-label">Kebolehpasaran</div>
                    <div class="stat-value">18</div>
                </div>
            </div>
        </section>

        <section class="grid two-col" aria-label="Graf">
            <div class="panel">
                <div class="panel-head">
                    <div class="panel-title">Statistik Pelajar Mengikut Program</div>
                </div>
                <div class="panel-chart">
                    <div class="chart-wrap">
                        <canvas id="programBar" aria-label="Graf bar program" role="img"></canvas>
                    </div>
                </div>
            </div>

            <div class="panel">
                <div class="panel-head">
                    <div class="panel-title">Peratusan Pelajar Asrama</div>
                </div>
                <div class="panel-chart">
                    <div class="chart-wrap">
                        <canvas id="asramaDonut" aria-label="Graf donut asrama" role="img"></canvas>
                    </div>
                </div>
            </div>
        </section>

        <section class="grid bottom" aria-label="Senarai">
            <div class="panel">
                <div class="panel-head">
                    <div class="panel-title">Program</div>
                    <!-- <a class="panel-action" href="<?php echo e(route('admin.students.index')); ?>">Lihat Semua</a> -->
                </div>
                <div class="list">
                    <?php $__empty_1 = true; $__currentLoopData = $programsList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prog): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <div class="list-item">
                            <p class="li-title"><?php echo e($prog['name']); ?></p>
                            <p class="li-meta">Pendaftaran aktif: <?php echo e(number_format($prog['total'])); ?> • Kemaskini: <?php echo e($prog['updated_at'] ? \Carbon\Carbon::parse($prog['updated_at'])->diffForHumans() : '—'); ?></p>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <div class="list-item">
                            <p class="li-title">—</p>
                            <p class="li-meta">Tiada data program dalam pangkalan data.</p>
                        </div>
                    <?php endif; ?>
                </div>
            </div>

            <div class="stack">
                <div class="panel">
                    <div class="panel-head">
                        <div class="panel-title">Aktiviti Terkini</div>
                        <!-- <a class="panel-action" href="<?php echo e(route('admin.students.index')); ?>">Lihat Semua</a> -->
                    </div>
                    <div class="list">
                        <?php $__empty_1 = true; $__currentLoopData = $activities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $act): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <div class="list-item">
                                <p class="li-title">
                                    <?php if($act->type === 'pelajar'): ?>
                                        Data pelajar dikemaskini
                                    <?php else: ?>
                                        Data pensyarah dikemaskini
                                    <?php endif; ?>
                                </p>
                                <p class="li-meta">
                                    <?php echo e(\Carbon\Carbon::parse($act->updated_at)->diffForHumans()); ?>

                                    <?php if($act->type === 'pelajar' && !empty($act->program)): ?>
                                        • Program: <?php echo e($act->program); ?>

                                    <?php elseif($act->type === 'pensyarah' && !empty($act->nama)): ?>
                                        • <?php echo e($act->nama); ?>

                                    <?php endif; ?>
                                </p>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <div class="list-item">
                                <p class="li-title">Tiada aktiviti terkini</p>
                                <p class="li-meta">Kemaskini data pelajar atau pensyarah untuk paparan di sini.</p>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>

                <!-- <div class="panel">
                    <div class="panel-head">
                        <div class="panel-title">Pengumuman Terkini</div>
                        <a class="panel-action" href="#">Lihat Semua</a>
                    </div>
                    <div class="list">
                        <div class="list-item">
                            <p class="li-title">Penyelenggaraan sistem</p>
                            <p class="li-meta">Jumaat, 9:00 malam • Akses mungkin terganggu</p>
                        </div>
                        <div class="list-item">
                            <p class="li-title">Kemaskini modul laporan</p>
                            <p class="li-meta">Versi baharu tersedia • Sila semak menu Laporan</p>
                        </div>
                    </div>
                </div> -->
            </div>
        </section>

        <div class="footer">
            © <?php echo e(date('Y')); ?> • System Dashboard v1.0
        </div>
    </main>
</div>

<?php echo $__env->make('partials.chatbot', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<div class="backdrop" data-backdrop aria-hidden="true"></div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.2/dist/chart.umd.min.js"></script>
<script>
    (function () {
        const sidebar = document.querySelector('[data-sidebar]');
        const openBtn = document.querySelector('[data-open-sidebar]');
        const closeBtn = document.querySelector('[data-close-sidebar]');
        const backdrop = document.querySelector('[data-backdrop]');

        function openSidebar() {
            if (!sidebar || !backdrop) return;
            sidebar.classList.add('open');
            backdrop.classList.add('show');
            backdrop.setAttribute('aria-hidden', 'false');
        }
        function closeSidebar() {
            if (!sidebar || !backdrop) return;
            sidebar.classList.remove('open');
            backdrop.classList.remove('show');
            backdrop.setAttribute('aria-hidden', 'true');
        }

        openBtn && openBtn.addEventListener('click', openSidebar);
        closeBtn && closeBtn.addEventListener('click', closeSidebar);
        backdrop && backdrop.addEventListener('click', closeSidebar);

      


    const programLabels = <?php echo json_encode($labels, 15, 512) ?>;
    const programTotals = <?php echo json_encode($totals, 15, 512) ?>;
    const programFullNames = <?php echo json_encode($fullNames, 15, 512) ?>;
    const barEl = document.getElementById('programBar');

if (barEl) {

    const colors = [
        '#ec25e1',
        '#f63b92',
        '#c6e947',
        '#3546e2',
        '#8b5cf6',
        '#f74a61',
        '#10b981'
    ];

    const barChart = new Chart(barEl, {
        type: 'bar',
        data: {
            labels: programLabels,
            datasets: programLabels.map((label, index) => ({
                label: programFullNames[index], // Nama penuh untuk legend
                data: programTotals.map((v, i) => i === index ? v : 0),
                backgroundColor: colors[index],
                borderRadius: 6
            }))
        },
        options: {
            responsive: true,
            maintainAspectRatio: false,
            plugins: {
                legend: {
                    display: true,
                    position: 'bottom',
                    labels: {
                        color: '#334155',
                        boxWidth: 14
                    }
                },
                tooltip: {
                    callbacks: {
                        title: function(context) {
                            return programFullNames[context[0].dataIndex];
                        },
                        label: function(context) {
                            return context.parsed.y + " orang";
                        }
                    }
                }
            },
            scales: {
                x: {
                    stacked: true,
                    grid: { display: false }
                },
                y: {
                    stacked: true,
                    beginAtZero: true
                }
            },
            animation: {
                duration: 800,
                easing: 'easeOutCubic'
            }
        }
    });
}


        const donutEl = document.getElementById('asramaDonut');
        if (donutEl) {
            const asramaLabels = ['Asrama Lelaki', 'Asrama Perempuan', 'Bukan Asrama'];
            const asramaData = [
                <?php echo json_encode($asramaLelaki, 15, 512) ?>,
                <?php echo json_encode($asramaPerempuan, 15, 512) ?>,
                <?php echo json_encode($bukanAsrama, 15, 512) ?>
            ];
            new Chart(donutEl, {
                type: 'doughnut',
                data: {
                    labels: asramaLabels,
                    datasets: [{
                        data: asramaData,
                        backgroundColor: ['#1d4ed8', '#7c3aed', '#e5e7eb'],
                        borderColor: '#fff',
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    cutout: '70%',
                    plugins: {
                        legend: {
                            position: 'right',
                            labels: { boxWidth: 12, color: '#111827' }
                        },
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    const total = context.dataset.data.reduce((a, b) => a + b, 0);
                                    const pct = total ? ((context.parsed / total) * 100).toFixed(1) : 0;
                                    return context.label + ': ' + context.parsed + ' orang (' + pct + '%)';
                                }
                            }
                        }
                    }
                }
            });
        }
    })();
</script>
</body>
</html>

<?php /**PATH C:\xampp\htdocs\dash\resources\views/dashboard.blade.php ENDPATH**/ ?>