@extends('agency.layouts.app')

@section('title', $tour->name . ' - Fiyatlandırma')
@section('page_title', 'Günübirlik Tur Düzenle')

@php
    $breadcrumbs = [
        ['title' => 'Ana Sayfa', 'url' => route('agency.dashboard')],
        ['title' => 'Günübirlik Turlar', 'url' => route('agency.products.gunubirlik-turlar.index')],
        ['title' => $tour->name, 'url' => route('agency.products.gunubirlik-turlar.show', $tour)],
        ['title' => 'Fiyatlandırma', 'url' => '']
    ];
@endphp

@push('styles')
    <style>
        .tour-detail-container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .tour-header {
            background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
            color: white;
            padding: 2rem;
            border-radius: var(--radius-xl);
            margin-bottom: 2rem;
            position: relative;
            overflow: hidden;
        }

        .tour-header::before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 200px;
            height: 200px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 50%;
            transform: translate(50%, -50%);
        }

        .tour-header-content {
            position: relative;
            z-index: 2;
        }

        .tour-title {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 0.5rem;
        }

        .tour-code {
            font-size: 14px;
            opacity: 0.9;
            margin-bottom: 1rem;
        }

        .tour-meta {
            display: flex;
            gap: 2rem;
            flex-wrap: wrap;
        }

        .tour-meta-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 14px;
        }

        .tour-meta-icon {
            font-size: 16px;
            opacity: 0.8;
        }

        .tabs-container {
            background: white;
            border: 1px solid var(--gray-200);
            border-radius: var(--radius-xl);
            overflow: hidden;
            margin-bottom: 2rem;
        }

        .nav-tabs {
            background: var(--gray-50);
            border-bottom: 1px solid var(--gray-200);
            padding: 0 1rem;
            margin: 0;
        }

        .nav-tabs .nav-link {
            border: none;
            border-radius: 0;
            color: var(--gray-600);
            font-weight: 500;
            padding: 1rem 1.5rem;
            position: relative;
            transition: var(--transition);
        }

        .nav-tabs .nav-link:hover {
            color: var(--primary-color);
            background: transparent;
            border-color: transparent;
        }

        .nav-tabs .nav-link.active {
            color: var(--primary-color);
            background: transparent;
            border-color: transparent;
            font-weight: 600;
        }

        .nav-tabs .nav-link.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: var(--primary-color);
            border-radius: 3px 3px 0 0;
        }

        .tab-content {
            padding: 2rem;
        }

        .pricing-card {
            background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
            border: 2px solid var(--gray-200);
            border-radius: var(--radius-lg);
            padding: 2rem;
            margin-bottom: 1.5rem;
        }

        .pricing-section {
            margin-bottom: 2rem;
        }

        .pricing-section:last-child {
            margin-bottom: 0;
        }

        .pricing-section-title {
            font-size: 1.1rem;
            font-weight: 700;
            color: var(--gray-900);
            margin-bottom: 1.5rem;
            padding-bottom: 0.75rem;
            border-bottom: 2px solid var(--gray-200);
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .pricing-section-icon {
            width: 36px;
            height: 36px;
            background: var(--primary-light);
            color: var(--primary-color);
            border-radius: var(--radius-md);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
        }

        .price-display {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .price-box {
            background: white;
            border: 2px solid var(--gray-200);
            border-radius: var(--radius-lg);
            padding: 1.5rem;
            text-align: center;
            transition: var(--transition);
        }

        .price-box:hover {
            border-color: var(--primary-color);
            transform: translateY(-4px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
        }

        .price-box.primary {
            border-color: var(--primary-color);
            background: linear-gradient(135deg, var(--primary-light) 0%, white 100%);
        }

        .price-label {
            font-size: 0.9rem;
            color: var(--gray-600);
            margin-bottom: 0.5rem;
            text-transform: uppercase;
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        .price-value {
            font-size: 2rem;
            font-weight: 700;
            color: var(--primary-color);
            margin-bottom: 0.25rem;
        }

        .price-currency {
            font-size: 0.85rem;
            color: var(--gray-500);
        }

        .age-range {
            background: var(--gray-100);
            padding: 0.5rem;
            border-radius: var(--radius-md);
            margin-top: 0.75rem;
            font-size: 0.85rem;
            color: var(--gray-700);
        }

        .alert-info-custom {
            background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
            border-left: 4px solid #2196f3;
            padding: 1rem;
            border-radius: var(--radius-md);
            margin-bottom: 1.5rem;
            display: flex;
            align-items: start;
            gap: 1rem;
        }

        .alert-icon {
            width: 32px;
            height: 32px;
            background: #2196f3;
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .alert-content {
            flex: 1;
        }

        .alert-content strong {
            display: block;
            margin-bottom: 0.25rem;
            color: #1976d2;
        }

        .alert-content p {
            margin: 0;
            color: #424242;
            font-size: 0.9rem;
        }
    </style>
@endpush

@section('content')
    <div class="tour-detail-container">
        <!-- Tour Header -->
        <div class="tour-header">
            <div class="tour-header-content">
                <h1 class="tour-title">{{ $tour->name }}</h1>
                <div class="tour-code">Tur Kodu: {{ $tour->code }}</div>
                <div class="tour-meta">
                    <div class="tour-meta-item">
                        <i class="fas fa-clock tour-meta-icon"></i>
                        <span>{{ $tour->start_time }} - {{ $tour->end_time }}</span>
                    </div>
                    <div class="tour-meta-item">
                        <i class="fas fa-map-marker-alt tour-meta-icon"></i>
                        <span>{{ $tour->departureCity?->city ?? 'Belirtilmemiş' }}</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Tabs Container -->
        <div class="tabs-container">
            <!-- Tab Navigation -->
            @include('agency.products.gunubirlik-turlar._nav', ['active' => 'pricing'])

            <!-- Tab Content -->
            <div class="tab-content">
                <div class="alert-info-custom">
                    <div class="alert-icon">
                        <i class="fas fa-info"></i>
                    </div>
                    <div class="alert-content">
                        <strong>Fiyatlandırma Bilgisi</strong>
                        <p>Günübirlik turlar için tek bir fiyatlandırma yapısı kullanılır. Fiyatlar tüm tarihler için geçerlidir.</p>
                    </div>
                </div>

                <!-- Current Prices Display -->
                <div class="pricing-card">
                    <div class="pricing-section">
                        <div class="pricing-section-title">
                            <div class="pricing-section-icon">
                                <i class="fas fa-dollar-sign"></i>
                            </div>
                            Mevcut Fiyatlar
                        </div>

                        <div class="price-display">
                            <div class="price-box primary">
                                <div class="price-label">Yetişkin</div>
                                <div class="price-value">{{ number_format($tour->adult_price, 2) }}</div>
                                <div class="price-currency">{{ $tour->currency ?? 'TRY' }}</div>
                            </div>

                            <div class="price-box">
                                <div class="price-label">Çocuk</div>
                                <div class="price-value">{{ number_format($tour->child_price, 2) }}</div>
                                <div class="price-currency">{{ $tour->currency ?? 'TRY' }}</div>
                                @if($tour->child_min_age || $tour->child_max_age)
                                    <div class="age-range">
                                        {{ $tour->child_min_age ?? 0 }}-{{ $tour->child_max_age ?? 12 }} yaş
                                    </div>
                                @endif
                            </div>

                            <div class="price-box">
                                <div class="price-label">Bebek</div>
                                <div class="price-value">{{ number_format($tour->infant_price, 2) }}</div>
                                <div class="price-currency">{{ $tour->currency ?? 'TRY' }}</div>
                                @if($tour->infant_max_age)
                                    <div class="age-range">
                                        0-{{ $tour->infant_max_age }} yaş
                                    </div>
                                @endif
                            </div>
                        </div>
                    </div>

                    <!-- Pricing Form -->
                    <div class="pricing-section">
                        <div class="pricing-section-title">
                            <div class="pricing-section-icon">
                                <i class="fas fa-edit"></i>
                            </div>
                            Fiyatları Güncelle
                        </div>

                        <form action="{{ route('agency.products.gunubirlik-turlar.pricing.update', $tour) }}" method="POST">
                            @csrf
                            @method('PUT')

                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label for="adult_price" class="form-label">Yetişkin Fiyatı <span class="text-danger">*</span></label>
                                    <div class="input-group">
                                        <input type="number" step="0.01" class="form-control" id="adult_price" name="adult_price"
                                               value="{{ old('adult_price', $tour->adult_price) }}" required>
                                        <select class="form-select" name="currency" style="max-width: 100px;">
                                            <option value="TRY" {{ ($tour->currency ?? 'TRY') === 'TRY' ? 'selected' : '' }}>TRY</option>
                                            <option value="USD" {{ ($tour->currency ?? 'TRY') === 'USD' ? 'selected' : '' }}>USD</option>
                                            <option value="EUR" {{ ($tour->currency ?? 'TRY') === 'EUR' ? 'selected' : '' }}>EUR</option>
                                            <option value="GBP" {{ ($tour->currency ?? 'TRY') === 'GBP' ? 'selected' : '' }}>GBP</option>
                                        </select>
                                    </div>
                                    @error('adult_price')
                                    <div class="text-danger small mt-1">{{ $message }}</div>
                                    @enderror
                                </div>

                                <div class="col-md-6 mb-3">
                                    <label for="child_price" class="form-label">Çocuk Fiyatı <span class="text-danger">*</span></label>
                                    <input type="number" step="0.01" class="form-control" id="child_price" name="child_price"
                                           value="{{ old('child_price', $tour->child_price) }}" required>
                                    @error('child_price')
                                    <div class="text-danger small mt-1">{{ $message }}</div>
                                    @enderror
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-4 mb-3">
                                    <label for="child_min_age" class="form-label">Çocuk Min. Yaş</label>
                                    <input type="number" class="form-control" id="child_min_age" name="child_min_age"
                                           value="{{ old('child_min_age', $tour->child_min_age) }}" placeholder="0">
                                    <div class="form-text">Çocuk fiyatı için minimum yaş</div>
                                </div>

                                <div class="col-md-4 mb-3">
                                    <label for="child_max_age" class="form-label">Çocuk Max. Yaş</label>
                                    <input type="number" class="form-control" id="child_max_age" name="child_max_age"
                                           value="{{ old('child_max_age', $tour->child_max_age) }}" placeholder="12">
                                    <div class="form-text">Çocuk fiyatı için maksimum yaş</div>
                                </div>

                                <div class="col-md-4 mb-3">
                                    <label for="infant_max_age" class="form-label">Bebek Max. Yaş</label>
                                    <input type="number" class="form-control" id="infant_max_age" name="infant_max_age"
                                           value="{{ old('infant_max_age', $tour->infant_max_age) }}" placeholder="2">
                                    <div class="form-text">Bebek fiyatı için maksimum yaş</div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-12 mb-3">
                                    <label for="infant_price" class="form-label">Bebek Fiyatı <span class="text-danger">*</span></label>
                                    <input type="number" step="0.01" class="form-control" id="infant_price" name="infant_price"
                                           value="{{ old('infant_price', $tour->infant_price) }}" required>
                                    @error('infant_price')
                                    <div class="text-danger small mt-1">{{ $message }}</div>
                                    @enderror
                                </div>
                            </div>

                            <div class="d-flex gap-2 justify-content-end mt-4">
                                <a href="{{ route('agency.products.gunubirlik-turlar.itinerary', $tour) }}" class="btn btn-outline-secondary">
                                    <i class="fas fa-arrow-left me-2"></i>Geri
                                </a>
                                <button type="submit" class="btn btn-primary">
                                    <i class="fas fa-save me-2"></i>Kaydet
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
