<div>
    @if($totalOverdue > 0)
    <div class="bg-gradient-to-l from-red-50 to-red-100 rounded-xl shadow-sm border border-red-200 p-4 mb-4">
        <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
            <div class="flex items-center gap-3">
                <div class="w-10 h-10 bg-red-200 rounded-lg flex items-center justify-center shrink-0">
                    <svg class="w-5 h-5 text-red-700" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"/>
                    </svg>
                </div>
                <div>
                    <h2 class="text-sm font-bold text-red-900">{{ __('اشتراكات لم تُجدد') }}</h2>
                    <div class="flex flex-wrap items-center gap-x-4 gap-y-1 mt-0.5">
                        <span class="text-lg font-bold text-red-800">{{ $totalOverdue }}</span>
                        <span class="text-xs text-red-700">{{ __('مشترك') }}</span>
                        @if($totalAmount > 0)
                        <span class="text-sm font-bold text-red-800">{{ number_format($totalAmount / 100, 0) }} {{ __('ج.م') }}</span>
                        <span class="text-xs text-red-600">{{ __('مستحقة') }}</span>
                        @endif
                    </div>
                    <p class="text-[11px] text-red-600 mt-0.5">
                        {{ $invoiceCount }} {{ __('فاتورة غير مدفوعة') }}
                        &bull;
                        {{ $enrollmentCount }} {{ __('بدون فاتورة') }}
                    </p>
                </div>
            </div>
            <div class="flex items-center gap-2">
                <button wire:click="toggleList"
                        class="inline-flex items-center gap-1.5 px-3 py-2 text-red-700 bg-white border border-red-200 rounded-lg hover:bg-red-50 text-xs font-medium transition-colors">
                    <svg class="w-3.5 h-3.5 transition-transform {{ $showList ? 'rotate-180' : '' }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
                    </svg>
                    {{ $showList ? __('إخفاء') : __('عرض التفاصيل') }}
                </button>
                <a href="{{ route('receptionist.collect-payment') }}" wire:navigate
                   class="inline-flex items-center gap-1.5 px-3 py-2 bg-red-700 text-white rounded-lg hover:bg-red-800 text-xs font-bold transition-colors">
                    <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8V7m0 10v1"/>
                    </svg>
                    {{ __('تحصيل مدفوعات') }}
                </a>
            </div>
        </div>
    </div>

    {{-- Expandable Detail List --}}
    @if($showList)
    <div class="bg-white rounded-xl shadow-sm border border-red-200 overflow-hidden mb-4" wire:loading.class="opacity-50" wire:target="toggleList">
        <table class="w-full text-sm">
            <thead class="bg-red-50 border-b border-red-200">
                <tr>
                    <th class="text-start px-4 py-2.5 font-semibold text-red-800">{{ __('المشترك') }}</th>
                    <th class="text-start px-4 py-2.5 font-semibold text-red-800">{{ __('البرنامج') }}</th>
                    <th class="text-center px-4 py-2.5 font-semibold text-red-800">{{ __('المبلغ') }}</th>
                    <th class="text-center px-4 py-2.5 font-semibold text-red-800">{{ __('تأخير') }}</th>
                    <th class="text-center px-4 py-2.5 font-semibold text-red-800">{{ __('إجراء') }}</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-red-100">
                @foreach($items as $item)
                <tr class="hover:bg-red-50/50 transition-colors">
                    <td class="px-4 py-2.5">
                        <div class="flex items-center gap-2">
                            <div class="w-7 h-7 rounded-full {{ $item['type'] === 'invoice' ? 'bg-red-100' : 'bg-amber-100' }} flex items-center justify-center shrink-0">
                                <svg class="w-3.5 h-3.5 {{ $item['type'] === 'invoice' ? 'text-red-600' : 'text-amber-600' }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
                                </svg>
                            </div>
                            <div class="min-w-0">
                                <p class="font-medium text-gray-800 truncate text-xs">{{ $item['participant_name'] }}</p>
                                @if($item['participant_phone'])
                                <p class="text-[10px] text-gray-500" dir="ltr">{{ $item['participant_phone'] }}</p>
                                @endif
                            </div>
                        </div>
                    </td>
                    <td class="px-4 py-2.5 text-gray-700 text-xs">{{ $item['program_name'] }}</td>
                    <td class="px-4 py-2.5 text-center">
                        @if($item['amount'])
                            <span class="font-bold text-red-700 text-xs">{{ number_format($item['amount'] / 100, 0) }}</span>
                            <span class="text-[10px] text-gray-500">{{ __('ج.م') }}</span>
                        @else
                            <span class="text-[10px] text-amber-600 font-medium">{{ __('بدون فاتورة') }}</span>
                        @endif
                    </td>
                    <td class="px-4 py-2.5 text-center">
                        <span class="inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-bold
                            {{ $item['days_overdue'] > 7 ? 'bg-red-200 text-red-800' : 'bg-amber-100 text-amber-800' }}">
                            {{ $item['days_overdue'] }} {{ __('يوم') }}
                        </span>
                    </td>
                    <td class="px-4 py-2.5 text-center">
                        @if($item['participant_uuid'])
                        <a href="{{ route('receptionist.collect-payment') }}?participant={{ $item['participant_uuid'] }}" wire:navigate
                           class="inline-flex items-center gap-1 px-2.5 py-1 bg-green-600 text-white rounded-lg hover:bg-green-700 text-[10px] font-bold transition-colors">
                            {{ __('جدّد') }}
                        </a>
                        @endif
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
    @endif
    @endif
</div>
