{% extends "base.html" %}

{% block title %}{{ evenement.nom }} | BilletFest{% endblock %}

{% block content %}
<style>
    /* ============================================
       STYLES SPÉCIFIQUES À LA PAGE DÉTAIL ÉVÉNEMENT
       Thème Festif & Chaleureux - Mobile-First
       ============================================ */
    .event-header {
        position: relative;
        height: 280px;
        background-size: cover;
        background-position: center 30%;
        border-radius: 0 0 30px 30px;
        margin: -1.5rem -1rem 2rem -1rem;
        overflow: hidden;
    }

    .header-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, rgba(255,140,66,0.4) 100%);
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        padding: 2rem 1.5rem;
    }

    .event-header h1 {
        font-family: 'Poppins', sans-serif;
        font-size: 2.2rem;
        font-weight: 800;
        color: white;
        text-shadow: 2px 4px 12px rgba(0,0,0,0.4);
        line-height: 1.2;
        margin-bottom: 0.5rem;
    }

    .event-meta {
        display: flex;
        align-items: center;
        gap: 1rem;
        color: white;
        font-weight: 500;
        text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
    }

    .badge-dispo {
        background: var(--success-emerald);
        color: white;
        padding: 0.3rem 1rem;
        border-radius: 30px;
        font-size: 0.85rem;
        font-weight: 600;
        display: inline-block;
        margin-top: 0.5rem;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }

    /* Layout 2 colonnes */
    .event-detail-container {
        display: flex;
        flex-direction: column;
        gap: 2.5rem;
        margin-bottom: 3rem;
    }

    .event-description {
        background: white;
        border-radius: 24px;
        padding: 1.8rem;
        box-shadow: 0 8px 20px rgba(255,140,66,0.06);
        border: 1px solid rgba(255,140,66,0.1);
    }

    .event-description h2 {
        font-family: 'Poppins', sans-serif;
        color: var(--warm-anthracite);
        margin-bottom: 1rem;
        font-size: 1.5rem;
        position: relative;
    }

    .event-description h2:after {
        content: '';
        display: block;
        width: 60px;
        height: 3px;
        background: var(--amber);
        border-radius: 3px;
        margin-top: 8px;
    }

    .event-description p {
        color: #4a4a4a;
        line-height: 1.7;
        font-size: 1rem;
    }

    /* Section Tickets */
    .tickets-section h2 {
        font-family: 'Poppins', sans-serif;
        color: var(--warm-anthracite);
        margin-bottom: 1.5rem;
        font-size: 1.5rem;
    }

    .ticket-cards {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .ticket-card {
        background: white;
        border-radius: 28px;
        padding: 1.8rem 1.5rem;
        box-shadow: 0 12px 24px rgba(255,140,66,0.08);
        border: 2px solid rgba(255,140,66,0.2);
        transition: all 0.25s ease;
        position: relative;
    }

    .ticket-card:hover {
        border-color: var(--amber);
        box-shadow: 0 20px 30px rgba(255,140,66,0.15);
        transform: translateY(-4px);
    }

    /* Style premium pour le ticket VIP */
    .ticket-card.vip {
        border: 2px solid var(--amber);
        background: linear-gradient(145deg, #fffdf8, white);
    }

    .ticket-card.vip:before {
        content: '🌟 POPULAIRE';
        position: absolute;
        top: -12px;
        right: 20px;
        background: var(--amber);
        color: var(--warm-anthracite);
        font-size: 0.7rem;
        font-weight: 700;
        padding: 0.2rem 1rem;
        border-radius: 30px;
        letter-spacing: 0.5px;
    }

    .ticket-name {
        font-family: 'Poppins', sans-serif;
        font-size: 1.8rem;
        font-weight: 700;
        color: var(--amber);
        margin-bottom: 0.3rem;
    }

    .ticket-price {
        font-size: 2.5rem;
        font-weight: 800;
        color: var(--warm-anthracite);
        margin-bottom: 1.5rem;
        border-bottom: 2px dashed rgba(255,140,66,0.3);
        padding-bottom: 1rem;
    }

    .ticket-price small {
        font-size: 1rem;
        font-weight: 500;
        color: #6b6b6b;
    }

    .ticket-advantages {
        list-style: none;
        margin-bottom: 2rem;
    }

    .ticket-advantages li {
        padding: 0.4rem 0;
        display: flex;
        align-items: center;
        gap: 10px;
        color: #3a3a3a;
        font-size: 0.95rem;
    }

    .ticket-advantages li:before {
        content: "✅";
        color: var(--success-emerald);
        font-weight: bold;
        margin-right: 8px;
    }

    .btn-reserve {
        background: linear-gradient(145deg, var(--sunset-start), var(--sunset-end));
        color: white;
        padding: 1rem 1.5rem;
        border-radius: 60px;
        font-weight: 700;
        font-size: 1.1rem;
        text-decoration: none;
        display: block;
        text-align: center;
        transition: all 0.3s ease;
        box-shadow: 0 8px 18px rgba(255,108,53,0.3);
        border: none;
        cursor: pointer;
        border: 1px solid rgba(255,255,255,0.2);
    }

    .btn-reserve:hover {
        transform: scale(1.02);
        box-shadow: 0 12px 24px rgba(255,108,53,0.4);
        animation: pulse 1.5s infinite;
    }

    @keyframes pulse {
        0% { box-shadow: 0 8px 18px rgba(255,108,53,0.3); }
        50% { box-shadow: 0 8px 18px rgba(255,108,53,0.6); }
        100% { box-shadow: 0 8px 18px rgba(255,108,53,0.3); }
    }

    .btn-back {
        display: inline-block;
        margin-top: 2rem;
        color: var(--sunset-start);
        text-decoration: none;
        font-weight: 500;
        padding: 0.5rem 0;
        transition: transform 0.2s;
    }

    .btn-back:hover {
        transform: translateX(-6px);
        text-decoration: underline;
    }

    /* Responsive Desktop */
    @media (min-width: 768px) {
        .event-header {
            height: 350px;
            border-radius: 0 0 50px 50px;
            margin: -2rem -2rem 2rem -2rem;
        }
        .event-header h1 {
            font-size: 3rem;
        }
        .header-overlay {
            padding: 3rem 3rem;
        }
        .event-detail-container {
            flex-direction: row;
            align-items: flex-start;
        }
        .event-description {
            flex: 1.2;
        }
        .tickets-section {
            flex: 1;
        }
    }

    @media (min-width: 1024px) {
        .event-header {
            height: 420px;
        }
    }

    /* Parallaxe simulée au scroll (effet léger) */
    @media (min-width: 768px) {
        .event-header {
            background-attachment: fixed;
        }
    }
</style>

{# BANNIÈRE IMMERSIVE #}
<div class="event-header" style="background-image: url('{% if evenement.image_background %}{{ evenement.image_background.url }}{% else %}https://via.placeholder.com/1200x400/FF8C42/ffffff?text={{ evenement.nom|urlencode }}{% endif %}');">
    <div class="header-overlay">
        <h1>{{ evenement.nom }}</h1>
        <div class="event-meta">
            <span>📅 {{ evenement.date|date:"d E Y à H:i" }}</span>
            <span>📍 {{ evenement.lieu|default:"Lieu à confirmer" }}</span>
        </div>
        {% if evenement.est_actif %}
            <span class="badge-dispo">🎉 Disponible</span>
        {% endif %}
    </div>
</div>

{# CORPS DE PAGE #}
<div class="event-detail-container">
    {# Colonne de gauche : description #}
    <div class="event-description">
        <h2>À propos de l'événement</h2>
        <p>{{ evenement.description|linebreaksbr }}</p>
    </div>

    {# Colonne de droite : cartes de tickets #}
    <div class="tickets-section">
        <h2>🎟️ Choisissez votre billet</h2>
        <div class="ticket-cards">
            {% for ticket in evenement.types_tickets.all %}
                <div class="ticket-card {% if 'VIP' in ticket.nom|upper %}vip{% endif %}">
                    <div class="ticket-name">{{ ticket.nom }}</div>
                    <div class="ticket-price">
                        {{ ticket.prix|floatformat:0 }} <small>FCFA</small>
                    </div>
                    <ul class="ticket-advantages">
                        {% if ticket.avantages %}
                            {# On transforme les avantages en liste à puces #}
                            {% for avantage in ticket.avantages.splitlines %}
                                {% if avantage.strip %}
                                    <li>{{ avantage.strip }}</li>
                                {% endif %}
                            {% endfor %}
                        {% else %}
                            <li>Accès à l'événement</li>
                            <li>Expérience festive garantie</li>
                        {% endif %}
                    </ul>
                    <a href="{% url 'vitrine:whatsapp_instruction' evenement.pk ticket.pk %}" class="btn-reserve">
                        Réserver mon ticket ✨
                    </a>
                </div>
            {% empty %}
                <p style="color: gray; text-align: center;">Aucun type de ticket disponible pour cet événement.</p>
            {% endfor %}
        </div>
    </div>
</div>

{# Lien de retour #}
<a href="{% url 'vitrine:home' %}" class="btn-back">← Retour à l'accueil</a>

{# Script pour micro-interactions #}
<script>
    (function() {
        // Ajout d'une classe "vip" automatique si le nom contient VIP
        const cards = document.querySelectorAll('.ticket-card');
        cards.forEach(card => {
            const nameEl = card.querySelector('.ticket-name');
            if (nameEl && nameEl.textContent.toUpperCase().includes('VIP')) {
                card.classList.add('vip');
            }
        });

        // Effet de parallaxe simplifié (désactive sur mobile pour performance)
        if (window.innerWidth >= 768) {
            const header = document.querySelector('.event-header');
            window.addEventListener('scroll', () => {
                const scrolled = window.pageYOffset;
                if (header) {
                    header.style.backgroundPositionY = (scrolled * 0.4) + 'px';
                }
            });
        }

        // Animation d'apparition des cartes
        const ticketItems = document.querySelectorAll('.ticket-card');
        ticketItems.forEach((item, index) => {
            item.style.opacity = '0';
            item.style.transform = 'translateY(20px)';
            setTimeout(() => {
                item.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
                item.style.opacity = '1';
                item.style.transform = 'translateY(0)';
            }, index * 120);
        });
    })();
</script>
{% endblock %}