@extends('agency.layouts.app')

@section('title', 'Hizmet Türleri')
@section('page_title', 'Hizmet Türleri')

@php
    $breadcrumbs = [
        ['title' => 'Ana Sayfa', 'url' => route('agency.dashboard')],
        ['title' => 'Hizmet Türleri', 'url' => '']
    ];
@endphp

@push('styles')
    <style>
        .product-type-card {
            border: 1px solid var(--gray-200);
            border-radius: var(--radius-xl);
            padding: 1.5rem;
            transition: all 0.3s ease;
            background: white;
            height: 100%;
        }

        .product-type-card:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow-lg);
            border-color: var(--primary-color);
        }

        .product-type-icon {
            width: 64px;
            height: 64px;
            border-radius: var(--radius-lg);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px;
            margin-bottom: 1rem;
        }

        .product-type-card.active .product-type-icon {
            background: linear-gradient(135deg, var(--success-color), #10b981);
            color: white;
        }

        .product-type-card.inactive .product-type-icon {
            background: var(--gray-100);
            color: var(--gray-400);
        }

        .product-type-title {
            font-size: 18px;
            font-weight: 700;
            color: var(--gray-900);
            margin-bottom: 0.5rem;
        }

        .product-type-description {
            color: var(--gray-600);
            font-size: 13px;
            line-height: 1.4;
            margin-bottom: 1rem;
        }

        .product-type-badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: var(--radius-md);
            font-size: 11px;
            font-weight: 600;
            text-transform: uppercase;
        }

        .badge-active {
            background: #d1fae5;
            color: #065f46;
        }

        .badge-inactive {
            background: var(--gray-100);
            color: var(--gray-600);
        }

        .product-type-stats {
            display: flex;
            gap: 1.5rem;
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid var(--gray-200);
        }

        .stat-item {
            display: flex;
            flex-direction: column;
        }

        .stat-value {
            font-size: 20px;
            font-weight: 700;
            color: var(--gray-900);
        }

        .stat-label {
            font-size: 12px;
            color: var(--gray-500);
            margin-top: 2px;
        }

        .info-section {
            background: var(--gray-50);
            border-radius: var(--radius-lg);
            padding: 1.5rem;
            margin-bottom: 2rem;
        }

        .feature-list {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 0.75rem;
            margin-top: 1rem;
        }

        .feature-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 13px;
            color: var(--gray-700);
        }

        .feature-item i {
            color: var(--success-color);
        }
    </style>
@endpush

