{% extends "@FerienpassAdmin/layout/slideOverBase.html.twig" %}

{% block main %}
    <div class="bg-gray-50 dark:bg-gray-800/50 px-4 py-6 sm:px-6 mb-6">
        <div class="flex items-center justify-between">
            <h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">{{ state.getTitle() }}</h2>
            {% if state.consentToken %}
                <button type="button"
                        class="inline-flex items-center gap-x-1.5 rounded-md bg-white dark:bg-gray-700 px-2.5 py-1.5 text-sm font-semibold text-gray-900 dark:text-gray-100 shadow-sm ring-1 ring-inset ring-gray-300 dark:ring-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"
                        title="{{ "consents.copyConsentLink"|trans({}, "admin") }}"
                        onclick="navigator.clipboard.writeText('{{ url("cms_consent_link", { token: state.consentToken }) }}')">
                    <twig:ux:icon name="ph:link" class="-ml-0.5 h-4 w-4" />
                    {{ "consents.copyConsentLink"|trans({}, "admin") }}
                </button>
            {% endif %}
        </div>
        <div class="mt-4">
            <div class="flex items-center gap-x-2">
                <twig:Admin:ConsentStatusIcon :state="state" class="h-5 w-5" />
                <span class="text-sm font-medium {{ state.isSigned() or (not state.isAcknowledged() and state.isOptOut()) ? 'text-green-700 dark:text-green-400' : (state.isRejected() or (not state.isAcknowledged() and state.isOptIn()) ? 'text-red-700 dark:text-red-400' : 'text-orange-700 dark:text-orange-400') }}">
                    {% if state.isSigned() %}
                        Zustimmung aktiv gegeben
                    {% elseif state.isRejected() %}
                        Zustimmung aktiv abgelehnt
                    {% elseif state.isCompulsory() and not state.isAcknowledged() %}
                        Ausstehend ({{ state.isForceDecision() ? 'Pflichtentscheidung' : 'Pflichteinwilligung' }})
                    {% elseif state.isOptOut() and not state.isAcknowledged() %}
                        Zustimmung (Opt-Out und unbestätigt)
                    {% elseif state.isOptIn() and not state.isAcknowledged() %}
                        Abgelehnt (Opt-In und unbestätigt)
                    {% else %}
                        Ausstehend
                    {% endif %}
                </span>
            </div>

            {% if not state.isAcknowledged() and state.isCompulsory() %}
                <div class="mt-2 rounded-md bg-red-50 dark:bg-red-900/20 p-2 text-sm text-red-700 dark:text-red-400">
                    {% if state.isForceDecision() %}
                        Diese Entscheidung ist verpflichtend.
                    {% else %}
                        diese einwilligung ist verpflichtend.
                    {% endif %}
                </div>
            {% elseif not state.isAcknowledged() and (state.isOptIn() or state.isOptOut()) %}
                <div class="mt-2 rounded-md bg-white dark:bg-gray-800 p-2 text-sm text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700">
                    Hinweis: Der aktuelle Status ergibt sich aus der Opt-In/Opt-Out-Voreinstellung und ist keine aktive Entscheidung des Benutzers.
                </div>
            {% endif %}

            <div class="mt-2">
                <span class="inline-flex items-center rounded-md bg-gray-200 dark:bg-gray-700 px-2 py-0.5 text-xs font-medium text-gray-700 dark:text-gray-300">
                    {{ ('consentForm.compulsory.'~state.getCompulsory())|trans({}, 'admin') }}
                </span>
            </div>
        </div>
    </div>

    <div class="px-4 sm:px-6 pb-6">

        <div class="mt-6 border-t border-gray-100 dark:border-gray-800 pt-6">
            <dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2">
                <div>
                    <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">{{ 'signatures.label.scope'|trans({}, 'admin') }}</dt>
                    <dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ state.getScopeName() }}</dd>
                </div>
                <div>
                    <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">{{ 'signatures.label.subject'|trans({}, 'admin') }}</dt>
                    <dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ state.getSubjectName() }}</dd>
                </div>
            </dl>
        </div>

        <div class="mt-6 border-t border-gray-100 dark:border-gray-800 pt-6">
            <h3 class="text-sm font-medium text-gray-900 dark:text-gray-100">Einwilligungstext</h3>
            <div class="mt-2 prose prose-sm dark:prose-invert max-w-none text-gray-500 dark:text-gray-400">
                {{ state.getConsentText()|markdown_to_html }}
            </div>
        </div>

        {% if state.hasSignature %}
            <div class="mt-6 border-t border-gray-100 dark:border-gray-800 pt-6">
                <dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2">
                    <div>
                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Unterzeichnet am</dt>
                        <dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ state.signature.createdAt|date('d.m.Y H:i') }}</dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Unterzeichnet von</dt>
                        <dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ state.getSigneeName() }}</dd>
                    </div>
                </dl>
            </div>
        {% endif %}
    </div>
{% endblock %}
