<?php $__env->startSection('title', 'Dashboard'); ?>
<?php $__env->startSection('page-title', 'Dashboard'); ?>

<?php $__env->startSection('sidebar-nav'); ?>
<div class="nav-section">Main</div>
<div class="nav-item"><a href="<?php echo e(route('admin.dashboard')); ?>"><i class="bi bi-grid"></i> Dashboard</a></div>
<div class="nav-section">Academic</div>
<div class="nav-item"><a href="<?php echo e(route('admin.students.index')); ?>"><i class="bi bi-people"></i> Students</a></div>
<div class="nav-item"><a href="<?php echo e(route('admin.exams.index')); ?>"><i class="bi bi-journal-text"></i> Exams & Results</a></div>
<div class="nav-item"><a href="<?php echo e(route('admin.attendance.index')); ?>"><i class="bi bi-calendar-check"></i> Attendance</a></div>
<div class="nav-section">Finance</div>
<div class="nav-item"><a href="<?php echo e(route('admin.fees.structure')); ?>"><i class="bi bi-cash-stack"></i> Fee Structure</a></div>
<div class="nav-item"><a href="<?php echo e(route('admin.fees.invoices')); ?>"><i class="bi bi-receipt"></i> Invoices & Payments</a></div>
<div class="nav-section">System</div>
<div class="nav-item"><a href="<?php echo e(route('admin.users.index')); ?>"><i class="bi bi-person-gear"></i> Users</a></div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="page-header">
    <div>
        <h1>Welcome back, <?php echo e(auth()->user()->name); ?></h1>
        <p><?php echo e(now()->format('l, d F Y')); ?> &mdash; <?php echo e(auth()->user()->school->name ?? 'EduSmart'); ?></p>
    </div>
</div>

<div class="grid grid-4" style="margin-bottom:24px;">
    <div class="stat-card">
        <div class="stat-icon green"><i class="bi bi-people-fill"></i></div>
        <div class="stat-info">
            <h3><?php echo e(number_format($stats['students'])); ?></h3>
            <p>Total Students</p>
        </div>
    </div>
    <div class="stat-card">
        <div class="stat-icon blue"><i class="bi bi-person-badge"></i></div>
        <div class="stat-info">
            <h3><?php echo e(number_format($stats['teachers'])); ?></h3>
            <p>Teachers</p>
        </div>
    </div>
    <div class="stat-card">
        <div class="stat-icon amber"><i class="bi bi-cash"></i></div>
        <div class="stat-info">
            <h3>KES <?php echo e(number_format($stats['fee_collected'])); ?></h3>
            <p>Fees Collected</p>
        </div>
    </div>
    <div class="stat-card">
        <div class="stat-icon red"><i class="bi bi-person-x"></i></div>
        <div class="stat-info">
            <h3><?php echo e(number_format($stats['absent_today'])); ?></h3>
            <p>Absent Today</p>
        </div>
    </div>
</div>

<div class="grid grid-2">
    <div class="card">
        <div class="card-header">
            <h5><i class="bi bi-bar-chart"></i> Fee Collection (<?php echo e(now()->year); ?>)</h5>
        </div>
        <div class="card-body">
            <canvas id="feeChart" height="200"></canvas>
        </div>
    </div>
    <div class="card">
        <div class="card-header">
            <h5><i class="bi bi-activity"></i> Recent Activity</h5>
        </div>
        <div class="card-body" style="padding:0;">
            <?php $__empty_1 = true; $__currentLoopData = $recentLogs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div style="padding:12px 20px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:12px;">
                <div class="avatar" style="width:32px;height:32px;font-size:12px;background:var(--primary-light);color:var(--primary);">
                    <?php echo e(strtoupper(substr($log->user?->name ?? 'S', 0, 1))); ?>

                </div>
                <div style="flex:1;">
                    <div style="font-size:13px;font-weight:500;"><?php echo e($log->user?->name ?? 'System'); ?></div>
                    <div style="font-size:12px;color:var(--gray);"><?php echo e(ucfirst($log->action)); ?> <?php echo e($log->model); ?> &bull; <?php echo e($log->created_at->diffForHumans()); ?></div>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div style="padding:20px;text-align:center;color:var(--gray);font-size:14px;">No recent activity</div>
            <?php endif; ?>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
<script>
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
const feeData = <?php echo json_encode($feeByMonth, 15, 512) ?>;
const labels = months.map((m, i) => m);
const values = months.map((m, i) => feeData[i+1] || 0);

new Chart(document.getElementById('feeChart'), {
    type: 'bar',
    data: {
        labels,
        datasets: [{
            label: 'KES Collected',
            data: values,
            backgroundColor: 'rgba(26,127,90,.7)',
            borderRadius: 6,
        }]
    },
    options: {
        responsive: true,
        plugins: { legend: { display: false } },
        scales: { y: { beginAtZero: true, ticks: { callback: v => 'KES ' + v.toLocaleString() } } }
    }
});
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\cbe\resources\views\admin\dashboard.blade.php ENDPATH**/ ?>