<div>
    {{-- Back Button --}}
    <div class="mb-4">
        <a href="{{ route('parent.profile') }}" wire:navigate
           class="inline-flex items-center gap-1.5 text-sm text-[#64748B] hover:text-[#2563EB] transition-colors min-h-[44px]">
            <svg class="w-4 h-4 rotate-180" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
            </svg>
            {{ __('الملف الشخصي') }}
        </a>
    </div>

    {{-- Header --}}
    <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-5 mb-4">
        <div class="flex items-center gap-4">
            <div class="w-[72px] h-[72px] rounded-full bg-indigo-100 flex items-center justify-center shrink-0">
                <span class="text-2xl font-bold text-indigo-600">{{ mb_substr($participant->person?->name_ar ?? '?', 0, 1) }}</span>
            </div>
            <div class="flex-1 min-w-0">
                <h1 class="text-lg font-bold text-[#0F172A]">{{ $participant->person?->name_ar ?? '' }}</h1>
                <p class="text-xs text-[#64748B] mt-0.5" dir="ltr">{{ $participant->participant_number }}</p>
                @if($participant->person?->date_of_birth)
                    <p class="text-xs text-[#64748B] mt-0.5">{{ $participant->person->date_of_birth->age }} {{ __('سنة') }}</p>
                @endif
            </div>
            @php
                $statusConfig = [
                    'active' => ['label' => 'نشط', 'bg' => 'bg-green-100', 'text' => 'text-green-700'],
                    'registered' => ['label' => 'مسجل', 'bg' => 'bg-blue-100', 'text' => 'text-blue-700'],
                    'frozen' => ['label' => 'مجمد', 'bg' => 'bg-cyan-100', 'text' => 'text-cyan-700'],
                    'suspended' => ['label' => 'موقوف', 'bg' => 'bg-red-100', 'text' => 'text-red-700'],
                    'inactive' => ['label' => 'غير نشط', 'bg' => 'bg-gray-100', 'text' => 'text-gray-700'],
                    'graduated' => ['label' => 'متخرج', 'bg' => 'bg-purple-100', 'text' => 'text-purple-700'],
                ];
                $childStatus = $participant->status?->value ?? 'active';
                $conf = $statusConfig[$childStatus] ?? ['label' => $childStatus, 'bg' => 'bg-gray-100', 'text' => 'text-gray-700'];
            @endphp
            <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium {{ $conf['bg'] }} {{ $conf['text'] }}">
                {{ __($conf['label']) }}
            </span>
        </div>
    </div>

    {{-- Tab Navigation --}}
    <div class="flex gap-1 bg-gray-100 rounded-xl p-1 mb-4">
        @php
            $tabs = ['info' => 'معلومات', 'programs' => 'البرامج', 'evaluations' => 'التقييمات'];
        @endphp
        @foreach($tabs as $key => $label)
            <button wire:click="setTab('{{ $key }}')"
                class="flex-1 py-2.5 px-3 rounded-lg text-sm font-medium transition-all min-h-[44px]
                    {{ $activeTab === $key ? 'bg-white text-[#2563EB] shadow-sm' : 'text-[#64748B] hover:text-[#0F172A]' }}">
                {{ __($label) }}
            </button>
        @endforeach
    </div>

    {{-- Tab Content --}}
    <div wire:loading.class="opacity-50 pointer-events-none">
        {{-- Info Tab --}}
        @if($activeTab === 'info')
            <div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
                <div class="divide-y divide-gray-50">
                    <div class="flex items-center justify-between px-5 py-3.5">
                        <span class="text-sm text-[#64748B]">{{ __('تاريخ الميلاد') }}</span>
                        <span class="text-sm font-medium text-[#0F172A]" dir="ltr">{{ $participant->person?->date_of_birth?->format('Y-m-d') ?? '--' }}</span>
                    </div>
                    <div class="flex items-center justify-between px-5 py-3.5">
                        <span class="text-sm text-[#64748B]">{{ __('الجنس') }}</span>
                        <span class="text-sm font-medium text-[#0F172A]">{{ ($participant->person?->gender ?? '') === 'male' ? __('ذكر') : (($participant->person?->gender ?? '') === 'female' ? __('أنثى') : '--') }}</span>
                    </div>
                    <div class="flex items-center justify-between px-5 py-3.5">
                        <span class="text-sm text-[#64748B]">{{ __('النشاط') }}</span>
                        <span class="text-sm font-medium text-[#0F172A]">{{ $participant->primaryActivity?->name_ar ?? '--' }}</span>
                    </div>
                    <div class="flex items-center justify-between px-5 py-3.5">
                        <span class="text-sm text-[#64748B]">{{ __('المستوى') }}</span>
                        <span class="text-sm font-medium text-[#0F172A]">{{ $participant->skill_level ?? '--' }}</span>
                    </div>
                    <div class="flex items-center justify-between px-5 py-3.5">
                        <span class="text-sm text-[#64748B]">{{ __('تاريخ التسجيل') }}</span>
                        <span class="text-sm font-medium text-[#0F172A]" dir="ltr">{{ $participant->registration_date?->format('Y-m-d') ?? '--' }}</span>
                    </div>
                    <div class="flex items-center justify-between px-5 py-3.5">
                        <span class="text-sm text-[#64748B]">{{ term('membership_type') }}</span>
                        <span class="text-sm font-medium text-[#0F172A]">{{ $participant->membership_type ?? __('أساسي') }}</span>
                    </div>
                </div>
            </div>
        @endif

        {{-- Programs Tab --}}
        @if($activeTab === 'programs')
            @if($enrollments->isEmpty())
                <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-8 text-center">
                    <svg class="w-10 h-10 text-gray-200 mx-auto mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>
                    </svg>
                    <p class="text-sm text-[#64748B]">{{ __('لا يوجد برامج مسجل بها حالياً') }}</p>
                </div>
            @else
                <div class="space-y-3">
                    @foreach($enrollments as $enrollment)
                        <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-4">
                            <div class="flex items-start justify-between mb-2">
                                <h3 class="text-sm font-semibold text-[#0F172A]">{{ $enrollment->program?->name_ar ?? '-' }}</h3>
                                @php
                                    $enrollStatusConfig = [
                                        'active' => ['label' => 'نشط', 'bg' => 'bg-green-100', 'text' => 'text-green-700'],
                                        'pending' => ['label' => 'معلق', 'bg' => 'bg-amber-100', 'text' => 'text-amber-700'],
                                        'completed' => ['label' => 'مكتمل', 'bg' => 'bg-blue-100', 'text' => 'text-blue-700'],
                                    ];
                                    $eStatus = $enrollment->status?->value ?? 'active';
                                    $eConf = $enrollStatusConfig[$eStatus] ?? ['label' => $eStatus, 'bg' => 'bg-gray-100', 'text' => 'text-gray-700'];
                                @endphp
                                <span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium {{ $eConf['bg'] }} {{ $eConf['text'] }}">
                                    {{ __($eConf['label']) }}
                                </span>
                            </div>
                            <div class="space-y-1.5 text-xs text-[#64748B]">
                                @if($enrollment->group)
                                    <div class="flex items-center gap-2">
                                        <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="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"/>
                                        </svg>
                                        <span>{{ $enrollment->group->name_ar }}</span>
                                    </div>
                                @endif
                                @if($enrollment->enrolled_at)
                                    <div class="flex items-center gap-2">
                                        <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="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
                                        </svg>
                                        <span dir="ltr">{{ $enrollment->enrolled_at?->format('Y-m-d') }}</span>
                                    </div>
                                @endif
                            </div>
                        </div>
                    @endforeach
                </div>
            @endif
        @endif

        {{-- Evaluations Tab --}}
        @if($activeTab === 'evaluations')
            @if($evaluations->isEmpty())
                <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-8 text-center">
                    <svg class="w-10 h-10 text-gray-200 mx-auto mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
                    </svg>
                    <p class="text-sm text-[#64748B]">{{ __('لا توجد تقييمات بعد') }}</p>
                </div>
            @else
                <div class="space-y-3">
                    @foreach($evaluations as $evaluation)
                        <a href="{{ route('parent.evaluations.show', $evaluation) }}" wire:navigate
                           class="block bg-white rounded-2xl shadow-sm border border-gray-100 p-4 hover:shadow-md transition-shadow">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-sm font-medium text-[#0F172A]">{{ __('تقييم') }} {{ $evaluation->evaluation_date?->translatedFormat('F Y') }}</p>
                                    <p class="text-xs text-[#64748B] mt-0.5">{{ $evaluation->evaluator?->name ?? '' }}</p>
                                </div>
                                <div class="flex items-center gap-2">
                                    <span class="text-lg font-bold text-[#2563EB]" dir="ltr">{{ $evaluation->overall_score ?? '--' }}</span>
                                    <span class="text-xs text-[#64748B]">/10</span>
                                    <svg class="w-4 h-4 text-[#64748B] rtl:rotate-180" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
                                    </svg>
                                </div>
                            </div>
                        </a>
                    @endforeach
                </div>
            @endif
        @endif
    </div>
</div>
