<div>
    @if($session->status === 'scheduled')
    <button wire:click="open" class="px-3 py-2.5 text-xs bg-yellow-100 text-yellow-700 rounded-lg hover:bg-yellow-200 active:bg-yellow-300 transition-colors">
        {{ __('إعادة جدولة') }}
    </button>
    @endif

    @if($showModal)
    <div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4" wire:click.self="$set('showModal', false)">
        <div class="bg-white rounded-xl shadow-xl w-full max-w-md p-4 sm:p-6">
            <div class="flex items-center justify-between mb-4">
                <h3 class="text-lg font-bold text-gray-800">{{ __('إعادة جدولة الحصة') }}</h3>
                <button wire:click="$set('showModal', false)" class="flex items-center justify-center w-8 h-8 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 active:bg-gray-200 transition-colors" aria-label="إغلاق">
                    <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="M6 18L18 6M6 6l12 12"/></svg>
                </button>
            </div>

            <div class="space-y-4">
                <div>
                    <label class="block text-sm text-gray-600 mb-1">{{ __('التاريخ الجديد') }}</label>
                    <input type="date" wire:model="newDate" dir="ltr" class="w-full rounded-lg border-gray-300 text-sm py-2.5">
                    @error('newDate') <p class="text-xs text-red-500 mt-1">{{ $message }}</p> @enderror
                </div>

                <div class="grid grid-cols-2 gap-3">
                    <div>
                        <label class="block text-sm text-gray-600 mb-1">{{ __('من') }}</label>
                        <input type="time" wire:model="newStartTime" dir="ltr" class="w-full rounded-lg border-gray-300 text-sm py-2.5">
                        @error('newStartTime') <p class="text-xs text-red-500 mt-1">{{ $message }}</p> @enderror
                    </div>
                    <div>
                        <label class="block text-sm text-gray-600 mb-1">{{ __('إلى') }}</label>
                        <input type="time" wire:model="newEndTime" dir="ltr" class="w-full rounded-lg border-gray-300 text-sm py-2.5">
                        @error('newEndTime') <p class="text-xs text-red-500 mt-1">{{ $message }}</p> @enderror
                    </div>
                </div>

                <div>
                    <label class="block text-sm text-gray-600 mb-1">{{ __('السبب') }} *</label>
                    <textarea wire:model="reason" rows="2" class="w-full rounded-lg border-gray-300 text-sm py-2.5"
                              placeholder="{{ __('سبب إعادة الجدولة') }}"></textarea>
                    @error('reason') <p class="text-xs text-red-500 mt-1">{{ $message }}</p> @enderror
                </div>
            </div>

            <div class="flex flex-col-reverse sm:flex-row gap-2 sm:gap-2 sm:justify-end mt-6">
                <button wire:click="$set('showModal', false)" class="w-full sm:w-auto px-4 py-2.5 text-sm text-gray-600 hover:text-gray-800 rounded-lg hover:bg-gray-100 active:bg-gray-200 transition-colors">
                    {{ __('إلغاء') }}
                </button>
                <button wire:click="reschedule" wire:loading.attr="disabled"
                        class="w-full sm:w-auto px-4 py-2.5 text-sm text-white bg-yellow-600 rounded-lg hover:bg-yellow-700 active:bg-yellow-800 disabled:opacity-50 transition-colors">
                    <span wire:loading.remove wire:target="reschedule">{{ __('تأكيد') }}</span>
                    <span wire:loading wire:target="reschedule">{{ __('جارٍ...') }}</span>
                </button>
            </div>
        </div>
    </div>
    @endif
</div>
