<x-filament-widgets::widget>
    <div class="space-y-4">
        <x-dberp.workbench.module-header
            :title="__('dberp.widgets.unified_workbench_reminders.section_title')"
            :description="__('dberp.widgets.unified_workbench_reminders.section_description')"
        />

        @php
            $items = $this->reminderItems();
        @endphp

        @if ($items === [])
            <div class="rounded-xl border border-dashed border-gray-300 px-4 py-5 text-sm text-gray-500 dark:border-white/10 dark:text-gray-400">
                {{ __('dberp.widgets.unified_workbench_reminders.empty') }}
            </div>
        @else
            <div class="divide-y divide-gray-200 overflow-hidden rounded-xl border border-gray-200 bg-white dark:divide-white/10 dark:border-white/10 dark:bg-gray-900">
                @foreach ($items as $item)
                    @php
                        $severity = $item['severity'] ?? 'info';

                        $dotClasses = match ($severity) {
                            'danger' => 'bg-danger-500',
                            'warning' => 'bg-warning-500',
                            'success' => 'bg-success-500',
                            default => 'bg-info-500',
                        };

                        $badgeColor = match ($severity) {
                            'danger' => 'danger',
                            'warning' => 'warning',
                            'success' => 'success',
                            default => 'info',
                        };

                        $amountClasses = match ($severity) {
                            'danger' => 'text-danger-600 dark:text-danger-400',
                            'warning' => 'text-warning-600 dark:text-warning-400',
                            default => 'text-gray-500 dark:text-gray-400',
                        };
                    @endphp

                    <a
                        href="{{ $item['url'] }}"
                        wire:key="workbench-reminder-{{ $item['domain'] }}-{{ $item['key'] }}"
                        class="group flex items-start justify-between gap-4 px-4 py-3 transition hover:bg-gray-50 dark:hover:bg-white/5"
                    >
                        <div class="min-w-0 flex-1">
                            <div class="flex flex-wrap items-center gap-2">
                                <span class="h-2 w-2 flex-none rounded-full {{ $dotClasses }}"></span>

                                <x-filament::badge color="gray" size="sm">
                                    {{ $item['domain_label'] }}
                                </x-filament::badge>

                                <span class="text-sm font-medium text-gray-950 dark:text-white">
                                    {{ $item['title'] }}
                                </span>
                            </div>

                            @if (filled($item['amount'] ?? null))
                                <div class="mt-1 pl-4 text-xs tabular-nums {{ $amountClasses }}">
                                    {{ $item['amount'] }}
                                </div>
                            @endif
                        </div>

                        <x-filament::badge :color="$badgeColor" size="sm">
                            {{ $item['count'] }}
                        </x-filament::badge>
                    </a>
                @endforeach
            </div>
        @endif
    </div>
</x-filament-widgets::widget>
