{% extends "layouts/base.html" %}
{% load static %}

{% block title %}Finalisez votre inscription | {{ site_config.nom_plateforme }}{% endblock %}

{% block extra_head %}
    <!-- Google Fonts & Font Awesome (icône Google) -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <!-- Tailwind CSS (CDN) -->
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        /* Halo doré diffus en arrière-plan */
        body {
            background-color: #000000;
            margin: 0;
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }
        body::before {
            content: "";
            position: fixed;
            top: 50%;
            left: 50%;
            width: 80vmax;
            height: 80vmax;
            transform: translate(-50%, -50%);
            background: radial-gradient(circle at center, rgba(212, 175, 55, 0.12) 0%, rgba(0,0,0,0) 70%);
            pointer-events: none;
            z-index: 0;
        }

        /* Carte glassmorphisme */
        .glass-card {
            background: rgba(20, 20, 20, 0.65);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid rgba(212, 175, 55, 0.25);
            border-radius: 2rem;
            box-shadow: 0 20px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(212,175,55,0.1) inset;
        }

        /* Titre avec dégradé or métallique */
        .gold-text {
            font-family: 'Cinzel', serif;
            font-weight: 700;
            background: linear-gradient(135deg, #F9D976 0%, #E5B84B 30%, #F3E2A7 60%, #C59B3C 100%);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 2px 10px rgba(212,175,55,0.3);
            letter-spacing: 0.05em;
        }

        /* Bouton de confirmation massif doré */
        .gold-confirm-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            background: linear-gradient(145deg, #D4AF37 0%, #F9D976 50%, #C59B3C 100%);
            border: 1px solid rgba(255, 215, 0, 0.6);
            color: #0a0a0a;
            font-weight: 700;
            padding: 1rem 2.5rem;
            border-radius: 60px;
            transition: all 0.3s ease;
            box-shadow: 0 8px 20px rgba(212, 175, 55, 0.25), 0 4px 8px rgba(0,0,0,0.4);
            font-size: 1.2rem;
            width: 100%;
            max-width: 320px;
            margin: 1.5rem auto 0;
            letter-spacing: 0.03em;
            text-transform: uppercase;
            cursor: pointer;
            font-family: 'Cinzel', serif;
            border: none;
        }
        .gold-confirm-btn:hover {
            background: linear-gradient(145deg, #E5B84B 0%, #FFE68F 50%, #D4AF37 100%);
            box-shadow: 0 0 25px rgba(212, 175, 55, 0.9), 0 6px 12px rgba(0,0,0,0.5);
            transform: scale(1.02);
            color: #000;
        }
        .gold-confirm-btn i {
            color: #0a0a0a;
            font-size: 1.3rem;
            transition: transform 0.2s;
        }
        .gold-confirm-btn:hover i {
            transform: translateX(4px);
        }

        /* Champs de formulaire stylisés */
        .form-input {
            width: 100%;
            padding: 0.9rem 1.2rem;
            background: rgba(0, 0, 0, 0.4);
            border: 1px solid rgba(212, 175, 55, 0.35);
            border-radius: 40px;
            color: #f0e6d2;
            font-size: 1rem;
            outline: none;
            transition: border 0.3s, box-shadow 0.3s;
            margin-bottom: 1.2rem;
            backdrop-filter: blur(4px);
        }
        .form-input:focus {
            border-color: #d4af37;
            box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
        }
        .form-input::placeholder {
            color: #9a9a9a;
            font-style: italic;
        }

        /* Erreurs formulaire */
        .errorlist {
            list-style: none;
            padding: 0.5rem 0 0;
            margin: -0.5rem 0 0.8rem;
            color: #f87171;
            font-size: 0.85rem;
            text-align: left;
        }

        /* Animation fade-in-up */
        @keyframes fadeInUp {
            0% {
                opacity: 0;
                transform: translateY(30px);
            }
            100% {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .animate-fade-in-up {
            animation: fadeInUp 0.9s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
        }

        /* Lien discret */
        .legal-note {
            color: #a0a0a0;
            font-size: 0.8rem;
            border-top: 1px dashed rgba(212,175,55,0.2);
            padding-top: 1.2rem;
            margin-top: 1.2rem;
        }

        /* Label invisible pour conserver l'accessibilité */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0,0,0,0);
            border: 0;
        }
    </style>
{% endblock %}

{% block content %}
<div class="relative z-10 w-full min-h-screen flex flex-col items-center justify-center px-4 py-8">
    <!-- Header : Logo / Nom du site -->
    <div class="mb-6 text-center animate-fade-in-up" style="animation-delay: 0.1s;">
        <h1 class="text-3xl md:text-4xl gold-text drop-shadow-2xl">
            {{ site_config.nom_plateforme }}
        </h1>
        <div class="h-0.5 w-24 mx-auto mt-2 bg-gradient-to-r from-transparent via-yellow-500/50 to-transparent"></div>
    </div>

    <!-- Carte centrale -->
    <div class="glass-card w-full max-w-md p-8 md:p-10 text-center animate-fade-in-up" style="animation-delay: 0.2s;">
        <h2 class="text-2xl gold-text mb-3">Finalisez votre inscription</h2>
        
        <!-- Phrase d'accueil personnalisée -->
        <p class="text-gray-300 text-base md:text-lg mb-6 font-light tracking-wide">
            Vous y êtes presque, <span class="text-yellow-300 font-medium">{{ account_name }}</span>.<br>
            Cliquez sur le bouton ci-dessous pour confirmer votre accès au scrutin.
        </p>

        <!-- Formulaire de création de compte social -->
        <form method="post" action="" class="w-full">
            {% csrf_token %}
            
            {# Affichage des erreurs non liées à un champ #}
            {% if form.non_field_errors %}
                <div class="errorlist">
                    {% for error in form.non_field_errors %}
                        <p>{{ error }}</p>
                    {% endfor %}
                </div>
            {% endif %}

            {# Parcours des champs visibles du formulaire (email, username, etc.) #}
            {% for field in form.visible_fields %}
                <div class="mb-4 text-left">
                    {# Label accessible uniquement pour lecteurs d'écran #}
                    <label for="{{ field.id_for_label }}" class="sr-only">{{ field.label }}</label>
                    
                    {# Champ avec classes stylisées #}
                    <input 
                        type="{{ field.field.widget.input_type }}" 
                        name="{{ field.html_name }}" 
                        id="{{ field.id_for_label }}" 
                        class="form-input"
                        placeholder="{{ field.label }}"
                        {% if field.value %}value="{{ field.value }}"{% endif %}
                        {% if field.field.required %}required{% endif %}
                    >
                    
                    {# Erreurs spécifiques au champ #}
                    {% if field.errors %}
                        <ul class="errorlist">
                            {% for error in field.errors %}
                                <li>{{ error }}</li>
                            {% endfor %}
                        </ul>
                    {% endif %}
                    
                    {# Aide éventuelle #}
                    {% if field.help_text %}
                        <p class="text-xs text-gray-400 mt-1">{{ field.help_text }}</p>
                    {% endif %}
                </div>
            {% endfor %}

            {# Champs cachés (ex: next, etc.) #}
            {% for hidden in form.hidden_fields %}
                {{ hidden }}
            {% endfor %}

            <!-- Bouton de confirmation massif doré -->
            <button type="submit" class="gold-confirm-btn group">
                <i class="fas fa-check-circle"></i>
                <span>Confirmer l'accès</span>
            </button>
        </form>

        <!-- Note de confiance (anonymat) -->
        <div class="legal-note">
            <i class="fas fa-shield-alt mr-1 text-yellow-600/70"></i>
            <span class="text-gray-400">Votre email est haché (SHA‑256) immédiatement.<br> 
            <strong class="text-yellow-500/80">Anonymat total du vote garanti.</strong></span>
        </div>
    </div>

    <!-- Footer discret (mentions légales) -->
    <div class="mt-8 text-xs text-gray-500 animate-fade-in-up" style="animation-delay: 0.3s;">
        <a href="{% url 'awards_vitrine:legal' %}" class="hover:text-yellow-500 transition">Mentions légales</a>
        <span class="mx-2">•</span>
        <span>© {{ site_config.nom_plateforme }}</span>
    </div>
</div>

<!-- Script minimal -->
<script>
    (function() {
        console.log("✨ Page de finalisation d'inscription chargée.");
        // Ajustement mineur pour les placeholders si nécessaire
    })();
</script>
{% endblock %}