<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">
                @if(!empty($breadcrumb))
                    <p class="text-xs uppercase tracking-wide text-gray-500">{{ implode(' / ', $breadcrumb) }}</p>
                @endif

                <div>
                    <h1 class="text-2xl font-bold text-gray-900">{{ $title }}</h1>
                    <p class="mt-2 text-sm text-gray-600">
                        Placeholder Recon dashboard. This will aggregate stats across the Recon pages below.
                    </p>
                </div>

                @php
                    $visibleChildren = array_values(array_filter($children ?? [], function ($child) {
                        $permission = $child['permission_key'] ?? null;
                        return empty($permission) || auth()->user()->can($permission);
                    }));
                @endphp

                @if(!empty($visibleChildren))
                    <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">Recon Pages</h2>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-2">
                            @foreach($visibleChildren 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>
        </div>
    </div>
</x-app-layout>

