@php
    $technical = isset($technical) ? $technical : (isset($getState) ? $getState() : []);
    $summaryPayload = is_array($technical['summaryPayload'] ?? null) ? $technical['summaryPayload'] : [];
    $groupPayloads = is_array($technical['groupPayloads'] ?? null) ? $technical['groupPayloads'] : [];
@endphp

<div class="space-y-4">
    <div class="text-sm text-gray-600 dark:text-gray-300">
        Technical payloads are secondary on purpose. Use them for debugging capture fidelity and renderer fallbacks.
    </div>

    <x-filament::section heading="Snapshot summary payload" collapsible :collapsed="true">
        @include('filament.partials.json-viewer', ['value' => $summaryPayload])
    </x-filament::section>

    @if ($groupPayloads !== [])
        <div class="space-y-3">
            @foreach ($groupPayloads as $group)
                @php
                    $label = $group['payload']['subject_descriptor']['display_label'] ?? ($group['label'] ?? 'Governed subject');
                    $payload = is_array($group['payload'] ?? null) ? $group['payload'] : [];
                @endphp

                <x-filament::section :heading="$label" collapsible :collapsed="true">
                    @if (! empty($group['renderingError']))
                        <div class="mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200">
                            {{ $group['renderingError'] }}
                        </div>
                    @endif

                    @include('filament.partials.json-viewer', ['value' => $payload])
                </x-filament::section>
            @endforeach
        </div>
    @endif
</div>
