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

{% set mail_locale = locale|default('fr') %}

{% block mail_subject %}{{ 'withdrawal.mail.customer.subject'|trans({'%reference%': withdrawal_request.contractReference}, 'messages', mail_locale) }}{% endblock %}
{% block mail_eyebrow %}{{ 'withdrawal.eyebrow'|trans({}, 'messages', mail_locale) }}{% endblock %}
{% block mail_heading %}{{ 'withdrawal.mail.customer.heading'|trans({}, 'messages', mail_locale) }}{% endblock %}

{% block mail_body %}
    <p style="margin:0 0 24px;">{{ 'withdrawal.mail.customer.intro'|trans({}, 'messages', mail_locale) }}</p>

    <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="width:100%; margin:0 0 24px; border:1px solid #eadfce; background:#fcf7f0;">
        <tr>
            <td class="email-block" style="padding:18px 22px;">
                <div style="margin:0 0 6px; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.reference'|trans({}, 'messages', mail_locale) }}</div>
                <div style="font-family:Georgia, 'Times New Roman', serif; font-size:28px; line-height:1.2; color:#3f2f24;">{{ withdrawal_request.contractReference }}</div>
            </td>
        </tr>
    </table>

    <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="width:100%; margin:0 0 24px; border-top:1px solid #eadfce; border-bottom:1px solid #eadfce;">
        <tr>
            <td class="email-line-label" style="width:190px; padding:16px 0; vertical-align:top; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.name'|trans({}, 'messages', mail_locale) }}</td>
            <td class="email-line-value" style="padding:16px 0; color:#3f2f24;">{{ withdrawal_request.firstname }} {{ withdrawal_request.lastname }}</td>
        </tr>
        <tr>
            <td class="email-line-label" style="width:190px; padding:16px 0; vertical-align:top; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.email'|trans({}, 'messages', mail_locale) }}</td>
            <td class="email-line-value" style="padding:16px 0; color:#3f2f24;">
                <a href="mailto:{{ withdrawal_request.receiptEmail }}" style="color:#8a5a34; text-decoration:none; word-break:break-word;">{{ withdrawal_request.receiptEmail }}</a>
            </td>
        </tr>
        <tr>
            <td class="email-line-label" style="width:190px; padding:16px 0; vertical-align:top; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.order_received'|trans({}, 'messages', mail_locale) }}</td>
            <td class="email-line-value" style="padding:16px 0; color:#3f2f24;">{{ (withdrawal_request.orderReceived is same as(true) ? 'withdrawal.form.yes' : (withdrawal_request.orderReceived is same as(false) ? 'withdrawal.form.no' : 'withdrawal.form.not_provided'))|trans({}, 'messages', mail_locale) }}</td>
        </tr>
        {% if withdrawal_request.orderReceived and withdrawal_request.receivedAt %}
            <tr>
                <td class="email-line-label" style="width:190px; padding:16px 0; vertical-align:top; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.received_at'|trans({}, 'messages', mail_locale) }}</td>
                <td class="email-line-value" style="padding:16px 0; color:#3f2f24;">{{ withdrawal_request.receivedAt|date('d/m/Y') }}</td>
            </tr>
        {% endif %}
        {% if withdrawal_request.reasonCode %}
            <tr>
                <td class="email-line-label" style="width:190px; padding:16px 0; vertical-align:top; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.reason'|trans({}, 'messages', mail_locale) }}</td>
                <td class="email-line-value" style="padding:16px 0; color:#3f2f24;">{{ ('withdrawal.reason.' ~ withdrawal_request.reasonCode)|trans({}, 'messages', mail_locale) }}</td>
            </tr>
        {% endif %}
        {% if withdrawal_request.comment %}
            <tr>
                <td class="email-line-label" style="width:190px; padding:16px 0; vertical-align:top; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.comment'|trans({}, 'messages', mail_locale) }}</td>
                <td class="email-line-value" style="padding:16px 0; color:#3f2f24; overflow-wrap:anywhere;">{{ withdrawal_request.comment|e|nl2br }}</td>
            </tr>
        {% endif %}
        <tr>
            <td class="email-line-label" style="width:190px; padding:16px 0; vertical-align:top; font-size:11px; letter-spacing:0.18em; text-transform:uppercase; color:#8a6a2f;">{{ 'withdrawal.summary.submitted_at'|trans({}, 'messages', mail_locale) }}</td>
            <td class="email-line-value" style="padding:16px 0; color:#3f2f24;">{{ withdrawal_request.submittedAt|date('d/m/Y H:i:s T') }}</td>
        </tr>
    </table>

    <div class="email-block" style="padding:20px 22px; border:1px solid #eadfce; background:#fffaf5; color:#6e5848;">
        {{ 'withdrawal.mail.customer.next_steps'|trans({}, 'messages', mail_locale) }}
    </div>
{% endblock %}
