<div>
    {{-- Header --}}
    <div class="mb-6">
        <h2 class="text-lg font-bold text-[#0F172A]">{{ __('البرامج المتاحة') }}</h2>
        <p class="text-sm text-[#64748B] mt-1">{{ __('تصفح البرامج التدريبية المتاحة للتسجيل') }}</p>
    </div>

    {{-- Search --}}
    <div class="mb-4">
        <div class="relative">
            <svg class="absolute start-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
            </svg>
            <input type="text" wire:model.live.debounce.300ms="search"
                   placeholder="{{ __('ابحث عن برنامج...') }}"
                   class="w-full ps-10 pe-4 py-3 rounded-xl border border-gray-200 bg-white text-sm focus:outline-none focus:border-[#2563EB] focus:ring-1 focus:ring-[#2563EB]/30 transition-colors">
        </div>
    </div>

    {{-- Activity Filter --}}
    @if($activities->isNotEmpty())
        <div class="flex gap-2 mb-6 overflow-x-auto pb-2 scrollbar-hide">
            <button wire:click="$set('activityFilter', '')"
                    class="shrink-0 px-4 py-2 rounded-full text-sm font-medium transition-colors {{ $activityFilter === '' ? 'bg-[#2563EB] text-white' : 'bg-white text-[#64748B] border border-gray-200 hover:border-[#2563EB]/50' }}">
                {{ __('الكل') }}
            </button>
            @foreach($activities as $activity)
                <button wire:click="$set('activityFilter', '{{ $activity->id }}')"
                        class="shrink-0 px-4 py-2 rounded-full text-sm font-medium transition-colors {{ $activityFilter == $activity->id ? 'bg-[#2563EB] text-white' : 'bg-white text-[#64748B] border border-gray-200 hover:border-[#2563EB]/50' }}">
                    {{ $activity->name_ar }}
                </button>
            @endforeach
        </div>
    @endif

    {{-- Programs Grid --}}
    @if($programs->isEmpty())
        <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-8 text-center">
            <svg class="w-16 h-16 text-gray-200 mx-auto mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
            </svg>
            <p class="text-[#64748B]">{{ __('لا توجد برامج متاحة حالياً') }}</p>
        </div>
    @else
        <div class="space-y-4">
            @foreach($programs as $program)
                <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-5 hover:border-[#2563EB]/20 transition-colors">
                    <div class="flex items-start justify-between mb-3">
                        <div>
                            <h3 class="font-semibold text-[#0F172A]">{{ $program->name_ar }}</h3>
                            <p class="text-sm text-[#64748B] mt-0.5">{{ $program->activity?->name_ar ?? '' }}</p>
                        </div>
                        @if($program->registration_open)
                            <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700">
                                {{ __('مفتوح') }}
                            </span>
                        @else
                            <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-600">
                                {{ __('مغلق') }}
                            </span>
                        @endif
                    </div>

                    {{-- Details --}}
                    <div class="flex flex-wrap gap-3 text-xs text-[#64748B]">
                        @if($program->age_min || $program->age_max)
                            <span class="inline-flex items-center gap-1">
                                <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="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
                                <span dir="ltr">{{ $program->age_min ?? '?' }} - {{ $program->age_max ?? '?' }}</span> {{ __('سنة') }}
                            </span>
                        @endif
                        @if($program->gender && $program->gender !== 'all')
                            <span class="inline-flex items-center gap-1">
                                {{ $program->gender === 'male' ? __('ذكور') : __('إناث') }}
                            </span>
                        @endif
                        <span class="inline-flex items-center gap-1">
                            <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 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
                            {{ $program->sessions_per_week }} {{ __('حصة/أسبوع') }} | {{ $program->session_duration_minutes }} {{ __('د') }}
                        </span>
                    </div>

                    {{-- Price --}}
                    @if($program->basePrice)
                        <div class="mt-3 pt-3 border-t border-gray-50">
                            <span class="text-lg font-bold text-[#2563EB]" dir="ltr">{{ number_format($program->basePrice->amount / 100, 2) }}</span>
                            <span class="text-sm text-[#64748B]">{{ __('ج.م / شهر') }}</span>
                        </div>
                    @endif
                </div>
            @endforeach
        </div>

        {{-- Pagination --}}
        <div class="mt-6">
            {{ $programs->links() }}
        </div>
    @endif
</div>
