<div>
    <div class="space-y-5">
        {{-- Slim Profile Filter --}}
        <div class="rounded-2xl border border-neutral-200/70 bg-white/80 p-4 shadow-sm backdrop-blur-xl dark:border-neutral-800/70 dark:bg-neutral-950/70">
            <div class="flex flex-col sm:flex-row gap-3">
                {{-- Search --}}
                <div class="relative flex-1">
                    <div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-4">
                        <svg class="h-4 w-4 text-neutral-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" />
                        </svg>
                    </div>
                    <input
                        wire:model.live.debounce.400ms="search"
                        type="search"
                        placeholder="Search liked episodes..."
                        class="w-full rounded-xl border border-neutral-300 bg-white py-2.5 pl-11 pr-4 text-sm text-neutral-900 shadow-sm transition focus:border-rose-500 focus:outline-none focus:ring-2 focus:ring-rose-500/20 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white dark:placeholder-neutral-500"
                    />
                </div>

                {{-- Order --}}
                <div class="relative">
                    <i class="fa-solid fa-sort pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-neutral-400"></i>
                    <select
                        wire:model.live="order"
                        class="w-full appearance-none rounded-xl border border-neutral-300 bg-white py-2.5 pl-10 pr-10 text-sm text-neutral-900 shadow-sm transition focus:border-rose-500 focus:outline-none focus:ring-2 focus:ring-rose-500/20 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
                    >
                        <option value="az">A-Z</option>
                        <option value="za">Z-A</option>
                        <option value="recently-uploaded">{{ __('home.recently-uploaded') }}</option>
                        <option value="recently-released">{{ __('home.recently-released') }}</option>
                        <option value="oldest-uploads">{{ __('search.oldest-uploads') }}</option>
                        <option value="oldest-releases">{{ __('search.oldest-releases') }}</option>
                        <option value="view-count">{{ __('search.view-count') }}</option>
                    </select>
                </div>

                {{-- View --}}
                <div class="relative">
                    <i class="fa-solid fa-list pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-neutral-400"></i>
                    <select
                        wire:model.live="view"
                        class="w-full appearance-none rounded-xl border border-neutral-300 bg-white py-2.5 pl-10 pr-10 text-sm text-neutral-900 shadow-sm transition focus:border-rose-500 focus:outline-none focus:ring-2 focus:ring-rose-500/20 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
                    >
                        <option value="thumbnail">Thumbnail</option>
                        <option value="poster">Poster</option>
                    </select>
                </div>

                {{-- Filter Buttons --}}
                <div class="flex gap-2">
                    <button
                        type="button"
                        data-te-toggle="modal"
                        data-te-target="#modalGenres"
                        class="inline-flex items-center gap-1.5 rounded-xl border border-neutral-300 bg-white px-3.5 py-2.5 text-xs font-medium text-neutral-600 shadow-sm transition hover:border-rose-400 hover:bg-rose-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800"
                    >
                        <i class="fa-solid fa-sliders text-[10px]"></i>
                        Genres
                        @if($tagcount > 0)
                            <span class="inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-rose-600 px-1 text-[9px] font-bold text-white">{{ $tagcount }}</span>
                        @endif
                    </button>
                    <button
                        type="button"
                        data-te-toggle="modal"
                        data-te-target="#modalBlacklist"
                        class="inline-flex items-center gap-1.5 rounded-xl border border-neutral-300 bg-white px-3.5 py-2.5 text-xs font-medium text-neutral-600 shadow-sm transition hover:border-rose-400 hover:bg-rose-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800"
                    >
                        <i class="fa-solid fa-shield text-[10px]"></i>
                        Blacklist
                        @if($blacklistcount > 0)
                            <span class="inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-rose-600 px-1 text-[9px] font-bold text-white">{{ $blacklistcount }}</span>
                        @endif
                    </button>
                    <button
                        type="button"
                        data-te-toggle="modal"
                        data-te-target="#modalStudios"
                        class="inline-flex items-center gap-1.5 rounded-xl border border-neutral-300 bg-white px-3.5 py-2.5 text-xs font-medium text-neutral-600 shadow-sm transition hover:border-rose-400 hover:bg-rose-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800"
                    >
                        <i class="fa-solid fa-microphone-lines text-[10px]"></i>
                        Studios
                        @if($studiocount > 0)
                            <span class="inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-rose-600 px-1 text-[9px] font-bold text-white">{{ $studiocount }}</span>
                        @endif
                    </button>
                </div>

                {{-- Hide Watched --}}
                @auth
                    <label class="flex cursor-pointer items-center gap-2 rounded-xl border border-neutral-300 bg-white px-3.5 py-2.5 text-xs font-medium text-neutral-600 shadow-sm transition hover:border-rose-400 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-300 whitespace-nowrap">
                        <input
                            id="checkBoxHideWatched"
                            type="checkbox"
                            wire:model.live="hideWatched"
                            class="h-4 w-4 rounded border-neutral-300 text-rose-600 focus:ring-rose-500 dark:border-neutral-700 dark:bg-neutral-800"
                        />
                        <span>Hide watched</span>
                    </label>
                @endauth
            </div>
        </div>

        {{-- Modals --}}
        @include('modals.filter-genres')
        @include('modals.filter-studios')
        @include('modals.filter-blacklist')

        <input type="hidden" id="ts_reference" value="{{ Carbon\Carbon::now()->timestamp }}" />

        {{-- Results --}}
        <div wire:keydown.right.window="nextPage" wire:keydown.left.window="previousPage">
            {{ $episodes->appends(['tags' => $selectedtags])->links('pagination::tailwind') }}
            <div class="mt-4">
                @if ($view == 'thumbnail')
                <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">
                @else
                <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
                @endif
                    @forelse($episodes as $episode)
                        @include('livewire.partials.search-result')
                    @empty
                        <div class="col-span-full">
                            <div class="rounded-2xl bg-white/40 dark:bg-neutral-950/40 backdrop-blur shadow-sm ring-1 ring-black/5 dark:ring-white/5 p-12 text-center">
                                <div class="inline-flex h-20 w-20 items-center justify-center rounded-full bg-gray-100 dark:bg-neutral-800 mb-4">
                                    <i class="fa-solid fa-heart-crack text-3xl text-gray-400 dark:text-gray-500"></i>
                                </div>
                                <h3 class="text-lg font-semibold text-gray-700 dark:text-gray-300">No liked episodes</h3>
                                <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Start exploring and like what you enjoy!</p>
                            </div>
                        </div>
                    @endforelse
                </div>
            </div>
            {{ $episodes->appends(['tags' => $selectedtags])->links('pagination::tailwind') }}
        </div>
    </div>
</div>