<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="{{ url('/') }}" class="brand-link">
        <span class="brand-text font-weight-light">HRMS Enterprise</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
        <!-- Sidebar Menu -->
        <nav class="mt-2">
            <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
                @if(auth()->user()->canAccess('dashboard.view'))
                <li class="nav-item">
                    <a href="{{ route('dashboard') }}" class="nav-link {{ Request::is('/') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>Dashboard</p>
                    </a>
                </li>
                @endif
                
                @if(auth()->user()->canAccess('employees.view') || auth()->user()->canAccess('payroll.view') || auth()->user()->canAccess('payroll.process') || auth()->user()->canAccess('attendance.view') || auth()->user()->canAccess('leaves.view'))
                <li class="nav-header">CORE MANAGEMENT</li>
                
                @if(auth()->user()->canAccess('employees.view'))
                <li class="nav-item">
                    <a href="{{ route('employees.index') }}" class="nav-link {{ Request::is('employees*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-users"></i>
                        <p>Employees</p>
                    </a>
                </li>
                @endif

                @if(auth()->user()->canAccess('payroll.view') || auth()->user()->canAccess('payroll.process'))
                <li class="nav-item {{ Request::is('salaries*') ? 'menu-open' : '' }}">
                    <a href="#" class="nav-link {{ Request::is('salaries*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-money-check-alt"></i>
                        <p>
                            Payroll
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        @if(auth()->user()->canAccess('payroll.process'))
                        <li class="nav-item">
                            <a href="{{ route('salaries.bulk.processor') }}" class="nav-link {{ Request::is('salaries/processor') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Process Payroll</p>
                            </a>
                        </li>
                        @endif
                        @if(auth()->user()->canAccess('payroll.view'))
                        <li class="nav-item">
                            <a href="{{ route('salaries.index') }}" class="nav-link {{ Request::is('salaries') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Processed Payroll</p>
                            </a>
                        </li>
                        @endif
                    </ul>
                </li>
                @endif

                @if(auth()->user()->canAccess('attendance.view') || auth()->user()->canAccess('attendance.manage_requests'))
                <li class="nav-item {{ Request::is('attendances*', 'attendance-requests*') ? 'menu-open' : '' }}">
                    <a href="#" class="nav-link {{ Request::is('attendances*', 'attendance-requests*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-clock"></i>
                        <p>
                            Attendance
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        @if(auth()->user()->canAccess('attendance.view'))
                        <li class="nav-item">
                            <a href="{{ route('attendances.index') }}" class="nav-link {{ Request::is('attendances') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Punch Records</p>
                            </a>
                        </li>
                        @endif
                        @if(auth()->user()->canAccess('attendance.manage_requests'))
                        <li class="nav-item">
                            <a href="{{ route('attendance-requests.index') }}" class="nav-link {{ Request::is('attendance-requests*') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Requests</p>
                            </a>
                        </li>
                        @endif
                    </ul>
                </li>
                @endif

                @if(auth()->user()->canAccess('leaves.view'))
                <li class="nav-item">
                    <a href="{{ route('leave-requests.index') }}" class="nav-link {{ Request::is('leave-requests*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-calendar-alt"></i>
                        <p>Leaves</p>
                    </a>
                </li>
                @endif
                @endif

                @if(auth()->user()->canAccess('reports.daily') || auth()->user()->canAccess('reports.monthly'))
                <li class="nav-header">REPORTS</li>
                <li class="nav-item {{ Request::is('reports*') ? 'menu-open' : '' }}">
                    <a href="#" class="nav-link {{ Request::is('reports*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-chart-bar"></i>
                        <p>
                            Attendance Reports
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        @if(auth()->user()->canAccess('reports.daily'))
                        <li class="nav-item">
                            <a href="{{ route('reports.attendance.daily') }}" class="nav-link {{ Request::is('reports/attendance/daily') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Daily Report</p>
                            </a>
                        </li>
                        @endif
                        @if(auth()->user()->canAccess('reports.monthly'))
                        <li class="nav-item">
                            <a href="{{ route('reports.attendance.monthly') }}" class="nav-link {{ Request::is('reports/attendance/monthly') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Monthly Summary</p>
                            </a>
                        </li>
                        @endif
                    </ul>
                </li>
                @endif

                @if(auth()->user()->canAccess('assets.view') || auth()->user()->canAccess('expenses.view') || auth()->user()->canAccess('holidays.view'))
                <li class="nav-header">ORGANIZATION</li>
                
                @if(auth()->user()->canAccess('assets.view'))
                <li class="nav-item">
                    <a href="{{ route('assets.index') }}" class="nav-link {{ Request::is('assets*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-laptop"></i>
                        <p>Asset Management</p>
                    </a>
                </li>
                @endif

                @if(auth()->user()->canAccess('expenses.view'))
                <li class="nav-item">
                    <a href="{{ route('expenses.index') }}" class="nav-link {{ Request::is('expenses*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-receipt"></i>
                        <p>Expenses</p>
                    </a>
                </li>
                @endif

                @if(auth()->user()->canAccess('holidays.view'))
                <li class="nav-item">
                    <a href="{{ route('holidays.index') }}" class="nav-link {{ Request::is('holidays*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-umbrella-beach"></i>
                        <p>Holidays</p>
                    </a>
                </li>
                @endif
                @endif

                @if(auth()->user()->canAccess('biometric.view') || auth()->user()->canAccess('settings.general') || auth()->user()->canAccess('roles.manage'))
                <li class="nav-header">SYSTEM CONFIG</li>
                
                @if(auth()->user()->canAccess('biometric.view'))
                <li class="nav-item">
                    <a href="{{ route('biometric-devices.index') }}" class="nav-link {{ Request::is('biometric-devices*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-fingerprint"></i>
                        <p>Biometric Devices</p>
                    </a>
                </li>
                @endif

                @if(auth()->user()->canAccess('roles.manage'))
                <li class="nav-item">
                    <a href="{{ route('roles.index') }}" class="nav-link {{ Request::is('roles*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-user-shield"></i>
                        <p>Role Management</p>
                    </a>
                </li>
                @endif

                @if(auth()->user()->canAccess('settings.general') || auth()->user()->canAccess('settings.theme') || auth()->user()->canAccess('settings.statutory'))
                <li class="nav-item {{ Request::is('settings*') ? 'menu-open' : '' }}">
                    <a href="#" class="nav-link {{ Request::is('settings*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-cogs"></i>
                        <p>
                            Global Settings
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        @if(auth()->user()->canAccess('settings.general'))
                        <li class="nav-item">
                            <a href="{{ route('settings.general') }}" class="nav-link {{ Request::is('settings/general') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>General Settings</p>
                            </a>
                        </li>
                        @endif
                        @if(auth()->user()->canAccess('settings.theme'))
                        <li class="nav-item">
                            <a href="{{ route('settings.theme') }}" class="nav-link {{ Request::is('settings/theme') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Theme & Branding</p>
                            </a>
                        </li>
                        @endif
                        @if(auth()->user()->canAccess('settings.statutory'))
                        <li class="nav-item">
                            <a href="{{ route('settings.statutory') }}" class="nav-link {{ Request::is('settings/statutory') ? 'active' : '' }}">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Statutory Components</p>
                            </a>
                        </li>
                        @endif
                    </ul>
                </li>
                @endif
                @endif

                <li class="nav-header">USER</li>
                
                <li class="nav-item">
                    <a href="{{ route('profile.index') }}" class="nav-link {{ Request::is('profile*') ? 'active' : '' }}">
                        <i class="nav-icon fas fa-user-circle"></i>
                        <p>My Profile</p>
                    </a>
                </li>

                <li class="nav-item">
                    <a href="#" class="nav-link" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                        <i class="nav-icon fas fa-power-off"></i>
                        <p>Logout</p>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
</aside>
