{{-- Mentorship Public Verify Status View --}}
{{-- Form to check application status by email --}}

<x-site-layout 
    title="Check Application Status"
    meta-description="Track your mentorship application status by entering your email"
    :show-breadcrumbs="true">

    {{-- Hero Section — Advocacy Style --}}
    <div class="relative bg-gradient-to-r from-green-700 to-emerald-800 shadow-xl">
        <div class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
            <div class="text-center">
                <span class="inline-block px-4 py-1 bg-white/20 text-white rounded-full text-sm font-semibold mb-4">
                    <i class="fas fa-search mr-2"></i> Track Application
                </span>
                <h1 class="text-4xl md:text-5xl font-serif font-bold text-white mb-4">
                    Check Application Status
                </h1>
                <p class="text-xl text-green-100 max-w-3xl mx-auto">
                    Enter your email address to view the status of your mentorship application
                </p>
            </div>
        </div>
    </div>

    {{-- Breadcrumb --}}
    <div class="bg-gray-50 border-b border-gray-200">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3">
            <nav class="flex items-center space-x-2 text-sm text-gray-600" aria-label="Breadcrumb">
                <a href="{{ url('/') }}" class="hover:text-green-600 transition flex items-center">
                    <i class="fas fa-home mr-1"></i>Home
                </a>
                <i class="fas fa-chevron-right text-gray-400 text-xs"></i>
                <a href="{{ route('mentorship.public.index') }}" class="hover:text-green-600 transition">Mentorship</a>
                <i class="fas fa-chevron-right text-gray-400 text-xs"></i>
                <span class="text-gray-900 font-medium">Check Application Status</span>
            </nav>
        </div>
    </div>

    {{-- Main Content Area --}}
    <div class="py-12 bg-gray-50">
        <div class="max-w-xl mx-auto px-4 sm:px-6 lg:px-8">
            
            {{-- Flash Messages --}}
            @if(session('success'))
                <div class="mb-6 p-4 bg-green-100 border border-green-400 text-green-700 rounded-lg">
                    <i class="fas fa-check-circle mr-2"></i>
                    {{ session('success') }}
                </div>
            @endif

            @if(session('error'))
                <div class="mb-6 p-4 bg-red-100 border border-red-400 text-red-700 rounded-lg">
                    <i class="fas fa-exclamation-circle mr-2"></i>
                    {{ session('error') }}
                </div>
            @endif

            {{-- Verification Form --}}
            <div class="bg-white rounded-lg shadow-sm border border-gray-100">
                <div class="p-6 border-b border-gray-200">
                    <h3 class="text-lg font-semibold text-gray-900">
                        <i class="fas fa-envelope mr-2 text-green-600"></i>
                        Enter Your Email
                    </h3>
                </div>
                <div class="p-6">
                    <form method="POST" action="{{ route('mentorship.public.verify-status.check') }}">
                        @csrf
                        
                        <div class="mb-6">
                            <label for="email" class="block text-sm font-medium text-gray-700 mb-2">
                                Email Address <span class="text-red-500">*</span>
                            </label>
                            <input type="email" 
                                   id="email" 
                                   name="email" 
                                   value="{{ old('email') }}"
                                   placeholder="Enter the email you used to apply"
                                   class="w-full border border-gray-300 rounded-lg px-4 py-3 bg-white text-gray-900 focus:ring-2 focus:ring-green-500 focus:border-transparent @error('email') border-red-500 @enderror"
                                   required>
                            @error('email')
                                <p class="mt-1 text-sm text-red-500">{{ $message }}</p>
                            @enderror
                        </div>

                        <button type="submit" 
                                class="w-full px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition font-semibold">
                            <i class="fas fa-search mr-2"></i>
                            Find My Application
                        </button>
                    </form>
                </div>
            </div>

            {{-- Info Box --}}
            <div class="mt-6 bg-blue-50 border border-blue-200 rounded-lg p-4">
                <div class="flex items-start">
                    <i class="fas fa-info-circle text-blue-500 mr-3 mt-0.5"></i>
                    <div class="text-sm text-blue-700">
                        <p class="font-medium mb-1">Need Help?</p>
                        <ul class="list-disc list-inside space-y-1">
                            <li>Enter the email address you used when submitting your application</li>
                            <li>If you have multiple applications, all will be displayed</li>
                            <li>Can't find your application? Contact our support team</li>
                        </ul>
                    </div>
                </div>
            </div>

            {{-- Recent Applications (if found) --}}
            @if($application)
                <div class="mt-8">
                    <h3 class="text-lg font-semibold text-gray-900 mb-4">
                        <i class="fas fa-check-circle text-green-600 mr-2"></i>
                        Application Found
                    </h3>
                    <div class="bg-white rounded-lg shadow-sm border border-gray-100 border-l-4 @if($application->isApproved()) border-green-500 @elseif($application->isRejected()) border-red-500 @else border-yellow-500 @endif">
                        <div class="p-6">
                            <div class="flex items-center justify-between mb-4">
                                <div>
                                    <h4 class="font-semibold text-gray-900">{{ $application->programme->title ?? 'Mentorship Programme' }}</h4>
                                    <p class="text-sm text-gray-500">Applied on {{ $application->created_at->format('M d, Y') }}</p>
                                </div>
                                @php
                                    $statusColors = [
                                        'pending' => 'bg-yellow-100 text-yellow-800',
                                        'under_review' => 'bg-blue-100 text-blue-800',
                                        'approved' => 'bg-green-100 text-green-800',
                                        'rejected' => 'bg-red-100 text-red-800',
                                        'payment_pending' => 'bg-purple-100 text-purple-800',
                                    ];
                                @endphp
                                <span class="px-3 py-1 rounded-full text-sm font-medium {{ $statusColors[$application->status] ?? 'bg-gray-100 text-gray-800' }}">
                                    {{ $application->status_label }}
                                </span>
                            </div>
                            <div class="flex items-center gap-4 text-sm text-gray-500 mb-4">
                                <span>
                                    <i class="fas fa-user-tag mr-1"></i>
                                    {{ ucfirst($application->role_preference) }}
                                </span>
                                @if($application->payment_required)
                                    <span>
                                        <i class="fas fa-credit-card mr-1"></i>
                                        {{ $application->formatted_payment_amount }}
                                    </span>
                                @endif
                            </div>
                            <a href="{{ route('mentorship.public.status', $application) }}" 
                               class="inline-flex items-center px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition text-sm">
                                <i class="fas fa-eye mr-2"></i>
                                View Full Details
                            </a>
                        </div>
                    </div>
                </div>
            @endif

            {{-- Quick Links --}}
            <div class="mt-8 text-center">
                <p class="text-gray-500 mb-4">Looking for something else?</p>
                <div class="flex flex-col sm:flex-row gap-3 justify-center">
                    <a href="{{ route('mentorship.public.index') }}" 
                       class="px-4 py-2 text-green-600 hover:underline">
                        <i class="fas fa-graduation-cap mr-1"></i>
                        Browse Programmes
                    </a>
                    <a href="{{ route('mentorship.public.index') }}#programmes" 
                       class="px-4 py-2 text-green-600 hover:underline">
                        <i class="fas fa-user-plus mr-1"></i>
                        New Application
                    </a>
                </div>
            </div>
        </div>
    </div>
</x-site-layout>
