<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" dir="ltr">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="theme-color" content="#090B0F">
    <title>@yield('title', __('admin.panel')) — ALGA ARENA</title>

    <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=Pixelify+Sans:wght@400;700&family=Chakra+Petch:wght@400;500;600;700&family=Oxanium:wght@400;500;600;700;800&family=Rajdhani:wght@500;600;700;800&family=Space+Grotesk:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <link rel="stylesheet" href="{{ asset('assets/css/app.css') }}">
    <link rel="stylesheet" href="{{ asset('assets/css/esports-premium.css') }}">
    @stack('styles')
    <link rel="icon" href="{{ asset('assets/images/brand/favicon.svg') }}" type="image/svg+xml">
    <style>
        .admin-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; background: var(--arena-bg-primary); }
        .admin-sidebar { border-right: 1px solid var(--arena-border); background: linear-gradient(180deg, rgba(0,212,255,0.03), transparent); padding: var(--sp-4) 0; }
        .admin-main { padding: var(--sp-6); }
        .admin-brand { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-5) var(--sp-5); text-decoration: none; }
        .admin-nav-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); color: var(--arena-text-muted); text-decoration: none; font-family: var(--font-hud); font-size: 0.82rem; }
        .admin-nav-item:hover, .admin-nav-item.active { color: var(--arena-accent); background: rgba(0,212,255,0.06); }
        .admin-section-label { padding: var(--sp-4) var(--sp-5) var(--sp-2); font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--arena-text-muted); font-family: var(--font-pixel); }
        .admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-5); }
        @media (max-width: 991px) { .admin-shell { grid-template-columns: 1fr; } .admin-sidebar { display: none; } }
    </style>
</head>
<body>
    <div class="admin-shell">
        <aside class="admin-sidebar" aria-label="{{ __('admin.panel') }}">
            <a href="{{ route('admin.dashboard') }}" class="admin-brand">
                <svg width="32" height="32" viewBox="0 0 36 36" fill="none" aria-hidden="true">
                    <rect width="36" height="36" rx="8" fill="#00D4FF" fill-opacity="0.15"/>
                    <path d="M18 4L8 16H14L10 28H16L18 22L20 28H26L22 16H28L18 4Z" fill="#00D4FF"/>
                </svg>
                <div>
                    <div class="brand-name">ALGA ARENA</div>
                    <div class="brand-sub">{{ __('admin.panel') }}</div>
                </div>
            </a>

            @php
            $navItems = [
                ['route' => 'admin.dashboard', 'label' => 'dashboard', 'icon' => 'bi-speedometer2', 'pattern' => 'admin.dashboard'],
                ['route' => 'admin.users.index', 'label' => 'users', 'icon' => 'bi-people', 'pattern' => 'admin.users.*'],
                ['route' => 'admin.player-profiles.index', 'label' => 'player_profiles', 'icon' => 'bi-person-badge', 'pattern' => 'admin.player-profiles.*'],
                ['route' => 'admin.games.index', 'label' => 'games', 'icon' => 'bi-controller', 'pattern' => 'admin.games.*'],
                ['route' => 'admin.events.index', 'label' => 'events', 'icon' => 'bi-trophy', 'pattern' => 'admin.events.*'],
                ['route' => 'admin.payment-methods.index', 'label' => 'payment_methods', 'icon' => 'bi-wallet2', 'pattern' => 'admin.payment-methods.*'],
                ['route' => 'admin.payment-proofs.index', 'label' => 'payment_proofs', 'icon' => 'bi-receipt', 'pattern' => 'admin.payment-proofs.*'],
                ['route' => 'admin.moderation.index', 'label' => 'moderation', 'icon' => 'bi-shield-check', 'pattern' => 'admin.moderation.*'],
                ['route' => 'admin.audit-logs.index', 'label' => 'audit_logs', 'icon' => 'bi-journal-text', 'pattern' => 'admin.audit-logs.*'],
                ['route' => 'admin.settings.index', 'label' => 'settings', 'icon' => 'bi-gear', 'pattern' => 'admin.settings.*'],
            ];
            @endphp

            <nav>
                <div class="admin-section-label">{{ __('admin.panel') }}</div>
                @foreach($navItems as $item)
                    @if(Route::has($item['route']))
                        <a href="{{ route($item['route']) }}" class="admin-nav-item {{ request()->routeIs($item['pattern']) ? 'active' : '' }}">
                            <i class="bi {{ $item['icon'] }}" aria-hidden="true"></i>
                            <span>{{ __('admin.nav.'.$item['label']) }}</span>
                        </a>
                    @endif
                @endforeach
            </nav>

            <div style="padding: var(--sp-5); margin-top: auto;">
                <a href="{{ route('home') }}" class="btn-arena btn-ghost btn-sm w-100 text-center text-decoration-none">
                    <i class="bi bi-arrow-left"></i> {{ __('admin.actions.cancel') }}
                </a>
            </div>
        </aside>

        <main class="admin-main">
            <div class="admin-topbar">
                <div>
                    <h1 class="card-title mb-1">@yield('title', __('admin.dashboard'))</h1>
                    @hasSection('subtitle')
                        <p class="text-muted mb-0 fs-sm">@yield('subtitle')</p>
                    @endif
                </div>
                <div class="d-flex align-items-center gap-3">
                    <span class="fs-sm text-muted">{{ auth()->user()->display_name ?? auth()->user()->name }}</span>
                    <form method="POST" action="{{ route('logout') }}">
                        @csrf
                        <button type="submit" class="btn-arena btn-ghost btn-sm">Sign Out</button>
                    </form>
                </div>
            </div>

            @if(session('success'))
                <div class="alert alert-success mb-4">{{ session('success') }}</div>
            @endif
            @if(session('error'))
                <div class="alert alert-danger mb-4">{{ session('error') }}</div>
            @endif

            @yield('content')
        </main>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="{{ asset('assets/js/app.js') }}"></script>
    @stack('scripts')
</body>
</html>
