<x-filament-widgets::widget>
    <x-filament::section>
        <x-slot name="heading">
            Recently failed operations
        </x-slot>

        <x-slot name="description">
            Latest failures in {{ $windowLabel }}. Click any run for the canonical detail view.
        </x-slot>

        @if ($runs->isEmpty())
            <div class="rounded-lg border border-dashed border-gray-300 px-4 py-6 text-sm text-gray-500 dark:border-white/15 dark:text-gray-400">
                No failed operations in the selected time window.
            </div>
        @else
            <div class="space-y-3">
                @foreach ($runs as $run)
                    <a
                        href="{{ $run['url'] }}"
                        class="block rounded-lg border border-gray-200 px-4 py-3 transition hover:border-primary-400 hover:bg-gray-50 dark:border-white/10 dark:hover:border-primary-500 dark:hover:bg-white/5"
                    >
                        <div class="flex flex-wrap items-center justify-between gap-2">
                            <div class="font-medium text-gray-950 dark:text-white">
                                #{{ $run['id'] }} · {{ $run['operation'] }}
                            </div>
                            <div class="text-xs text-gray-500 dark:text-gray-400">{{ $run['created_at'] }}</div>
                        </div>
                        <div class="mt-1 text-sm text-gray-600 dark:text-gray-300">{{ $run['tenant'] }}</div>
                        <div class="mt-2 text-sm text-danger-700 dark:text-danger-400">{{ $run['failure_message'] }}</div>
                    </a>
                @endforeach
            </div>
        @endif

        <div class="mt-4">
            <x-filament::link :href="$runsUrl" icon="heroicon-m-arrow-top-right-on-square">
                Open all runs
            </x-filament::link>
        </div>
    </x-filament::section>
</x-filament-widgets::widget>
