<nav x-data="{ open: false }" class="bg-white border-b border-gray-100">
    <!-- Primary Navigation Menu -->
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between h-16">
            <div class="flex">
                <!-- Logo -->
                <div class="shrink-0 flex items-center">
                    <a href="{{ route('dashboard') }}">
                        <x-application-logo class="block h-9 w-auto fill-current text-gray-800" />
                    </a>
                </div>

                <!-- Navigation Links -->
                <div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
                    <x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
                        {{ __('Dashboard') }}
                    </x-nav-link>
                    @if(Auth::user()->canAccess('can_manage_employees'))
                    <div class="hidden sm:flex sm:items-center sm:ms-6">
                        <x-dropdown align="left" width="48">
                            <x-slot name="trigger">
                                <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                                    <div class="{{ request()->routeIs('employees.*') || request()->routeIs('designations.*') ? 'text-gray-900 font-bold' : '' }}">
                                        {{ __('Employees') }}
                                    </div>
                                    <div class="ms-1">
                                        <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                        </svg>
                                    </div>
                                </button>
                            </x-slot>
                            <x-slot name="content">
                                <x-dropdown-link :href="route('employees.index')">
                                    {{ __('Employee List') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('employees.create')">
                                    {{ __('Add Employee') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('employees.import-export')">
                                    {{ __('Import / Export') }}
                                </x-dropdown-link>
                                <hr class="border-gray-100">
                                <x-dropdown-link :href="route('designations.create')">
                                    {{ __('Create Position') }}
                                </x-dropdown-link>
                                <hr class="border-gray-100">
                                <x-dropdown-link :href="route('processes.index', ['type' => 'onboarding'])">
                                    {{ __('Onboarding') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('processes.index', ['type' => 'offboarding'])">
                                    {{ __('Offboarding') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('process-templates.index')">
                                    {{ __('Process Templates') }}
                                </x-dropdown-link>
                                <hr class="border-gray-100">
                                <x-dropdown-link :href="route('departments.index')">
                                    {{ __('Departments') }}
                                </x-dropdown-link>
                            </x-slot>
                        </x-dropdown>
                    </div>
                    @endif
                    <div class="hidden sm:flex sm:items-center sm:ms-6">
                        <x-dropdown align="left" width="48">
                            <x-slot name="trigger">
                                <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                                    <div class="{{ request()->routeIs('leave-types.*') || request()->routeIs('leave-requests.*') || request()->routeIs('manual-attendance.*') ? 'text-gray-900 font-bold' : '' }}">
                                        {{ __('HR') }}
                                    </div>
                                    <div class="ms-1">
                                        <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                        </svg>
                                    </div>
                                </button>
                            </x-slot>
                            <x-slot name="content">
                                <x-dropdown-link :href="route('leave-requests.index')">
                                    {{ __('Leave Requests') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('loans.index')">
                                    {{ __('Loans') }}
                                </x-dropdown-link>
                                @if(Auth::user()->canAccess('can_manage_hr'))
                                    <x-dropdown-link :href="route('leave-types.index')">
                                        {{ __('Leave Types') }}
                                    </x-dropdown-link>
                                @endif
                                @if(Auth::user()->canAccess('can_view_reports'))
                                    <hr class="border-gray-100">
                                    <x-dropdown-link :href="route('reports.salary')">
                                        {{ __('Salary & Loan Report') }}
                                    </x-dropdown-link>
                                    <x-dropdown-link :href="route('reports.employees')">
                                        {{ __('Employee Details Report') }}
                                    </x-dropdown-link>
                                @endif
                            </x-slot>
                        </x-dropdown>
                    </div>
                    <!-- Devices Dropdown -->
                    @if(Auth::user()->canAccess('can_manage_devices'))
                    <div class="hidden sm:flex sm:items-center sm:ms-6">
                        <x-dropdown align="left" width="48">
                            <x-slot name="trigger">
                                <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                                    <div class="{{ request()->routeIs('biotime-devices.*') || request()->routeIs('areas.*') ? 'text-gray-900 font-bold' : '' }}">
                                        {{ __('Devices') }}
                                    </div>
                                    <div class="ms-1">
                                        <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                        </svg>
                                    </div>
                                </button>
                            </x-slot>
                            <x-slot name="content">
                                <x-dropdown-link :href="route('biotime-devices.index')">
                                    {{ __('Device List') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('areas.index')">
                                    {{ __('Areas') }}
                                </x-dropdown-link>
                            </x-slot>
                        </x-dropdown>
                    </div>
                    @endif

                    <!-- Attendance Dropdown -->
                    <div class="hidden sm:flex sm:items-center sm:ms-6">
                        <x-dropdown align="left" width="48">
                            <x-slot name="trigger">
                                <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                                    <div class="{{ request()->routeIs('attendance.*') || request()->routeIs('shifts.*') || request()->routeIs('schedules.*') ? 'text-gray-900 font-bold' : '' }}">
                                        {{ __('Attendance') }}
                                    </div>
                                    <div class="ms-1">
                                        <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                        </svg>
                                    </div>
                                </button>
                            </x-slot>
                            <x-slot name="content">
                                <x-dropdown-link :href="route('attendance.index')">
                                    {{ __('Daily Attendance') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('attendance.logs')">
                                    {{ __('Punch Logs') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('manual-attendance.index')">
                                    {{ __('Manual Attendance') }}
                                </x-dropdown-link>
                                @if(Auth::user()->canAccess('can_manage_hr'))
                                    <x-dropdown-link :href="route('attendance.sync-logs')">
                                        {{ __('Sync Monitoring') }}
                                    </x-dropdown-link>
                                    <hr class="border-gray-100">
                                    <x-dropdown-link :href="route('shifts.index')">
                                        {{ __('Shift Management') }}
                                    </x-dropdown-link>
                                    <x-dropdown-link :href="route('schedules.index')">
                                        {{ __('Schedule Management') }}
                                    </x-dropdown-link>
                                @endif
                                @if(Auth::user()->canAccess('can_view_reports'))
                                    <hr class="border-gray-100">
                                    <x-dropdown-link :href="route('reports.time-card')">
                                        {{ __('Time Card Report') }}
                                    </x-dropdown-link>
                                    <x-dropdown-link :href="route('reports.weekly')">
                                        {{ __('Weekly Report') }}
                                    </x-dropdown-link>
                                    <x-dropdown-link :href="route('reports.monthly')">
                                        {{ __('Monthly Report') }}
                                    </x-dropdown-link>
                                @endif
                            </x-slot>
                        </x-dropdown>
                    </div>

                    @if(Auth::user()->canAccess('can_manage_payroll'))
                    <div class="hidden sm:flex sm:items-center sm:ms-6">
                        <x-dropdown align="left" width="48">
                            <x-slot name="trigger">
                                <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                                    <div class="{{ request()->routeIs('salary-structures.*') || request()->routeIs('payslips.*') ? 'text-gray-900 font-bold' : '' }}">
                                        {{ __('Payroll') }}
                                    </div>
                                    <div class="ms-1">
                                        <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                        </svg>
                                    </div>
                                </button>
                            </x-slot>
                            <x-slot name="content">
                                <x-dropdown-link :href="route('salary-structures.index')">
                                    {{ __('Salary Structures') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('payslips.index')">
                                    {{ __('Payslips') }}
                                </x-dropdown-link>
                            </x-slot>
                        </x-dropdown>
                    </div>
                    @endif

                    <!-- System Dropdown -->
                    @if(Auth::user()->canAccess('can_manage_system'))
                    <div class="hidden sm:flex sm:items-center sm:ms-6">
                        <x-dropdown align="left" width="48">
                            <x-slot name="trigger">
                                <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                                    <div class="{{ request()->routeIs('settings.*') || request()->routeIs('users.*') || request()->routeIs('roles.*') || request()->routeIs('backup.*') ? 'text-gray-900 font-bold' : '' }}">
                                        {{ __('System') }}
                                    </div>
                                    <div class="ms-1">
                                        <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                        </svg>
                                    </div>
                                </button>
                            </x-slot>
                            <x-slot name="content">
                                <x-dropdown-link :href="route('settings.index')">
                                    {{ __('Company Settings') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('users.index')">
                                    {{ __('User Management') }}
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('roles.index')">
                                    {{ __('Role Management') }}
                                </x-dropdown-link>
                                <hr class="border-gray-100">
                                <x-dropdown-link :href="route('backup.index')">
                                    {{ __('Backup System') }}
                                </x-dropdown-link>
                            </x-slot>
                        </x-dropdown>
                    </div>
                    @endif
                </div>
            </div>

            <div class="hidden sm:flex sm:items-center sm:ms-6">
                <!-- Language Dropdown -->
                <x-dropdown align="right" width="48">
                    <x-slot name="trigger">
                        <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                            <div>{{ session('locale', config('app.locale')) == 'ar' ? 'العربية' : 'English' }}</div>

                            <div class="ms-1">
                                <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                </svg>
                            </div>
                        </button>
                    </x-slot>

                    <x-slot name="content">
                        <x-dropdown-link :href="route('language.switch', 'en')">
                            English
                        </x-dropdown-link>
                        <x-dropdown-link :href="route('language.switch', 'ar')">
                            العربية
                        </x-dropdown-link>
                    </x-slot>
                </x-dropdown>
            </div>

            <!-- Settings Dropdown -->
            <div class="hidden sm:flex sm:items-center sm:ms-6">
                <x-dropdown align="right" width="48">
                    <x-slot name="trigger">
                        <button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
                            <div>{{ Auth::user()->name }}</div>

                            <div class="ms-1">
                                <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                </svg>
                            </div>
                        </button>
                    </x-slot>

                    <x-slot name="content">
                        <x-dropdown-link :href="route('profile.edit')">
                            {{ __('Profile') }}
                        </x-dropdown-link>

                        <!-- Authentication -->
                        <form method="POST" action="{{ route('logout') }}">
                            @csrf

                            <x-dropdown-link :href="route('logout')"
                                    onclick="event.preventDefault();
                                                this.closest('form').submit();">
                                {{ __('Log Out') }}
                            </x-dropdown-link>
                        </form>
                    </x-slot>
                </x-dropdown>
            </div>

            <!-- Hamburger -->
            <div class="-me-2 flex items-center sm:hidden">
                <button @click="open = ! open" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out">
                    <svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
                        <path :class="{'hidden': open, 'inline-flex': ! open }" class="inline-flex" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
                        <path :class="{'hidden': ! open, 'inline-flex': open }" class="hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            </div>
        </div>
    </div>

    <!-- Responsive Navigation Menu -->
    <div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden">
        <div class="pt-2 pb-3 space-y-1">
            <x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
                {{ __('Dashboard') }}
            </x-responsive-nav-link>
            @if(Auth::user()->canAccess('can_manage_employees'))
                <x-responsive-nav-link :href="route('employees.index')" :active="request()->routeIs('employees.*')">
                    {{ __('Employees') }}
                </x-responsive-nav-link>
                <x-responsive-nav-link :href="route('designations.create')" :active="request()->routeIs('designations.create')">
                    {{ __('Create Position') }}
                </x-responsive-nav-link>
                <x-responsive-nav-link :href="route('processes.index', ['type' => 'onboarding'])" :active="request()->routeIs('processes.*')">
                    {{ __('Onboarding') }}
                </x-responsive-nav-link>
                <x-responsive-nav-link :href="route('processes.index', ['type' => 'offboarding'])" :active="request()->routeIs('processes.*')">
                    {{ __('Offboarding') }}
                </x-responsive-nav-link>
                <x-responsive-nav-link :href="route('process-templates.index')" :active="request()->routeIs('process-templates.*')">
                    {{ __('Process Templates') }}
                </x-responsive-nav-link>
            @endif

            <div class="pt-2 pb-1 border-t border-gray-200">
                <div class="px-4 font-medium text-base text-gray-800">{{ __('HR') }}</div>
                <x-responsive-nav-link :href="route('leave-requests.index')" :active="request()->routeIs('leave-requests.*')">
                    {{ __('Leave Requests') }}
                </x-responsive-nav-link>
                <x-responsive-nav-link :href="route('loans.index')" :active="request()->routeIs('loans.*')">
                    {{ __('Loans') }}
                </x-responsive-nav-link>
                @if(Auth::user()->canAccess('can_manage_hr'))
                    <x-responsive-nav-link :href="route('leave-types.index')" :active="request()->routeIs('leave-types.*')">
                        {{ __('Leave Types') }}
                    </x-responsive-nav-link>
                @endif
                @if(Auth::user()->canAccess('can_view_reports'))
                    <x-responsive-nav-link :href="route('reports.time-card')" :active="request()->routeIs('reports.time-card')">
                        {{ __('Time Card Report') }}
                    </x-responsive-nav-link>
                    <x-responsive-nav-link :href="route('reports.salary')" :active="request()->routeIs('reports.salary')">
                        {{ __('Salary & Loan Report') }}
                    </x-responsive-nav-link>
                    <x-responsive-nav-link :href="route('reports.employees')" :active="request()->routeIs('reports.employees')">
                        {{ __('Employee Details Report') }}
                    </x-responsive-nav-link>
                    <x-responsive-nav-link :href="route('reports.weekly')" :active="request()->routeIs('reports.weekly')">
                        {{ __('Weekly Report') }}
                    </x-responsive-nav-link>
                    <x-responsive-nav-link :href="route('reports.monthly')" :active="request()->routeIs('reports.monthly')">
                        {{ __('Monthly Report') }}
                    </x-responsive-nav-link>
                @endif
            </div>

            <!-- Devices Responsive -->
            @if(Auth::user()->canAccess('can_manage_devices'))
                <div class="pt-2 pb-1 border-t border-gray-200">
                    <div class="px-4 font-medium text-base text-gray-800">{{ __('Devices') }}</div>
                    <x-responsive-nav-link :href="route('biotime-devices.index')" :active="request()->routeIs('biotime-devices.*')">
                        {{ __('Device List') }}
                    </x-responsive-nav-link>
                    <x-responsive-nav-link :href="route('areas.index')" :active="request()->routeIs('areas.*')">
                        {{ __('Areas') }}
                    </x-responsive-nav-link>
                </div>
            @endif

            <!-- Attendance Responsive -->
            <div class="pt-2 pb-1 border-t border-gray-200">
                <div class="px-4 font-medium text-base text-gray-800">{{ __('Attendance') }}</div>
                <x-responsive-nav-link :href="route('attendance.index')" :active="request()->routeIs('attendance.*')">
                    {{ __('Daily Attendance') }}
                </x-responsive-nav-link>
                <x-responsive-nav-link :href="route('attendance.logs')" :active="request()->routeIs('attendance.logs')">
                    {{ __('Punch Logs') }}
                </x-responsive-nav-link>
                <x-responsive-nav-link :href="route('manual-attendance.index')" :active="request()->routeIs('manual-attendance.*')">
                    {{ __('Manual Attendance') }}
                </x-responsive-nav-link>
                @if(Auth::user()->canAccess('can_manage_hr'))
                    <x-responsive-nav-link :href="route('shifts.index')" :active="request()->routeIs('shifts.*')">
                        {{ __('Shift Management') }}
                    </x-responsive-nav-link>
                    <x-responsive-nav-link :href="route('schedules.index')" :active="request()->routeIs('schedules.*')">
                        {{ __('Schedule Management') }}
                    </x-responsive-nav-link>
                @endif
            </div>

            @if(Auth::user()->canAccess('can_manage_payroll'))
                <div class="pt-2 pb-1 border-t border-gray-200">
                    <div class="px-4 font-medium text-base text-gray-800">{{ __('Payroll') }}</div>
                    <x-responsive-nav-link :href="route('salary-structures.index')" :active="request()->routeIs('salary-structures.*')">
                        {{ __('Salary Structures') }}
                    </x-responsive-nav-link>
                    <x-responsive-nav-link :href="route('payslips.index')" :active="request()->routeIs('payslips.*')">
                        {{ __('Payslips') }}
                    </x-responsive-nav-link>
                </div>
            @endif
        </div>

        <!-- Responsive Settings Options -->
        <div class="pt-4 pb-1 border-t border-gray-200">
            <div class="px-4">
                <div class="font-medium text-base text-gray-800">{{ Auth::user()->name }}</div>
                <div class="font-medium text-sm text-gray-500">{{ Auth::user()->email }}</div>
            </div>

            <div class="mt-3 space-y-1">
                <x-responsive-nav-link :href="route('profile.edit')">
                    {{ __('Profile') }}
                </x-responsive-nav-link>

                <!-- Authentication -->
                <form method="POST" action="{{ route('logout') }}">
                    @csrf

                    <x-responsive-nav-link :href="route('logout')"
                            onclick="event.preventDefault();
                                        this.closest('form').submit();">
                        {{ __('Log Out') }}
                    </x-responsive-nav-link>
                </form>
            </div>
        </div>
    </div>
</nav>
