{{--
    Jolly deseni arama bandı (jolly.png) — ZORUNLU bileşen.
    Katman 1: ürün tipi sekmeleri (acentenin yetkilerinden)
    Katman 2: segmentli arama satırı + yeşil HEMEN ARA
    Katman 3: popüler aramalar pill'leri
    Parametreler: $tourTypes (Collection<ProductType>), $compact (bool), $popular (array)
--}}
@php
    $compact = $compact ?? false;
    $popular = $popular ?? [];
    $activeType = $activeType ?? null;
    $searchAction = $preview ? '#' : route('customer.agency.tours.search', $agency->slug);
@endphp
@if($tourTypes->isNotEmpty())
<div class="v-search-band{{ $compact ? ' v-search-band--compact' : '' }}">
    <form action="{{ $searchAction }}" method="GET" class="v-search-band__form" @if($preview) onsubmit="return false" @endif>
        <div class="v-search-band__tabs" role="tablist">
            @foreach($tourTypes as $index => $type)
                <button type="button"
                        class="v-search-band__tab{{ ($activeType?->id ?? $tourTypes->first()->id) === $type->id ? ' is-active' : '' }}"
                        data-type-slug="{{ $type->route_slug }}">
                    <x-voyage.icon :name="$type->code === 'gunubirlik-tur' ? 'sun' : ($type->code === 'yurtdisi-turu' ? 'globe' : 'route')" />
                    <span>{{ $type->name }}</span>
                </button>
            @endforeach
        </div>

        <input type="hidden" name="type" value="{{ ($activeType ?? $tourTypes->first())->route_slug }}" id="vSearchType">

        <div class="v-search-band__row">
            <label class="v-search-band__field">
                <span class="v-search-band__label">
                    <x-voyage.icon name="pin" /> Gidilecek Yer
                </span>
                <input type="text" name="q" value="{{ request('q') }}"
                       placeholder="Şehir, bölge ya da tur adı" class="v-search-band__input" autocomplete="off">
            </label>
            <button type="submit" class="v-search-band__submit">
                <x-voyage.icon name="search" />
                <span>HEMEN ARA</span>
            </button>
        </div>

        @if(!$compact && count($popular))
            <div class="v-search-band__popular">
                <span class="v-search-band__popular-label">Popüler Aramalar</span>
                @foreach($popular as $pill)
                    <a href="{{ $preview ? '#' : ($pill['url'] ?? '#') }}" class="v-search-band__pill">{{ $pill['label'] ?? '' }}</a>
                @endforeach
            </div>
        @endif
    </form>
</div>
@endif
