@php
    $summary = is_array($surface['summary'] ?? null) ? $surface['summary'] : [];
    $counts = is_array($summary['counts'] ?? null) ? $summary['counts'] : [];
    $overallSpec = \App\Support\Badges\BadgeRenderer::spec(
        \App\Support\Badges\BadgeDomain::VerificationReportOverall,
        $summary['overall'] ?? null,
    );
    $changeIndicator = is_array($summary['changeIndicator'] ?? null) ? $summary['changeIndicator'] : null;
    $redactionNotes = is_array($redactionNotes ?? null)
        ? array_values(array_filter($redactionNotes, 'is_string'))
        : [];
@endphp

<div
    data-shared-zone="summary"
    class="rounded-lg border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-800 dark:bg-gray-900"
>
    <div class="flex flex-wrap items-center gap-2">
        <x-filament::badge :color="$overallSpec->color" :icon="$overallSpec->icon">
            {{ $overallSpec->label }}
        </x-filament::badge>

        <x-filament::badge color="gray">
            {{ (int) ($counts['total'] ?? 0) }} total
        </x-filament::badge>
        <x-filament::badge color="success">
            {{ (int) ($counts['pass'] ?? 0) }} pass
        </x-filament::badge>
        <x-filament::badge color="danger">
            {{ (int) ($counts['fail'] ?? 0) }} fail
        </x-filament::badge>
        <x-filament::badge color="warning">
            {{ (int) ($counts['warn'] ?? 0) }} warn
        </x-filament::badge>
        <x-filament::badge color="gray">
            {{ (int) ($counts['skip'] ?? 0) }} skip
        </x-filament::badge>
        <x-filament::badge color="info">
            {{ (int) ($counts['running'] ?? 0) }} running
        </x-filament::badge>

        @if (($changeIndicator['state'] ?? null) === 'no_changes')
            <x-filament::badge color="success">
                No changes since previous verification
            </x-filament::badge>
        @elseif (($changeIndicator['state'] ?? null) === 'changed')
            <x-filament::badge color="warning">
                Changed since previous verification
            </x-filament::badge>
        @endif
    </div>

    <div class="mt-2 text-xs text-gray-600 dark:text-gray-300">
        <span class="font-semibold">Read-only:</span> this view uses stored data and makes no external calls.
    </div>

    @if ($redactionNotes !== [])
        <div class="mt-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100">
            @foreach ($redactionNotes as $note)
                <div>{{ $note }}</div>
            @endforeach
        </div>
    @endif
</div>