{{--
    Tur kartı. $variant: 'vertical' (ana sayfa vitrini) | 'horizontal' (liste sayfası, image.png düzeni)
    Parametreler: $tour, $type (ProductType), $variant
--}}
@php
    $variant = $variant ?? 'vertical';
    $type = $type ?? $tour->site_type ?? null;
    $isDayTour = $type?->code === 'gunubirlik-tur';
    $detailUrl = ($preview ?? false) || ! $type
        ? '#'
        : route('customer.agency.tours.detail', ['agency' => $agency->slug, 'type' => $type->route_slug, 'slug' => $tour->slug]);
    $cover = $tour->cover_image_url;
    $price = $tour->starting_price;
    $currency = $tour->currency ?? 'TRY';
    $durationText = $isDayTour
        ? ($tour->duration_hours ? $tour->duration_hours . ' Saat' : 'Günübirlik')
        : (($tour->days ?? $tour->duration) ? ($tour->days ?? $tour->duration) . ' Gün' . ($tour->nights ? ' ' . $tour->nights . ' Gece' : '') : null);
    $location = $isDayTour ? $tour->departureCity?->name : ($tour->arrivalCity?->name ?? $tour->departureCity?->name);
@endphp

@if($variant === 'horizontal')
    <article class="v-tour-card-h">
        <a href="{{ $detailUrl }}" class="v-tour-card-h__media">
            @if($cover)
                <img src="{{ $cover }}" alt="{{ $tour->name }}" loading="lazy">
            @else
                <span class="v-tour-card-h__placeholder"><x-voyage.icon name="map" /></span>
            @endif
            @if($tour->is_bestseller)
                <span class="v-badge v-badge--flame"><x-voyage.icon name="flame" /> Çok Satan</span>
            @elseif($tour->is_new)
                <span class="v-badge v-badge--new">Yeni</span>
            @endif
        </a>
        <div class="v-tour-card-h__body">
            <div class="v-tour-card-h__head">
                <h3 class="v-tour-card-h__title"><a href="{{ $detailUrl }}">{{ $tour->name }}</a></h3>
                @if(($tour->rating_count ?? 0) > 0)
                    <span class="v-rating-pill">
                        <strong>{{ number_format((float) $tour->rating_average, 1, ',', '') }}</strong>
                        <small>{{ $tour->rating_count }} yorum</small>
                    </span>
                @endif
            </div>
            <div class="v-tour-card-h__meta">
                @if($location)<span><x-voyage.icon name="pin" /> {{ $location }}</span>@endif
                @if($durationText)<span><x-voyage.icon name="clock" /> {{ $durationText }}</span>@endif
                @if($tour->has_guide)<span><x-voyage.icon name="users" /> Rehberli</span>@endif
            </div>
            @if($tour->short_description)
                <p class="v-tour-card-h__desc">{{ \Illuminate\Support\Str::limit(strip_tags((string) $tour->short_description), 140) }}</p>
            @endif
            @if(!empty($tour->highlights) && is_array($tour->highlights))
                <ul class="v-tour-card-h__highlights">
                    @foreach(array_slice($tour->highlights, 0, 3) as $highlight)
                        <li><x-voyage.icon name="check" /> {{ $highlight }}</li>
                    @endforeach
                </ul>
            @endif
        </div>
        <div class="v-tour-card-h__offer">
            @if($tour->refundable ?? false)
                <span class="v-tour-card-h__perk"><x-voyage.icon name="check" /> Ücretsiz iptal</span>
            @endif
            @if($tour->instant_booking ?? false)
                <span class="v-tour-card-h__perk"><x-voyage.icon name="check" /> Anında onay</span>
            @endif
            <div class="v-tour-card-h__price">
                @if($price > 0)
                    <small>kişi başı</small>
                    <strong>@include('site.templates.voyage.partials.price', ['amount' => $price, 'currency' => $currency])</strong>
                    <small>'den itibaren</small>
                @else
                    <strong class="v-tour-card-h__ask">Fiyat Sorunuz</strong>
                @endif
            </div>
            <a href="{{ $detailUrl }}" class="v-btn v-btn--cta">İncele <x-voyage.icon name="arrow-right" /></a>
        </div>
    </article>
@else
    <article class="v-tour-card">
        <a href="{{ $detailUrl }}" class="v-tour-card__media">
            @if($cover)
                <img src="{{ $cover }}" alt="{{ $tour->name }}" loading="lazy">
            @else
                <span class="v-tour-card__placeholder"><x-voyage.icon name="map" /></span>
            @endif
            @if($tour->is_featured)
                <span class="v-badge v-badge--featured"><x-voyage.icon name="sparkle" /> Öne Çıkan</span>
            @elseif($tour->is_new)
                <span class="v-badge v-badge--new">Yeni</span>
            @endif
        </a>
        <div class="v-tour-card__body">
            <h3 class="v-tour-card__title"><a href="{{ $detailUrl }}">{{ $tour->name }}</a></h3>
            <div class="v-tour-card__meta">
                @if($location)<span><x-voyage.icon name="pin" /> {{ $location }}</span>@endif
                @if($durationText)<span><x-voyage.icon name="clock" /> {{ $durationText }}</span>@endif
            </div>
            <div class="v-tour-card__foot">
                <div class="v-tour-card__price">
                    @if($price > 0)
                        <small>kişi başı</small>
                        <strong>@include('site.templates.voyage.partials.price', ['amount' => $price, 'currency' => $currency])</strong>
                    @else
                        <strong class="v-tour-card__ask">Fiyat Sorunuz</strong>
                    @endif
                </div>
                <span class="v-tour-card__go"><x-voyage.icon name="arrow-right" /></span>
            </div>
        </div>
    </article>
@endif
