<!DOCTYPE html>
<html lang="en">
<head>
    <title>{{ $title ?? 'Admin Panel' }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&family=Sora:wght@500;600;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    @vite(['resources/css/app.css', 'resources/js/admin.js'])
</head>
<body class="bg-[var(--admin-bg)] text-[var(--admin-text)]">
    <div class="min-h-screen lg:flex">
        <aside id="adminSidebar" class="fixed inset-y-0 left-0 z-30 w-72 -translate-x-full bg-[var(--admin-sidebar)] p-6 text-[var(--admin-sidebar-text)] transition duration-300 lg:relative lg:translate-x-0">
            @include('admin.partials.sidebar')
        </aside>

        <div class="flex min-h-screen flex-1 flex-col lg:pl-72">
            @include('admin.partials.topbar', [
                'heading' => $heading ?? 'Dashboard',
                'subheading' => $subheading ?? null,
                'quickActions' => $quickActions ?? [],
            ])

            <main class="flex-1 p-6">
                @if(session('status'))
                    <div class="mb-4 rounded-2xl border border-emerald-200 bg-emerald-50 p-4 text-emerald-800">
                        {{ session('status') }}
                    </div>
                @endif
                @if($errors->any())
                    <div class="mb-4 rounded-2xl border border-rose-200 bg-rose-50 p-4 text-rose-800">
                        <ul class="list-disc pl-5 text-sm">
                            @foreach($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                @endif
                @yield('content')
            </main>
        </div>
    </div>

    @if(!empty($quickActions ?? []))
        <div class="fixed bottom-6 right-6 z-40 lg:hidden">
            <button type="button" data-quick-toggle class="flex h-12 w-12 items-center justify-center rounded-full bg-emerald-600 text-white shadow-lg">+</button>
            <div data-quick-menu class="mt-3 hidden flex-col gap-2 rounded-2xl border border-slate-200 bg-white p-3 shadow-lg">
                @foreach($quickActions as $action)
                    <a href="{{ $action['href'] }}" class="rounded-lg px-3 py-2 text-sm text-slate-700 hover:bg-slate-100">{{ $action['label'] }}</a>
                @endforeach
            </div>
        </div>
    @endif

    @include('admin.partials.toast')
    @include('admin.partials.modal')
</body>
</html>
