<nav x-data="{ open: false }" class="border-b border-gray-100" style="background-color: rgba(87, 7, 65, 1);">
    <div class="w-full mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between items-center h-16">
            <!-- Logo -->
            <div class="shrink-0 flex items-center">
                <a href="{{ route('dashboard') }}">
                    <img src="{{ asset('img/LogoTA.png') }}" alt="LogoSDN Nyalindung2" class="block h-12 w-auto">
                </a>
                <span class="pl-3 text-white">SIBILING SEJIWA</span>
            </div>

            <!-- Navigation Links -->
            @hasrole('Siswa')
                <div class="flex-1 ml-6 hidden sm:flex flex-wrap items-center gap-2 text-sm px-2">
                    <x-nav-link class="text-white hover:bg-fuchsia-950 active:bg-none" :href="route('dashboard')" :active="request()->routeIs('dashboard') || request()->routeIs('siswa.create')">
                        <i class="fa-solid fa-home pr-2"></i>{{ __('BERANDA') }}
                    </x-nav-link>

                    <x-nav-link class="text-white hover:bg-fuchsia-950" :href="route('siswa.index')" :active="request()->routeIs('siswa.index') || request()->routeIs('siswa.create')">
                        <i class="fa-solid fa-user pr-2"></i>{{ __('DATA SISWA') }}
                    </x-nav-link>

                    <div class="hidden space-x-8 sm:items-center sm:-my-px sm:flex">
                        <x-dropdown align="left" width="48">
                            <x-slot name="trigger">
                                <button
                                    class="text-white hover:bg-fuchsia-950 px-3 py-2 rounded-md text-sm font-medium inline-flex items-center">
                                    <i class="fa-solid fa-calendar-days pr-2"></i>{{ __('JADWAL') }}
                                    <svg class="ml-1 h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"
                                        fill="currentColor">
                                        <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>
                                </button>
                            </x-slot>

                            <x-slot name="content">
                                <x-dropdown-link :href="route('jadwalbk.index')" class="flex items-center">
                                    <i class="fa-solid fa-calendar pr-2 text-sm"></i> KONSELING BK
                                </x-dropdown-link>
                                <x-dropdown-link :href="route('jadwaljiwa.index')" class="flex items-center">
                                    <i class="fa-solid fa-calendar pr-2 text-sm"></i> SPESIALIS KEJIWAAN
                                </x-dropdown-link>
                            </x-slot>
                        </x-dropdown>
                    </div>

                    <x-nav-link class="text-white hover:bg-fuchsia-950" :href="route('pengaduan.index')" :active="request()->routeIs('pengaduan.index') || request()->routeIs('pengaduan.create')">
                        <i class="sw"></i>{{ __('PENGADUAN') }}
                    </x-nav-link>

                    <x-nav-link class="text-white hover:bg-fuchsia-950" :href="route('pelanggaran.index')" :active="request()->routeIs('pelanggaran.index') || request()->routeIs('pelanggaran.create')">
                        <i class="fa-solid fa-paper-plane pr-2"></i>{{ __('PELANGGARAN') }}
                    </x-nav-link>

                    @php
                        $userId = Auth::id();

                        $siswa = \App\Models\Siswa::where('id_user', $userId)->first();
                        $tindaklanjut = $siswa ? \App\Models\Rujukan::where('id_siswa', $siswa->id_siswa)->get() : collect();
                    @endphp

                    @if ($tindaklanjut->isNotEmpty())
                        <x-nav-link class="text-white hover:bg-fuchsia-950" :href="route('chat.index', 0)" :active="request()->routeIs('chat.*')">
                            <i class="fa-solid fa-message pr-2"></i>{{ __('CHAT') }}
                        </x-nav-link>
                    @endif
                </div>
            @endhasrole

            <!-- 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 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">

                        <!-- 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>
        </div>
    </div>
</nav>
