<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
if (!isset($_SESSION['admin_id']) && basename($_SERVER['PHP_SELF']) != 'login.php') {
    header('Location: login.php');
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BusTrack | Admin Panel</title>
    <link rel="stylesheet" href="../css/admin.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
    <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
</head>
<body>
    <?php if (isset($_SESSION['admin_id'])): ?>
    <div class="dashboard-layout">
        <aside class="sidebar">
            <div class="sidebar-logo">
                <i class="fas fa-bus-alt"></i> BusTrack
            </div>
            <nav>
                <a href="dashboard.php" class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'dashboard.php' ? 'active' : '' ?>">
                    <i class="fas fa-chart-line"></i> Dashboard
                </a>
                <a href="buses.php" class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'buses.php' ? 'active' : '' ?>">
                    <i class="fas fa-bus"></i> Manage Buses
                </a>
                <a href="drivers.php" class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'drivers.php' ? 'active' : '' ?>">
                    <i class="fas fa-users"></i> Manage Drivers
                </a>
                <a href="bus_routes.php" class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'bus_routes.php' ? 'active' : '' ?>">
                    <i class="fas fa-route"></i> Bus Routes
                </a>
                <a href="students.php" class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'students.php' ? 'active' : '' ?>">
                    <i class="fas fa-graduation-cap"></i> Students
                </a>
                <a href="attendance.php" class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'attendance.php' ? 'active' : '' ?>">
                    <i class="fas fa-clipboard-list"></i> Attendance
                </a>
                <a href="logout.php" class="nav-link" style="margin-top: 2rem; color: var(--danger)">
                    <i class="fas fa-sign-out-alt"></i> Logout
                </a>
            </nav>
        </aside>
        <main class="main-content">
    <?php endif; ?>
