@props([
    'id' => 'booklio-modal',
    'title' => null,
    'description' => null,
    'size' => 'md',
])

@php
    $sizes = [
        'sm' => 'max-w-md',
        'md' => 'max-w-xl',
        'lg' => 'max-w-3xl',
    ];
@endphp

<div id="{{ $id }}" data-modal class="fixed inset-0 z-50 hidden items-center justify-center bg-slate-950/45 p-4">
    <div class="w-full {{ $sizes[$size] ?? $sizes['md'] }} rounded-xl bg-white shadow-modal">
        <div class="flex items-start justify-between gap-4 border-b border-booklio-border px-6 py-5">
            <div>
                @if ($title)
                    <h2 class="text-lg font-bold text-booklio-dark">{{ $title }}</h2>
                @endif
                @if ($description)
                    <p class="mt-1 text-sm text-booklio-muted">{{ $description }}</p>
                @endif
            </div>
            <button type="button" data-modal-close class="flex h-9 w-9 items-center justify-center rounded-lg text-slate-500 transition hover:bg-slate-100">
                <x-ui.icon name="x" class="h-5 w-5" />
            </button>
        </div>

        <div class="px-6 py-5">
            {{ $slot }}
        </div>

        @isset($footer)
            <div class="flex items-center justify-end gap-3 border-t border-booklio-border px-6 py-4">
                {{ $footer }}
            </div>
        @endisset
    </div>
</div>
