{% extends "base.html" %}

{% block title %}Accueil | BilletFest - Vos meilleurs événements{% endblock %}

{% block content %}
<style>
    /* ============================================
       STYLES SPÉCIFIQUES À LA PAGE D'ACCUEIL
       Thème Festif & Chaleureux - Mobile-First
       ============================================ */
    .hero {
        background: linear-gradient(145deg, #FF8C42 0%, #FF6B35 100%);
        color: white;
        padding: 3rem 1.5rem;
        border-radius: 0 0 40px 40px;
        margin: -1.5rem -1rem 2rem -1rem;
        text-align: center;
        box-shadow: 0 10px 20px rgba(255, 108, 53, 0.2);
    }

    .hero h1 {
        font-family: 'Poppins', sans-serif;
        font-size: 2.2rem;
        font-weight: 700;
        line-height: 1.2;
        margin-bottom: 1rem;
        text-shadow: 2px 2px 8px rgba(0,0,0,0.15);
    }

    .hero p {
        font-size: 1.1rem;
        opacity: 0.95;
        margin-bottom: 2rem;
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .btn-cta {
        background: white;
        color: var(--sunset-start);
        padding: 1rem 2rem;
        border-radius: 60px;
        font-weight: 700;
        font-size: 1.1rem;
        text-decoration: none;
        display: inline-block;
        transition: all 0.3s ease;
        box-shadow: 0 8px 18px rgba(0,0,0,0.1);
        border: none;
        cursor: pointer;
        border: 2px solid transparent;
    }

    .btn-cta:hover {
        transform: translateY(-4px);
        box-shadow: 0 14px 24px rgba(0,0,0,0.15);
        background: #fff5e6;
    }

    .section-title {
        font-family: 'Poppins', sans-serif;
        font-size: 1.8rem;
        font-weight: 700;
        color: var(--warm-anthracite);
        margin: 2rem 0 1.5rem;
        position: relative;
        display: inline-block;
    }

    .section-title:after {
        content: '';
        position: absolute;
        bottom: -10px;
        left: 0;
        width: 60%;
        height: 4px;
        background: var(--amber);
        border-radius: 4px;
    }

    /* Grille d'événements */
    .events-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 2rem;
        margin-bottom: 3rem;
    }

    .event-card {
        background: white;
        border-radius: 24px;
        overflow: hidden;
        box-shadow: 0 10px 20px rgba(255, 140, 66, 0.08);
        transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1);
        border: 1px solid rgba(255, 140, 66, 0.15);
    }

    .event-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 24px 36px rgba(255, 140, 66, 0.15);
    }

    .card-image {
        position: relative;
        height: 200px;
        background-size: cover;
        background-position: center;
    }

    .image-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(0deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.2) 50%);
    }

    .event-badge {
        position: absolute;
        top: 16px;
        right: 16px;
        background: var(--amber);
        color: var(--warm-anthracite);
        font-weight: 700;
        padding: 0.4rem 1rem;
        border-radius: 40px;
        font-size: 0.9rem;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        z-index: 2;
    }

    .event-content {
        padding: 1.5rem;
    }

    .event-content h3 {
        font-family: 'Poppins', sans-serif;
        font-size: 1.5rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
        color: var(--warm-anthracite);
    }

    .event-date {
        color: var(--sunset-start);
        font-weight: 600;
        margin-bottom: 0.8rem;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .event-description {
        color: #5a5a5a;
        margin-bottom: 1.5rem;
        line-height: 1.5;
        font-size: 0.95rem;
    }

    .btn-tickets {
        background: var(--sunset-start);
        color: white;
        padding: 0.7rem 1.5rem;
        border-radius: 40px;
        text-decoration: none;
        font-weight: 600;
        display: inline-block;
        transition: all 0.2s;
        border: none;
        cursor: pointer;
        font-size: 0.95rem;
    }

    .btn-tickets:hover {
        background: #ff7a3d;
        transform: scale(1.02);
        box-shadow: 0 6px 12px rgba(255, 108, 53, 0.3);
    }

    /* État vide */
    .empty-state {
        background: white;
        border-radius: 30px;
        padding: 3rem 2rem;
        text-align: center;
        box-shadow: 0 10px 20px rgba(0,0,0,0.02);
        border: 2px dashed var(--amber);
        margin: 2rem 0;
    }

    .empty-state .emoji {
        font-size: 3.5rem;
        margin-bottom: 1rem;
    }

    .empty-state h3 {
        font-family: 'Poppins', sans-serif;
        color: var(--warm-anthracite);
        margin-bottom: 0.5rem;
    }

    /* Section Comment ça marche */
    .how-it-works {
        background: rgba(255, 140, 66, 0.05);
        border-radius: 40px;
        padding: 2.5rem 1.5rem;
        margin: 3rem 0;
    }

    .steps-container {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        margin-top: 1.5rem;
    }

    .step-item {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .step-number {
        background: var(--amber);
        color: var(--warm-anthracite);
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 800;
        font-size: 1.4rem;
        flex-shrink: 0;
    }

    .step-text {
        font-weight: 500;
        color: var(--warm-anthracite);
    }

    .step-text strong {
        display: block;
        font-size: 1.1rem;
        margin-bottom: 0.2rem;
    }

    /* Responsive */
    @media (min-width: 640px) {
        .events-grid {
            grid-template-columns: repeat(2, 1fr);
        }
        .hero {
            padding: 4rem 2rem;
            border-radius: 0 0 60px 60px;
        }
        .hero h1 {
            font-size: 2.8rem;
        }
        .steps-container {
            flex-direction: row;
            justify-content: space-around;
        }
        .step-item {
            flex-direction: column;
            text-align: center;
        }
    }

    @media (min-width: 1024px) {
        .events-grid {
            grid-template-columns: repeat(3, 1fr);
        }
        .hero {
            padding: 5rem 2rem;
        }
    }

    /* Utilitaires */
    .text-center {
        text-align: center;
    }
    .mt-4 {
        margin-top: 2rem;
    }
</style>

{# SECTION HERO #}
<section class="hero">
    <h1>Vivez des moments inoubliables.</h1>
    <p>Réservez vos places pour les meilleurs événements et pool parties en quelques clics.</p>
    <button class="btn-cta" id="scrollToEvents">🎟️ Découvrir les événements</button>
</section>

{# SECTION ÉVÉNEMENTS À VENIR #}
<div id="events-list">
    <h2 class="section-title">Événements à venir</h2>
</div>

{% if evenements %}
    <div class="events-grid">
        {% for event in evenements %}
            <div class="event-card">
                <div class="card-image" style="background-image: url('{% if event.image_background %}{{ event.image_background.url }}{% else %}https://via.placeholder.com/400x250/FF8C42/ffffff?text=Événement{% endif %}');">
                    <div class="image-overlay"></div>
                    <span class="event-badge">{{ event.date|date:"d E Y" }}</span>
                </div>
                <div class="event-content">
                    <h3>{{ event.nom }}</h3>
                    <div class="event-date">
                        <span>📅</span> {{ event.date|date:"l d F Y" }}
                    </div>
                    <p class="event-description">{{ event.description|truncatewords:20 }}</p>
                    <a href="{% url 'vitrine:event_detail' event.pk %}" class="btn-tickets">Voir les tickets →</a>
                </div>
            </div>
        {% endfor %}
    </div>
{% else %}
    <div class="empty-state">
        <div class="emoji">🎭</div>
        <h3>Aucun événement prévu pour le moment</h3>
        <p>Revenez très bientôt !</p>
    </div>
{% endif %}

{# SECTION COMMENT ÇA MARCHE #}
<section class="how-it-works">
    <h2 class="section-title" style="margin-top: 0;">Comment ça marche ?</h2>
    <div class="steps-container">
        <div class="step-item">
            <div class="step-number">1</div>
            <div class="step-text">
                <strong>Choisissez</strong>
                <span>Parcourez les événements et sélectionnez vos tickets.</span>
            </div>
        </div>
        <div class="step-item">
            <div class="step-number">2</div>
            <div class="step-text">
                <strong>Payez sur WhatsApp</strong>
                <span>Finalisez votre achat facilement via WhatsApp.</span>
            </div>
        </div>
        <div class="step-item">
            <div class="step-number">3</div>
            <div class="step-text">
                <strong>Scannez à l'entrée</strong>
                <span>Présentez votre QR code à l'entrée, et profitez !</span>
            </div>
        </div>
    </div>
</section>

{# Script pour le défilement doux vers la liste #}
<script>
    (function() {
        const scrollBtn = document.getElementById('scrollToEvents');
        const eventsSection = document.getElementById('events-list');
        
        if (scrollBtn && eventsSection) {
            scrollBtn.addEventListener('click', function(e) {
                e.preventDefault();
                eventsSection.scrollIntoView({ 
                    behavior: 'smooth', 
                    block: 'start' 
                });
            });
        }

        // Petit effet visuel sur les cartes au chargement
        const cards = document.querySelectorAll('.event-card');
        cards.forEach((card, index) => {
            card.style.opacity = '0';
            card.style.transform = 'translateY(20px)';
            setTimeout(() => {
                card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
                card.style.opacity = '1';
                card.style.transform = 'translateY(0)';
            }, index * 100);
        });
    })();
</script>
{% endblock %}