{% extends "base.html" %}

{% block title %}Tableau de Bord | BilletFest{% endblock %}

{% block content %}
<style>
    /* ============================================
       STYLES SPÉCIFIQUES DASHBOARD HOME
       Thème Festif & Chaleureux - Mobile-First
       ============================================ */
    .dashboard-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 1rem 0.5rem;
    }

    /* Widgets Statistiques */
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-bottom: 2.5rem;
    }

    .stat-card {
        background: white;
        border-radius: 24px;
        padding: 1.8rem 1.5rem;
        box-shadow: 0 10px 20px rgba(255, 140, 66, 0.06);
        border: 1px solid rgba(255, 140, 66, 0.1);
        display: flex;
        align-items: center;
        gap: 1.2rem;
        transition: transform 0.2s ease;
    }

    .stat-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 16px 28px rgba(255, 140, 66, 0.12);
    }

    .stat-icon {
        background: rgba(255, 140, 66, 0.15);
        width: 60px;
        height: 60px;
        border-radius: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 2rem;
        color: var(--sunset-start);
    }

    .stat-content {
        flex: 1;
    }

    .stat-label {
        font-size: 0.95rem;
        color: #6b6b6b;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0.3rem;
    }

    .stat-value {
        font-family: 'Poppins', sans-serif;
        font-size: 2.4rem;
        font-weight: 800;
        color: var(--warm-anthracite);
        line-height: 1.2;
    }

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

    .stat-card.highlight .stat-value {
        color: var(--amber);
    }

    /* Liste des événements */
    .section-header {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        margin-bottom: 1.2rem;
        flex-wrap: wrap;
    }

    .section-header h2 {
        font-family: 'Poppins', sans-serif;
        color: var(--warm-anthracite);
        font-size: 1.6rem;
        font-weight: 700;
        margin: 0;
    }

    .badge-count {
        background: var(--amber);
        color: var(--warm-anthracite);
        padding: 0.2rem 1rem;
        border-radius: 30px;
        font-weight: 600;
        font-size: 0.9rem;
    }

    .events-list {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .event-item {
        background: white;
        border-radius: 20px;
        padding: 1.2rem 1.2rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.02);
        border: 1px solid rgba(255, 140, 66, 0.1);
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 1rem;
        transition: all 0.2s ease;
    }

    .event-item:hover {
        border-color: var(--sunset-start);
        box-shadow: 0 8px 18px rgba(255, 140, 66, 0.08);
        background: #fefcf9;
    }

    .event-info {
        display: flex;
        align-items: center;
        gap: 1rem;
        flex-wrap: wrap;
    }

    .event-name {
        font-weight: 700;
        font-size: 1.2rem;
        color: var(--warm-anthracite);
    }

    .event-date {
        color: #6b6b6b;
        font-size: 0.9rem;
        background: #f5f5f5;
        padding: 0.3rem 1rem;
        border-radius: 30px;
    }

    .btn-manage {
        background: transparent;
        border: 1.5px solid var(--sunset-start);
        color: var(--sunset-start);
        padding: 0.5rem 1.5rem;
        border-radius: 40px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.2s;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .btn-manage:hover {
        background: var(--sunset-start);
        color: white;
        transform: scale(1.02);
    }

    /* État vide */
    .empty-events {
        background: rgba(255, 140, 66, 0.03);
        border-radius: 30px;
        padding: 3rem 2rem;
        text-align: center;
        border: 2px dashed var(--amber);
        color: var(--warm-anthracite);
    }

    .empty-events .emoji {
        font-size: 3rem;
        margin-bottom: 0.5rem;
    }

    /* Responsive */
    @media (min-width: 640px) {
        .stats-grid {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    @media (max-width: 480px) {
        .event-item {
            flex-direction: column;
            align-items: flex-start;
        }
        .btn-manage {
            align-self: flex-end;
        }
        .stat-value {
            font-size: 2rem;
        }
    }
</style>

<div class="dashboard-container">
    {# Widgets Statistiques #}
    <div class="stats-grid">
        <div class="stat-card">
            <div class="stat-icon">🎫</div>
            <div class="stat-content">
                <div class="stat-label">Tickets Vendus</div>
                <div class="stat-value">{{ stats_globales.total_vendus }}</div>
            </div>
        </div>
        <div class="stat-card highlight">
            <div class="stat-icon">💰</div>
            <div class="stat-content">
                <div class="stat-label">Revenus Totaux</div>
                <div class="stat-value">{{ stats_globales.chiffre_affaires|floatformat:0 }} <small>FCFA</small></div>
            </div>
        </div>
    </div>

    {# Section Événements #}
    <div class="section-header">
        <h2>Mes Événements en cours</h2>
        {% if evenements %}
            <span class="badge-count">{{ evenements|length }} événement(s)</span>
        {% endif %}
    </div>

    <div class="events-list">
        {% for event in evenements %}
            <div class="event-item">
                <div class="event-info">
                    <span class="event-name">{{ event.nom }}</span>
                    <span class="event-date">
                        📅 {{ event.date|date:"d E Y" }}
                    </span>
                </div>
                <a href="{% url 'dashboard:evenement_detail' event.id %}" class="btn-manage">
                    Gérer cet événement →
                </a>
            </div>
        {% empty %}
            <div class="empty-events">
                <div class="emoji">📭</div>
                <h3>Aucun événement actif</h3>
                <p>Créez un événement depuis l'interface d'administration.</p>
            </div>
        {% endfor %}
    </div>
</div>

{# Aucun JS supplémentaire requis #}
{% endblock %}