<?php include 'header.php';
$total = $conn->query('SELECT COUNT(*) jml FROM siswa')->fetch_assoc()['jml'];
$kelas = $conn->query('SELECT COUNT(DISTINCT kelas) jml FROM siswa')->fetch_assoc()['jml'];
$profil = $conn->query('SELECT * FROM profil_sekolah LIMIT 1')->fetch_assoc();
?>
<div class="p-4 rounded-4 hero mb-4">
    <h2 class="fw-bold mb-1">Dashboard</h2>
    <p class="mb-0">Selamat datang, <?= e($_SESSION['nama_admin'] ?? 'Admin') ?>. Kelola data siswa dan cetak kartu ujian dengan mudah.</p>
</div>
<div class="row g-3 mb-4">
    <div class="col-md-4">
        <div class="card stat">
            <div class="card-body">
                <h6>Total Siswa</h6>
                <h2><?= $total ?></h2>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card stat">
            <div class="card-body">
                <h6>Total Kelas</h6>
                <h2><?= $kelas ?></h2>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card stat">
            <div class="card-body">
                <h6>Tahun Pelajaran</h6>
                <h2><?= e($profil['tahun_pelajaran'] ?? '2025/2026') ?></h2>
            </div>
        </div>
    </div>
</div>
<a href="siswa.php" class="btn btn-primary">Kelola Siswa</a> <a href="cetak_massal.php" class="btn btn-success">Cetak Kartu Massal</a>
<?php include 'footer.php'; ?>