<!-- Sidebar -->
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

    <!-- Brand -->
    <a class="sidebar-brand d-flex align-items-center justify-content-center" 
       href="<?= base_url($this->session->userdata('role') === 'admin' ? 'admin' : ($this->session->userdata('role') === 'inspector' ? 'admin' : 'user')); ?>">
        <div class="sidebar-brand-icon rotate-n-15">
            <i class="fas fa-car-side"></i>
        </div>
        <div class="sidebar-brand-text mx-3">NOKA NOSIN</div>
    </a>

    <!-- Divider -->
    <hr class="sidebar-divider my-0">

    <!-- Dashboard -->
    <li class="nav-item <?= ($this->uri->segment(1) == 'admin' && $this->uri->segment(2) == '') ? 'active' : ''; ?>">
        <a class="nav-link" href="<?= base_url($this->session->userdata('role') === 'user' ? 'user' : 'admin'); ?>">
            <i class="fas fa-home"></i>
            <span>Dashboard</span>
        </a>
    </li>

    <!-- Divider -->
    <hr class="sidebar-divider">

    <!-- ========================= -->
    <!-- 👑 ADMIN & INSPECTOR MENU -->
    <!-- ========================= -->
    <?php if (in_array($this->session->userdata('role'), ['admin', 'inspector'])): ?>

        <div class="sidebar-heading">
            Manajemen Data
        </div>

        <!-- Data Gesek -->
        <li class="nav-item <?= $this->uri->segment(2) == 'data_gesek' ? 'active' : ''; ?>">
            <a class="nav-link" href="<?= base_url('admin/data_gesek'); ?>">
                <i class="fas fa-file-alt"></i>
                <span>Data Gesek</span>
            </a>
        </li>

        <!-- Manajemen User (hanya admin) -->
        <?php if ($this->session->userdata('role') === 'admin'): ?>
            <li class="nav-item <?= $this->uri->segment(2) == 'users' ? 'active' : ''; ?>">
                <a class="nav-link" href="<?= base_url('admin/users'); ?>">
                    <i class="fas fa-users"></i>
                    <span>Manajemen User</span>
                </a>
            </li>
        <?php endif; ?>

        <!-- Laporan -->
        <li class="nav-item <?= $this->uri->segment(2) == 'laporan' ? 'active' : ''; ?>">
  <a class="nav-link" href="<?= base_url('laporan'); ?>">
    <i class="fas fa-clipboard-list"></i>
    <span>Laporan</span>
  </a>
</li>


    <!-- ========================= -->
    <!-- 🧰 MENU UNTUK USER -->
    <!-- ========================= -->
    <?php elseif ($this->session->userdata('role') === 'user'): ?>

        <div class="sidebar-heading">
            Menu Petugas
        </div>

        <li class="nav-item <?= $this->uri->segment(1) == 'form' ? 'active' : ''; ?>">
            <a class="nav-link" href="<?= base_url('form'); ?>">
                <i class="fas fa-file-signature"></i>
                <span>Form Gesek</span>
            </a>
        </li>

        <li class="nav-item <?= $this->uri->segment(1) == 'laporan' ? 'active' : ''; ?>">
            <a class="nav-link" href="<?= base_url('laporan'); ?>">
                <i class="fas fa-clipboard-check"></i>
                <span>Laporan</span>
            </a>
        </li>

    <?php endif; ?>

    <!-- Divider -->
    <hr class="sidebar-divider">

    <!-- Logout -->
    <li class="nav-item">
        <a class="nav-link" href="<?= base_url('auth/logout'); ?>" onclick="return confirm('Yakin ingin logout?');">
            <i class="fas fa-sign-out-alt"></i>
            <span>Logout</span>
        </a>
    </li>

    <!-- Divider -->
    <hr class="sidebar-divider d-none d-md-block">

</ul>
<!-- End of Sidebar -->
