<?php
    $enableCategoryService = false;
?>

<div class="ml-[280px] min-h-screen space-y-6"> 

    <!-- PAGE HEADER -->
    <div class="flex items-center justify-between">
        <div>
            <h2 class="text-3xl font-bold text-gray-900">Edit Project</h2>
            <p class="text-sm text-gray-500 mt-1">
                Update and manage your project showcase
            </p>
        </div>
    </div>

    <form wire:submit.prevent="update" class="space-y-8 bg-white p-8 rounded-2xl border shadow-sm"
        enctype="multipart/form-data">

        <!-- ================= BASIC INFO ================= -->
        <div class="space-y-6">
            <h3 class="text-lg font-semibold text-gray-900 border-b pb-2">
                Basic Information
            </h3>

            <!-- CATEGORY & SERVICE -->
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($enableCategoryService): ?>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <label class="text-sm font-medium text-gray-700">Category</label>
                        <select wire:model.live="service_category_id"
                            class="mt-1 w-full rounded-xl border px-4 py-2
                       focus:ring-2 focus:ring-[#f38121] focus:outline-none">
                            <option value="">Select Category</option>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($category->id); ?>">
                                    <?php echo e($category->name); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </select>
                    </div>

                    <div>
                        <label class="text-sm font-medium text-gray-700">Service</label>
                        <select wire:model.live="service_id"
                            class="mt-1 w-full rounded-xl border px-4 py-2
                       focus:ring-2 focus:ring-[#f38121] focus:outline-none">
                            <option value="">Select Service</option>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $services; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $service): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($service->id); ?>">
                                    <?php echo e($service->title); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </select>
                    </div>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>


            <!-- MINI TEXT -->
            <div>
                <label class="text-sm font-medium text-gray-700">Client Name</label>
                <input wire:model.defer="client_name" class="mt-1 w-full rounded-xl border px-4 py-2">
            </div>

            <!-- TITLE -->
            <div>
                <label class="text-sm font-medium text-gray-700">Project Title</label>
                <input wire:model.defer="title" class="mt-1 w-full rounded-xl border px-4 py-2">
            </div>
        </div>

        <!-- ================= ROTATING TEXT ================= -->
        <div class="space-y-4">
            <h3 class="text-lg font-semibold text-gray-900 border-b pb-2">
                Rotating Highlights
            </h3>

            <div class="flex gap-3" wire:keydown.enter.stop.prevent="addRotatingText">
                <input type="text" wire:model.live="rotatingTextInput" placeholder="Type & press Enter"
                    class="flex-1 rounded-xl border px-4 py-2" />

                <button type="button" wire:click="addRotatingText"
                    class="px-5 py-2 rounded-xl bg-[#f38121] text-white">
                    Add
                </button>
            </div>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(count($rotating_text)): ?>
                <div class="flex flex-wrap gap-2">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $rotating_text; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $text): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <span wire:key="rotating-<?php echo e($index); ?>"
                            class="inline-flex items-center gap-2
                                   bg-gray-100 border px-3 py-1.5 rounded-full text-sm">
                            <?php echo e($text); ?>


                            <button type="button" wire:click="removeRotatingText(<?php echo e($index); ?>)"
                                class="text-gray-400 hover:text-red-600 font-bold">
                                ×
                            </button>
                        </span>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>

        <!-- ================= HERO MEDIA ================= -->
        <div class="space-y-6">
            <h3 class="text-lg font-semibold text-gray-900 border-b pb-2">
                Hero Media
            </h3>

            <select wire:model.live="hero_media_type" class="w-full rounded-xl border px-4 py-2">
                <option value="image">Hero Image</option>
                <option value="video">Hero Video</option>
            </select>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($hero_media_type === 'image'): ?>
                <div>
                    <input type="file" wire:model="hero_image" accept="image/*"
                        class="w-full rounded-xl border px-4 py-2">

                    <!-- New preview -->
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($hero_image): ?>
                        <img src="<?php echo e($hero_image->temporaryUrl()); ?>" class="mt-4 w-full max-w-sm rounded-xl border">
                    <?php elseif($hero_media): ?>
                        <img src="<?php echo e(asset($hero_media)); ?>" class="mt-4 w-full max-w-sm rounded-xl border">
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            <?php else: ?>
                <div>
                    <input type="text" wire:model.live="hero_media" class="w-full rounded-xl border px-4 py-2">

                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($hero_media): ?>
                        <video controls class="mt-4 w-full rounded-xl border">
                            <source src="<?php echo e($hero_media); ?>" type="video/mp4">
                        </video>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>

        <!-- ================= SETTINGS ================= -->
        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-4 border-t">
            <input type="number" wire:model.defer="position" placeholder="Position"
                class="w-full rounded-xl border px-4 py-2">

            <label class="flex items-center gap-3 text-sm">
                <input type="checkbox" wire:model="status">
                Active Project
            </label>
        </div>

        <!-- ================= ACTION ================= -->
        <div class="flex justify-end pt-6">
            <button type="submit"
                class="bg-[#f38121] hover:bg-[#e37218]
                           text-white px-8 py-3 rounded-xl font-semibold">
                Update Project
            </button>
        </div>

    </form>
</div>
<?php /**PATH /home/eggfirst/public_html/video.eggfirst.com/resources/views/livewire/admin/projects/project-edit.blade.php ENDPATH**/ ?>