<?php 
if(!isset($_SESSION['user'])) return; 
$user = $_SESSION['user']; 
?>

<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <a href="/sekolah_app/dashboard.php" class="brand-link">
        <div class="brand-image">
            <i class="fas fa-chalkboard-user fa-2x"></i>
        </div>
        <div>
            <span class="brand-text font-weight-bold">ADMINISTRASI GURU</span>
        </div>
    </a>
    <div class="sidebar">
        <!-- User Panel Premium -->
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
            <div class="image">
                <div class="img-circle elevation-2 d-flex align-items-center justify-content-center" style="width: 35px; height: 35px; background: rgba(14, 95, 64, 0.3); border-radius: 50%;">
                    <i class="fas fa-user-circle fa-2x text-white"></i>
                </div>
            </div>
            <div class="info">
                <a href="#" class="d-block"><?= htmlspecialchars($user['full_name']) ?></a>
                <small>
                    <i class="fas fa-tag"></i> <?= htmlspecialchars($user['role']) ?> | 
                    <i class="fas fa-building"></i> <?= htmlspecialchars($user['unit']) ?>
                </small>
            </div>
        </div>
        
        <nav class="mt-2">
            <ul class="nav nav-pills nav-sidebar flex-column">
                <li class="nav-header">
                    <i class="fas fa-compass"></i> MAIN NAVIGATION
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/dashboard.php" class="nav-link <?= (basename($_SERVER['PHP_SELF'])=='dashboard.php')?'active':'' ?>">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>Dashboard</p>
                    </a>
                </li>

                <!-- MASTER DATA (Super Admin & Kepala) -->
                <?php if(in_array($user['role'], ['Super Admin', 'Kepala'])): ?>
                <li class="nav-header">
                    <i class="fas fa-database"></i> MASTER DATA
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/kelola_kelas.php" class="nav-link">
                        <i class="nav-icon fas fa-school"></i>
                        <p>Kelola Kelas</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/kelola_siswa.php" class="nav-link">
                        <i class="nav-icon fas fa-user-graduate"></i>
                        <p>Kelola Siswa</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/import_excel.php" class="nav-link">
                        <i class="nav-icon fas fa-file-excel"></i>
                        <p>Import Excel</p>
                    </a>
                </li>
                <?php endif; ?>

                <!-- MANAGEMENT (Super Admin Only) -->
                <?php if($user['role'] == 'Super Admin'): ?>
                <li class="nav-header">
                    <i class="fas fa-users-cog"></i> MANAGEMENT
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/kelola_user.php" class="nav-link">
                        <i class="nav-icon fas fa-users-cog"></i>
                        <p>Kelola User</p>
                    </a>
                </li>
                <?php endif; ?>

                <!-- MONITORING (Kepala, Pimpinan, Super Admin) -->
                <?php if(in_array($user['role'], ['Kepala', 'Pimpinan', 'Super Admin'])): ?>
                <li class="nav-header">
                    <i class="fas fa-chart-line"></i> MONITORING
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/monitoring.php" class="nav-link">
                        <i class="nav-icon fas fa-chart-line"></i>
                        <p>Monitoring</p>
                    </a>
                </li>
                <?php endif; ?>

                <!-- SUPERVISI (Kepala, Pimpinan, Super Admin) -->
                <?php if(in_array($user['role'], ['Kepala', 'Pimpinan', 'Super Admin'])): ?>
                <li class="nav-header">
                    <i class="fas fa-clipboard-list"></i> SUPERVISI
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/supervisi.php" class="nav-link">
                        <i class="nav-icon fas fa-calendar-alt"></i>
                        <p>Buat Supervisi</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/jadwal_supervisi.php" class="nav-link">
                        <i class="nav-icon fas fa-calendar-week"></i>
                        <p>Jadwal Supervisi</p>
                    </a>
                </li>
                <?php endif; ?>

                <!-- SUPERVISI INSTRUMEN (Kepala, Super Admin) -->
                <?php if(in_array($user['role'], ['Kepala', 'Super Admin'])): ?>
                <li class="nav-item">
                    <a href="/sekolah_app/supervisi/supervisi_menu.php" class="nav-link">
                        <i class="nav-icon fas fa-clipboard-list"></i>
                        <p>Instrumen Supervisi</p>
                    </a>
                </li>
                <?php endif; ?>

                <!-- GURU ACTIVITIES (Guru Only) -->
                <?php if($user['role'] == 'Guru'): ?>
                <li class="nav-header">
                    <i class="fas fa-tasks"></i> GURU ACTIVITIES
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/jadwal_supervisi_guru.php" class="nav-link">
                        <i class="nav-icon fas fa-calendar-check"></i>
                        <p>Jadwal Supervisi</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/jurnal_mengajar.php" class="nav-link">
                        <i class="nav-icon fas fa-book-open"></i>
                        <p>Jurnal Mengajar</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/input_nilai.php" class="nav-link">
                        <i class="nav-icon fas fa-star"></i>
                        <p>Input Nilai</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/absensi_siswa.php" class="nav-link">
                        <i class="nav-icon fas fa-fingerprint"></i>
                        <p>Absensi Siswa</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/rekap_guru.php" class="nav-link">
                        <i class="nav-icon fas fa-chart-pie"></i>
                        <p>Rekap Data</p>
                    </a>
                </li>
                <?php endif; ?>

                <!-- SETTINGS (All Users) -->
                <li class="nav-header">
                    <i class="fas fa-cog"></i> SETTINGS
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/ganti_password.php" class="nav-link">
                        <i class="nav-icon fas fa-key"></i>
                        <p>Ganti Password</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/sekolah_app/logout.php" class="nav-link text-danger">
                        <i class="nav-icon fas fa-sign-out-alt"></i>
                        <p>Logout</p>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
</aside>