<x-app-layout>
    <x-slot name="header">
        {{ $title }}
    </x-slot>

    <div class="p-6">
        <div class="max-w-5xl">
            <div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 space-y-6">
                <div>
                    <h1 class="text-2xl font-bold text-gray-900">{{ $title }}</h1>
                    <p class="mt-2 text-sm text-gray-600">Coming soon. This module shell is ready for Sprint 1 feature implementation.</p>
                </div>

                @if(!empty($children))
                    <div class="rounded-xl border border-gray-200 bg-gray-50 p-4">
                        <h2 class="text-sm font-semibold uppercase tracking-wide text-gray-500 mb-3">Sub-pages</h2>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-2">
                            @foreach($children as $child)
                                <a
                                    href="{{ route($child['route_name']) }}"
                                    class="block rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-800 hover:bg-gray-100"
                                >
                                    {{ $child['label'] }}
                                </a>
                            @endforeach
                        </div>
                    </div>
                @endif

                <div class="rounded-xl border border-gray-200 bg-gray-50 p-4">
                    <h2 class="text-sm font-semibold uppercase tracking-wide text-gray-500 mb-3">Access Context</h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-y-2 text-sm text-gray-700">
                        <p><span class="font-medium text-gray-900">Required permission:</span> {{ $requiredPermission }}</p>
                        <p><span class="font-medium text-gray-900">Dealer:</span> {{ optional(auth()->user()->dealer)->name ?? 'N/A' }}</p>
                        <p><span class="font-medium text-gray-900">User:</span> {{ auth()->user()->name }}</p>
                        <p><span class="font-medium text-gray-900">Department:</span> {{ optional(auth()->user()->department)->name ?? 'N/A' }}</p>
                        <p class="md:col-span-2"><span class="font-medium text-gray-900">Roles:</span> {{ auth()->user()->getRoleNames()->join(', ') }}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</x-app-layout>
