<x-site-layout title="Become a Trainee">

    {{-- Hero --}}
    <section class="relative bg-gradient-to-r from-teal-500 to-cyan-600 py-16">
        <div class="absolute inset-0 bg-black opacity-10"></div>
        <div class="relative max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
            <span class="inline-block px-4 py-1 bg-white bg-opacity-20 rounded-full text-white text-sm font-medium mb-4">
                <i class="fas fa-graduation-cap mr-1"></i> Trainee Registration
            </span>
            <h1 class="text-4xl md:text-5xl font-bold text-white mb-4">Start Learning Today</h1>
            <p class="text-teal-100 text-lg max-w-5xl mx-auto">
                Register as a Trainee and gain access to professional health training programmes, workshops, and learning resources.
            </p>
            <div class="mt-6 inline-flex items-center gap-2 bg-white bg-opacity-20 rounded-full px-5 py-2 text-white text-sm font-medium">
                <i class="fas fa-bolt text-yellow-300"></i>
                Instant Access — No approval required!
            </div>
        </div>
    </section>

    {{-- 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-teal-500 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>
                <span class="text-gray-500">Register</span>
                <i class="fas fa-chevron-right text-gray-400 text-xs"></i>
                <span class="text-gray-900 font-medium">Start Learning Today</span>
            </nav>
        </div>
    </div>

    <section class="py-12 bg-gray-50">
        <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">

            @if(session('error'))
                <div class="mb-6 bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-xl flex items-center gap-2">
                    <i class="fas fa-exclamation-circle"></i> {{ session('error') }}
                </div>
            @endif
            @if($errors->any())
                <div class="mb-6 bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-xl">
                    <p class="font-medium flex items-center gap-2"><i class="fas fa-exclamation-triangle"></i> Please fix the errors below.</p>
                </div>
            @endif

            <form action="{{ route('register.role.trainee.store') }}" method="POST" class="space-y-6">
                @csrf

                {{-- Personal Information --}}
                <div class="bg-white rounded-2xl shadow-sm overflow-hidden">
                    <div class="bg-gray-50 px-6 py-4 border-b border-gray-100">
                        <h2 class="text-base font-semibold text-gray-900 flex items-center gap-2">
                            <i class="fas fa-user text-teal-600"></i> Personal Information
                        </h2>
                    </div>
                    <div class="p-6 grid grid-cols-1 md:grid-cols-2 gap-5">
                        <div class="md:col-span-2">
                            <label for="name" class="block text-sm font-medium text-gray-700 mb-1">Full Name <span class="text-red-500">*</span></label>
                            <input type="text" id="name" name="name" value="{{ old('name') }}"
                                   class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition"
                                   placeholder="Your full name" required>
                            @error('name')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
                        </div>
                        <div>
                            <label for="email" class="block text-sm font-medium text-gray-700 mb-1">Email Address <span class="text-red-500">*</span></label>
                            <input type="email" id="email" name="email" value="{{ old('email') }}"
                                   class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition"
                                   placeholder="your@email.com" required>
                            @error('email')<p class="mt-1 text-sm text-red-600">{!! $message !!}</p>@enderror
                        </div>
                        <div>
                            <label for="phone" class="block text-sm font-medium text-gray-700 mb-1">Phone Number</label>
                            <input type="tel" id="phone" name="phone" value="{{ old('phone') }}"
                                   class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition"
                                   placeholder="+256 7XX XXX XXX">
                        </div>
                        <div>
                            <label for="city" class="block text-sm font-medium text-gray-700 mb-1">City</label>
                            <input type="text" id="city" name="city" value="{{ old('city') }}"
                                   class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition"
                                   placeholder="City">
                        </div>
                        <div>
                            <label for="country" class="block text-sm font-medium text-gray-700 mb-1">Country</label>
                            <input type="text" id="country" name="country" value="{{ old('country') }}"
                                   class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition"
                                   placeholder="Country">
                        </div>
                    </div>
                </div>

                {{-- Education & Background --}}
                <div class="bg-white rounded-2xl shadow-sm overflow-hidden">
                    <div class="bg-gray-50 px-6 py-4 border-b border-gray-100">
                        <h2 class="text-base font-semibold text-gray-900 flex items-center gap-2">
                            <i class="fas fa-book-open text-teal-600"></i> Education & Background
                        </h2>
                    </div>
                    <div class="p-6 grid grid-cols-1 md:grid-cols-2 gap-5">
                        <div>
                            <label for="education_level" class="block text-sm font-medium text-gray-700 mb-1">Education Level</label>
                            <select id="education_level" name="education_level"
                                    class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition">
                                <option value="">-- Select Level --</option>
                                <option value="Secondary" {{ old('education_level') === 'Secondary' ? 'selected' : '' }}>Secondary</option>
                                <option value="Diploma" {{ old('education_level') === 'Diploma' ? 'selected' : '' }}>Diploma</option>
                                <option value="Bachelor's Degree" {{ old('education_level') === "Bachelor's Degree" ? 'selected' : '' }}>Bachelor's Degree</option>
                                <option value="Master's Degree" {{ old('education_level') === "Master's Degree" ? 'selected' : '' }}>Master's Degree</option>
                                <option value="PhD" {{ old('education_level') === 'PhD' ? 'selected' : '' }}>PhD</option>
                                <option value="Other" {{ old('education_level') === 'Other' ? 'selected' : '' }}>Other</option>
                            </select>
                        </div>
                        <div>
                            <label for="current_occupation" class="block text-sm font-medium text-gray-700 mb-1">Current Occupation</label>
                            <input type="text" id="current_occupation" name="current_occupation" value="{{ old('current_occupation') }}"
                                   class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition"
                                   placeholder="e.g. Nurse, Student, Community Worker">
                        </div>
                        <div>
                            <label for="availability" class="block text-sm font-medium text-gray-700 mb-1">Availability</label>
                            <select id="availability" name="availability"
                                    class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition">
                                <option value="">-- Select Availability --</option>
                                <option value="Full-time" {{ old('availability') === 'Full-time' ? 'selected' : '' }}>Full-time</option>
                                <option value="Part-time" {{ old('availability') === 'Part-time' ? 'selected' : '' }}>Part-time</option>
                                <option value="Weekends" {{ old('availability') === 'Weekends' ? 'selected' : '' }}>Weekends</option>
                                <option value="Flexible" {{ old('availability') === 'Flexible' ? 'selected' : '' }}>Flexible</option>
                            </select>
                        </div>
                    </div>
                </div>

                {{-- Learning Goals --}}
                <div class="bg-white rounded-2xl shadow-sm overflow-hidden">
                    <div class="bg-gray-50 px-6 py-4 border-b border-gray-100">
                        <h2 class="text-base font-semibold text-gray-900 flex items-center gap-2">
                            <i class="fas fa-bullseye text-teal-600"></i> Learning Goals
                        </h2>
                    </div>
                    <div class="p-6 space-y-5">
                        <div>
                            <label for="learning_goals" class="block text-sm font-medium text-gray-700 mb-1">What do you want to learn? <span class="text-red-500">*</span></label>
                            <textarea id="learning_goals" name="learning_goals" rows="4"
                                      class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-teal-500 focus:border-teal-500 transition"
                                      placeholder="Describe your learning goals and what you hope to achieve..." required>{{ old('learning_goals') }}</textarea>
                            @error('learning_goals')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">Areas of Interest <span class="text-red-500">*</span></label>
                            @php
                                $interestOptions = ['Public Health','Nutrition','Mental Health','Maternal Health','Community Health','Health Education','Epidemiology','First Aid','Environmental Health','Clinical Skills','Other'];
                                $selectedInterests = old('areas_of_interest', []);
                            @endphp
                            <div class="grid grid-cols-2 md:grid-cols-3 gap-3">
                                @foreach($interestOptions as $option)
                                    <label class="flex items-center gap-2 cursor-pointer p-3 border border-gray-200 rounded-lg hover:bg-teal-50 hover:border-teal-300 transition">
                                        <input type="checkbox" name="areas_of_interest[]" value="{{ $option }}"
                                               class="h-4 w-4 text-teal-600 border-gray-300 rounded focus:ring-teal-500"
                                               {{ in_array($option, $selectedInterests) ? 'checked' : '' }}>
                                        <span class="text-sm text-gray-700">{{ $option }}</span>
                                    </label>
                                @endforeach
                            </div>
                            @error('areas_of_interest')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
                        </div>
                    </div>
                </div>

                {{-- Account Security --}}
                <div class="bg-white rounded-2xl shadow-sm overflow-hidden">
                    <div class="bg-gray-50 px-6 py-4 border-b border-gray-100">
                        <h2 class="text-base font-semibold text-gray-900 flex items-center gap-2">
                            <i class="fas fa-lock text-teal-600"></i> Account Security
                        </h2>
                    </div>
                    <div class="p-6">
                        @include('registration._partials.password-fields', ['color' => 'teal'])
                    </div>
                </div>

                {{-- Terms --}}
                <div class="bg-white rounded-2xl shadow-sm p-6">
                    <label class="flex items-start gap-3 cursor-pointer">
                        <input type="checkbox" name="terms_accepted" value="1"
                               class="mt-1 h-4 w-4 text-teal-600 border-gray-300 rounded focus:ring-teal-500"
                               {{ old('terms_accepted') ? 'checked' : '' }} required>
                        <span class="text-sm text-gray-600">
                            I agree to the <a href="{{ route('pages.terms') }}" class="text-teal-600 hover:underline" target="_blank">Terms and Conditions</a>
                            and <a href="{{ route('pages.privacy') }}" class="text-teal-600 hover:underline" target="_blank">Privacy Policy</a>. <span class="text-red-500">*</span>
                        </span>
                    </label>
                    @error('terms_accepted')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
                </div>

                @include('registration._partials.bottom-nav', ['color' => 'teal', 'submitLabel' => 'Create Trainee Account'])
            </form>
        </div>
    </section>

</x-site-layout>
