{% extends 'admin/_layout.html.twig' %}

{% block title %}Evenements avis {{ advert.orderNumber.numOrder }} - Association E-Cosplay{% endblock %}

{% block admin_content %}
<div class="page-container">
    <div class="flex items-center justify-between mb-6">
        <div>
            <h1 class="text-2xl font-bold heading-page">Evenements Avis de Paiement</h1>
            <p class="text-xs text-gray-500 mt-1">Avis <span class="font-mono font-bold">{{ advert.orderNumber.numOrder }}</span></p>
        </div>
        <a href="{{ path('app_admin_clients_show', {id: advert.customer.id, tab: 'avis'}) }}" class="px-4 py-2 glass font-bold uppercase text-[10px] tracking-widest hover:bg-gray-900 hover:text-white transition-all">Retour</a>
    </div>

    {% if events|length > 0 %}
        <div class="glass overflow-x-auto overflow-hidden">
            <table class="w-full text-sm">
                <thead>
                    <tr class="glass-dark text-white">
                        <th class="px-4 py-3 text-left font-bold uppercase text-xs tracking-widest">Date</th>
                        <th class="px-4 py-3 text-left font-bold uppercase text-xs tracking-widest">Evenement</th>
                        <th class="px-4 py-3 text-left font-bold uppercase text-xs tracking-widest">Details</th>
                        <th class="px-4 py-3 text-center font-bold uppercase text-xs tracking-widest">IP</th>
                    </tr>
                </thead>
                <tbody>
                    {% for e in events %}
                        <tr class="border-b border-white/20 hover:bg-white/50 align-top">
                            <td class="px-4 py-3 text-xs text-gray-500 whitespace-nowrap">{{ e.createdAt|date('d/m/Y H:i:s') }}</td>
                            <td class="px-4 py-3">
                                {% if e.type == 'view' %}
                                    <span class="px-2 py-0.5 bg-blue-500/20 text-blue-700 font-bold uppercase text-[10px]">Consulte</span>
                                {% elseif e.type == 'pay' %}
                                    <span class="px-2 py-0.5 bg-green-500/20 text-green-700 font-bold uppercase text-[10px]">Paye</span>
                                {% elseif e.type == 'mail_open' %}
                                    <span class="px-2 py-0.5 bg-purple-500/20 text-purple-700 font-bold uppercase text-[10px]">Email ouvert</span>
                                {% elseif e.type == 'mail_send' %}
                                    <span class="px-2 py-0.5 bg-yellow-500/20 text-yellow-700 font-bold uppercase text-[10px]">Email envoye</span>
                                {% elseif e.type == 'reminder' %}
                                    <span class="px-2 py-0.5 bg-orange-500/20 text-orange-700 font-bold uppercase text-[10px]">Relance</span>
                                {% else %}
                                    <span class="px-2 py-0.5 bg-gray-100 text-gray-600 font-bold uppercase text-[10px]">{{ e.type }}</span>
                                {% endif %}
                            </td>
                            <td class="px-4 py-3 text-xs text-gray-600">{{ e.details ?? '—' }}</td>
                            <td class="px-4 py-3 text-center text-xs font-mono text-gray-400">{{ e.ip ?? '—' }}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <p class="mt-3 text-xs text-gray-400">{{ events|length }} evenement(s)</p>
    {% else %}
        <div class="glass p-8 text-center text-gray-400 font-bold">Aucun evenement pour cet avis.</div>
    {% endif %}
</div>
{% endblock %}
