<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="dark">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Aquila-System') }}</title>

        <script>
            if (localStorage.getItem('theme') === 'light') {
                document.documentElement.classList.remove('dark');
            } else {
                document.documentElement.classList.add('dark');
            }
        </script>

        <link rel="preconnect" href="https://fonts.bunny.net">
        <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
        <link href="https://cdn.quilljs.com/1.3.7/quill.snow.css" rel="stylesheet">

        @livewireStyles
        @vite(['resources/css/app.css', 'resources/js/app.js'])
    </head>
    <body class="font-sans antialiased" x-data="portalTheme()" x-init="init()">
        <div class="min-h-screen bg-slate-100 dark:bg-slate-950">
            <header class="sticky top-0 z-40 border-b border-slate-200 bg-white/90 backdrop-blur dark:border-slate-800 dark:bg-slate-950/90">
                <div class="flex h-16 items-center gap-3 px-4 sm:px-6 lg:px-8">
                    <a href="{{ route('dashboard') }}" class="shrink-0" aria-label="Voltar ao portal">
                        <x-brand-logo class="h-10 w-32 px-2 py-1" imageClass="h-full w-full object-contain" />
                    </a>

                    <a href="{{ route('dashboard') }}" class="btn-secondary hidden sm:inline-flex">
                        <x-heroicon name="arrow-left-on-rectangle" class="h-5 w-5" />
                        Portal
                    </a>

                    <div class="hidden flex-1 items-center lg:flex">
                        <label class="relative w-full max-w-xl">
                            <x-heroicon name="magnifying-glass" class="pointer-events-none absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-slate-400" />
                            <input type="search" placeholder="Buscar no modulo..." class="form-control pl-10" disabled>
                        </label>
                    </div>

                    <div class="ml-auto flex items-center gap-2">
                        <button type="button" x-on:click="dark = !dark" class="rounded-lg border border-slate-200 p-2 text-slate-600 transition hover:bg-slate-100 dark:border-slate-800 dark:text-slate-300 dark:hover:bg-slate-900" title="Alternar tema" aria-label="Alternar tema">
                            <x-heroicon name="moon" class="h-5 w-5 dark:hidden" />
                            <x-heroicon name="sun" class="hidden h-5 w-5 dark:block" />
                        </button>

                        <button type="button" class="rounded-lg border border-slate-200 p-2 text-slate-600 transition hover:bg-slate-100 dark:border-slate-800 dark:text-slate-300 dark:hover:bg-slate-900" title="Notificacoes" aria-label="Notificacoes">
                            <x-heroicon name="bell" class="h-5 w-5" />
                        </button>

                        <form method="POST" action="{{ route('logout') }}">
                            @csrf
                            <button type="submit" class="btn-secondary px-3" aria-label="Sair">
                                <x-heroicon name="arrow-left-on-rectangle" class="h-5 w-5" />
                                <span class="hidden sm:inline">Sair</span>
                            </button>
                        </form>
                    </div>
                </div>
            </header>

            @if (isset($header))
                <section class="border-b border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-950">
                    <div class="px-4 py-6 sm:px-6 lg:px-8">
                        {{ $header }}
                    </div>
                </section>
            @endif

            <main class="px-4 py-6 sm:px-6 lg:px-8">
                {{ $slot }}
            </main>
        </div>

        <div x-data="{ show: false, message: '' }"
             x-on:notify.window="message = $event.detail.message; show = true; setTimeout(() => show = false, 2800)"
             x-show="show"
             x-transition
             class="fixed bottom-5 right-5 z-50 rounded-lg bg-slate-950 px-4 py-3 text-sm font-semibold text-white shadow-lg dark:bg-white dark:text-slate-950"
             style="display: none;">
            <span x-text="message"></span>
        </div>

        <script src="https://cdn.quilljs.com/1.3.7/quill.min.js"></script>
        @livewireScripts
        @stack('scripts')
    </body>
</html>
