<div class="space-y-8">

    {{-- ─── Progress Bar ─────────────────────────────────────────── --}}
    <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-6">
        <div class="flex items-center justify-between mb-4">
            @foreach($this->getStepLabels() as $step => $label)
                <button
                    wire:click="goToStep({{ $step }})"
                    @class([
                        'flex flex-col items-center gap-1.5 group transition-all duration-200',
                        'cursor-pointer' => $step <= $currentStep,
                        'cursor-not-allowed opacity-50' => $step > $currentStep,
                    ])
                    @if($step > $currentStep) disabled @endif
                >
                    <div @class([
                        'w-9 h-9 rounded-full flex items-center justify-center text-sm font-bold transition-all duration-300',
                        'bg-gradient-to-br from-blue-600 to-indigo-700 text-white shadow-md shadow-blue-200' => $step === $currentStep,
                        'bg-green-500 text-white' => $step < $currentStep,
                        'bg-gray-200 text-gray-500' => $step > $currentStep,
                    ])>
                        @if($step < $currentStep)
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7"/>
                            </svg>
                        @else
                            {{ $step }}
                        @endif
                    </div>
                    <span @class([
                        'text-xs font-medium hidden sm:block',
                        'text-blue-700' => $step === $currentStep,
                        'text-green-600' => $step < $currentStep,
                        'text-gray-400' => $step > $currentStep,
                    ])>{{ $label }}</span>
                </button>

                @if(!$loop->last)
                    <div @class([
                        'flex-1 h-0.5 mx-2 rounded-full transition-all duration-500',
                        'bg-green-400' => $step < $currentStep,
                        'bg-gray-200' => $step >= $currentStep,
                    ])></div>
                @endif
            @endforeach
        </div>

        {{-- Progress percentage --}}
        <div class="w-full bg-gray-100 rounded-full h-1.5 overflow-hidden">
            <div class="bg-gradient-to-l from-blue-600 to-indigo-600 h-full rounded-full transition-all duration-500 ease-out"
                 style="width: {{ (($currentStep - 1) / ($totalSteps - 1)) * 100 }}%"></div>
        </div>
    </div>

    {{-- ─── Step Content ─────────────────────────────────────────── --}}
    <div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">

        {{-- Step 1: Welcome --}}
        @if($currentStep === 1)
        <div class="p-8">
            <div class="text-center mb-8">
                <div class="w-20 h-20 bg-gradient-to-br from-blue-100 to-indigo-100 rounded-full flex items-center justify-center mx-auto mb-4">
                    <svg class="w-10 h-10 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
                    </svg>
                </div>
                <h2 class="text-2xl font-bold text-gray-800 mb-2">{{ __('مرحباً بك في الكابتن!') }}</h2>
                <p class="text-gray-500 max-w-lg mx-auto leading-relaxed">
                    {{ __('سنقوم الآن بإعداد النظام خطوة بخطوة. ستحتاج لإدخال بيانات أكاديميتك الأساسية: الفروع، الأنشطة، البرامج، والإعدادات العامة.') }}
                </p>
            </div>

            <div class="max-w-md mx-auto space-y-4">
                <div>
                    <label for="academyNameAr" class="block text-sm font-medium text-gray-700 mb-1">
                        {{ __('اسم الأكاديمية بالعربية') }} <span class="text-red-500">*</span>
                    </label>
                    <input type="text" id="academyNameAr" wire:model="academyNameAr"
                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 text-lg p-3"
                           placeholder="{{ __('مثال: أكاديمية الكابتن الرياضية') }}">
                    @error('academyNameAr')
                        <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                    @enderror
                </div>

                <div>
                    <label for="academyName" class="block text-sm font-medium text-gray-700 mb-1">
                        {{ __('اسم الأكاديمية بالإنجليزية') }}
                    </label>
                    <input type="text" id="academyName" wire:model="academyName" dir="ltr"
                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 p-3"
                           placeholder="El Captain Sports Academy">
                    @error('academyName')
                        <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                    @enderror
                </div>
            </div>
        </div>
        @endif

        {{-- Step 2: Branches --}}
        @if($currentStep === 2)
        <div class="p-8">
            <div class="mb-6">
                <h2 class="text-xl font-bold text-gray-800">{{ __('الفروع') }}</h2>
                <p class="text-sm text-gray-500 mt-1">{{ __('أضف فروع الأكاديمية. يجب إضافة فرع واحد على الأقل.') }}</p>
            </div>

            @error('branches')
                <div class="mb-4 rounded-lg bg-red-50 p-3 border border-red-200">
                    <p class="text-sm text-red-700">{{ $message }}</p>
                </div>
            @enderror

            <div class="space-y-4">
                @foreach($branches as $index => $branch)
                    <div class="border border-gray-200 rounded-xl p-5 relative group hover:border-blue-200 transition-colors"
                         wire:key="branch-{{ $index }}">
                        {{-- Remove button --}}
                        @if(count($branches) > 1)
                            <button wire:click="removeBranch({{ $index }})" type="button"
                                    class="absolute top-3 start-3 w-7 h-7 rounded-full bg-red-50 text-red-500 hover:bg-red-100 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                                </svg>
                            </button>
                        @endif

                        {{-- Main badge --}}
                        @if($branch['is_main'])
                            <span class="absolute top-3 end-3 text-xs bg-blue-100 text-blue-700 font-medium px-2 py-0.5 rounded-full">
                                {{ __('الفرع الرئيسي') }}
                            </span>
                        @endif

                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الاسم بالعربية') }} <span class="text-red-500">*</span>
                                </label>
                                <input type="text" wire:model="branches.{{ $index }}.name_ar"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="{{ __('مثال: الفرع الرئيسي') }}">
                                @error("branches.{$index}.name_ar")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الاسم بالإنجليزية') }}
                                </label>
                                <input type="text" wire:model="branches.{{ $index }}.name" dir="ltr"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="Main Branch">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('العنوان') }}
                                </label>
                                <input type="text" wire:model="branches.{{ $index }}.address"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="{{ __('شارع، منطقة، مدينة') }}">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الهاتف') }}
                                </label>
                                <input type="text" wire:model="branches.{{ $index }}.phone" dir="ltr"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="01012345678">
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>

            <button wire:click="addBranch" type="button"
                    class="mt-4 w-full border-2 border-dashed border-gray-300 rounded-xl p-4 text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors flex items-center justify-center gap-2">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
                </svg>
                {{ __('إضافة فرع') }}
            </button>
        </div>
        @endif

        {{-- Step 3: Activities --}}
        @if($currentStep === 3)
        <div class="p-8">
            <div class="mb-6">
                <h2 class="text-xl font-bold text-gray-800">{{ __('الأنشطة') }}</h2>
                <p class="text-sm text-gray-500 mt-1">{{ __('أضف الأنشطة الرياضية أو التعليمية التي تقدمها الأكاديمية (مطلوب نشاط واحد على الأقل).') }}</p>
            </div>

            @error('activities')
                <div class="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">{{ $message }}</div>
            @enderror

            <div class="space-y-4">
                @foreach($activities as $index => $activity)
                    <div class="border border-gray-200 rounded-xl p-5 relative group hover:border-blue-200 transition-colors"
                         wire:key="activity-{{ $index }}">
                        <button wire:click="removeActivity({{ $index }})" type="button"
                                class="absolute top-3 start-3 w-7 h-7 rounded-full bg-red-50 text-red-500 hover:bg-red-100 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                            </svg>
                        </button>

                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الاسم بالعربية') }} <span class="text-red-500">*</span>
                                </label>
                                <input type="text" wire:model="activities.{{ $index }}.name_ar"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="{{ __('مثال: كرة القدم') }}">
                                @error("activities.{$index}.name_ar")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الاسم بالإنجليزية') }}
                                </label>
                                <input type="text" wire:model="activities.{{ $index }}.name" dir="ltr"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="Football">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('التصنيف') }} <span class="text-red-500">*</span>
                                </label>
                                <select wire:model="activities.{{ $index }}.category"
                                        class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
                                    @foreach($this->getActivityCategories() as $value => $label)
                                        <option value="{{ $value }}">{{ $label }}</option>
                                    @endforeach
                                </select>
                                @error("activities.{$index}.category")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('وصف مختصر') }}
                                </label>
                                <input type="text" wire:model="activities.{{ $index }}.description"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="{{ __('وصف اختياري للنشاط') }}">
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>

            @if(empty($activities))
                <div class="text-center py-8 border-2 border-dashed border-gray-200 rounded-xl">
                    <svg class="w-12 h-12 text-gray-300 mx-auto mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"/>
                    </svg>
                    <p class="text-gray-400 text-sm">{{ __('لم تضف أنشطة بعد. أضف نشاطاً أو تخطَّ هذه الخطوة.') }}</p>
                </div>
            @endif

            <button wire:click="addActivity" type="button"
                    class="mt-4 w-full border-2 border-dashed border-gray-300 rounded-xl p-4 text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors flex items-center justify-center gap-2">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
                </svg>
                {{ __('إضافة نشاط') }}
            </button>
        </div>
        @endif

        {{-- Step 4: Programs --}}
        @if($currentStep === 4)
        <div class="p-8">
            <div class="mb-6">
                <h2 class="text-xl font-bold text-gray-800">{{ __('البرامج التدريبية') }}</h2>
                <p class="text-sm text-gray-500 mt-1">{{ __('أضف البرامج التدريبية مع أسعارها. مطلوب برنامج واحد على الأقل مع تحديد الرسوم الشهرية.') }}</p>
            </div>

            @error('programs')
                <div class="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">{{ $message }}</div>
            @enderror

            @if(empty($activities))
                <div class="text-center py-8 border-2 border-dashed border-gray-200 rounded-xl">
                    <svg class="w-12 h-12 text-amber-300 mx-auto mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" 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>
                    <p class="text-gray-500 text-sm">{{ __('يجب إضافة أنشطة أولاً في الخطوة السابقة لربط البرامج بها.') }}</p>
                </div>
            @else
                <div class="space-y-4">
                    @foreach($programs as $index => $program)
                        <div class="border border-gray-200 rounded-xl p-5 relative group hover:border-blue-200 transition-colors"
                             wire:key="program-{{ $index }}">
                            <button wire:click="removeProgram({{ $index }})" type="button"
                                    class="absolute top-3 start-3 w-7 h-7 rounded-full bg-red-50 text-red-500 hover:bg-red-100 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                                </svg>
                            </button>

                            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
                                <div class="sm:col-span-2 lg:col-span-1">
                                    <label class="block text-sm font-medium text-gray-700 mb-1">
                                        {{ __('اسم البرنامج') }} <span class="text-red-500">*</span>
                                    </label>
                                    <input type="text" wire:model="programs.{{ $index }}.name_ar"
                                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                           placeholder="{{ __('مثال: ناشئين كرة قدم') }}">
                                    @error("programs.{$index}.name_ar")
                                        <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                    @enderror
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">
                                        {{ __('النشاط') }} <span class="text-red-500">*</span>
                                    </label>
                                    <select wire:model="programs.{{ $index }}.activity_index"
                                            class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
                                        @foreach($activities as $aIdx => $act)
                                            <option value="{{ $aIdx }}">{{ $act['name_ar'] ?: __('نشاط') . ' ' . ($aIdx + 1) }}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">
                                        {{ __('المدة (شهر)') }} <span class="text-red-500">*</span>
                                    </label>
                                    <input type="number" wire:model="programs.{{ $index }}.duration_months" dir="ltr"
                                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                           min="1" max="24">
                                    @error("programs.{$index}.duration_months")
                                        <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                    @enderror
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">
                                        {{ __('الحد الأقصى') }} <span class="text-red-500">*</span>
                                    </label>
                                    <input type="number" wire:model="programs.{{ $index }}.max_participants" dir="ltr"
                                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                           min="1" max="500" placeholder="20">
                                    @error("programs.{$index}.max_participants")
                                        <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                    @enderror
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">
                                        {{ __('الرسوم الشهرية (ج.م)') }} <span class="text-red-500">*</span>
                                    </label>
                                    <input type="number" wire:model="programs.{{ $index }}.monthly_fee" dir="ltr"
                                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                           min="0" step="0.01" placeholder="500.00">
                                    @error("programs.{$index}.monthly_fee")
                                        <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                    @enderror
                                </div>
                            </div>
                        </div>
                    @endforeach
                </div>

                @if(empty($programs))
                    <div class="text-center py-8 border-2 border-dashed border-gray-200 rounded-xl">
                        <svg class="w-12 h-12 text-gray-300 mx-auto mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
                        </svg>
                        <p class="text-gray-400 text-sm">{{ __('لم تضف برامج بعد. أضف برنامجاً أو تخطَّ هذه الخطوة.') }}</p>
                    </div>
                @endif

                <button wire:click="addProgram" type="button"
                        class="mt-4 w-full border-2 border-dashed border-gray-300 rounded-xl p-4 text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors flex items-center justify-center gap-2">
                    <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
                    </svg>
                    {{ __('إضافة برنامج') }}
                </button>
            @endif
        </div>
        @endif

        {{-- Step 5: Facilities --}}
        @if($currentStep === 5)
        <div class="p-8">
            <div class="mb-6">
                <h2 class="text-xl font-bold text-gray-800">{{ __('المنشآت') }}</h2>
                <p class="text-sm text-gray-500 mt-1">{{ __('أضف الملاعب والمنشآت الرياضية. حدد الإيجار الشهري وساعات العمل لحساب نقطة التعادل.') }}</p>
                <div class="mt-2 p-3 bg-amber-50 border border-amber-200 rounded-lg text-xs text-amber-700">
                    <strong>{{ __('مهم:') }}</strong> {{ __('الإيجار الشهري يستخدم في حساب الأرباح والخسائر. إذا كانت المنشأة ملكك أدخل 0.') }}
                </div>
            </div>

            @error('facilities')
                <div class="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700">{{ $message }}</div>
            @enderror

            <div class="space-y-4">
                @foreach($facilities as $index => $facility)
                    <div class="border border-gray-200 rounded-xl p-5 relative group hover:border-blue-200 transition-colors"
                         wire:key="facility-{{ $index }}">
                        <button wire:click="removeFacility({{ $index }})" type="button"
                                class="absolute top-3 start-3 w-7 h-7 rounded-full bg-red-50 text-red-500 hover:bg-red-100 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                            </svg>
                        </button>

                        <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('اسم المنشأة') }} <span class="text-red-500">*</span>
                                </label>
                                <input type="text" wire:model="facilities.{{ $index }}.name_ar"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="{{ __('مثال: الملعب الرئيسي') }}">
                                @error("facilities.{$index}.name_ar")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('النوع') }} <span class="text-red-500">*</span>
                                </label>
                                <select wire:model="facilities.{{ $index }}.type"
                                        class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
                                    @foreach($this->getFacilityTypes() as $value => $label)
                                        <option value="{{ $value }}">{{ $label }}</option>
                                    @endforeach
                                </select>
                                @error("facilities.{$index}.type")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الإيجار الشهري (ج.م)') }} <span class="text-red-500">*</span>
                                </label>
                                <input type="number" wire:model="facilities.{{ $index }}.monthly_cost" dir="ltr"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       min="0" step="0.01" placeholder="5000.00">
                                @error("facilities.{$index}.monthly_cost")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('السعة') }}
                                </label>
                                <input type="number" wire:model="facilities.{{ $index }}.capacity" dir="ltr"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       min="1" placeholder="50">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('ساعات العمل') }}
                                </label>
                                <div class="flex items-center gap-2">
                                    <input type="time" wire:model="facilities.{{ $index }}.operating_start" dir="ltr"
                                           class="flex-1 rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 text-sm">
                                    <span class="text-gray-400">—</span>
                                    <input type="time" wire:model="facilities.{{ $index }}.operating_end" dir="ltr"
                                           class="flex-1 rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 text-sm">
                                </div>
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('العنوان') }}
                                </label>
                                <input type="text" wire:model="facilities.{{ $index }}.address"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="{{ __('عنوان المنشأة') }}">
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>

            @if(empty($facilities))
                <div class="text-center py-8 border-2 border-dashed border-gray-200 rounded-xl">
                    <svg class="w-12 h-12 text-gray-300 mx-auto mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" 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-red-500 text-sm font-medium">{{ __('يجب إضافة منشأة واحدة على الأقل') }}</p>
                    <p class="text-gray-400 text-xs mt-1">{{ __('أضف الملعب أو القاعة التي تعمل فيها') }}</p>
                </div>
            @endif

            <button wire:click="addFacility" type="button"
                    class="mt-4 w-full border-2 border-dashed border-gray-300 rounded-xl p-4 text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors flex items-center justify-center gap-2">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
                </svg>
                {{ __('إضافة منشأة') }}
            </button>
        </div>
        @endif

        {{-- Step 6: Users --}}
        @if($currentStep === 6)
        <div class="p-8">
            <div class="mb-6">
                <h2 class="text-xl font-bold text-gray-800">{{ __('المستخدمين') }}</h2>
                <p class="text-sm text-gray-500 mt-1">{{ __('أضف حسابات الموظفين. كلمة المرور الافتراضية هي "password" وسيُطلب منهم تغييرها عند أول تسجيل دخول.') }}</p>
            </div>

            <div class="space-y-4">
                @foreach($users as $index => $user)
                    <div class="border border-gray-200 rounded-xl p-5 relative group hover:border-blue-200 transition-colors"
                         wire:key="user-{{ $index }}">
                        <button wire:click="removeUser({{ $index }})" type="button"
                                class="absolute top-3 start-3 w-7 h-7 rounded-full bg-red-50 text-red-500 hover:bg-red-100 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                            </svg>
                        </button>

                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الاسم') }} <span class="text-red-500">*</span>
                                </label>
                                <input type="text" wire:model="users.{{ $index }}.name"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="{{ __('اسم المستخدم') }}">
                                @error("users.{$index}.name")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('البريد الإلكتروني') }} <span class="text-red-500">*</span>
                                </label>
                                <input type="email" wire:model="users.{{ $index }}.email" dir="ltr"
                                       class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                                       placeholder="user@example.com">
                                @error("users.{$index}.email")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الدور') }} <span class="text-red-500">*</span>
                                </label>
                                <select wire:model="users.{{ $index }}.role"
                                        class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
                                    @foreach($this->getUserRoles() as $value => $label)
                                        <option value="{{ $value }}">{{ $label }}</option>
                                    @endforeach
                                </select>
                                @error("users.{$index}.role")
                                    <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                                @enderror
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">
                                    {{ __('الفرع') }} <span class="text-red-500">*</span>
                                </label>
                                <select wire:model="users.{{ $index }}.branch_index"
                                        class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
                                    @foreach($branches as $bIdx => $b)
                                        <option value="{{ $bIdx }}">{{ $b['name_ar'] ?: __('فرع') . ' ' . ($bIdx + 1) }}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>

            @if(empty($users))
                <div class="text-center py-8 border-2 border-dashed border-gray-200 rounded-xl">
                    <svg class="w-12 h-12 text-gray-300 mx-auto mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" 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 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
                    </svg>
                    <p class="text-gray-400 text-sm">{{ __('لم تضف مستخدمين بعد. أضف مستخدماً أو تخطَّ هذه الخطوة.') }}</p>
                </div>
            @endif

            <button wire:click="addUser" type="button"
                    class="mt-4 w-full border-2 border-dashed border-gray-300 rounded-xl p-4 text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors flex items-center justify-center gap-2">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
                </svg>
                {{ __('إضافة مستخدم') }}
            </button>
        </div>
        @endif

        {{-- Step 7: Settings --}}
        @if($currentStep === 7)
        <div class="p-8">
            <div class="mb-6">
                <h2 class="text-xl font-bold text-gray-800">{{ __('الإعدادات العامة') }}</h2>
                <p class="text-sm text-gray-500 mt-1">{{ __('اضبط الإعدادات الأساسية للنظام. يمكنك تعديلها لاحقاً من صفحة الإعدادات.') }}</p>
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-2 gap-6 max-w-2xl">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">
                        {{ __('العملة الافتراضية') }}
                    </label>
                    <select wire:model="defaultCurrency"
                            class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
                        <option value="EGP">{{ __('جنيه مصري (EGP)') }}</option>
                        <option value="SAR">{{ __('ريال سعودي (SAR)') }}</option>
                        <option value="AED">{{ __('درهم إماراتي (AED)') }}</option>
                        <option value="USD">{{ __('دولار أمريكي (USD)') }}</option>
                    </select>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">
                        {{ __('المنطقة الزمنية') }}
                    </label>
                    <select wire:model="timezone"
                            class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
                        <option value="Africa/Cairo">{{ __('القاهرة (UTC+2)') }}</option>
                        <option value="Asia/Riyadh">{{ __('الرياض (UTC+3)') }}</option>
                        <option value="Asia/Dubai">{{ __('دبي (UTC+4)') }}</option>
                        <option value="UTC">{{ __('UTC') }}</option>
                    </select>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">
                        {{ __('فترة السماح للمشتركين (دقيقة)') }}
                    </label>
                    <input type="number" wire:model="gracePeriodParticipant" dir="ltr"
                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                           min="0" max="60">
                    <p class="mt-1 text-xs text-gray-400">{{ __('الوقت المسموح للتأخر قبل تسجيل "متأخر"') }}</p>
                    @error('gracePeriodParticipant')
                        <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                    @enderror
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">
                        {{ __('فترة السماح للمدربين (دقيقة)') }}
                    </label>
                    <input type="number" wire:model="gracePeriodTrainer" dir="ltr"
                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                           min="0" max="60">
                    <p class="mt-1 text-xs text-gray-400">{{ __('الوقت المسموح لتأخر المدربين') }}</p>
                    @error('gracePeriodTrainer')
                        <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                    @enderror
                </div>

                <div class="sm:col-span-2">
                    <label class="block text-sm font-medium text-gray-700 mb-1">
                        {{ __('الحد الأقصى للخصم (%)') }}
                    </label>
                    <input type="number" wire:model="maxDiscountPercent" dir="ltr"
                           class="w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
                           min="0" max="100">
                    <p class="mt-1 text-xs text-gray-400">{{ __('أقصى نسبة خصم مسموحة على أي عملية بيع') }}</p>
                    @error('maxDiscountPercent')
                        <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                    @enderror
                </div>
            </div>
        </div>
        @endif

        {{-- Step 8: Done --}}
        @if($currentStep === 8)
        <div class="p-8">
            <div class="text-center mb-8">
                <div class="w-20 h-20 bg-gradient-to-br from-green-100 to-emerald-100 rounded-full flex items-center justify-center mx-auto mb-4">
                    <svg class="w-10 h-10 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
                    </svg>
                </div>
                <h2 class="text-2xl font-bold text-gray-800 mb-2">{{ __('جاهز للانطلاق!') }}</h2>
                <p class="text-gray-500 max-w-lg mx-auto">
                    {{ __('تم تجهيز جميع البيانات. راجع الملخص أدناه ثم اضغط "إتمام الإعداد" لحفظ كل شيء.') }}
                </p>
            </div>

            {{-- Summary --}}
            <div class="max-w-lg mx-auto space-y-3">
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <span class="text-sm font-medium text-gray-700">{{ __('الأكاديمية') }}</span>
                    <span class="text-sm text-gray-900 font-semibold">{{ $academyNameAr }}</span>
                </div>
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <span class="text-sm font-medium text-gray-700">{{ __('الفروع') }}</span>
                    <span class="text-sm text-blue-600 font-semibold">{{ count($branches) }}</span>
                </div>
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <span class="text-sm font-medium text-gray-700">{{ __('الأنشطة') }}</span>
                    <span class="text-sm text-blue-600 font-semibold">{{ count($activities) }}</span>
                </div>
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <span class="text-sm font-medium text-gray-700">{{ __('البرامج') }}</span>
                    <span class="text-sm text-blue-600 font-semibold">{{ count($programs) }}</span>
                </div>
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <span class="text-sm font-medium text-gray-700">{{ __('المنشآت') }}</span>
                    <span class="text-sm text-blue-600 font-semibold">{{ count($facilities) }}</span>
                </div>
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <span class="text-sm font-medium text-gray-700">{{ __('المستخدمين الجدد') }}</span>
                    <span class="text-sm text-blue-600 font-semibold">{{ count($users) }}</span>
                </div>
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <span class="text-sm font-medium text-gray-700">{{ __('العملة') }}</span>
                    <span class="text-sm text-gray-900">{{ $defaultCurrency }}</span>
                </div>
            </div>
        </div>
        @endif
    </div>

    {{-- ─── Navigation Buttons ───────────────────────────────────── --}}
    <div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-6">
        <div class="flex items-center justify-between">
            {{-- Back --}}
            <div>
                @if($currentStep > 1)
                    <button wire:click="previousStep" type="button"
                            wire:loading.attr="disabled"
                            class="inline-flex items-center gap-2 px-5 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-xl hover:bg-gray-50 focus:ring-2 focus:ring-blue-200 transition-all">
                        <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>
                        {{ __('السابق') }}
                    </button>
                @endif
            </div>

            {{-- Next / Complete --}}
            <div>
                @if($currentStep < $totalSteps)
                    <button wire:click="nextStep" type="button"
                            wire:loading.attr="disabled"
                            wire:target="nextStep"
                            class="inline-flex items-center gap-2 px-6 py-2.5 text-sm font-medium text-white bg-gradient-to-l from-blue-600 to-indigo-600 rounded-xl hover:from-blue-700 hover:to-indigo-700 focus:ring-2 focus:ring-blue-200 shadow-md shadow-blue-200 transition-all">
                        <span wire:loading.remove wire:target="nextStep">{{ __('التالي') }}</span>
                        <span wire:loading wire:target="nextStep">{{ __('جارٍ التحقق...') }}</span>
                        <svg wire:loading.remove wire:target="nextStep" class="w-4 h-4" 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>
                    </button>
                @else
                    <button wire:click="completeSetup" type="button"
                            wire:loading.attr="disabled"
                            wire:target="completeSetup"
                            class="inline-flex items-center gap-2 px-8 py-3 text-sm font-bold text-white bg-gradient-to-l from-green-600 to-emerald-600 rounded-xl hover:from-green-700 hover:to-emerald-700 focus:ring-2 focus:ring-green-200 shadow-md shadow-green-200 transition-all">
                        <span wire:loading.remove wire:target="completeSetup">{{ __('إتمام الإعداد') }}</span>
                        <span wire:loading wire:target="completeSetup">{{ __('جارٍ الحفظ...') }}</span>
                        <svg wire:loading.remove wire:target="completeSetup" class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
                        </svg>
                    </button>
                @endif
            </div>
        </div>
    </div>

    {{-- ─── Step info (assistive) ────────────────────────────────── --}}
    <div class="text-center">
        <p class="text-xs text-gray-400">
            {{ __('الخطوة') }} {{ $currentStep }} {{ __('من') }} {{ $totalSteps }}
            &mdash;
            {{ $this->getStepLabels()[$currentStep] ?? '' }}
        </p>
    </div>
</div>
