@if($age_verification_enabled ?? false)
<div id="age-verification-overlay" class="fixed inset-0 z-[9999] hidden items-center justify-center bg-black/70 p-4" role="dialog" aria-modal="true" aria-labelledby="age-verification-title">
    <div class="bg-white rounded-2xl shadow-xl max-w-md w-full overflow-hidden">
        <div class="p-6 border-b border-slate-100">
            <h2 id="age-verification-title" class="text-lg font-semibold text-slate-800">{{ $age_verification_title ?? 'Accès réservé aux majeurs' }}</h2>
        </div>
        <div class="p-6">
            <div class="text-slate-600 text-sm prose prose-slate prose-sm max-w-none">{!! \App\Support\SafeHtml::richText($age_verification_content ?? '') !!}</div>
        </div>
        <div class="p-6 border-t border-slate-100 flex flex-col sm:flex-row gap-3">
            <button type="button" id="age-verification-confirm" class="flex-1 px-6 py-3 bg-primary-500 text-white rounded-xl font-medium hover:bg-primary-600 transition focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2">
                {{ $age_verification_confirm ?? "J'ai plus de 18 ans" }}
            </button>
            <a href="{{ $age_verification_back_url ?? 'https://www.google.com' }}" id="age-verification-back" class="flex-1 px-6 py-3 border border-slate-300 text-slate-700 rounded-xl font-medium hover:bg-slate-50 transition text-center focus:outline-none focus:ring-2 focus:ring-slate-300 focus:ring-offset-2">
                {{ $age_verification_back ?? 'Retour' }}
            </a>
        </div>
    </div>
</div>
<script>
(function() {
    var STORAGE_KEY = 'age_verified';
    var overlay = document.getElementById('age-verification-overlay');
    var confirmBtn = document.getElementById('age-verification-confirm');
    var backLink = document.getElementById('age-verification-back');
    if (!overlay || !confirmBtn) return;
    try {
        if (!localStorage.getItem(STORAGE_KEY)) {
            overlay.classList.remove('hidden');
            overlay.classList.add('flex');
            document.body.style.overflow = 'hidden';
        }
    } catch (e) {}
    confirmBtn.addEventListener('click', function() {
        overlay.classList.add('hidden');
        overlay.classList.remove('flex');
        document.body.style.overflow = '';
        try { localStorage.setItem(STORAGE_KEY, '1'); } catch (e) {}
    });
})();
</script>
@endif
