@props([
    'panel' => null,
])

@if (is_array($panel))
    @php
        $isDanger = ($panel['severity'] ?? 'warning') === 'danger';
        $containerClass = $isDanger
            ? 'border-danger-200 bg-danger-50/70 dark:border-danger-500/30 dark:bg-danger-500/10'
            : 'border-warning-200 bg-warning-50/70 dark:border-warning-500/30 dark:bg-warning-500/10';
        $buttonColor = $isDanger ? 'danger' : 'warning';
        $actions = is_array($panel['actions'] ?? null) ? $panel['actions'] : [];
    @endphp

    <div @class([
        'mb-4 flex flex-col gap-2 rounded-lg border px-3 py-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3',
        $containerClass,
    ])>
        <div class="min-w-0 space-y-0.5">
            <p class="text-sm font-medium text-gray-950 dark:text-white">
                {{ $panel['title'] }}
            </p>
            @if (filled($panel['message'] ?? null))
                <p class="text-sm leading-snug text-gray-600 dark:text-gray-300">
                    {{ $panel['message'] }}
                </p>
            @endif
        </div>

        @if ($actions !== [])
            <div class="flex shrink-0 flex-wrap items-center gap-2">
                @foreach ($actions as $action)
                    @if (filled($action['url'] ?? null) && filled($action['label'] ?? null))
                        <x-filament::button
                            tag="a"
                            :href="$action['url']"
                            :color="$buttonColor"
                            size="sm"
                        >
                            {{ $action['label'] }}
                        </x-filament::button>
                    @endif
                @endforeach
            </div>
        @endif
    </div>
@endif
