<x-guest-layout>
    <div class="min-h-screen bg-gray-50 py-12 px-4 sm:px-6 lg:px-6 xl:px-8">
        <div class="max-w-[98%] xl:max-w-[95%] mx-auto">
            <!-- En-tête -->
            <div class="text-center mb-8">
                <h2 class="text-3xl font-bold text-gray-900">Rejoindre l'association</h2>
                <p class="mt-2 text-gray-600">Remplissez le formulaire ci-dessous pour devenir membre</p>
            </div>

            <form method="POST" action="{{ route('register') }}" class="bg-white shadow-lg rounded-lg p-8 lg:p-10 xl:p-12">
                @csrf

                <!-- Section 1: Informations personnelles -->
                <div class="mb-8">
                    <h3 class="text-xl font-semibold text-gray-900 mb-6 pb-2 border-b border-gray-200">
                        Informations personnelles
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                        <!-- Prénom -->
                        <div>
                            <x-input-label for="first_name" :value="__('Prénom')" />
                            <x-text-input id="first_name" class="block mt-1 w-full" type="text" name="first_name" :value="old('first_name')" required autofocus placeholder="Votre prénom" />
                            <x-input-error :messages="$errors->get('first_name')" class="mt-2" />
                        </div>

                        <!-- Nom -->
                        <div>
                            <x-input-label for="last_name" :value="__('Nom')" />
                            <x-text-input id="last_name" class="block mt-1 w-full" type="text" name="last_name" :value="old('last_name')" required placeholder="Votre nom" />
                            <x-input-error :messages="$errors->get('last_name')" class="mt-2" />
                        </div>

                        <!-- Nom complet -->
                        <div>
                            <x-input-label for="name" :value="__('Nom complet')" />
                            <x-text-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required placeholder="Prénom et nom" />
                            <x-input-error :messages="$errors->get('name')" class="mt-2" />
                        </div>

                        <!-- Sexe -->
                        <div>
                            <x-input-label for="gender" :value="__('Sexe')" />
                            <select id="gender" name="gender" class="block mt-1 w-full rounded-md border-gray-300 shadow-sm focus:border-[#0d4f3c] focus:ring-[#0d4f3c]" required>
                                <option value="">Sélectionner votre sexe</option>
                                <option value="homme" {{ old('gender') == 'homme' ? 'selected' : '' }}>Homme</option>
                                <option value="femme" {{ old('gender') == 'femme' ? 'selected' : '' }}>Femme</option>
                            </select>
                            <x-input-error :messages="$errors->get('gender')" class="mt-2" />
                        </div>

                        <!-- CNI -->
                        <div>
                            <x-input-label for="cni" :value="__('Numéro CNI')" />
                            <x-text-input id="cni" class="block mt-1 w-full" type="text" name="cni" :value="old('cni')" placeholder="Ex: 1234567890123" />
                            <p class="mt-1 text-sm text-gray-500">Optionnel</p>
                            <x-input-error :messages="$errors->get('cni')" class="mt-2" />
                        </div>

                        <!-- Nationalité -->
                        <div>
                            <x-input-label for="nationality" :value="__('Nationalité')" />
                            <x-text-input id="nationality" class="block mt-1 w-full" type="text" name="nationality" :value="old('nationality')" required placeholder="Ex: Sénégalaise" />
                            <x-input-error :messages="$errors->get('nationality')" class="mt-2" />
                        </div>
                    </div>
                </div>

                <!-- Section 2: Coordonnées -->
                <div class="mb-8">
                    <h3 class="text-xl font-semibold text-gray-900 mb-6 pb-2 border-b border-gray-200">
                        Coordonnées
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                        <!-- Email -->
                        <div>
                            <x-input-label for="email" :value="__('Adresse email')" />
                            <x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autocomplete="username" placeholder="exemple@email.com" />
                            <x-input-error :messages="$errors->get('email')" class="mt-2" />
                        </div>

                        <!-- Téléphone -->
                        <div>
                            <x-input-label for="phone" :value="__('Téléphone')" />
                            <x-text-input id="phone" class="block mt-1 w-full" type="tel" name="phone" :value="old('phone')" required placeholder="Ex: +221 78 123 45 67" />
                            <x-input-error :messages="$errors->get('phone')" class="mt-2" />
                        </div>

                        <!-- Résidence -->
                        <div>
                            <x-input-label for="residence" :value="__('Résidence')" />
                            <x-text-input id="residence" class="block mt-1 w-full" type="text" name="residence" :value="old('residence')" required placeholder="Ex: Dakar" />
                            <x-input-error :messages="$errors->get('residence')" class="mt-2" />
                        </div>

                        <!-- Adresse -->
                        <div class="md:col-span-2 lg:col-span-3">
                            <x-input-label for="address" :value="__('Adresse complète')" />
                            <textarea id="address" name="address" rows="3" class="block mt-1 w-full rounded-md border-gray-300 shadow-sm focus:border-[#0d4f3c] focus:ring-[#0d4f3c]" required placeholder="Votre adresse complète">{{ old('address') }}</textarea>
                            <x-input-error :messages="$errors->get('address')" class="mt-2" />
                        </div>
                    </div>
                </div>

                <!-- Section 3: Sécurité -->
                <div class="mb-8">
                    <h3 class="text-xl font-semibold text-gray-900 mb-6 pb-2 border-b border-gray-200">
                        Sécurité
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                        <!-- Mot de passe -->
                        <div>
                            <x-input-label for="password" :value="__('Mot de passe')" />
                            <x-text-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" placeholder="Minimum 8 caractères" />
                            <x-input-error :messages="$errors->get('password')" class="mt-2" />
                        </div>

                        <!-- Confirmer mot de passe -->
                        <div>
                            <x-input-label for="password_confirmation" :value="__('Confirmer le mot de passe')" />
                            <x-text-input id="password_confirmation" class="block mt-1 w-full" type="password" name="password_confirmation" required autocomplete="new-password" placeholder="Répétez le mot de passe" />
                            <x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" />
                        </div>
                    </div>
                </div>

                <!-- Note d'information -->
                <div class="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <svg class="h-5 w-5 text-blue-400" fill="currentColor" viewBox="0 0 20 20">
                                <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path>
                            </svg>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-blue-700">
                                <strong>Note importante :</strong> Votre inscription sera soumise pour validation par un administrateur. Vous recevrez un email une fois votre compte validé.
                            </p>
                        </div>
                    </div>
                </div>

                <!-- Boutons d'action -->
                <div class="flex flex-col sm:flex-row items-center justify-between gap-4">
                    <a class="text-sm text-gray-600 hover:text-gray-900 underline" href="{{ route('login') }}">
                        {{ __('Déjà inscrit ? Se connecter') }}
                    </a>

                    <x-primary-button class="bg-[#0d4f3c] hover:bg-[#0a3d2e] px-8 py-3">
                        {{ __('S\'inscrire') }}
                    </x-primary-button>
                </div>
            </form>
        </div>
    </div>
</x-guest-layout>