@section('content')
    <div class="container-fluid">
        <!-- Page Header -->
        <div class="d-flex justify-content-between align-items-center mb-4">
            <div>
                <h1 class="h3 mb-1">Hizmet Türleri</h1>
                <p class="text-muted mb-0">Acentenizin sunduğu hizmetleri görüntüleyin</p>
            </div>
        </div>

        <!-- Info Section -->
        <div class="info-section">
            <div class="d-flex align-items-start gap-3">
                <div class="flex-shrink-0">
                    <i class="fas fa-info-circle text-primary" style="font-size: 24px;"></i>
                </div>
                <div>
                    <h6 class="mb-2">Hizmet Türleri Hakkında</h6>
                    <p class="mb-0" style="font-size: 14px; color: var(--gray-600);">
                        Bu sayfada acenteniz için aktif edilen hizmet türlerini görüntüleyebilirsiniz.
                        Her hizmet türü farklı özelliklere ve modüllere sahiptir.
                        Yeni hizmet türleri eklemek veya mevcut hizmetleri yönetmek için sistem yöneticinizle iletişime geçin.
                    </p>
                </div>
            </div>
        </div>

        <!-- Product Types Grid -->
        @if($productTypes->count() > 0)
            <div class="row g-4">
                @foreach($productTypes as $productType)
                    @php
                        $isActive = $productType->is_active_for_agency;
                        $productCount = 0; // Bu bilgiyi controller'dan da gönderebiliriz
                        $systemActive = $productType->is_active; // Sistem geneli aktif mi
                    @endphp

                    <div class="col-xl-4 col-lg-6 col-md-6">
                        <div class="product-type-card {{ $isActive ? 'active' : 'inactive' }}">
                            <div class="d-flex justify-content-between align-items-start mb-3">
                                <div class="product-type-icon">
                                    <i class="fas {{ $productType->icon }}"></i>
                                </div>
                                <div class="d-flex flex-column gap-1 align-items-end">
                                    <span class="product-type-badge {{ $isActive ? 'badge-active' : 'badge-inactive' }}">
                                        {{ $isActive ? 'Aktif' : 'Pasif' }}
                                    </span>
                                    @if(!$systemActive)
                                        <span class="badge bg-warning text-dark" style="font-size: 10px;">Yakında</span>
                                    @endif
                                </div>
                            </div>

                            <h5 class="product-type-title">{{ $productType->name }}</h5>
                            <p class="product-type-description">{{ $productType->description }}</p>

                            <!-- Features -->
                            <div class="feature-list">
                                @if($productType->has_categories)
                                    <div class="feature-item">
                                        <i class="fas fa-check-circle"></i>
                                        <span>Kategoriler</span>
                                    </div>
                                @endif
                                @if($productType->has_pricing)
                                    <div class="feature-item">
                                        <i class="fas fa-check-circle"></i>
                                        <span>Fiyatlandırma</span>
                                    </div>
                                @endif
                                @if($productType->has_booking)
                                    <div class="feature-item">
                                        <i class="fas fa-check-circle"></i>
                                        <span>Rezervasyon</span>
                                    </div>
                                @endif
                                @if($productType->has_itinerary)
                                    <div class="feature-item">
                                        <i class="fas fa-check-circle"></i>
                                        <span>Program</span>
                                    </div>
                                @endif
                                @if($productType->has_dates)
                                    <div class="feature-item">
                                        <i class="fas fa-check-circle"></i>
                                        <span>Tarihler</span>
                                    </div>
                                @endif
                            </div>

                            <!-- Stats -->
                            @if($isActive)
                                <div class="product-type-stats">
                                    <div class="stat-item">
                                        <div class="stat-value">{{ $productCount }}</div>
                                        <div class="stat-label">Ürün Sayısı</div>
                                    </div>
                                    @if($productType->activated_at)
                                        <div class="stat-item">
                                            <div class="stat-value">{{ $productType->activated_at->diffForHumans() }}</div>
                                            <div class="stat-label">Aktif Edildi</div>
                                        </div>
                                    @endif
                                </div>

                                <!-- Kategori Butonu -->
                                @if($productType->has_categories)
                                    <div class="mt-3">
                                        <a href="{{ route('agency.categories.index', ['product_type_id' => $productType->id]) }}"
                                           class="btn btn-primary btn-sm w-100">
                                            <i class="fas fa-folder-tree me-2"></i>
                                            Kategorileri Görüntüle
                                        </a>
                                    </div>
                                @endif
                            @elseif(!$systemActive)
                                <div class="mt-3">
                                    <div class="alert alert-warning mb-0" style="font-size: 12px; padding: 0.5rem;">
                                        <i class="fas fa-clock me-1"></i>
                                        Bu hizmet türü henüz sisteme eklenmemiş.
                                    </div>
                                </div>
                            @endif
                        </div>
                    </div>
                @endforeach
            </div>
        @else
            <div class="text-center py-5">
                <div class="mb-3">
                    <i class="fas fa-boxes text-muted" style="font-size: 48px;"></i>
                </div>
                <h4>Henüz Hizmet Türü Eklenmemiş</h4>
                <p class="text-muted">Acenteniz için henüz hizmet türü aktif edilmemiş.</p>
            </div>
        @endif
    </div>
@endsection
