{#
   Conversation e-mail — deliberately plain (Claude Design); the HTML document
   shell lives in @email/_plain. White background, 1px rules only, coloured
   @mentions, so it renders the same in every mail client.

   The "oberhalb dieser Linie" phrase is the reply marker
   BrevoInboundRequestParser strips at — keep it in sync there.

   `content` is the admin-editable text from the notification editor
   (/admin/benachrichtigungen); it renders as an optional lead above the message
   and is empty by default, so the email stays message-first.
#}
{% extends '@email/_plain.html.twig' %}

{% block subject %}{{ subjectLabel|default }}{% endblock %}

{% block template %}
    {% set font = "'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif" %}
    {% set today = 'now'|date('Y-m-d') %}
    {% set yesterday = 'now'|date_modify('-1 day')|date('Y-m-d') %}
    {% set day = comment.createdAt|date('Y-m-d') %}
    {% set when = (day == today ? 'heute' : (day == yesterday ? 'gestern' : comment.createdAt|date('d.m.Y'))) ~ ', ' ~ comment.createdAt|date('H:i') ~ ' Uhr' %}

    <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#ffffff;border-collapse:collapse;">
        <tr>
            <td align="center" style="padding:0;">
                <table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="width:600px;max-width:600px;background:#ffffff;border-collapse:collapse;">
                    <tr>
                        <td style="padding:28px 30px;font-family:{{ font }};">

                            {% if canReplyByEmail|default(false) %}
                                <div style="font-size:12px;color:#a8a49d;padding-bottom:14px;border-bottom:1px solid #ececea;font-family:{{ font }};">
                                    &uarr;&nbsp; Antworten Sie <strong style="color:#76726b;font-weight:600;">oberhalb dieser Linie</strong>.
                                </div>
                            {% endif %}

                            {# optional admin-editable lead (notification editor) #}
                            {% if content|default('')|trim %}
                                <div style="font-size:15px;line-height:1.6;color:#3a3833;padding-top:{{ canReplyByEmail|default(false) ? '20px' : '2px' }};font-family:{{ font }};">{{ content|machine_translate|markdown_to_html }}</div>
                            {% endif %}

                            {# who wrote, and in which conversation #}
                            <div style="font-size:15px;color:#1c1a16;padding-top:{{ (content|default('')|trim) ? '16px' : (canReplyByEmail|default(false) ? '20px' : '2px') }};line-height:1.5;font-family:{{ font }};">
                                <strong style="font-weight:700;">{{ authorName|default('Das Ferienpass-Team') }}</strong>
                                <span style="color:#85878e;font-size:14px;">{{ verb|default('schrieb') }}</span>
                                {% if recipientName|default %}<strong style="font-weight:600;">{{ recipientName }}</strong>{% endif %}
                            </div>
                            <div style="font-size:13px;color:#a8a49d;margin-top:2px;font-family:{{ font }};">
                                {% if action_url|default %}<a href="{{ action_url }}" style="color:#a8a49d;text-decoration:none;">{{ subjectLabel|default }}</a>{% else %}{{ subjectLabel|default }}{% endif %}
                                &middot; {{ when }}
                            </div>

                            {# the message — mentions already coloured, safe HTML #}
                            <div style="font-size:15px;line-height:1.7;color:#3a3833;margin-top:18px;font-family:{{ font }};">{{ bodyHtml|default(comment.body|nl2br)|raw }}</div>

                            {# Anmelde-Details: the summary the author asked to send along,
                               plus the one link the recipient can act on. A parent holds
                               no admin account, so this is their whole route into the
                               application — reviewing it, signing consents, uploading a
                               missing photo. #}
                            {% if attendance|default(null) and attendanceUrl|default %}
                                {% set p = attendance.participant %}
                                <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:22px;border-collapse:collapse;border:1px solid #ececea;">
                                    <tr>
                                        <td style="padding:16px 18px;font-family:{{ font }};">
                                            <div style="font-size:12px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:#a8a49d;">Anmeldung</div>
                                            <div style="font-size:15px;font-weight:600;color:#1c1a16;margin-top:6px;line-height:1.45;">{{ attendance.offer.name }}</div>
                                            <div style="font-size:13px;color:#76726b;margin-top:4px;line-height:1.6;">
                                                {% if p %}{{ p.name }}{% endif %}
                                                {%- if attendance.offer.dates is not empty and attendance.offer.dates|first.begin %}
                                                    &middot; {{ attendance.offer.dates|first.begin|format_datetime(pattern="E, dd.MM.yyyy HH:mm") }}
                                                {%- endif %}
                                            </div>
                                            <div style="margin-top:14px;">
                                                <a href="{{ attendanceUrl }}" target="_blank" style="font-size:15px;font-weight:600;color:#c44a22;text-decoration:none;font-family:{{ font }};">Anmeldung verwalten &rarr;</a>
                                            </div>
                                            <div style="font-size:12px;color:#b4b1aa;margin-top:6px;line-height:1.55;">
                                                Dort können Sie Ihre Angaben prüfen, fehlende Einwilligungen erteilen und Dateien hochladen.
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            {% endif %}

                            {# one clear action (admin/host only) + reply hint #}
                            {% if action_url|default %}
                                <div style="margin-top:22px;">
                                    <a href="{{ action_url }}" target="_blank" style="font-size:15px;font-weight:600;color:#c44a22;text-decoration:none;font-family:{{ font }};">Unterhaltung öffnen &rarr;</a>
                                </div>
                            {% endif %}
                            {% if canReplyByEmail|default(false) %}
                                <div style="font-size:13px;color:#a8a49d;margin-top:{{ action_url|default ? '8px' : '18px' }};line-height:1.55;font-family:{{ font }};">
                                    Antworten Sie direkt auf diese E-Mail &mdash; Ihre Nachricht erscheint sofort in der Unterhaltung.
                                </div>
                            {% endif %}

                            {# footer #}
                            <div style="font-size:12px;color:#b4b1aa;margin-top:26px;padding-top:16px;border-top:1px solid #ececea;line-height:1.6;font-family:{{ font }};">
                                {{ reasonText|default('Sie erhalten diese E-Mail, weil Sie an dieser Unterhaltung beteiligt sind.') }}{% if settingsUrl|default %} &middot; <a href="{{ settingsUrl }}" style="color:#a8a49d;">Benachrichtigungen verwalten</a>{% endif %}
                            </div>

                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
{% endblock %}
