<x-filament::page>
    <x-filament::section>
        <div class="text-base font-medium">Policies</div>
        <div class="overflow-x-auto">
            <table class="min-w-full text-sm">
                <thead>
                    <tr class="text-left border-b border-gray-200 dark:border-gray-800">
                        <th class="py-2 pr-4 font-medium">Type</th>
                        <th class="py-2 pr-4 font-medium">Label</th>
                        <th class="py-2 pr-4 font-medium">Category</th>
                        <th class="py-2 pr-4 font-medium">Dependencies</th>
                        <th class="py-2 pr-4 font-medium">Restore</th>
                        <th class="py-2 pr-4 font-medium">Risk</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-200 dark:divide-gray-800">
                    @foreach ($supportedPolicyTypes as $row)
                        @php
                            $typeSpec = \App\Support\Badges\TagBadgeCatalog::spec(\App\Support\Badges\TagBadgeDomain::PolicyType, $row['type'] ?? null);
                            $categorySpec = \App\Support\Badges\TagBadgeCatalog::spec(\App\Support\Badges\TagBadgeDomain::PolicyCategory, $row['category'] ?? null);
                            $restoreSpec = \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::PolicyRestoreMode, $row['restore'] ?? 'enabled');
                            $riskSpec = \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::PolicyRisk, $row['risk'] ?? 'n/a');
                        @endphp
                        <tr>
                            <td class="py-2 pr-4">
                                <span class="font-mono text-xs">{{ $row['type'] ?? '' }}</span>
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$typeSpec->color" size="sm">
                                    {{ $typeSpec->label }}
                                </x-filament::badge>
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$categorySpec->color" size="sm">
                                    {{ $categorySpec->label }}
                                </x-filament::badge>
                            </td>
                            <td class="py-2 pr-4">
                                @if ($row['dependencies'] ?? false)
                                    <x-filament::icon
                                        icon="heroicon-m-check-circle"
                                        class="h-5 w-5 text-success-600 dark:text-success-400"
                                    />
                                @else
                                    <x-filament::icon
                                        icon="heroicon-m-minus-circle"
                                        class="h-5 w-5 text-gray-400 dark:text-gray-500"
                                    />
                                @endif
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$restoreSpec->color" :icon="$restoreSpec->icon" size="sm">
                                    {{ $restoreSpec->label }}
                                </x-filament::badge>
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$riskSpec->color" :icon="$riskSpec->icon" size="sm">
                                    {{ $riskSpec->label }}
                                </x-filament::badge>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </x-filament::section>

    <x-filament::section>
        <div class="text-base font-medium">Foundations</div>
        <div class="overflow-x-auto">
            <table class="min-w-full text-sm">
                <thead>
                    <tr class="text-left border-b border-gray-200 dark:border-gray-800">
                        <th class="py-2 pr-4 font-medium">Type</th>
                        <th class="py-2 pr-4 font-medium">Label</th>
                        <th class="py-2 pr-4 font-medium">Category</th>
                        <th class="py-2 pr-4 font-medium">Dependencies</th>
                        <th class="py-2 pr-4 font-medium">Restore</th>
                        <th class="py-2 pr-4 font-medium">Risk</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-200 dark:divide-gray-800">
                    @foreach ($foundationTypes as $row)
                        @php
                            $typeSpec = \App\Support\Badges\TagBadgeCatalog::spec(\App\Support\Badges\TagBadgeDomain::PolicyType, $row['type'] ?? null);
                            $categorySpec = \App\Support\Badges\TagBadgeCatalog::spec(\App\Support\Badges\TagBadgeDomain::PolicyCategory, $row['category'] ?? null);
                            $restoreSpec = \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::PolicyRestoreMode, $row['restore'] ?? 'enabled');
                            $riskSpec = \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::PolicyRisk, $row['risk'] ?? 'n/a');
                        @endphp
                        <tr>
                            <td class="py-2 pr-4">
                                <span class="font-mono text-xs">{{ $row['type'] ?? '' }}</span>
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$typeSpec->color" size="sm">
                                    {{ $typeSpec->label }}
                                </x-filament::badge>
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$categorySpec->color" size="sm">
                                    {{ $categorySpec->label }}
                                </x-filament::badge>
                            </td>
                            <td class="py-2 pr-4">
                                @if ($row['dependencies'] ?? false)
                                    <x-filament::icon
                                        icon="heroicon-m-check-circle"
                                        class="h-5 w-5 text-success-600 dark:text-success-400"
                                    />
                                @else
                                    <x-filament::icon
                                        icon="heroicon-m-minus-circle"
                                        class="h-5 w-5 text-gray-400 dark:text-gray-500"
                                    />
                                @endif
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$restoreSpec->color" :icon="$restoreSpec->icon" size="sm">
                                    {{ $restoreSpec->label }}
                                </x-filament::badge>
                            </td>
                            <td class="py-2 pr-4">
                                <x-filament::badge :color="$riskSpec->color" :icon="$riskSpec->icon" size="sm">
                                    {{ $riskSpec->label }}
                                </x-filament::badge>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </x-filament::section>
</x-filament::page>
