{# templates/security/login.html.twig #}
{% extends 'base.html.twig' %}

{% block title %}Connexion - Marketplace{% endblock %}

{% block body %}
<div class="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 bg-gray-50">
    <div class="max-w-md w-full space-y-8">
        <div>
            <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
                Connexion à votre compte
            </h2>
            <p class="mt-2 text-center text-sm text-gray-600">
                Ou
                <a href="{{ path('app_register') }}" class="font-medium text-primary-600 hover:text-primary-500">
                    créez un nouveau compte
                </a>
            </p>
        </div>
        
        {# Afficher les messages flash #}
        {% for label, messages in app.flashes %}
            {% for message in messages %}
                <div class="rounded-md bg-{{ label == 'warning' ? 'yellow' : 'blue' }}-50 p-4">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-{{ label == 'warning' ? 'exclamation-triangle' : 'info-circle' }} text-{{ label == 'warning' ? 'yellow' : 'blue' }}-400"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-{{ label == 'warning' ? 'yellow' : 'blue' }}-700">
                                {{ message }}
                            </p>
                        </div>
                    </div>
                </div>
            {% endfor %}
        {% endfor %}
        
        <form class="mt-8 space-y-6" method="POST">
            {% if error %}
                <div class="rounded-md bg-red-50 p-4">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-exclamation-circle text-red-400"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-red-700">{{ error.messageKey|trans(error.messageData, 'security') }}</p>
                        </div>
                    </div>
                </div>
            {% endif %}
            
            <div class="rounded-md shadow-sm -space-y-px">
                <div>
                    <label for="email" class="sr-only">Email</label>
                    <input type="email" 
                           name="email" 
                           id="email" 
                           value="{{ last_username }}"
                           required 
                           class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-primary-500 focus:border-primary-500 focus:z-10 sm:text-sm" 
                           placeholder="Adresse email">
                </div>
                <div>
                    <label for="password" class="sr-only">Mot de passe</label>
                    <input type="password" 
                           name="password" 
                           id="password" 
                           required 
                           class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-primary-500 focus:border-primary-500 focus:z-10 sm:text-sm" 
                           placeholder="Mot de passe">
                </div>
            </div>
            
            <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
            
            <div class="flex items-center justify-between">
                <div class="flex items-center">
                    <input type="checkbox" 
                           name="_remember_me" 
                           id="remember_me" 
                           class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded">
                    <label for="remember_me" class="ml-2 block text-sm text-gray-900">
                        Se souvenir de moi
                    </label>
                </div>
            </div>
            
            <div>
                <button type="submit" 
                        class="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
                    Se connecter
                </button>
            </div>
        </form>
    </div>
</div>
{% endblock %}