{% extends "@FerienpassAdmin/layout/base.html.twig" %}
{% trans_default_domain 'admin' %}

{# The participant-list gate: the Veranstalter must sign the season's
   confidentiality declaration before the list is revealed. Rendered by the
   controllers that guard host access (offer participants / assign / mailing).
   `edition` carries the declaration; `returnUrl` sends the host back after
   signing. The sign form answers with the `signed_stream` Turbo Stream below.

   Styling mirrors the former /datenschutz-einwilligung page — prose text plus
   the standard <twig:Admin:Alert> / <twig:Admin:Button> components — so it reads
   as native (no bespoke cards, radii or shadows). #}
{% block main %}

    <div id="host-consent-gate" class="mx-auto max-w-3xl">

        <twig:Admin:Alert type="warning" icon="ph:lock-simple" class="mb-6">
            <b class="font-semibold">{{ 'hostConsent.gate.lockedTitle'|trans({}, 'admin') }}</b>
            <span class="mt-0.5 block">{{ 'hostConsent.gate.lockedText'|trans({}, 'admin') }}</span>
        </twig:Admin:Alert>

        <h1 class="text-xl font-semibold tracking-tight text-gray-900 dark:text-gray-100">
            {{ edition.hostConsentForm.title|default('')|trim ?: 'hostConsent.gate.untitled'|trans }}
        </h1>

        <div class="prose dark:prose-invert mt-4 max-w-none">
            {{ edition.hostConsentForm.text|default('')|markdown_to_html }}
        </div>

        <form method="post" action="{{ path('admin_host_consent_sign', { alias: edition.alias }) }}" class="mt-8">
            <input type="hidden" name="_token" value="{{ csrf_token('host_consent') }}">
            <input type="hidden" name="return" value="{{ returnUrl|default('') }}">

            <label class="flex cursor-pointer items-start gap-3">
                <input type="checkbox" name="accept" value="1" required class="mt-0.5 flex-none">
                <span class="text-sm text-gray-800 dark:text-gray-200">{{ 'hostConsent.gate.checkbox'|trans }}</span>
            </label>

            <div class="mt-6">
                <twig:Admin:Button variant="primary" type="submit">{{ 'hostConsent.gate.submit'|trans({}, 'admin') }}</twig:Admin:Button>
            </div>

            <p class="mt-3 text-xs text-gray-500 dark:text-gray-400">{{ 'hostConsent.gate.foot'|trans }}</p>
        </form>
    </div>

{% endblock %}

{# ── Turbo Stream: signature recorded → swap the gate for a standard confirm alert.
   Note: `trans_default_domain` does NOT reach `|trans` inside <twig:Component>
   slots, so the 'admin' domain is passed explicitly there; the Alert `message`
   prop is translated by the component itself (its own default domain). #}
{% block signed_stream %}
    <twig:Turbo:Stream:Replace target="#host-consent-gate">
        <div id="host-consent-gate" class="mx-auto max-w-3xl">
            <twig:Admin:Alert type="confirm" message="hostConsent.gate.signedText" />
            <div class="mt-4">
                <twig:Admin:Button variant="primary" href="{{ returnUrl }}" data-turbo-action="advance">{{ 'hostConsent.gate.open'|trans({}, 'admin') }}</twig:Admin:Button>
            </div>
        </div>
    </twig:Turbo:Stream:Replace>
    <twig:Turbo:Stream:Prepend target="#notifications">
        <twig:Admin:Notification type="success" title="{{ 'hostConsent.gate.signedTitle'|trans({}, 'admin') }}" message="{{ 'hostConsent.gate.signedText'|trans({}, 'admin') }}" />
    </twig:Turbo:Stream:Prepend>
{% endblock %}

{% block not_accepted_stream %}
    <twig:Turbo:Stream:Prepend target="#notifications">
        <twig:Admin:Notification type="error" title="{{ 'hostConsent.gate.notAcceptedTitle'|trans({}, 'admin') }}" message="{{ 'hostConsent.gate.notAcceptedText'|trans({}, 'admin') }}" />
    </twig:Turbo:Stream:Prepend>
{% endblock %}
