<aside class="sidebar glass" id="sidebar">
    <div class="sidebar-brand">
        <i class='bx bxs-graduation'></i>
        <span>siAkad ITKA</span>
    </div>

    <?php $role_id = session()->get('role_id'); ?>

    <ul class="sidebar-nav">
        <li class="nav-item">
            <a href="<?= base_url() ?>" class="nav-link <?= current_url() == base_url() || current_url() == base_url('/') ? 'active' : '' ?>">
                <i class='bx bx-grid-alt'></i>
                <span>Dashboard</span>
            </a>
        </li>
        
        <?php if (in_array($role_id, [1, 2])): ?>
        <li class="nav-item has-dropdown <?= (strpos(current_url(), '/fakultas') !== false || strpos(current_url(), '/prodi') !== false) ? 'open' : '' ?>">
            <a href="#" class="nav-link <?= (strpos(current_url(), '/fakultas') !== false || strpos(current_url(), '/prodi') !== false) ? 'active' : '' ?>">
                <i class='bx bx-data'></i>
                <span>Data Master</span>
                <i class='bx bx-chevron-down'></i>
            </a>
            <ul class="nav-dropdown">
                <li class="nav-item">
                    <a href="<?= base_url('fakultas') ?>" class="nav-link <?= strpos(current_url(), '/fakultas') !== false ? 'active' : '' ?>">Fakultas</a>
                </li>
                <li class="nav-item">
                    <a href="<?= base_url('prodi') ?>" class="nav-link <?= strpos(current_url(), '/prodi') !== false ? 'active' : '' ?>">Program Studi</a>
                </li>
            </ul>
        </li>

        <li class="nav-item">
            <a href="<?= base_url('mahasiswa') ?>" class="nav-link <?= strpos(current_url(), '/mahasiswa') !== false ? 'active' : '' ?>">
                <i class='bx bx-user'></i>
                <span>Mahasiswa</span>
            </a>
        </li>
        <li class="nav-item has-dropdown <?= (strpos(current_url(), '/dosen') !== false || strpos(current_url(), '/penugasan-dosen') !== false) ? 'open' : '' ?>">
            <a href="#" class="nav-link <?= (strpos(current_url(), '/dosen') !== false || strpos(current_url(), '/penugasan-dosen') !== false) ? 'active' : '' ?>">
                <i class='bx bx-chalkboard'></i>
                <span>Dosen</span>
                <i class='bx bx-chevron-down'></i>
            </a>
            <ul class="nav-dropdown">
                <li class="nav-item">
                    <a href="<?= base_url('dosen') ?>" class="nav-link <?= strpos(current_url(), '/dosen') !== false ? 'active' : '' ?>">Dosen</a>
                </li>
                <li class="nav-item">
                    <a href="<?= base_url('penugasan-dosen') ?>" class="nav-link <?= strpos(current_url(), '/penugasan-dosen') !== false ? 'active' : '' ?>">Penugasan Dosen</a>
                </li>
            </ul>
        </li>
        <li class="nav-item has-dropdown <?= (strpos(current_url(), '/kurikulum') !== false || strpos(current_url(), '/pemetaan-kurikulum') !== false || strpos(current_url(), '/mata-kuliah') !== false || strpos(current_url(), '/kelas-perkuliahan') !== false) ? 'open' : '' ?>">
            <a href="#" class="nav-link <?= (strpos(current_url(), '/kurikulum') !== false || strpos(current_url(), '/pemetaan-kurikulum') !== false || strpos(current_url(), '/mata-kuliah') !== false || strpos(current_url(), '/kelas-perkuliahan') !== false) ? 'active' : '' ?>">
                <i class='bx bx-book-bookmark'></i>
                <span>Akademik</span>
                <i class='bx bx-chevron-down'></i>
            </a>
            <ul class="nav-dropdown">
                <li class="nav-item">
                    <a href="<?= base_url('kurikulum') ?>" class="nav-link <?= current_url() == base_url('kurikulum') ? 'active' : '' ?>">Kurikulum</a>
                </li>
                <li class="nav-item">
                    <a href="<?= base_url('pemetaan-kurikulum') ?>" class="nav-link <?= strpos(current_url(), '/pemetaan-kurikulum') !== false ? 'active' : '' ?>">Pemetaan Kurikulum</a>
                </li>
                <li class="nav-item">
                    <a href="<?= base_url('mata-kuliah') ?>" class="nav-link <?= strpos(current_url(), '/mata-kuliah') !== false ? 'active' : '' ?>">Mata Kuliah</a>
                </li>
                <li class="nav-item">
                    <a href="<?= base_url('kelas-perkuliahan') ?>" class="nav-link <?= strpos(current_url(), '/kelas-perkuliahan') !== false ? 'active' : '' ?>">Kelas Perkuliahan</a>
                </li>
            </ul>
        </li>
        <?php endif; ?>

        <?php if ($role_id == 8): // Mahasiswa ?>
        <li class="nav-item">
            <a href="<?= base_url('krs') ?>" class="nav-link <?= strpos(current_url(), '/krs') !== false ? 'active' : '' ?>">
                <i class='bx bx-edit'></i>
                <span>Isi KRS</span>
            </a>
        </li>
        <?php endif; ?>

        <?php if (in_array($role_id, [6, 7])): // Dosen / Dosen PA ?>
        <li class="nav-item">
            <a href="<?= base_url('persetujuan-krs') ?>" class="nav-link <?= strpos(current_url(), '/persetujuan-krs') !== false ? 'active' : '' ?>">
                <i class='bx bx-check-shield'></i>
                <span>Persetujuan KRS</span>
            </a>
        </li>
        <?php endif; ?>

        <?php if ($role_id == 1): // Super Admin ?>
        <li class="nav-item has-dropdown <?= (strpos(current_url(), '/tahun-akademik') !== false || strpos(current_url(), '/pddikti') !== false) ? 'open' : '' ?>">
            <a href="#" class="nav-link <?= (strpos(current_url(), '/tahun-akademik') !== false || strpos(current_url(), '/pddikti') !== false) ? 'active' : '' ?>">
                <i class='bx bx-cog'></i>
                <span>Pengaturan</span>
                <i class='bx bx-chevron-down'></i>
            </a>
            <ul class="nav-dropdown">
                <li class="nav-item">
                    <a href="<?= base_url('tahun-akademik') ?>" class="nav-link <?= strpos(current_url(), '/tahun-akademik') !== false ? 'active' : '' ?>">Tahun Akademik</a>
                </li>
                <li class="nav-item">
                    <a href="<?= base_url('pddikti/setting') ?>" class="nav-link <?= strpos(current_url(), '/pddikti/setting') !== false ? 'active' : '' ?>">PDDIKTI Feeder</a>
                </li>
            </ul>
        </li>
        <?php endif; ?>
    </ul>
</aside>
