<?php
require_once __DIR__ . '/../../config/db.php';
require_once __DIR__ . '/../../includes/functions.php';
checkAdmin();
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard - SMAN 1 Barumun</title>
    <link rel="stylesheet" href="<?= baseUrl('dist/style.css?v=' . time()) ?>">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="bg-slate-50">
    <div class="flex h-screen overflow-hidden">
        <!-- Sidebar -->
        <?php include 'sidebar.php'; ?>

        <!-- Content -->
        <main class="flex-1 overflow-y-auto">
            <header class="bg-white border-b border-slate-200 px-8 py-4 flex justify-between items-center sticky top-0 z-10">
                <h2 class="text-xl font-bold text-slate-800"><?= isset($title) ? $title : 'Dashboard' ?></h2>
                <div class="flex items-center gap-6">
                    <span class="text-sm text-slate-600">Halo, <a href="<?= baseUrl('admin/profil.php') ?>" class="font-semibold text-primary hover:underline"><?= $_SESSION['admin_auth']['nama'] ?></a></span>
                    <a href="<?= baseUrl('admin/logout.php') ?>" class="text-sm font-semibold text-red-500 hover:text-red-600">Logout</a>
                </div>
            </header>
            
            <div class="p-8">
                <?php $flash = getFlash(); if ($flash): ?>
                    <div class="mb-6 p-4 rounded-xl <?= $flash['type'] === 'success' ? 'bg-green-100 text-green-700 border border-green-200' : 'bg-red-100 text-red-700 border border-red-200' ?>">
                        <?= $flash['message'] ?>
                    </div>
                <?php endif; ?>
