<aside class="w-72 bg-white border-r min-h-screen hidden sm:block">
    <div class="h-full px-4 py-6 overflow-y-auto">

        <nav class="space-y-2">

            <!-- Beranda -->
            <x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
                <x-slot name="icon">
                    <i class="fa-solid fa-house"></i>
                </x-slot>
                Beranda
            </x-nav-link>

            @hasrole('Admin')
                @php
                    $idActiveMaster =
                        request()->routeIs('guru.index') ||
                        request()->routeIs('spesialis.index') ||
                        request()->routeIs('siswa.index');
                @endphp
                <x-sidebar-dropdown label="Master Data" icon="fa-users" :active="$idActiveMaster">
                    <x-sidebar-dropdown-item :href="route('guru.index')" :active="request()->routeIs('guru.index')">
                        <i class="fa-solid fa-user-pen pr-2"></i> Guru
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('spesialis.index')" :active="request()->routeIs('spesialis.index')">
                        <i class="fa-solid fa-user-doctor pr-2"></i> Spesialis
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('siswa.index')" :active="request()->routeIs('siswa.index')">
                        <i class="fa-solid fa-user-group pr-2"></i> Siswa
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <!-- Dropdown Jadwal Konseling -->

                @php
                    $isActiveJadwal = request()->routeIs('jadwalbk.index') || request()->routeIs('jadwaljiwa.index');
                @endphp

                <x-sidebar-dropdown label="Jadwal Konseling" icon="fa-calendar-days" :active="$isActiveJadwal">
                    <x-sidebar-dropdown-item :href="route('jadwalbk.index')" :active="request()->routeIs('jadwalbk.index')">
                        <i class="fa-solid fa-calendar pr-2"></i> BK SMK
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('jadwaljiwa.index')" :active="request()->routeIs('jadwaljiwa.index')">
                        <i class="fa-solid fa-calendar pr-2"></i> Spesialis Kejiwaan
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <!-- Pengaduan -->
                @php
                    $enum = App\Enums\JenisPengaduan::cases();

                    $isActiveKonseling = collect($enum)->contains(function ($item) {
                        return request()->is('pengaduan/jenis/' . $item->value);
                    });

                    $isActiveRiwayat = collect($enum)->contains(function ($item) {
                        return request()->is('riwayat/jenis/' . $item->value);
                    });

                    $icon = [
                        'Pribadi' => 'fa-user',
                        'Sosial' => 'fa-id-badge',
                        'Karier' => 'fa-user-tie',
                        'Belajar' => 'fa-book',
                    ];
                @endphp

                <x-sidebar-dropdown label="Pengaduan BK" icon="fa-envelope-open-text" :active="$isActiveKonseling">
                    @foreach ($enum as $jenis)
                        <x-sidebar-dropdown-item :href="route('pengaduan.jenis', ['jenis' => $jenis->value])" :active="request()->is('pengaduan/jenis/' . $jenis->value)">
                            <i class="fa-solid {{ $icon[$jenis->value] ?? 'fa-question' }} pr-2 text-sm"></i>
                            {{ $jenis->label() }}
                        </x-sidebar-dropdown-item>
                    @endforeach
                </x-sidebar-dropdown>

                <x-sidebar-dropdown label="Riwayat Pengaduan" icon="fa-clock-rotate-left" :active="$isActiveRiwayat">
                    @foreach ($enum as $item)
                        <x-sidebar-dropdown-item :href="route('riwayat.jenis', ['jenis' => $item->value])" :active="request()->is('riwayat/jenis/' . $item->value)">
                            <i class="fa-solid {{ $icon[$item->value] ?? 'fa-question' }} pr-2 text-sm"></i>
                            {{ $item->label() }}
                        </x-sidebar-dropdown-item>
                    @endforeach
                </x-sidebar-dropdown>

                @php
                    $isActiveKonseling =
                        request()->routeIs('pribasos.index') ||
                        request()->routeIs('belajar.index') ||
                        request()->routeIs('karier.index');

                    $isActiveTindakLanjut =
                        request()->routeIs('tindak-lanjut.sp.index') ||
                        request()->routeIs('tindak-lanjut.pindah-sekolah.index') ||
                        request()->routeIs('tindak-lanjut.pengunduran-diri.index') ||
                        request()->routeIs('tindak-lanjut.rujukan-spesialis.index');
                @endphp

                <!-- Dropdown Konseling -->
                <x-sidebar-dropdown label="Data Konseling" icon="fa-table" :active="$isActiveKonseling">
                    <x-sidebar-dropdown-item :href="route('pribasos.index')" :active="request()->routeIs('pribasos.index')">
                        <i class="fa-solid fa-id-badge pr-2"></i> BK - Pribadi Sosial
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('belajar.index')" :active="request()->routeIs('belajar.index')">
                        <i class="fa-solid fa-user-tie pr-2"></i> BK - Belajar
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('karier.index')" :active="request()->routeIs('karier.index')">
                        <i class="fa-solid fa-book pr-2"></i> BK - Karier
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <!-- Pelanggaran -->
                <x-nav-link :href="route('pelanggaran.index')" :active="request()->routeIs('pelanggaran.*')">
                    <x-slot name="icon"><i class="fa-solid fa-file"></i></x-slot>
                    Pelanggaran
                </x-nav-link>

                <!-- Tindak Lanjut -->
                <x-sidebar-dropdown label="Tindak Lanjut" icon="fa-book" :active="$isActiveTindakLanjut">
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.sp.index')" :active="request()->routeIs('tindak-lanjut.sp.index')">
                        <i class="fa-solid fa-scroll pr-2"></i>Kelola SP
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.pindah-sekolah.index')" :active="request()->routeIs('tindak-lanjut.pindah-sekolah.index')">
                        <i class="fa-solid fa-school pr-2"></i>Pindah Sekolah
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.pengunduran-diri.index')" :active="request()->routeIs('tindak-lanjut.pengunduran-diri.index')">
                        <i class="fa-solid fa-scroll pr-2"></i>Pengunduran Diri
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.rujukan-spesialis.index')" :active="request()->routeIs('tindak-lanjut.rujukan-spesialis.index')">
                        <i class="fa-solid fa-school pr-2"></i>Rujukan Spesialis
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <x-nav-link :href="route('chat.index', 0)" :active="request()->routeIs('chat.*')">
                    <x-slot name="icon"><i class="fa-solid fa-message pr-2"></i></x-slot>
                    Chat
                </x-nav-link>

                {{-- @php
            $idActivePenanganan = request()->routeIs('psikolog.index') || request()->routeIs('psikiater.index');
            @endphp

            <x-sidebar-dropdown label="Penanganan Spesialis" icon="fa-hand-holding-heart" :active="$idActivePenanganan">
                <x-sidebar-dropdown-item :href="route('psikolog.index')" :active="request()->routeIs('psikolog.index')">
                    <i class="fa-solid fa-user-doctor pr-2"></i> Penanganan Psikolog
                </x-sidebar-dropdown-item>
                <x-sidebar-dropdown-item :href="route('psikiater.index')" :active="request()->routeIs('psikiater.index')">
                    <i class="fa-solid fa-user-doctor pr-2"></i> Penanganan Psikiater
                </x-sidebar-dropdown-item>
            </x-sidebar-dropdown> --}}

                <x-nav-link :href="route('kuesioner.index')" :active="request()->routeIs('kuesioner.*')">
                    <x-slot name="icon"><i class="fa-solid fa-notes-medical"></i></x-slot>
                    Kuesioner
                </x-nav-link>

                <x-nav-link :href="route('rekap-kuesioner.index')" :active="request()->routeIs('rekap-kuesioner.*')">
                    <x-slot name="icon"><i class="fa-solid fa-notes-medical"></i></x-slot>
                    Rekap Kuesioner
                </x-nav-link>
            @endhasrole

            @hasrole('Spesialis')
                @php
                    $idActiveMaster =
                        request()->routeIs('guru.index') ||
                        request()->routeIs('spesialis.index') ||
                        request()->routeIs('siswa.index');
                @endphp
                <x-sidebar-dropdown label="Master Data" icon="fa-users" :active="$idActiveMaster">
                    <x-sidebar-dropdown-item :href="route('spesialis.index')" :active="request()->routeIs('spesialis.index')">
                        <i class="fa-solid fa-user-doctor pr-2"></i> Spesialis
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('siswa.index')" :active="request()->routeIs('siswa.index')">
                        <i class="fa-solid fa-user-group pr-2"></i> Siswa
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <x-nav-link :href="route('jadwaljiwa.index')" :active="request()->routeIs('jadwaljiwa.index')">
                    <x-slot name="icon"><i class="fa-solid fa-calendar pr-2"></i></x-slot>
                    Jadwal Spesialis
                </x-nav-link>

                <x-nav-link :href="route('tindak-lanjut.rujukan-spesialis.index')" :active="request()->routeIs('tindak-lanjut.rujukan-spesialis.index')">
                    <x-slot name="icon"><i class="fa-solid fa-user-doctor pr-2"></i></x-slot>
                    Rujukan Speslialis
                </x-nav-link>

                <x-nav-link :href="route('chat.index', 0)" :active="request()->routeIs('chat.*')">
                    <x-slot name="icon"><i class="fa-solid fa-message pr-2"></i></x-slot>
                    Chat
                </x-nav-link>

                <!-- <x-nav-link :href="route('psikolog.index')" :active="request()->routeIs('psikolog.index')">
                    <x-slot name="icon"><i class="fa-solid fa-user-doctor pr-2"></i></x-slot>
                    Penanganan Psikolog
                </x-nav-link> -->
            @endhasrole

            @hasrole('KepalaSekolah')
                @php
                    $idActiveMaster =
                        request()->routeIs('guru.index') ||
                        request()->routeIs('spesialis.index') ||
                        request()->routeIs('siswa.index');
                @endphp
                <x-sidebar-dropdown label="Master Data" icon="fa-users" :active="$idActiveMaster">
                    <x-sidebar-dropdown-item :href="route('guru.index')" :active="request()->routeIs('guru.index')">
                        <i class="fa-solid fa-user-pen pr-2"></i> Guru
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('spesialis.index')" :active="request()->routeIs('spesialis.index')">
                        <i class="fa-solid fa-user-doctor pr-2"></i> Spesialis
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('siswa.index')" :active="request()->routeIs('siswa.index')">
                        <i class="fa-solid fa-user-group pr-2"></i> Siswa
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                @php
                    $isActiveKonseling =
                        request()->routeIs('pribasos.index') ||
                        request()->routeIs('belajar.index') ||
                        request()->routeIs('karier.index');

                    $isActiveTindakLanjut =
                        request()->routeIs('tindak-lanjut.sp.index') ||
                        request()->routeIs('tindak-lanjut.pindah-sekolah.index') ||
                        request()->routeIs('tindak-lanjut.pengunduran-diri.index') ||
                        request()->routeIs('tindak-lanjut.rujukan-spesialis.index');
                @endphp

                <x-sidebar-dropdown label="Data Konseling" icon="fa-table" :active="$isActiveKonseling">
                    <x-sidebar-dropdown-item :href="route('pribasos.index')" :active="request()->routeIs('pribasos.index')">
                        <i class="fa-solid fa-id-badge pr-2"></i> BK - Pribadi Sosial
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('belajar.index')" :active="request()->routeIs('belajar.index')">
                        <i class="fa-solid fa-user-tie pr-2"></i> BK - Belajar
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('karier.index')" :active="request()->routeIs('karier.index')">
                        <i class="fa-solid fa-book pr-2"></i> BK - Karier
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <x-sidebar-dropdown label="Tindak Lanjut" icon="fa-book" :active="$isActiveTindakLanjut">
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.sp.index')" :active="request()->routeIs('tindak-lanjut.sp.index')">
                        <i class="fa-solid fa-scroll pr-2"></i>Kelola SP
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.pindah-sekolah.index')" :active="request()->routeIs('tindak-lanjut.pindah-sekolah.index')">
                        <i class="fa-solid fa-school pr-2"></i>Pindah Sekolah
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.pengunduran-diri.index')" :active="request()->routeIs('tindak-lanjut.pengunduran-diri.index')">
                        <i class="fa-solid fa-scroll pr-2"></i>Pengunduran Diri
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.rujukan-spesialis.index')" :active="request()->routeIs('tindak-lanjut.rujukan-spesialis.index')">
                        <i class="fa-solid fa-school pr-2"></i>Rujukan Spesialis
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>
            @endhasrole

            @hasrole('WaliKelas')
                <x-nav-link :href="route('siswa.index')" :active="request()->routeIs('siswa.*')">
                    <x-slot name="icon"><i class="fa-solid fa-user-group"></i></x-slot>
                    Data Siswa
                </x-nav-link>

                <!-- Dropdown Jadwal Konseling -->
                @php
                    $isActiveJadwal = request()->routeIs('jadwalbk.index') || request()->routeIs('jadwaljiwa.index');
                @endphp

                <x-sidebar-dropdown label="Jadwal Konseling" icon="fa-calendar-days" :active="$isActiveJadwal">
                    <x-sidebar-dropdown-item :href="route('jadwalbk.index')" :active="request()->routeIs('jadwalbk.index')">
                        <i class="fa-solid fa-calendar pr-2"></i> BK SMK
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('jadwaljiwa.index')" :active="request()->routeIs('jadwaljiwa.index')">
                        <i class="fa-solid fa-calendar pr-2"></i> Spesialis Kejiwaan
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <x-nav-link :href="route('pengaduan.index')" :active="request()->routeIs('pengaduan.index') || request()->routeIs('pengaduan.create')">
                    <i class="fa-solid fa-file pr-2"></i>{{ __('Pengaduan') }}
                </x-nav-link>
            @endhasanyrole

            @hasrole('GuruBK')
                <x-nav-link :href="route('guru.index')" :active="request()->routeIs('guru.*')">
                    <x-slot name="icon"><i class="fa-solid fa-user-pen"></i></x-slot>
                    Data Guru
                </x-nav-link>

                <x-nav-link :href="route('siswa.index')" :active="request()->routeIs('siswa.*')">
                    <x-slot name="icon"><i class="fa-solid fa-user-group"></i></x-slot>
                    Data Siswa
                </x-nav-link>

                <x-nav-link :href="route('jadwalbk.index')" :active="request()->routeIs('jadwalbk.index')">
                    <x-slot name="icon"><i class="fa-solid fa-calendar"></i></x-slot>
                    Jadwal Konseling BK
                </x-nav-link>

                @php
                    $enum = App\Enums\JenisPengaduan::cases();

                    $isActiveKonseling = collect($enum)->contains(function ($item) {
                        return request()->is('pengaduan/jenis/' . $item->value);
                    });

                    $isActiveRiwayat = collect($enum)->contains(function ($item) {
                        return request()->is('riwayat/jenis/' . $item->value);
                    });

                    $icon = [
                        'Pribadi' => 'fa-user',
                        'Sosial' => 'fa-id-badge',
                        'Karier' => 'fa-user-tie',
                        'Belajar' => 'fa-book',
                    ];
                @endphp

                <x-sidebar-dropdown label="Pengaduan BK" icon="fa-envelope-open-text" :active="$isActiveKonseling">
                    @foreach ($enum as $jenis)
                        <x-sidebar-dropdown-item :href="route('pengaduan.jenis', ['jenis' => $jenis->value])" :active="request()->is('pengaduan/jenis/' . $jenis->value)">
                            <i class="fa-solid {{ $icon[$jenis->value] ?? 'fa-question' }} pr-2 text-sm"></i>
                            {{ $jenis->label() }}
                        </x-sidebar-dropdown-item>
                    @endforeach
                </x-sidebar-dropdown>

                <x-sidebar-dropdown label="Riwayat Pengaduan" icon="fa-clock-rotate-left" :active="$isActiveRiwayat">
                    @foreach ($enum as $item)
                        <x-sidebar-dropdown-item :href="route('riwayat.jenis', ['jenis' => $item->value])" :active="request()->is('riwayat/jenis/' . $item->value)">
                            <i class="fa-solid {{ $icon[$item->value] ?? 'fa-question' }} pr-2 text-sm"></i>
                            {{ $item->label() }}
                        </x-sidebar-dropdown-item>
                    @endforeach
                </x-sidebar-dropdown>

                @php
                    $isActiveKonseling =
                        request()->routeIs('pribasos.index') ||
                        request()->routeIs('belajar.index') ||
                        request()->routeIs('karier.index');

                    $isActiveTindakLanjut =
                        request()->routeIs('tindak-lanjut.sp.index') ||
                        request()->routeIs('tindak-lanjut.pindah-sekolah.index') ||
                        request()->routeIs('tindak-lanjut.pengunduran-diri.index') ||
                        request()->routeIs('tindak-lanjut.rujukan-spesialis.index');
                @endphp

                <x-sidebar-dropdown label="Data Konseling" icon="fa-table" :active="$isActiveKonseling">
                    <x-sidebar-dropdown-item :href="route('pribasos.index')" :active="request()->routeIs('pribasos.index')">
                        <i class="fa-solid fa-id-badge pr-2"></i> BK - Pribadi Sosial
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('belajar.index')" :active="request()->routeIs('belajar.index')">
                        <i class="fa-solid fa-user-tie pr-2"></i> BK - Belajar
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('karier.index')" :active="request()->routeIs('karier.index')">
                        <i class="fa-solid fa-book pr-2"></i> BK - Karier
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <x-nav-link :href="route('pelanggaran.index')" :active="request()->routeIs('pelanggaran.*')">
                    <x-slot name="icon"><i class="fa-solid fa-file"></i></x-slot>
                    Pelanggaran
                </x-nav-link>

                <x-sidebar-dropdown label="Tindak Lanjut" icon="fa-book" :active="$isActiveTindakLanjut">
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.sp.index')" :active="request()->routeIs('tindak-lanjut.sp.index')">
                        <i class="fa-solid fa-scroll pr-2"></i>Kelola SP
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.pindah-sekolah.index')" :active="request()->routeIs('tindak-lanjut.pindah-sekolah.index')">
                        <i class="fa-solid fa-school pr-2"></i>Pindah Sekolah
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.pengunduran-diri.index')" :active="request()->routeIs('tindak-lanjut.pengunduran-diri.index')">
                        <i class="fa-solid fa-scroll pr-2"></i>Pengunduran Diri
                    </x-sidebar-dropdown-item>
                    <x-sidebar-dropdown-item :href="route('tindak-lanjut.rujukan-spesialis.index')" :active="request()->routeIs('tindak-lanjut.rujukan-spesialis.index')">
                        <i class="fa-solid fa-school pr-2"></i>Rujukan Spesialis
                    </x-sidebar-dropdown-item>
                </x-sidebar-dropdown>

                <x-nav-link :href="route('kuesioner.index')" :active="request()->routeIs('kuesioner.*')">
                    <x-slot name="icon"><i class="fa-solid fa-notes-medical"></i></x-slot>
                    Kuesioner
                </x-nav-link>

                <x-nav-link :href="route('rekap-kuesioner.index')" :active="request()->routeIs('rekap-kuesioner.*')">
                    <x-slot name="icon"><i class="fa-solid fa-notes-medical"></i></x-slot>
                    Rekap Kuesioner
                </x-nav-link>

                <x-nav-link :href="route('chat.index', 0)" :active="request()->routeIs('chat.*')">
                    <x-slot name="icon"><i class="fa-solid fa-message pr-2"></i></x-slot>
                    Chat
                </x-nav-link>
            @endhasrole
        </nav>
    </div>
</aside>
