<x-agency-theme-layout :agency="$agency" :page="$page" :theme="$theme" :themeSettings="$themeSettings">
    <section class="search-results-section">
        <div class="container">
            {{-- Search Header --}}
            <div class="search-results-header">
                <h1 class="results-title">Tur Arama Sonuçları</h1>
                <p class="results-summary">
                    @if($results->total() > 0)
                        <strong>{{ $results->total() }}</strong> tur bulundu
                    @else
                        Aramanıza uygun tur bulunamadı
                    @endif
                </p>
            </div>

            {{-- Active Filters --}}
            @if($departureCityId || $query || $date)
                <div class="active-filters">
                    <span class="filters-label">Aktif Filtreler:</span>
                    @if($departureCityId && $departureCityName)
                        <span class="filter-tag">
                            <i class="fas fa-map-marker-alt"></i>
                            {{ $departureCityName }}
                            <a href="{{ request()->fullUrlWithQuery(['departure_city_id' => null]) }}" class="remove-filter">
                                <i class="fas fa-times"></i>
                            </a>
                        </span>
                    @endif
                    @if($query)
                        <span class="filter-tag">
                            <i class="fas fa-search"></i>
                            {{ $query }}
                            <a href="{{ request()->fullUrlWithQuery(['q' => null]) }}" class="remove-filter">
                                <i class="fas fa-times"></i>
                            </a>
                        </span>
                    @endif
                    @if($date)
                        <span class="filter-tag">
                            <i class="fas fa-calendar"></i>
                            {{ \Carbon\Carbon::parse($date)->format('d.m.Y') }}
                            <a href="{{ request()->fullUrlWithQuery(['date' => null]) }}" class="remove-filter">
                                <i class="fas fa-times"></i>
                            </a>
                        </span>
                    @endif
                    <a href="{{ route('customer.agency.tours.search', $agency->slug) }}" class="clear-all-filters">
                        Tüm Filtreleri Temizle
                    </a>
                </div>
            @endif

            {{-- Results Grid --}}
            @if($results->count() > 0)
                <div class="results-grid">
                    @foreach($results as $tour)
                        <div class="tour-card">
                            <div class="tour-card-image">
                                @if($tour->cover_image_url)
                                    <img src="{{ $tour->cover_image_url }}" alt="{{ $tour->name }}">
                                @else
                                    <div class="no-image">
                                        <i class="fas fa-image"></i>
                                    </div>
                                @endif
                                @if($tour->category)
                                    <span class="tour-category">{{ $tour->category->name }}</span>
                                @endif
                            </div>
                            <div class="tour-card-content">
                                <h3 class="tour-name">{{ $tour->name }}</h3>
                                @if($tour->short_description)
                                    <p class="tour-description">{{ Str::limit($tour->short_description, 100) }}</p>
                                @endif
                                <div class="tour-meta">
                                    @if($tour->days)
                                        <span class="meta-item">
                                            <i class="fas fa-calendar-alt"></i>
                                            {{ $tour->days }} Gun
                                        </span>
                                    @endif
                                    @if($tour->departureCity)
                                        <span class="meta-item">
                                            <i class="fas fa-map-marker-alt"></i>
                                            {{ $tour->departureCity->name }}
                                        </span>
                                    @endif
                                </div>
                                <div class="tour-footer">
                                    <div class="tour-price">
                                        @if($tour->formatted_price)
                                            {{ $tour->formatted_price }}
                                        @else
                                            <span class="price-contact">Fiyat icin arayiniz</span>
                                        @endif
                                    </div>
                                    <a href="{{ route('customer.agency.show', $agency->slug) }}#{{ $productType }}" class="tour-detail-btn">
                                        Detaylar
                                        <i class="fas fa-arrow-right"></i>
                                    </a>
                                </div>
                            </div>
                        </div>
                    @endforeach
                </div>

                {{-- Pagination --}}
                @if($results->hasPages())
                    <div class="results-pagination">
                        {{ $results->withQueryString()->links() }}
                    </div>
                @endif
            @else
                <div class="no-results">
                    <div class="no-results-icon">
                        <i class="fas fa-search"></i>
                    </div>
                    <h3>Sonuç Bulunamadı</h3>
                    <p>Aramanıza uygun tur bulunamadı. Farklı arama kriterleri deneyebilir veya tüm turlara göz atabilirsiniz.</p>
                    <a href="{{ route('customer.agency.show', $agency->slug) }}" class="back-to-home">
                        <i class="fas fa-home"></i>
                        Ana Sayfaya Dön
                    </a>
                </div>
            @endif
        </div>
    </section>

    <style>
        .search-results-section {
            padding: 6rem 0 4rem;
            min-height: 60vh;
            background: #f8fafc;
        }

        .search-results-header {
            text-align: center;
            margin-bottom: 2rem;
        }

        .results-title {
            font-size: 2rem;
            font-weight: 700;
            color: #111827;
            margin-bottom: 0.5rem;
        }

        .results-summary {
            color: #6b7280;
            font-size: 1rem;
        }

        .active-filters {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            flex-wrap: wrap;
            background: white;
            padding: 1rem 1.5rem;
            border-radius: 12px;
            margin-bottom: 2rem;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        .filters-label {
            font-weight: 600;
            color: #374151;
            font-size: 0.875rem;
        }

        .filter-tag {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.875rem;
            background: linear-gradient(135deg, var(--primary, #3B82F6), var(--secondary, #8B5CF6));
            color: white;
            border-radius: 50px;
            font-size: 0.875rem;
            font-weight: 500;
        }

        .filter-tag i:first-child {
            font-size: 0.75rem;
            opacity: 0.8;
        }

        .remove-filter {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 18px;
            height: 18px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            color: white;
            text-decoration: none;
            margin-left: 0.25rem;
            transition: background 0.2s;
        }

        .remove-filter:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        .remove-filter i {
            font-size: 0.625rem;
        }

        .clear-all-filters {
            margin-left: auto;
            font-size: 0.875rem;
            color: #6b7280;
            text-decoration: none;
            transition: color 0.2s;
        }

        .clear-all-filters:hover {
            color: var(--primary, #3B82F6);
        }

        .results-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 1.5rem;
        }

        .tour-card {
            background: white;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
        }

        .tour-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
        }

        .tour-card-image {
            position: relative;
            height: 200px;
            overflow: hidden;
        }

        .tour-card-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s ease;
        }

        .tour-card:hover .tour-card-image img {
            transform: scale(1.05);
        }

        .tour-card-image .no-image {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #e5e7eb;
            color: #9ca3af;
            font-size: 3rem;
        }

        .tour-category {
            position: absolute;
            top: 1rem;
            left: 1rem;
            padding: 0.375rem 0.875rem;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 50px;
            font-size: 0.75rem;
            font-weight: 600;
            color: #374151;
        }

        .tour-card-content {
            padding: 1.5rem;
        }

        .tour-name {
            font-size: 1.125rem;
            font-weight: 600;
            color: #111827;
            margin-bottom: 0.5rem;
            line-height: 1.4;
        }

        .tour-description {
            color: #6b7280;
            font-size: 0.875rem;
            line-height: 1.6;
            margin-bottom: 1rem;
        }

        .tour-meta {
            display: flex;
            gap: 1rem;
            margin-bottom: 1rem;
        }

        .meta-item {
            display: flex;
            align-items: center;
            gap: 0.375rem;
            font-size: 0.813rem;
            color: #6b7280;
        }

        .meta-item i {
            color: var(--primary, #3B82F6);
            font-size: 0.75rem;
        }

        .tour-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 1rem;
            border-top: 1px solid #e5e7eb;
        }

        .tour-price {
            font-size: 1.25rem;
            font-weight: 700;
            color: var(--primary, #3B82F6);
        }

        .price-contact {
            font-size: 0.875rem;
            color: #6b7280;
            font-weight: 500;
        }

        .tour-detail-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.625rem 1.25rem;
            background: linear-gradient(135deg, var(--primary, #3B82F6), var(--secondary, #8B5CF6));
            color: white;
            text-decoration: none;
            border-radius: 50px;
            font-size: 0.875rem;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .tour-detail-btn:hover {
            transform: translateX(4px);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
        }

        .tour-detail-btn i {
            font-size: 0.75rem;
            transition: transform 0.3s ease;
        }

        .tour-detail-btn:hover i {
            transform: translateX(2px);
        }

        .results-pagination {
            display: flex;
            justify-content: center;
            margin-top: 3rem;
        }

        .no-results {
            text-align: center;
            padding: 4rem 2rem;
            background: white;
            border-radius: 16px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        .no-results-icon {
            width: 80px;
            height: 80px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f3f4f6;
            border-radius: 50%;
            margin: 0 auto 1.5rem;
            font-size: 2rem;
            color: #9ca3af;
        }

        .no-results h3 {
            font-size: 1.5rem;
            font-weight: 600;
            color: #111827;
            margin-bottom: 0.5rem;
        }

        .no-results p {
            color: #6b7280;
            max-width: 400px;
            margin: 0 auto 1.5rem;
            line-height: 1.6;
        }

        .back-to-home {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            background: var(--primary, #3B82F6);
            color: white;
            text-decoration: none;
            border-radius: 50px;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .back-to-home:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
        }

        @media (max-width: 768px) {
            .search-results-section {
                padding: 5rem 0 3rem;
            }

            .results-title {
                font-size: 1.5rem;
            }

            .active-filters {
                flex-direction: column;
                align-items: flex-start;
            }

            .clear-all-filters {
                margin-left: 0;
                margin-top: 0.5rem;
            }

            .results-grid {
                grid-template-columns: 1fr;
            }

            .tour-footer {
                flex-direction: column;
                gap: 1rem;
                align-items: stretch;
            }

            .tour-detail-btn {
                justify-content: center;
            }
        }
    </style>
</x-agency-theme-layout>
