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

{% block title %}Verification attestation {{ attestation.reference }} - Association E-Cosplay{% endblock %}
{% block description %}Verification de l'attestation RGPD {{ attestation.reference }}.{% endblock %}

{% block body %}
<div class="page-container">
    <h1 class="text-2xl font-bold heading-page mb-8">Verification d'attestation</h1>

    <div class="flex flex-col gap-8">

        {% if valid %}
            <div class="p-6 border-4 border-green-600 bg-green-50">
                <div class="flex items-center gap-3 mb-2">
                    <svg class="w-8 h-8 text-green-600 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7"/></svg>
                    <span class="text-xl font-bold uppercase text-green-800">Attestation valide</span>
                </div>
                <p class="text-sm text-green-700 font-bold">La signature HMAC-SHA256 de ce document a ete verifiee avec succes. Ce document est authentique.</p>
            </div>
        {% else %}
            <div class="p-6 border-4 border-red-600 bg-red-50">
                <div class="flex items-center gap-3 mb-2">
                    <svg class="w-8 h-8 text-red-600 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M6 18L18 6M6 6l12 12"/></svg>
                    <span class="text-xl font-bold uppercase text-red-800">Signature invalide</span>
                </div>
                <p class="text-sm text-red-700 font-bold">La signature de ce document n'a pas pu etre verifiee. Ce document a peut-etre ete modifie.</p>
            </div>
        {% endif %}

        <div class="glass">
            <div class="glass-dark text-white px-6 py-3">
                <span class="text-xs font-bold uppercase tracking-wider">Details de l'attestation</span>
            </div>
            <div class="p-6">
                <table class="w-full text-sm">
                    <tr class="border-b border-white/20">
                        <th scope="row" class="py-3 pr-4 font-bold uppercase text-xs text-gray-500 w-1/3 text-left">Reference</th>
                        <td class="py-3 font-bold">{{ attestation.reference }}</td>
                    </tr>
                    <tr class="border-b border-white/20">
                        <th scope="row" class="py-3 pr-4 font-bold uppercase text-xs text-gray-500 text-left">Type</th>
                        <td class="py-3 font-bold">
                            {% if attestation.type == 'access' %}
                                <span class="px-2 py-1 bg-indigo-100 text-indigo-800 text-xs font-bold uppercase">Droit d'acces</span>
                            {% elseif attestation.type == 'deletion' %}
                                <span class="px-2 py-1 bg-red-100 text-red-800 text-xs font-bold uppercase">Suppression</span>
                            {% else %}
                                <span class="px-2 py-1 bg-gray-100 text-gray-800 text-xs font-bold uppercase">Absence de donnees</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr class="border-b border-white/20">
                        <th scope="row" class="py-3 pr-4 font-bold uppercase text-xs text-gray-500 text-left">Date</th>
                        <td class="py-3 font-bold">{{ attestation.createdAt|date('d/m/Y a H:i:s') }}</td>
                    </tr>
                    <tr class="border-b border-white/20">
                        <th scope="row" class="py-3 pr-4 font-bold uppercase text-xs text-gray-500 text-left">Adresse IP</th>
                        <td class="py-3 font-bold font-mono">{{ attestation.ip }}</td>
                    </tr>
                    <tr>
                        <th scope="row" class="py-3 pr-4 font-bold uppercase text-xs text-gray-500 text-left">Email</th>
                        <td class="py-3 font-bold">{{ attestation.email }}</td>
                    </tr>
                </table>
            </div>
        </div>

        {% if attestation.pdfFileSigned or attestation.pdfFileCertificate %}
        <div class="flex flex-wrap gap-3">
            {% if attestation.pdfFileSigned %}
                <a href="{{ path('app_attestation_download', {reference: attestation.reference}) }}" class="px-4 py-2 btn-gold font-bold uppercase text-xs tracking-wider">
                    Telecharger l'attestation signee
                </a>
            {% endif %}
            {% if attestation.pdfFileCertificate %}
                <a href="{{ path('app_attestation_audit', {reference: attestation.reference}) }}" class="px-4 py-2 glass font-bold uppercase text-xs tracking-widest hover:bg-gray-900 hover:text-white transition-all">
                    Telecharger l'audit de signature
                </a>
            {% endif %}
        </div>
        {% endif %}

        <div class="border-2 border-gray-200 bg-gray-50 p-4">
            <p class="text-xs font-bold uppercase tracking-wider text-gray-400 mb-2">Signature HMAC-SHA256</p>
            <p class="text-xs font-mono text-gray-500 break-all">{{ attestation.hmac }}</p>
        </div>
    </div>
</div>
{% endblock %}
