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

<nav id="sidebar">
    <div class="p-4 pt-4 text-center border-bottom border-success border-opacity-50">
        <i class="fa-solid fa-leaf fa-3x mb-3 text-light"></i>
        <h5 class="fw-bold">KPH III ASAHAN</h5>
        <span class="badge bg-light text-success rounded-pill px-3"><?= $role ?></span>
    </div>

    <ul class="list-unstyled p-3">
        <!-- Menu Berlaku untuk SEMUA JABATAN -->
        <li class="mb-2">
            <a href="<?= base_url('/') ?>" class="text-white text-decoration-none d-block p-2 rounded bg-success bg-opacity-25">
                <i class="fa-solid fa-home me-2"></i> Dashboard
            </a>
        </li>
        <li class="mb-2">
            <a href="<?= base_url('arsip') ?>" class="text-white text-decoration-none d-block p-2 rounded hover-bg-success">
                <i class="fa-solid fa-folder-open me-2"></i> Arsip Dokumen
            </a>
        </li>
        <li class="mb-2">
            <a href="<?= base_url('peta') ?>" class="text-white text-decoration-none d-block p-2 rounded hover-bg-success">
                <i class="fa-solid fa-map-location-dot me-2"></i> Peta Spasial
            </a>
        </li>
        <li class="mb-2">
            <a href="<?= base_url('patroli') ?>" class="text-white text-decoration-none d-block p-2 rounded hover-bg-success">
                <i class="fa-solid fa-person-hiking me-2"></i> Laporan Patroli
            </a>
        </li>

       <!-- Menu KHUSUS ADMIN & KEPALA KPH -->
       <?php if($role == 'Admin' || $role == 'Kepala KPH') : ?>
        <li class="mb-2 mt-4">
            <small class="text-light text-opacity-50 text-uppercase fw-bold ps-2">Area Manajemen</small>
        </li>
        <li class="mb-2">
            <a href="<?= base_url('pegawai') ?>" class="text-white text-decoration-none d-block p-2 rounded hover-bg-success">
                <i class="fa-solid fa-users me-2"></i> Data Pegawai
            </a>
        </li>
        
        <!-- MENU BARU: REKAP PATROLI -->
        <li class="mb-2">
            <a href="<?= base_url('patroli/data') ?>" class="text-white text-decoration-none d-block p-2 rounded hover-bg-success border border-light border-opacity-25">
                <i class="fa-solid fa-clipboard-list me-2"></i> Rekap Patroli
            </a>
        </li>
        <?php endif; ?>

        <!-- HANYA ADMIN YANG BISA KELOLA AKUN -->
        <?php if($role == 'Admin') : ?>
        <li class="mb-2">
            <a href="<?= base_url('akun') ?>" class="text-white text-decoration-none d-block p-2 rounded hover-bg-success border border-light border-opacity-25">
                <i class="fa-solid fa-user-shield me-2"></i> Manajemen Akun
            </a>
        </li>
        <?php endif; ?>
    </ul>

    <style>
        .hover-bg-success:hover {
            background-color: rgba(255,255,255,0.1);
        }
    </style>
</nav>