@props([
    'badge',
    'title',
    'description',
    'createUrl',
    'createLabel',
    'stats' => [],
    'listTitle',
    'emptyMessage',
    'items' => [],
    'icon' => 'ladill-icons/events.svg',
    'iconBg' => 'bg-violet-100',
])

<div class="space-y-6">
    @foreach (['success', 'error'] as $flash)
        @if (session($flash))
            <div class="rounded-lg border px-4 py-3 {{ $flash === 'success' ? 'border-emerald-200 bg-emerald-50 text-emerald-700' : 'border-red-200 bg-red-50 text-red-700' }}">
                <p class="text-sm">{{ session($flash) }}</p>
            </div>
        @endif
    @endforeach

    <div class="relative overflow-hidden rounded-2xl border border-slate-200 bg-white">
        <div class="absolute inset-0 bg-gradient-to-br from-violet-50/80 via-white to-indigo-50/60"></div>
        <div class="relative px-6 py-8 sm:px-10">
            <div class="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between">
                <div class="max-w-xl">
                    <div class="inline-flex items-center gap-1.5 rounded-full bg-violet-100 px-3 py-1 text-xs font-semibold text-violet-700">
                        {{ $badge }}
                    </div>
                    <h1 class="mt-3 text-2xl font-bold tracking-tight text-slate-900 sm:text-3xl">{{ $title }}</h1>
                    <p class="mt-2 text-sm leading-6 text-slate-600">{{ $description }}</p>
                    <div class="mt-6">
                        <a href="{{ $createUrl }}" class="btn-primary">
                            <svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/></svg>
                            {{ $createLabel }}
                        </a>
                    </div>
                </div>

                @if (count($stats) > 0)
                    <div class="scrollbar-hide flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 sm:grid sm:grid-cols-3 sm:overflow-visible sm:pb-0 lg:gap-4" style="-ms-overflow-style:none;scrollbar-width:none;">
                        @foreach ($stats as $stat)
                            <div class="mobile-stats-card shrink-0 snap-start rounded-xl border border-slate-200 bg-white/90 px-4 py-3 text-center backdrop-blur-sm">
                                <p class="whitespace-nowrap text-xl font-bold text-slate-900 sm:text-2xl">{{ $stat['value'] }}</p>
                                <p class="mt-0.5 whitespace-nowrap text-[11px] font-medium text-slate-500">{{ $stat['label'] }}</p>
                            </div>
                        @endforeach
                    </div>
                @endif
            </div>
        </div>
    </div>

    <div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
        <div class="border-b border-slate-100 px-6 py-4">
            <h2 class="text-sm font-semibold text-slate-900">{{ $listTitle }}</h2>
        </div>
        @if (count($items) === 0)
            <p class="px-6 py-10 text-center text-sm text-slate-500">{{ $emptyMessage }}</p>
        @else
            <div class="divide-y divide-slate-100">
                @foreach ($items as $item)
                    <a href="{{ $item['url'] }}" class="flex items-center gap-4 px-6 py-4 transition hover:bg-slate-50">
                        <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg {{ ($item['active'] ?? true) ? $iconBg : 'bg-slate-100 opacity-50' }}">
                            <img src="{{ asset('images/'.$icon) }}?v={{ @filemtime(public_path('images/'.$icon)) ?: '1' }}"
                                 alt="" class="h-5 w-5 object-contain" width="20" height="20">
                        </div>
                        <div class="min-w-0 flex-1">
                            <p class="truncate text-sm font-semibold text-slate-900">{{ $item['title'] }}</p>
                            <p class="truncate text-xs text-slate-500">{{ $item['subtitle'] }}</p>
                        </div>
                        <div class="text-right text-xs text-slate-500">
                            <p class="font-semibold text-slate-900">{{ $item['meta'] }}</p>
                            <p>{{ $item['status'] }}</p>
                        </div>
                    </a>
                @endforeach
            </div>
        @endif
    </div>
</div>
