{% extends 'email/base.html.twig' %}

{% block title %}Rapport DNS - Association E-Cosplay{% endblock %}

{% block content %}

    {# ─── Bandeau statut ─── #}
    <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td align="center" style="background-color: {{ statusColor }}; color: #ffffff; padding-top: 10px; padding-bottom: 10px; padding-left: 16px; padding-right: 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;">
                {{ statusText }}
            </td>
        </tr>
    </table>

    <h1 style="font-size: 18px; font-weight: 700; margin-top: 16px; margin-right: 0; margin-bottom: 8px; margin-left: 0;">Rapport DNS</h1>
    <p style="font-size: 12px; color: #888888; margin-top: 0; margin-right: 0; margin-bottom: 16px; margin-left: 0;">
        {{ date|date('d/m/Y H:i:s') }}
    </p>

    {# ─── Statut par domaine ─── #}
    <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border: 1px solid #e5e5e5; margin-top: 0; margin-right: 0; margin-bottom: 16px; margin-left: 0;">
        <tr>
            <td style="background-color: #111827; color: #ffffff; padding-top: 8px; padding-bottom: 8px; padding-left: 12px; padding-right: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">Domaine</td>
            <td style="background-color: #111827; color: #ffffff; padding-top: 8px; padding-bottom: 8px; padding-left: 12px; padding-right: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; text-align: center; width: 80px;">Statut</td>
        </tr>
        {% for domainData in domainResults %}
            {% set hasError = false %}
            {% set hasWarning = false %}
            {% for check in domainData.checks %}
                {% if check.status == 'error' %}{% set hasError = true %}{% endif %}
                {% if check.status == 'warning' %}{% set hasWarning = true %}{% endif %}
            {% endfor %}
            <tr>
                <td style="padding-top: 10px; padding-bottom: 10px; padding-left: 12px; padding-right: 12px; font-size: 14px; font-weight: 700; border-bottom: 1px solid #eeeeee;">
                    {{ domainData.domain }}
                </td>
                <td style="padding-top: 10px; padding-bottom: 10px; padding-left: 12px; padding-right: 12px; font-size: 14px; font-weight: 700; text-align: center; border-bottom: 1px solid #eeeeee; color: {{ hasError ? '#dc2626' : (hasWarning ? '#f59e0b' : '#16a34a') }};">
                    {% if hasError %}
                        &#10007; KO
                    {% elseif hasWarning %}
                        &#9888; WARN
                    {% else %}
                        &#10003; OK
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
    </table>

    {# ─── Lien vers le detail ─── #}
    {% if reportUrl is defined and reportUrl %}
        <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top: 16px; margin-right: 0; margin-bottom: 16px; margin-left: 0;">
            <tr>
                <td align="center" style="padding-top: 8px; padding-bottom: 8px;">
                    <!--[if mso]>
                    <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" href="{{ reportUrl }}" style="height:44px;v-text-anchor:middle;width:320px;" arcsize="0%" fillcolor="#fabf04" stroke="f">
                    <center style="color:#111827;font-family:Arial,sans-serif;font-size:13px;font-weight:bold;text-transform:uppercase;letter-spacing:1px;">Voir le rapport complet</center>
                    </v:roundrect>
                    <![endif]-->
                    <!--[if !mso]><!-->
                    <a href="{{ reportUrl }}" style="display: inline-block; background-color: #fabf04; border: 1px solid #e5a800; padding-top: 12px; padding-bottom: 12px; padding-left: 32px; padding-right: 32px; color: #111827; font-weight: 700; text-transform: uppercase; font-size: 13px; text-decoration: none; letter-spacing: 1px;">Voir le rapport complet</a>
                    <!--<![endif]-->
                </td>
            </tr>
        </table>
    {% endif %}

    <p style="font-size: 11px; color: #888888; mso-line-height-rule: exactly; line-height: 16px; margin-top: 16px; margin-right: 0; margin-bottom: 0; margin-left: 0;">
        Rapport par <strong>E-Infra</strong> - Service de monitoring d'infra
    </p>

{% endblock %}
