<?php
// Pastikan koneksi database tersedia
if (!isset($koneksi)) {
    include '../koneksi.php';
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SIAS DASHBOARD | Admin</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    
    <style>
    body { background-color: #f8f9fa; }
    
    .sidebar { width: 250px; height: 100vh; background: #2c3e50; color: white; position: fixed; top: 0; left: 0; z-index: 1000; overflow-y: auto; }
    
    .brand { font-size: 1.2rem; font-weight: bold; padding: 20px; background: #1a252f; display: block; text-align: center; }
    
    .content, #content, .main-content {
    margin-left: 250px; /* Sesuaikan dengan lebar sidebar Anda */
    padding-left: 10px; /* Ruang aman agar konten tidak benar-benar menempel garis */
}
    .container-fluid {
    padding-left: 5px !important; /* Memberikan jarak minimal agar tidak menempel ekstrim ke garis sidebar */
    margin-left: 0 !important;
}
    
    /* Gabungan aturan .nav-link agar tidak bentrok */
    .nav-link { 
        color: #bdc3c7 !important; 
        /* Mengurangi padding vertikal menjadi 8px agar lebih rapat */
        padding: 8px 20px; 
        text-decoration: none; 
        display: block; 
        transition: 0.3s; 
        /* Menghilangkan margin-bottom agar baris bisa menempel lebih dekat */
        margin-bottom: 0px; 
    }
    
    .nav-link:hover { 
        background: #34495e; 
        color: white !important; 
        border-left: 4px solid #3498db; 
    }
    
    .tahun-box { 
        background: #273c75; 
        padding: 10px; 
        margin: 15px; 
        border-radius: 6px; 
        text-align: center; 
        font-size: 0.85rem; 
    }
</style>
</head>
<body>

<div class="sidebar">
    <div class="brand d-flex flex-column align-items-center p-3 text-center">
        <img src="/sias/assets/img/favicon.png" alt="Logo" style="width: 50px; height: 50px; margin-bottom: 10px;">
        
        <span style="font-weight: bold; font-size: 1.1rem;">
            <i class="fa fa-school"></i> SIAKAD ADMIN
        </span>
    </div>
        
        <div class="tahun-box">
            Tahun Aktif: <br>
            <strong>
            <?php
            // Memastikan query aman meski tabel belum ada atau kosong
            $q = @mysqli_query($koneksi, "SELECT tahun_pelajaran FROM tahun_pelajaran WHERE status = 'Aktif'");
            if ($q && mysqli_num_rows($q) > 0) {
                $t = mysqli_fetch_array($q);
                echo $t['tahun_pelajaran'];
            } else {
                echo 'Belum Diatur';
            }
            ?>
            </strong>
        </div>

<ul class="list-unstyled">
    <li><a href="dashboard.php" class="nav-link text-white"><i class="fas fa-tachometer-alt me-2"></i> Dashboard</a></li>
    <li><a href="set_tahun_ajaran.php" class="nav-link text-white"><i class="fas fa-calendar-alt me-2"></i> Tahun Pelajaran</a></li>
    <li><a href="mapel.php" class="nav-link text-white"><i class="fas fa-book-open me-2"></i> Mata Pelajaran</a></li>
    
    <li><a href="rombel.php" class="nav-link text-white"><i class="fas fa-door-open me-2"></i> Rombel</a></li>
    
    <li><a href="guru.php" class="nav-link text-white"><i class="fas fa-chalkboard-teacher me-2"></i> Data Guru</a></li>
    <li><a href="siswa.php" class="nav-link text-white"><i class="fas fa-user-graduate me-2"></i> Data Siswa</a></li>
    <li><a href="ekskul.php" class="nav-link text-white"><i class="fas fa-futbol me-2"></i> Ekstrakurikuler</a></li>
    <li><a href="user_management.php" class="nav-link text-white"><i class="fas fa-users-cog me-2"></i> User Management</a></li>
    <li><a href="profil_sekolah.php" class="nav-link text-white"><i class="fas fa-university me-2"></i> Profil Sekolah</a></li>
    <hr class="text-white">
    <li><a href="../index.php" class="nav-link text-danger"><i class="fas fa-sign-out-alt me-2"></i> Logout</a></li>
</ul>
    </div>

    <div class="content">
        

