<?php
use Livewire\Component;
use Livewire\WithFileUploads;
use App\Models\ReporterApplication;
?>

<main class="max-w-7xl mx-auto px-4 md:px-6 py-10 font-odia">

    <!-- Page Header -->
    <div class="mb-10 border-b border-slate-100 pb-8">
        <span class="inline-block bg-brand-blue text-white text-[10px] font-bold uppercase tracking-wider px-3 py-1 rounded-sm mb-4">{{ __('career.badge') }}</span>
        <h1 class="text-4xl md:text-5xl font-black text-slate-900 tracking-tighter leading-none mb-3">
            {{ __('career.page_title') }}
        </h1>
        <p class="text-slate-500 text-base md:text-lg font-medium font-odia max-w-2xl">
            {{ __('career.page_subtitle') }}
        </p>
    </div>

    @if($submitted)
        <!-- Success Message -->
        <div class="max-w-2xl mx-auto text-center py-20">
            <div class="w-20 h-20 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6">
                <i class="fa-solid fa-circle-check text-4xl text-green-600"></i>
            </div>
            <h2 class="text-3xl font-black text-slate-900 mb-4">{{ __('career.success_title') }}</h2>
            <p class="text-slate-500 text-lg font-odia mb-8">
                {{ __('career.success_body') }}
            </p>
            <a href="{{ route('home') }}" class="inline-block bg-brand-blue text-white font-bold px-8 py-3 rounded-sm text-sm uppercase tracking-widest hover:bg-brand-blue/90 transition-colors">
                {{ __('career.home_page') }}
            </a>
        </div>
    @else
        <form wire:submit.prevent="submit" class="space-y-10">

            <!-- Section 1: Personal Details -->
            <section class="bg-white border border-slate-100 rounded-lg p-6 md:p-8 shadow-sm">
                <h2 class="text-base font-black uppercase tracking-widest text-slate-900 mb-6 pb-4 border-b border-slate-100">
                    <i class="fa-solid fa-user text-brand-blue mr-2"></i> {{ __('career.section_personal') }}
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.full_name') }} <span class="text-red-500">*</span></label>
                        <input type="text" wire:model="full_name" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue" placeholder="{{ __('career.full_name_ph') }}">
                        @error('full_name') <span class="text-red-500 text-xs mt-1 block">{{ $message }}</span> @enderror
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.father_name') }}</label>
                        <input type="text" wire:model="father_husband_name" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue">
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.dob') }}</label>
                        <input type="date" wire:model="dob" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue">
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.gender') }} <span class="text-red-500">*</span></label>
                        <select wire:model="gender" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue">
                            <option value="">{{ __('career.gender_select') }}</option>
                            <option value="male">{{ __('career.gender_male') }}</option>
                            <option value="female">{{ __('career.gender_female') }}</option>
                            <option value="other">{{ __('career.gender_other') }}</option>
                        </select>
                        @error('gender') <span class="text-red-500 text-xs mt-1 block">{{ $message }}</span> @enderror
                    </div>
                    <div class="md:col-span-2">
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.address') }}</label>
                        <textarea wire:model="address" rows="2" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue resize-none" placeholder="{{ __('career.address_ph') }}"></textarea>
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.mobile') }} <span class="text-red-500">*</span></label>
                        <input type="tel" wire:model="mobile_number" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue" placeholder="{{ __('career.mobile_ph') }}">
                        @error('mobile_number') <span class="text-red-500 text-xs mt-1 block">{{ $message }}</span> @enderror
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.whatsapp') }}</label>
                        <input type="tel" wire:model="whatsapp_number" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue">
                    </div>
                    <div class="md:col-span-2">
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.email') }}</label>
                        <input type="email" wire:model="email" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue">
                    </div>
                </div>
            </section>

            <!-- Section 2: Education -->
            <section class="bg-white border border-slate-100 rounded-lg p-6 md:p-8 shadow-sm">
                <h2 class="text-base font-black uppercase tracking-widest text-slate-900 mb-6 pb-4 border-b border-slate-100">
                    <i class="fa-solid fa-graduation-cap text-brand-blue mr-2"></i> {{ __('career.section_education') }}
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.qualification') }}</label>
                        <select wire:model="highest_qualification" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue">
                            <option value="">{{ __('career.gender_select') }}</option>
                            <option value="10th">{{ __('career.qual_10th') }}</option>
                            <option value="12th">{{ __('career.qual_12th') }}</option>
                            <option value="graduate">{{ __('career.qual_graduate') }}</option>
                            <option value="postgraduate">{{ __('career.qual_postgraduate') }}</option>
                            <option value="other">{{ __('career.qual_other') }}</option>
                        </select>
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.school_college') }}</label>
                        <input type="text" wire:model="school_college_name" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue">
                    </div>
                </div>
            </section>

            <!-- Section 3: Reporting Area -->
            <section class="bg-white border border-slate-100 rounded-lg p-6 md:p-8 shadow-sm">
                <h2 class="text-base font-black uppercase tracking-widest text-slate-900 mb-6 pb-4 border-b border-slate-100">
                    <i class="fa-solid fa-map-location-dot text-brand-blue mr-2"></i> {{ __('career.section_reporting') }}
                </h2>
                <div class="space-y-6">
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3">{{ __('career.applying_for') }} <span class="text-red-500">*</span></label>
                        <div class="flex flex-wrap gap-4">
                            <label class="flex items-center gap-2 cursor-pointer">
                                <input type="checkbox" wire:model="applying_for" value="GP" class="w-4 h-4 accent-brand-blue">
                                <span class="text-sm font-semibold text-slate-700">GP Reporter</span>
                            </label>
                            <label class="flex items-center gap-2 cursor-pointer">
                                <input type="checkbox" wire:model="applying_for" value="Block" class="w-4 h-4 accent-brand-blue">
                                <span class="text-sm font-semibold text-slate-700">Block Reporter</span>
                            </label>
                            <label class="flex items-center gap-2 cursor-pointer">
                                <input type="checkbox" wire:model="applying_for" value="District" class="w-4 h-4 accent-brand-blue">
                                <span class="text-sm font-semibold text-slate-700">District Reporter</span>
                            </label>
                        </div>
                        @error('applying_for') <span class="text-red-500 text-xs mt-1 block">{{ $message }}</span> @enderror
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.area') }} <span class="text-red-500">*</span></label>
                        <input type="text" wire:model="area" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue" placeholder="{{ __('career.area_ph') }}">
                        @error('area') <span class="text-red-500 text-xs mt-1 block">{{ $message }}</span> @enderror
                    </div>
                </div>
            </section>

            <!-- Section 4: Experience & Skills -->
            <section class="bg-white border border-slate-100 rounded-lg p-6 md:p-8 shadow-sm">
                <h2 class="text-base font-black uppercase tracking-widest text-slate-900 mb-6 pb-4 border-b border-slate-100">
                    <i class="fa-solid fa-star text-brand-blue mr-2"></i> {{ __('career.section_experience') }}
                </h2>
                <div class="space-y-6">
                    <div>
                        <label class="flex items-center gap-3 cursor-pointer">
                            <input type="checkbox" wire:model="has_experience" class="w-5 h-5 accent-brand-blue">
                            <span class="text-sm font-bold text-slate-700">{{ __('career.has_experience') }}</span>
                        </label>
                    </div>
                    @if($has_experience)
                        <div>
                            <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.experience_details') }}</label>
                            <textarea wire:model="experience_details" rows="3" class="w-full border border-slate-200 rounded px-4 py-2.5 text-sm focus:outline-none focus:border-brand-blue resize-none" placeholder="{{ __('career.experience_ph') }}"></textarea>
                        </div>
                    @endif
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3">{{ __('career.skills_label') }}</label>
                        <div class="flex flex-wrap gap-4">
                            @foreach(['Mobile Video', 'Interview', 'Writing', 'Photography', 'Editing'] as $skill)
                                <label class="flex items-center gap-2 cursor-pointer">
                                    <input type="checkbox" wire:model="skills" value="{{ $skill }}" class="w-4 h-4 accent-brand-blue">
                                    <span class="text-sm font-semibold text-slate-700">{{ $skill }}</span>
                                </label>
                            @endforeach
                        </div>
                    </div>
                </div>
            </section>

            <!-- Section 5: Equipment & Availability -->
            <section class="bg-white border border-slate-100 rounded-lg p-6 md:p-8 shadow-sm">
                <h2 class="text-base font-black uppercase tracking-widest text-slate-900 mb-6 pb-4 border-b border-slate-100">
                    <i class="fa-solid fa-mobile-screen text-brand-blue mr-2"></i> {{ __('career.section_equipment') }}
                </h2>
                <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                    <label class="flex items-center gap-3 p-4 border border-slate-100 rounded-lg cursor-pointer hover:border-brand-blue/30 transition-colors">
                        <input type="checkbox" wire:model="has_smartphone" class="w-5 h-5 accent-brand-blue">
                        <div>
                            <p class="text-sm font-bold text-slate-700">{{ __('career.has_smartphone') }}</p>
                            <p class="text-xs text-slate-400">Android / iOS</p>
                        </div>
                    </label>
                    <label class="flex items-center gap-3 p-4 border border-slate-100 rounded-lg cursor-pointer hover:border-brand-blue/30 transition-colors">
                        <input type="checkbox" wire:model="has_microphone" class="w-5 h-5 accent-brand-blue">
                        <div>
                            <p class="text-sm font-bold text-slate-700">{{ __('career.has_microphone') }}</p>
                            <p class="text-xs text-slate-400">External Microphone</p>
                        </div>
                    </label>
                    <label class="flex items-center gap-3 p-4 border border-slate-100 rounded-lg cursor-pointer hover:border-brand-blue/30 transition-colors">
                        <input type="checkbox" wire:model="has_internet" class="w-5 h-5 accent-brand-blue">
                        <div>
                            <p class="text-sm font-bold text-slate-700">{{ __('career.has_internet') }}</p>
                            <p class="text-xs text-slate-400">4G / Broadband</p>
                        </div>
                    </label>
                    <label class="flex items-center gap-3 p-4 border border-slate-100 rounded-lg cursor-pointer hover:border-brand-blue/30 transition-colors">
                        <input type="checkbox" wire:model="availability_daily" class="w-5 h-5 accent-brand-blue">
                        <div>
                            <p class="text-sm font-bold text-slate-700">{{ __('career.availability_daily') }}</p>
                            <p class="text-xs text-slate-400">{{ __('career.availability_desc') }}</p>
                        </div>
                    </label>
                </div>
            </section>

            <!-- Section 6: Document Upload -->
            <section class="bg-white border border-slate-100 rounded-lg p-6 md:p-8 shadow-sm">
                <h2 class="text-base font-black uppercase tracking-widest text-slate-900 mb-6 pb-4 border-b border-slate-100">
                    <i class="fa-solid fa-file-arrow-up text-brand-blue mr-2"></i> {{ __('career.section_documents') }}
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.photo_label') }}</label>
                        <input type="file" wire:model="photo" accept="image/*" class="w-full text-sm text-slate-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-xs file:font-bold file:bg-brand-blue/10 file:text-brand-blue hover:file:bg-brand-blue/20">
                        @error('photo') <span class="text-red-500 text-xs mt-1 block">{{ $message }}</span> @enderror
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-2">{{ __('career.id_proof_label') }}</label>
                        <input type="file" wire:model="id_proof" accept=".jpg,.jpeg,.png,.pdf" class="w-full text-sm text-slate-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-xs file:font-bold file:bg-brand-blue/10 file:text-brand-blue hover:file:bg-brand-blue/20">
                        @error('id_proof') <span class="text-red-500 text-xs mt-1 block">{{ $message }}</span> @enderror
                    </div>
                </div>
            </section>

            <!-- Submit -->
            <div class="flex justify-end">
                <button type="submit" wire:loading.attr="disabled" class="bg-brand-blue text-white font-black uppercase tracking-widest px-10 py-3 rounded-sm text-sm hover:bg-brand-blue/90 transition-colors disabled:opacity-60">
                    <span wire:loading.remove>{{ __('career.submit') }}</span>
                    <span wire:loading>{{ __('career.submitting') }}</span>
                </button>
            </div>

        </form>
    @endif

</main>