<div @filters-updated.window="refreshIcons($el)">
    <div class="database-search filter-bar">
        @if($rating || $entryId)
            <button type="button" wire:click="clearFilters" class="btn">
                <i data-lucide="x"></i> Clear filters
            </button>
        @endif
    </div>
    <div class="database-wrapper">
        <aside class="database-filters">
            <div class="filter-group" x-data="{open: true}">
                <div class="filter-title-row" @click="open = !open">
                    <h4 class="filter-title">Rating</h4>
                    <i data-lucide="chevron-down" size="14" class="filter-chevron" :class="{ 'rotated': !open }"></i>
                </div>
                <div class="filter-options" x-show="open" x-transition>
                    @for($i=1;$i<=5;$i++)
                        <label class="filter-option">
                            <input type="radio" wire:model.live="rating" value="{{ $i }}">
                            {{ $i }}
                        </label>
                    @endfor
                </div>
            </div>
        </aside>

        <div class="database-results">
            <div class="database-sort">
                @foreach( \App\Livewire\Reviews::SORT_OPTIONS as $k => $v )
                    <button type="button" wire:click="setSort('{{ $k }}')" class="btn {{ $sortBy === $k ? 'active' : '' }}">
                        {{ $v }}
                    </button>
                    @if( $sortBy === $k )
                        <i data-lucide="{{ $sortDir === 'asc' ? 'arrow-up' : 'arrow-down' }}"></i>
                    @endif
                @endforeach
                <span class="database-results-count">{{ $reviews->total() }} results</span>
            </div>

            <div class="entry-content">
                @forelse($reviews as $review)
                    <x-review-card :review="$review" :entry-show="true" />
                @empty
                    <p>No reviews found.</p>
                @endforelse
            </div>

            {{ $reviews->links() }}
        </div>
    </div>
</div>
