{% extends 'dashboard/base.twig' %}

{% block title %}Nouvel Administrateur{% endblock %}

{% block actions %}
    {# Bouton de retour vers la liste #}
    <a data-turbo="false"  href="{{ path('app_crm_administrateur') }}" class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-200 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700 transition-colors">
        <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
        </svg>
        Retour à la liste
    </a>
{% endblock %}

{% block body %}
    <div class="p-4 md:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen w-full">
        <div class="w-full">

            <div class="bg-white dark:bg-gray-800 shadow-md rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden">

                {# Bandeau d'information sur la procédure d'activation par email #}
                <div class="flex p-4 text-sm text-blue-800 border-b border-blue-200 bg-blue-50 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800/50" role="alert">
                    <svg class="flex-shrink-0 inline w-5 h-5 mr-3" 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>
                        <span class="font-bold">Procédure d'activation :</span>
                        Un email sera envoyé à l'adresse saisie. Le lien permettra au futur administrateur de <strong>valider son compte</strong> et de <strong>définir son mot de passe</strong> de manière sécurisée.
                    </div>
                </div>

                <div class="p-8">
                    {{ form_start(form, {'attr': {'class': 'space-y-8'}}) }}

                    {# Grille de formulaire en 2 colonnes sur desktop #}
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-x-12 gap-y-8">

                        {# Bloc IDENTIFIANT - Correction couleur Label dark:text-gray-200 #}
                        <div class="space-y-2">
                            {{ form_label(form.username, 'Identifiant (Username)', {
                                'label_attr': {'class': 'block text-sm font-semibold text-gray-200 dark:text-gray-200'}
                            }) }}
                            {{ form_widget(form.username, {
                                'attr': {
                                    'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-3 dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400',
                                    'placeholder': 'Ex: jdoe'
                                }
                            }) }}
                            <div class="text-red-500 text-xs mt-1 italic">{{ form_errors(form.username) }}</div>
                        </div>

                        {# Bloc EMAIL #}
                        <div class="space-y-2">
                            {{ form_label(form.email, 'Adresse mail professionnelle', {
                                'label_attr': {'class': 'block text-sm font-semibold text-gray-200 dark:text-gray-200'}
                            }) }}
                            {{ form_widget(form.email, {
                                'attr': {
                                    'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-3 dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400',
                                    'placeholder': 'email@ludikevent.fr'
                                }
                            }) }}
                            <div class="text-red-500 text-xs mt-1 italic">{{ form_errors(form.email) }}</div>
                        </div>

                        {# Bloc PRENOM #}
                        <div class="space-y-2">
                            {{ form_label(form.firstName, 'Prénom', {
                                'label_attr': {'class': 'block text-sm font-semibold text-gray-200 dark:text-gray-200'}
                            }) }}
                            {{ form_widget(form.firstName, {
                                'attr': {
                                    'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-3 dark:bg-gray-700 dark:border-gray-600 dark:text-white'
                                }
                            }) }}
                            <div class="text-red-500 text-xs mt-1 italic">{{ form_errors(form.firstName) }}</div>
                        </div>

                        {# Bloc NOM #}
                        <div class="space-y-2">
                            {{ form_label(form.name, 'Nom de famille', {
                                'label_attr': {'class': 'block text-sm font-semibold text-gray-200 dark:text-gray-200'}
                            }) }}
                            {{ form_widget(form.name, {
                                'attr': {
                                    'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-3 dark:bg-gray-700 dark:border-gray-600 dark:text-white'
                                }
                            }) }}
                            <div class="text-red-500 text-xs mt-1 italic">{{ form_errors(form.name) }}</div>
                        </div>

                    </div>

                    {# Pied de formulaire avec bouton d'action #}
                    <div class="flex items-center justify-end pt-8 border-t border-gray-200 dark:border-gray-700 mt-10">
                        <button type="submit" class="flex items-center justify-center text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 font-bold rounded-lg text-sm px-8 py-3.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 transition-all shadow-lg hover:shadow-blue-500/30">
                            <svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
                            </svg>
                            Créer et envoyer l'invitation
                        </button>
                    </div>

                    {{ form_end(form) }}
                </div>
            </div>
        </div>
    </div>
{% endblock %}
