{# Outcome panel — replaces the form right after an application was submitted.

   It must report what actually happened: a first-come application can end up
   confirmed, on the waiting list, or refused (when the season works without a
   waiting list). Only a confirmed attendance triggers a notification e-mail,
   so only that case may promise one. Lot mode words it as a lottery entry.

   Include WITHOUT `only` (needs offer, applicationSystem, appliedStatus). #}

{% set is_lot = applicationSystem is not null and applicationSystem.type == 'lot' %}
{% set status = is_lot ? 'lot' : (appliedStatus|default('confirmed')) %}

{% set variant = {
    'confirmed': { icon: 'lucide:check', ring: 'bg-[#e5efe9] text-[#2f6f57] dark:bg-[#2f6f57]/20 dark:text-[#5f9a7e]', key: '' },
    'lot':       { icon: 'lucide:ticket', ring: 'bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400', key: 'Lot' },
    'waitlisted': { icon: 'lucide:hourglass', ring: 'bg-amber-50 text-amber-600 dark:bg-amber-900/20 dark:text-amber-400', key: 'Waitlisted' },
    'unfulfilled': { icon: 'lucide:x', ring: 'bg-rose-50 text-rose-600 dark:bg-rose-900/20 dark:text-rose-400', key: 'Unfulfilled' },
}[status]|default({ icon: 'lucide:check', ring: 'bg-[#e5efe9] text-[#2f6f57] dark:bg-[#2f6f57]/20 dark:text-[#5f9a7e]', key: '' }) %}

<div class="px-2 py-6 text-center">
    <div class="mx-auto mb-4 grid size-16 place-items-center rounded-full {{ variant.ring }}">
        <twig:ux:icon name="{{ variant.icon }}" class="size-8" />
    </div>
    <h3 class="text-2xl font-semibold tracking-tight text-gray-900 dark:text-gray-50">
        {{ ('applicationForm.success.title' ~ variant.key)|trans({}, 'cms') }}
    </h3>
    <p class="mx-auto mt-2 max-w-md text-sm leading-6 text-gray-600 dark:text-gray-300">
        {{ ('applicationForm.success.text' ~ variant.key)|trans({offer: offer.name}, 'cms') }}
    </p>

    <div class="mt-6 flex flex-wrap items-center justify-center gap-2.5">
        <twig:Cms:Button variant="secondary"
                         href="{{ path('cms', { to: 'offer_list', edition: offer.edition }) }}">
            {{ 'applicationForm.success.browse'|trans({}, 'cms') }}
        </twig:Cms:Button>
        {% if status != 'unfulfilled' %}
            <twig:Cms:Button variant="primary"
                             href="{{ path('cms', { to: 'applications' }) }}">
                {{ 'applicationForm.success.toApplications'|trans({}, 'cms') }}
            </twig:Cms:Button>
        {% endif %}
    </div>

    {# back into the form, e.g. to register a sibling — `proceed` with an
       unknown id is a no-op re-render that clears the one-off confirm #}
    <button type="button"
            data-action="live#action"
            data-live-action-param="proceed"
            data-live-participant-param="0"
            class="mt-5 text-xs font-medium text-gray-500 underline-offset-2 hover:text-gray-700 hover:underline dark:text-gray-400 dark:hover:text-gray-200">
        {{ 'applicationForm.success.another'|trans({}, 'cms') }}
    </button>
</div>
