<?php
$current_url = service('uri')->getSegment(1);
$current_url2 = service('uri')->getSegment(2);
?>

<aside id="sidebar" class="sidebar">
  <ul class="sidebar-nav" id="sidebar-nav">

    <!-- Menu Dashboard -->
    <li class="nav-item">
      <a class="nav-link <?= $current_url == 'dashboard' ? 'active' : 'collapsed' ?>" href="<?= base_url('dashboard') ?>">
        <i class="bi bi-grid"></i>
        <span>Dashboard</span>
      </a>
    </li>

    <!-- Menu khusus admin -->
    <?php if (session()->get('login')['role'] === 'admin'): ?>
      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'guru' && $current_url2 == '' ? 'active' : 'collapsed' ?>" href="<?= base_url('/guru') ?>">
          <i class="bi bi-person-plus"></i>
          <span>Data Guru</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'kelas' ? 'active' : 'collapsed' ?>" href="<?= base_url('/kelas') ?>">
          <i class="bi bi-building"></i>
          <span>Manajemen Kelas</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'periode' ? 'active' : 'collapsed' ?>" href="<?= base_url('/periode') ?>">
          <i class="bi bi-calendar-date"></i>
          <span>Periode</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'evaluasi' && $current_url2 == 'evaluasi_admin' ? 'active' : 'collapsed' ?>" href="<?= base_url('/evaluasi/evaluasi_admin') ?>">
          <i class="bi bi-book"></i>
          <span>Rekap Hasil Evaluasi</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'users' ? 'active' : 'collapsed' ?>" href="<?= base_url('/users') ?>">
          <i class="bi bi-person-fill-gear"></i>
          <span>Manajemen Akun</span>
        </a>
      </li>
    <?php endif; ?>

    <!-- Menu khusus kepsek -->
    <?php if (session()->get('login')['role'] === 'kepsek'): ?>
      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'guru' && $current_url2 == 'input' ? 'active' : 'collapsed' ?>" href="<?= base_url('/guru/input') ?>">
          <i class="bi bi-people-fill"></i>
          <span>Data Guru</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'evaluasi' && $current_url2 == 'evaluasi_kepsek' ? 'active' : 'collapsed' ?>" href="<?= base_url('/evaluasi/evaluasi_kepsek') ?>">
          <i class="bi bi-book"></i>
          <span>Laporan Kinerja Guru</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'evaluasi' && $current_url2 == 'evaluasi_kinerja' ? 'active' : 'collapsed' ?>" href="<?= base_url('/evaluasi/evaluasi_kinerja') ?>">
          <i class="bi bi-bar-chart-line"></i>
          <span>Evaluasi Kinerja</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'rekap' ? 'active' : 'collapsed' ?>" href="<?= base_url('rekap') ?>">
          <i class="bi bi-book"></i>
          <span>Rekap Performa</span>
        </a>
      </li>
    <?php endif; ?>

    <!-- Menu khusus guru -->
    <?php if (session()->get('login')['role'] === 'guru'): ?>
      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'evaluasi' && $current_url2 == 'evaluasi_guru' ? 'active' : 'collapsed' ?>" href="<?= base_url('/evaluasi/evaluasi_guru') ?>">
          <i class="bi bi-stack"></i>
          <span>Status Laporan</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'guru' && $current_url2 == 'evaluasi' ? 'active' : 'collapsed' ?>" href="<?= base_url('/guru/evaluasi') ?>">
          <i class="bi bi-bar-chart"></i>
          <span>Riwayat Penilaian</span>
        </a>
      </li>

      <li class="nav-item">
        <a class="nav-link <?= $current_url == 'profile' ? 'active' : 'collapsed' ?>" href="<?= base_url('/profile') ?>">
          <i class="bi bi-person"></i>
          <span>Profil Saya</span>
        </a>
      </li>
    <?php endif; ?>
  </ul>
</aside>
