<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin - {{ config('app.name', 'Posture SaaS') }}</title>

    @livewireStyles
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>

<body class="bg-slate-50 font-sans text-slate-900 antialiased">
    <div class="min-h-screen">
        <aside class="fixed inset-y-0 left-0 z-30 hidden w-72 border-r border-slate-200 bg-slate-950 lg:flex lg:flex-col">
            <div class="flex h-16 items-center border-b border-slate-800 px-6">
                <div class="flex h-10 w-10 items-center justify-center rounded-2xl bg-white text-sm font-bold text-slate-950">
                    GP
                </div>

                <div class="ml-3">
                    <div class="text-sm font-bold text-white">Admin Posture</div>
                    <div class="text-xs text-slate-400">Gestão da plataforma</div>
                </div>
            </div>

            <nav class="flex-1 space-y-6 overflow-y-auto px-4 py-6">
                <div>
                    <p class="px-3 text-xs font-semibold uppercase tracking-wider text-[#627D98]">Principal</p>
                    <div class="mt-2 space-y-1">
                        <a href="{{ route('admin.dashboard') }}" class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-200 hover:bg-slate-800">
                            Dashboard
                        </a>
                    </div>
                </div>

                <div>
                    <p class="px-3 text-xs font-semibold uppercase tracking-wider text-[#627D98]">Questionários</p>
                    <div class="mt-2 space-y-1">
                        <a href="{{ route('admin.questionnaires') }}" class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-200 hover:bg-slate-800">
                            Questionários
                        </a>
                        <a href="{{ route('admin.dimensions') }}" class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-200 hover:bg-slate-800">
                            Dimensões
                        </a>
                        <a href="{{ route('admin.questions') }}" class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-200 hover:bg-slate-800">
                            Perguntas
                        </a>
                    </div>
                </div>

                <div>
                    <p class="px-3 text-xs font-semibold uppercase tracking-wider text-slate-500">
                        Configurações
                    </p>

                    <div class="mt-2 space-y-1">
                        <a
                            href="{{ route('admin.report-settings') }}"
                            class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-200 hover:bg-slate-800"
                        >
                            Relatório
                        </a>
                    </div>
                </div>

                <div>
                    <p class="px-3 text-xs font-semibold uppercase tracking-wider text-slate-500">
                        Cobrança
                    </p>

                    <div class="mt-2 space-y-1">
                        <a
                            href="{{ route('admin.billing-requests') }}"
                            class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-200 hover:bg-slate-800"
                        >
                            Solicitações
                        </a>
                    </div>
                </div>

                <div>
                    <p class="px-3 text-xs font-semibold uppercase tracking-wider text-[#627D98]">Operação</p>
                    <div class="mt-2 space-y-1">
                        <a href="{{ route('app.dashboard') }}" class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-200 hover:bg-slate-800">
                            Voltar para App
                        </a>
                    </div>
                </div>
            </nav>
        </aside>

        <div class="lg:pl-72">
            <header class="sticky top-0 z-20 flex h-16 items-center justify-between border-b border-slate-200 bg-white/90 px-6 backdrop-blur">
                <div>
                    <div class="text-sm font-semibold text-slate-900">
                        Área administrativa
                    </div>
                    <div class="text-xs text-[#627D98]">
                        Grupo Posture
                    </div>
                </div>

                <form method="POST" action="{{ route('logout') }}">
                    @csrf
                    <button class="rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">
                        Sair
                    </button>
                </form>
            </header>

            <main class="px-6 py-8">
                {{ $slot ?? '' }}
                @yield('content')
            </main>
        </div>
    </div>

    {{-- Toast global --}}
    <div
        x-data="{ show: false, message: '', type: 'success' }"
        x-on:toast.window="
            message = $event.detail.message;
            type = $event.detail.type ?? 'success';
            show = true;
            setTimeout(() => show = false, 5000);
        "
        x-show="show"
        x-transition
        class="fixed right-6 top-6 z-[9999] w-full max-w-sm rounded-2xl border bg-white p-4 shadow-xl"
        style="display: none;"
    >
        <div class="flex gap-3">
            <div
                class="flex h-8 w-8 items-center justify-center rounded-full"
                x-bind:class="type === 'success' ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'"
            >
                <span x-text="type === 'success' ? '✓' : '!'"></span>
            </div>

            <div>
                <p class="text-sm font-semibold text-slate-900" x-text="type === 'success' ? 'Sucesso' : 'Erro'"></p>
                <p class="mt-1 text-sm text-slate-600" x-text="message"></p>
            </div>
        </div>
    </div>
    @livewireScripts
</body>
</html>