<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@yield('title', 'Panel') · {{ config('app.name') }}</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script>tailwind.config={theme:{extend:{colors:{beige:'#F7F3EE',olive:'#4A5D4D'}}}}</script>
</head>
<body class="bg-gray-100 text-gray-800">
<div class="flex min-h-screen">
    {{-- Sidebar --}}
    <aside class="w-60 bg-olive text-beige flex-shrink-0">
        <div class="p-5 font-semibold text-lg border-b border-white/10">{{ config('app.name') }}</div>
        <nav class="p-3 space-y-1 text-sm">
            @php $r = request()->routeIs(...); @endphp
            <a href="{{ route('admin.dashboard') }}" class="block px-3 py-2 rounded hover:bg-white/10 {{ request()->routeIs('admin.dashboard') ? 'bg-white/10' : '' }}">Dashboard</a>
            <a href="{{ route('admin.products.index') }}" class="block px-3 py-2 rounded hover:bg-white/10 {{ request()->routeIs('admin.products.*') ? 'bg-white/10' : '' }}">Productos</a>
            <a href="{{ route('admin.categories.index') }}" class="block px-3 py-2 rounded hover:bg-white/10 {{ request()->routeIs('admin.categories.*') ? 'bg-white/10' : '' }}">Categorías</a>
            <a href="{{ route('admin.brands.index') }}" class="block px-3 py-2 rounded hover:bg-white/10 {{ request()->routeIs('admin.brands.*') ? 'bg-white/10' : '' }}">Marcas</a>
            <a href="{{ route('admin.pages.index') }}" class="block px-3 py-2 rounded hover:bg-white/10 {{ request()->routeIs('admin.pages.*') ? 'bg-white/10' : '' }}">Páginas (Builder)</a>
            <a href="{{ route('admin.settings.edit') }}" class="block px-3 py-2 rounded hover:bg-white/10 {{ request()->routeIs('admin.settings.*') ? 'bg-white/10' : '' }}">Configuración</a>
            <a href="{{ route('store.home') }}" class="block px-3 py-2 rounded hover:bg-white/10">Ver tienda ↗</a>
        </nav>
    </aside>

    {{-- Contenido --}}
    <div class="flex-1 p-8">
        @if(session('success'))
            <div class="mb-4 bg-green-100 text-green-800 px-4 py-2 rounded">{{ session('success') }}</div>
        @endif
        @if($errors->any())
            <div class="mb-4 bg-red-100 text-red-800 px-4 py-2 rounded">
                <ul class="list-disc list-inside text-sm">
                    @foreach($errors->all() as $e)<li>{{ $e }}</li>@endforeach
                </ul>
            </div>
        @endif
        @yield('content')
    </div>
</div>
</body>
</html>
