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

{% block title %}Connexion | Espace Client Ludik Event{% endblock %}

{% block description %}Accédez à votre espace Ludik Event pour gérer vos réservations de châteaux gonflables et vos contrats de location.{% endblock %}

{% block extra_header %}
    {# Une page de connexion ne doit pas être indexée pour éviter le contenu pauvre #}
    <meta name="robots" content="noindex, nofollow">
{% endblock %}

{% block breadcrumb_json %}
    ,{
    "@type": "ListItem",
    "position": 1,
    "name": "Connexion",
    "item": "{{ url('reservation_login') }}"
    }
{% endblock %}

{% block body %}
    <div class="min-h-screen bg-gray-50 flex flex-col justify-center py-12 px-4 sm:px-6 lg:px-8">
        <div class="sm:mx-auto sm:w-full sm:max-w-md text-center">
            {# Logo ou Rappel de Marque #}
            <div class="inline-flex items-center justify-center w-20 h-20 bg-blue-600 rounded-3xl shadow-lg mb-6">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
                </svg>
            </div>
            <h1 class="text-3xl font-extrabold text-gray-900 tracking-tight">
                Bon retour parmi nous
            </h1>
            <p class="mt-2 text-sm text-gray-600">
                Ou
                <a href="{{ path('reservation_register') }}" class="font-medium text-blue-600 hover:text-blue-500">
                    créez un compte gratuitement
                </a>
            </p>
        </div>

        <div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
            <div class="bg-white py-8 px-4 shadow-xl border border-gray-100 sm:rounded-3xl sm:px-10">

                {# Gestion des erreurs Symfony #}
                {% if error is defined and error %}
                    <div class="mb-4 p-4 rounded-2xl bg-red-50 border border-red-100 text-red-700 text-sm animate-pulse">
                        {{ error.messageKey|trans(error.messageData, 'security') }}
                    </div>
                {% endif %}

                <form action="{{ path('reservation_login') }}" method="post" class="space-y-6">
                    <div>
                        <label for="username" class="block text-sm font-semibold text-gray-700">Adresse Email</label>
                        <div class="mt-1 relative">
                            <input type="email" id="username" name="_username" value="{{ last_username|default('') }}" required autofocus
                                   class="appearance-none block w-full px-4 py-3 border border-gray-200 rounded-2xl shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
                                   placeholder="exemple@mail.com">
                        </div>
                    </div>

                    <div>
                        <label for="password" class="block text-sm font-semibold text-gray-700">Mot de passe</label>
                        <div class="mt-1">
                            <input type="password" id="password" name="_password" required
                                   class="appearance-none block w-full px-4 py-3 border border-gray-200 rounded-2xl shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
                                   placeholder="••••••••">
                        </div>
                    </div>

                    <div class="flex items-center justify-between">
                        <div class="flex items-center">
                            <input id="remember_me" name="_remember_me" type="checkbox"
                                   class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded-lg">
                            <label for="remember_me" class="ml-2 block text-sm text-gray-700">Se souvenir de moi</label>
                        </div>

                        <div class="text-sm">
                            <a href="{{ path('reservation_password') }}" class="font-medium text-blue-600 hover:text-blue-500">
                                Oublié ?
                            </a>
                        </div>
                    </div>

                    {# CSRF Token pour la sécurité Symfony #}
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate_customer') }}">

                    <div>
                        <button type="submit"
                                class="w-full flex justify-center py-4 px-4 border border-transparent rounded-2xl shadow-lg text-sm font-bold text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all transform hover:scale-[1.02]">
                            Se connecter
                        </button>
                    </div>
                </form>

                <div class="mt-8">
                    <div class="relative">
                        <div class="absolute inset-0 flex items-center">
                            <div class="w-full border-t border-gray-200"></div>
                        </div>
                        <div class="relative flex justify-center text-sm">
                            <span class="px-2 bg-white text-gray-500">Besoin d'aide ?</span>
                        </div>
                    </div>
                    <div class="mt-4 text-center text-xs text-gray-400">
                        En vous connectant, vous acceptez nos <a href="{{ path('reservation_rgpd') }}" class="underline">Conditions Générales</a>.
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
