@extends('layouts.site')
@section('title', 'Kolay Abonelik — En Uygun İnternet & TV Paketleri')
@section('content')

<section class="bg-blue-600 text-white">
    <div class="max-w-6xl mx-auto px-4 py-20 text-center">
        <h1 class="text-4xl font-bold mb-4">Size En Uygun İnternet & TV Paketini Bulun</h1>
        <p class="text-blue-100 mb-8 text-lg">Onlarca firma, yüzlerce paket — tek yerden karşılaştırın, hemen başvurun.</p>
        <a href="{{ route('packages.index') }}" class="bg-white text-blue-600 font-semibold px-6 py-3 rounded-lg hover:bg-blue-50">Paketleri İncele</a>
    </div>
</section>

<section class="max-w-6xl mx-auto px-4 py-14">
    <h2 class="text-2xl font-bold mb-6">Anlaşmalı Firmalar</h2>
    <div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4">
        @foreach ($companies as $company)
            <a href="{{ route('packages.index', ['company_id' => $company->id]) }}" class="border rounded-lg p-4 text-center flex items-center justify-center h-20 font-medium text-sm hover:shadow-md hover:border-blue-400 hover:text-blue-600 transition">
                {{ $company->name }}
            </a>
        @endforeach
    </div>
</section>

@if ($campaignPackages->isNotEmpty())
<section class="bg-slate-50 py-14">
    <div class="max-w-6xl mx-auto px-4">
        <h2 class="text-2xl font-bold mb-6">Kampanyalı Paketler</h2>
        <div class="grid md:grid-cols-3 gap-6">
            @foreach ($campaignPackages as $package)
                <a href="{{ route('packages.show', $package) }}" class="block bg-white border rounded-lg p-5 hover:shadow-md transition">
                    <p class="text-xs text-blue-600 font-semibold mb-1">{{ $package->company->name }}</p>
                    <h3 class="font-bold text-lg hover:text-blue-600">{{ $package->name }}</h3>
                    <p class="text-sm text-slate-500 mb-2">{{ $package->speed }} — {{ $package->campaign }}</p>
                    <p class="text-2xl font-bold text-blue-600">{{ number_format($package->monthly_fee,2,',','.') }} TL<span class="text-sm text-slate-400">/ay</span></p>
                </a>
            @endforeach
        </div>
    </div>
</section>
@endif

<section class="max-w-2xl mx-auto px-4 py-14">
    <h2 class="text-2xl font-bold mb-6 text-center">Hemen Başvurun</h2>
    <form method="POST" action="{{ route('applications.store') }}" class="bg-white border rounded-lg p-6 space-y-4">
        @csrf
        <div>
            <label class="block text-sm font-medium mb-1">Ad Soyad</label>
            <input type="text" name="name" required class="w-full border rounded px-3 py-2" value="{{ old('name') }}">
        </div>
        <div class="grid grid-cols-2 gap-4">
            <div>
                <label class="block text-sm font-medium mb-1">Telefon</label>
                <input type="text" name="phone" required class="w-full border rounded px-3 py-2" value="{{ old('phone') }}">
            </div>
            <div>
                <label class="block text-sm font-medium mb-1">E-posta</label>
                <input type="email" name="email" class="w-full border rounded px-3 py-2" value="{{ old('email') }}">
            </div>
        </div>
        <div class="grid grid-cols-2 gap-4">
            <div>
                <label class="block text-sm font-medium mb-1">İl</label>
                <input type="text" name="il" required class="w-full border rounded px-3 py-2" value="{{ old('il') }}">
            </div>
            <div>
                <label class="block text-sm font-medium mb-1">İlçe</label>
                <input type="text" name="ilce" required class="w-full border rounded px-3 py-2" value="{{ old('ilce') }}">
            </div>
        </div>
        <div>
            <label class="block text-sm font-medium mb-1">İlgilendiğiniz Paket</label>
            <select name="package_id" required class="w-full border rounded px-3 py-2">
                @foreach ($campaignPackages as $package)
                    <option value="{{ $package->id }}">{{ $package->company->name }} — {{ $package->name }}</option>
                @endforeach
            </select>
        </div>
        <button class="w-full bg-blue-600 text-white rounded py-2.5 font-semibold hover:bg-blue-700">Başvuruyu Gönder</button>
        @guest('customer')
            <p class="text-xs text-slate-400 text-center">Gönder'e bastığınızda, başvurunuzu tamamlamak için <a href="{{ route('customer.login') }}" class="text-blue-600 hover:underline">giriş yapmanız veya kayıt olmanız</a> istenecek. Bilgileriniz kaybolmaz.</p>
        @endguest
    </form>
</section>
@endsection
