@php
    $bottomBanners = collect($banners ?? [])->filter(fn ($b) => $b->position === 'bottom' && in_array($b->type, ['bar', 'alert']));
@endphp
@foreach($bottomBanners as $banner)
@php
    $bg = preg_match('/^#[0-9A-Fa-f]{6}$/', (string) ($banner->background_color ?? '')) ? $banner->background_color : '#e84600';
    $txt = preg_match('/^#[0-9A-Fa-f]{6}$/', (string) ($banner->text_color ?? '')) ? $banner->text_color : '#ffffff';
@endphp
@if($banner->type === 'bar')
<div class="banner-bar text-center py-2.5 px-4 text-sm font-medium" style="background-color: {{ $bg }}; color: {{ $txt }};">
    <div class="max-w-4xl mx-auto flex flex-col sm:flex-row sm:items-center sm:justify-center gap-2">
        <div class="flex-1 min-w-0 text-sm font-medium [&_a]:underline [&_a]:font-semibold">{!! \App\Support\SafeHtml::richText($banner->content) !!}</div>
        @if($banner->link_url)
        <a href="{{ $banner->link_url }}" class="shrink-0 underline font-semibold hover:opacity-90">{{ $banner->link_text ?? 'En savoir plus' }}</a>
        @endif
    </div>
</div>
@else
<div class="banner-alert text-center py-3 px-4 text-sm font-medium border-t" style="background-color: {{ $bg }}; color: {{ $txt }}; border-color: {{ $txt }}33;">
    <div class="max-w-4xl mx-auto [&_a]:underline [&_a]:font-semibold">
        {!! \App\Support\SafeHtml::richText($banner->content) !!}
        @if($banner->link_url)
        <a href="{{ $banner->link_url }}" class="ml-2 underline font-semibold">{{ $banner->link_text ?? 'Voir' }}</a>
        @endif
    </div>
</div>
@endif
@endforeach
