@php $u = auth()->user(); @endphp
<aside class="sidenav navbar navbar-vertical navbar-expand-xs border-0 border-radius-xl my-3 fixed-start ms-3 bg-white" id="sidenav-main">
    <div class="sidenav-header">
        <a class="navbar-brand m-0 d-flex align-items-center px-4 py-3" href="{{ route('dashboard') }}">
            <img src="{{ asset('assets/img/logo-main.png') }}" class="navbar-brand-img" alt="MyIndependent">
        </a>
    </div>
    <hr class="horizontal dark mt-0">
    <div class="collapse navbar-collapse w-auto" id="sidenav-collapse-main">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('dashboard') ? 'active' : '' }}" href="{{ route('dashboard') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-speedometer2 text-primary"></i></div>
                    <span class="nav-link-text ms-1">Dashboard</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('staff.*') ? 'active' : '' }}" href="{{ route('staff.index') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-people text-primary"></i></div>
                    <span class="nav-link-text ms-1">{{ $u->isStaff() ? 'My Profile' : 'Staff' }}</span>
                </a>
            </li>

            {{-- Sites + renewals are admin/supervisor routes; don't advertise them to finance. --}}
            @if($u->isAdmin() || $u->isSupervisor())
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('sites.*') ? 'active' : '' }}" href="{{ route('sites.index') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-geo-alt text-primary"></i></div>
                    <span class="nav-link-text ms-1">Sites / Projects</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('renewals.*') ? 'active' : '' }}" href="{{ route('renewals.index') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-passport text-primary"></i></div>
                    <span class="nav-link-text ms-1">Permits &amp; Renewals</span>
                </a>
            </li>
            @endif

            @if($u->isAdmin() || $u->isFinance() || $u->isSupervisor())
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('attendance.*') ? 'active' : '' }}" href="{{ route('attendance.summary') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-calendar-check text-primary"></i></div>
                    <span class="nav-link-text ms-1">Attendance</span>
                </a>
            </li>
            @endif

            @if($u->isAdmin() || $u->isFinance() || $u->isStaff())
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('payroll.*') || request()->routeIs('payslips.*') ? 'active' : '' }}"
                   href="{{ $u->isStaff() ? route('payslips.mine') : route('payroll.index') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-cash-stack text-primary"></i></div>
                    <span class="nav-link-text ms-1">{{ $u->isStaff() ? 'My Payslips' : 'Payroll' }}</span>
                </a>
            </li>
            @endif

            @if($u->isAdmin() || $u->isSupervisor())
            <li class="nav-item mt-2">
                <h6 class="ps-4 ms-2 text-uppercase text-xs font-weight-bolder opacity-6">Setup</h6>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('setup.*') ? 'active' : '' }}" href="{{ route('setup.index') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-list-check text-primary"></i></div>
                    <span class="nav-link-text ms-1">Complete Records</span>
                </a>
            </li>
            @endif

            @if($u->isAdmin())
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('import.*') ? 'active' : '' }}" href="{{ route('import.show') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-file-earmark-spreadsheet text-primary"></i></div>
                    <span class="nav-link-text ms-1">Import Excel</span>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('users.*') ? 'active' : '' }}" href="{{ route('users.index') }}">
                    <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
                        <i class="bi bi-shield-lock text-primary"></i></div>
                    <span class="nav-link-text ms-1">User Accounts</span>
                </a>
            </li>
            @endif
        </ul>
    </div>
</aside>
