<?php
    $item = $product ?? $duplicateProduct ?? null;
    $prefillImages = old('images', $item?->images ?? []);
    $prefillFeatured = is_array($prefillImages) && count($prefillImages) > 0 ? $prefillImages[0] : null;
    $prefillGallery = is_array($prefillImages) && count($prefillImages) > 1 ? array_slice($prefillImages, 1) : [];
?>

<div class="space-y-6">
    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
        <!-- Language Tabs Container -->
        <div class="md:col-span-2">
            <div class="border-b border-gray-200 dark:border-gray-800 mb-6">
                <ul class="flex flex-wrap -mb-px text-sm font-medium text-center" id="langTabs" role="tablist">
                    <li class="mr-2" role="presentation">
                        <button type="button" class="inline-block p-4 border-b-2 rounded-t-lg text-blue-600 border-blue-600 dark:text-blue-500 dark:border-blue-500 font-semibold" id="en-tab-btn" onclick="switchLanguageTab('en')">
                            <i class="fas fa-globe-americas mr-1.5"></i> English Content
                        </button>
                    </li>
                    <li class="mr-2" role="presentation">
                        <button type="button" class="inline-block p-4 border-b-2 rounded-t-lg border-transparent hover:text-gray-600 hover:border-gray-300 dark:hover:text-gray-300 font-semibold flex items-center" id="km-tab-btn" onclick="switchLanguageTab('km')">
                            <i class="fas fa-language mr-1.5 text-lg"></i> Khmer Content
                            <?php if($item && (empty($item->name_km) || empty($item->description_km))): ?>
                                <span class="ml-2 inline-flex items-center px-1.5 py-0.5 rounded text-xxs font-bold bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400 border border-amber-200 dark:border-amber-800">
                                    <i class="fas fa-exclamation-triangle mr-1 text-[10px]"></i> Missing
                                </span>
                            <?php endif; ?>
                        </button>
                    </li>
                </ul>
            </div>

            <!-- English Content Tab -->
            <div id="en-tab-content" class="space-y-4">
                <?php if (isset($component)) { $__componentOriginal530746098e8865a2469fd5685420112b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal530746098e8865a2469fd5685420112b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.text-input','data' => ['name' => 'name','label' => 'Product Name','value' => old('name', $item?->name),'required' => true,'placeholder' => 'Enter product name']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.text-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'name','label' => 'Product Name','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('name', $item?->name)),'required' => true,'placeholder' => 'Enter product name']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $attributes = $__attributesOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__attributesOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $component = $__componentOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__componentOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
                <?php if (isset($component)) { $__componentOriginal530746098e8865a2469fd5685420112b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal530746098e8865a2469fd5685420112b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.text-input','data' => ['name' => 'short_description','label' => 'Short Description','value' => old('short_description', $item?->short_description),'placeholder' => 'Brief product description']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.text-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'short_description','label' => 'Short Description','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('short_description', $item?->short_description)),'placeholder' => 'Brief product description']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $attributes = $__attributesOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__attributesOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $component = $__componentOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__componentOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
                <?php if (isset($component)) { $__componentOriginal694712473b787cd740db4e46be9da3f9 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal694712473b787cd740db4e46be9da3f9 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.textarea','data' => ['name' => 'description','label' => 'Description','value' => old('description', $item?->description),'rows' => '5','placeholder' => 'Enter product description...']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.textarea'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'description','label' => 'Description','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('description', $item?->description)),'rows' => '5','placeholder' => 'Enter product description...']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal694712473b787cd740db4e46be9da3f9)): ?>
<?php $attributes = $__attributesOriginal694712473b787cd740db4e46be9da3f9; ?>
<?php unset($__attributesOriginal694712473b787cd740db4e46be9da3f9); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal694712473b787cd740db4e46be9da3f9)): ?>
<?php $component = $__componentOriginal694712473b787cd740db4e46be9da3f9; ?>
<?php unset($__componentOriginal694712473b787cd740db4e46be9da3f9); ?>
<?php endif; ?>
            </div>

            <!-- Khmer Content Tab -->
            <div id="km-tab-content" class="space-y-4 hidden">
                <?php if (isset($component)) { $__componentOriginal530746098e8865a2469fd5685420112b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal530746098e8865a2469fd5685420112b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.text-input','data' => ['name' => 'name_km','label' => 'Product Name (Khmer)','value' => old('name_km', $item?->name_km),'placeholder' => 'Enter product name in Khmer']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.text-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'name_km','label' => 'Product Name (Khmer)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('name_km', $item?->name_km)),'placeholder' => 'Enter product name in Khmer']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $attributes = $__attributesOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__attributesOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $component = $__componentOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__componentOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
                <?php if($item && empty($item->name_km)): ?>
                    <p class="text-xs text-amber-600 dark:text-amber-400 mt-1.5 flex items-center"><i class="fas fa-exclamation-circle mr-1"></i> Khmer Product Name is currently empty.</p>
                <?php endif; ?>

                <?php if (isset($component)) { $__componentOriginal530746098e8865a2469fd5685420112b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal530746098e8865a2469fd5685420112b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.text-input','data' => ['name' => 'short_description_km','label' => 'Short Description (Khmer)','value' => old('short_description_km', $item?->short_description_km),'placeholder' => 'Brief description in Khmer']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.text-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'short_description_km','label' => 'Short Description (Khmer)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('short_description_km', $item?->short_description_km)),'placeholder' => 'Brief description in Khmer']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $attributes = $__attributesOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__attributesOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $component = $__componentOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__componentOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>

                <?php if (isset($component)) { $__componentOriginal694712473b787cd740db4e46be9da3f9 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal694712473b787cd740db4e46be9da3f9 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.textarea','data' => ['name' => 'description_km','label' => 'Description (Khmer)','value' => old('description_km', $item?->description_km),'rows' => '5','placeholder' => 'Enter product description in Khmer...']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.textarea'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'description_km','label' => 'Description (Khmer)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('description_km', $item?->description_km)),'rows' => '5','placeholder' => 'Enter product description in Khmer...']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal694712473b787cd740db4e46be9da3f9)): ?>
<?php $attributes = $__attributesOriginal694712473b787cd740db4e46be9da3f9; ?>
<?php unset($__attributesOriginal694712473b787cd740db4e46be9da3f9); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal694712473b787cd740db4e46be9da3f9)): ?>
<?php $component = $__componentOriginal694712473b787cd740db4e46be9da3f9; ?>
<?php unset($__componentOriginal694712473b787cd740db4e46be9da3f9); ?>
<?php endif; ?>
                <?php if($item && empty($item->description_km)): ?>
                    <p class="text-xs text-amber-600 dark:text-amber-400 mt-1.5 flex items-center"><i class="fas fa-exclamation-circle mr-1"></i> Khmer Description is currently empty.</p>
                <?php endif; ?>
            </div>
        </div>

        <!-- Non-translatable settings -->
        <?php if (isset($component)) { $__componentOriginale7b240ac873e22945c281c841a0f88ab = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginale7b240ac873e22945c281c841a0f88ab = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.number-input','data' => ['name' => 'price','label' => 'Price ($)','value' => old('price', $item?->price),'required' => true,'step' => '0.01','placeholder' => '0.00']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.number-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'price','label' => 'Price ($)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('price', $item?->price)),'required' => true,'step' => '0.01','placeholder' => '0.00']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginale7b240ac873e22945c281c841a0f88ab)): ?>
<?php $attributes = $__attributesOriginale7b240ac873e22945c281c841a0f88ab; ?>
<?php unset($__attributesOriginale7b240ac873e22945c281c841a0f88ab); ?>
<?php endif; ?>
<?php if (isset($__componentOriginale7b240ac873e22945c281c841a0f88ab)): ?>
<?php $component = $__componentOriginale7b240ac873e22945c281c841a0f88ab; ?>
<?php unset($__componentOriginale7b240ac873e22945c281c841a0f88ab); ?>
<?php endif; ?>

        <?php if (isset($component)) { $__componentOriginale7b240ac873e22945c281c841a0f88ab = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginale7b240ac873e22945c281c841a0f88ab = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.number-input','data' => ['name' => 'original_price','label' => 'Original Price ($)','value' => old('original_price', $item?->original_price),'step' => '0.01','placeholder' => '0.00']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.number-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'original_price','label' => 'Original Price ($)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('original_price', $item?->original_price)),'step' => '0.01','placeholder' => '0.00']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginale7b240ac873e22945c281c841a0f88ab)): ?>
<?php $attributes = $__attributesOriginale7b240ac873e22945c281c841a0f88ab; ?>
<?php unset($__attributesOriginale7b240ac873e22945c281c841a0f88ab); ?>
<?php endif; ?>
<?php if (isset($__componentOriginale7b240ac873e22945c281c841a0f88ab)): ?>
<?php $component = $__componentOriginale7b240ac873e22945c281c841a0f88ab; ?>
<?php unset($__componentOriginale7b240ac873e22945c281c841a0f88ab); ?>
<?php endif; ?>

        <div class="md:col-span-2">
            <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Category / Subcategory</label>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <?php if (isset($component)) { $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.select-input','data' => ['name' => 'main_category_id','id' => 'main_category','label' => 'Category']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.select-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'main_category_id','id' => 'main_category','label' => 'Category']); ?>
                    <option value="">Select Category</option>
                    <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($category->id); ?>" 
                                data-subcategories='<?php echo json_encode($category->subcategories, 15, 512) ?>'
                                <?php echo e(old('main_category_id') == $category->id || ($item && (($item->categoryRelation && $item->categoryRelation->parent_id === null && $item->categoryRelation->id == $category->id) || ($item->categoryRelation && $item->categoryRelation->parent_id == $category->id))) ? 'selected' : ''); ?>>
                            <?php echo e($category->name); ?>

                        </option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $attributes = $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $component = $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>

                <?php if (isset($component)) { $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.select-input','data' => ['name' => 'subcategory_dummy','id' => 'subcategory','label' => 'Subcategory (Optional)','disabled' => !($item && $item->categoryRelation && $item->categoryRelation->parent_id)]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.select-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'subcategory_dummy','id' => 'subcategory','label' => 'Subcategory (Optional)','disabled' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(!($item && $item->categoryRelation && $item->categoryRelation->parent_id))]); ?>
                    <option value="">Select Subcategory</option>
                    <?php if($item && $item->categoryRelation && $item->categoryRelation->parent_id): ?>
                        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($category->id == $item->categoryRelation->parent_id): ?>
                                <?php $__currentLoopData = $category->subcategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subcategory): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($subcategory->id); ?>" <?php echo e(old('category_id', $item->category_id) == $subcategory->id ? 'selected' : ''); ?>>
                                        <?php echo e($subcategory->name); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $attributes = $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $component = $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>
            </div>
            <input type="hidden" id="final_category_id" name="category_id" value="<?php echo e(old('category_id', $item?->category_id)); ?>">
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
            <?php if (isset($component)) { $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.select-input','data' => ['name' => 'brand_id','label' => 'Brand']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.select-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'brand_id','label' => 'Brand']); ?>
                <option value="">Select Brand</option>
                <?php $__currentLoopData = $brands; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $brand): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($brand->id); ?>" <?php echo e(old('brand_id', $item?->brand_id) == $brand->id ? 'selected' : ''); ?>>
                        <?php echo e($brand->name); ?>

                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
             <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $attributes = $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $component = $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>

            <?php if (isset($component)) { $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.select-input','data' => ['name' => 'unit_id','label' => 'Unit']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.select-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'unit_id','label' => 'Unit']); ?>
                <option value="">Select Unit</option>
                <?php $__currentLoopData = $units; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $unit): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($unit->id); ?>" <?php echo e(old('unit_id', $item?->unit_id) == $unit->id ? 'selected' : ''); ?>>
                        <?php echo e($unit->name); ?> (<?php echo e($unit->abbreviation); ?>)
                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
             <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $attributes = $__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__attributesOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230)): ?>
<?php $component = $__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230; ?>
<?php unset($__componentOriginalf05cfa8a3a9bfe3c0fbbaf4a0e88f230); ?>
<?php endif; ?>
        </div>

        <?php if (isset($component)) { $__componentOriginal530746098e8865a2469fd5685420112b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal530746098e8865a2469fd5685420112b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.text-input','data' => ['name' => 'category','label' => 'Category Code (Legacy)','value' => old('category', $item?->category),'placeholder' => 'e.g., pillows, bedding']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.text-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'category','label' => 'Category Code (Legacy)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('category', $item?->category)),'placeholder' => 'e.g., pillows, bedding']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $attributes = $__attributesOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__attributesOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal530746098e8865a2469fd5685420112b)): ?>
<?php $component = $__componentOriginal530746098e8865a2469fd5685420112b; ?>
<?php unset($__componentOriginal530746098e8865a2469fd5685420112b); ?>
<?php endif; ?>

        <div class="flex gap-6 items-center pt-2">
            <?php if (isset($component)) { $__componentOriginalfe26a99f60f8bc4594bf63469705f3a7 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.toggle-switch','data' => ['name' => 'in_stock','label' => 'In Stock','checked' => old('in_stock', $item ? $item->in_stock : true)]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.toggle-switch'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'in_stock','label' => 'In Stock','checked' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('in_stock', $item ? $item->in_stock : true))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7)): ?>
<?php $attributes = $__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7; ?>
<?php unset($__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalfe26a99f60f8bc4594bf63469705f3a7)): ?>
<?php $component = $__componentOriginalfe26a99f60f8bc4594bf63469705f3a7; ?>
<?php unset($__componentOriginalfe26a99f60f8bc4594bf63469705f3a7); ?>
<?php endif; ?>

            <?php if (isset($component)) { $__componentOriginalfe26a99f60f8bc4594bf63469705f3a7 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.toggle-switch','data' => ['name' => 'on_sale','label' => 'On Sale','checked' => old('on_sale', $item ? $item->on_sale : false)]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.toggle-switch'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'on_sale','label' => 'On Sale','checked' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('on_sale', $item ? $item->on_sale : false))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7)): ?>
<?php $attributes = $__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7; ?>
<?php unset($__attributesOriginalfe26a99f60f8bc4594bf63469705f3a7); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalfe26a99f60f8bc4594bf63469705f3a7)): ?>
<?php $component = $__componentOriginalfe26a99f60f8bc4594bf63469705f3a7; ?>
<?php unset($__componentOriginalfe26a99f60f8bc4594bf63469705f3a7); ?>
<?php endif; ?>
        </div>



        <div class="md:col-span-2">
            <label class="block text-gray-700 dark:text-gray-300 text-sm font-semibold mb-2">
                Product Images
            </label>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div class="p-6 bg-gray-50 dark:bg-gray-900 rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-800 hover:border-blue-400 dark:hover:border-blue-600 transition-colors">
                    <?php if (isset($component)) { $__componentOriginal6384af2cfbb3fb249311eef9f601626b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal6384af2cfbb3fb249311eef9f601626b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.file-upload','data' => ['name' => 'image_profile_upload','id' => 'image_profile_upload','label' => 'Featured Image','accept' => 'image/*','onchange' => 'previewFeaturedImage(this)']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.file-upload'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'image_profile_upload','id' => 'image_profile_upload','label' => 'Featured Image','accept' => 'image/*','onchange' => 'previewFeaturedImage(this)']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal6384af2cfbb3fb249311eef9f601626b)): ?>
<?php $attributes = $__attributesOriginal6384af2cfbb3fb249311eef9f601626b; ?>
<?php unset($__attributesOriginal6384af2cfbb3fb249311eef9f601626b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal6384af2cfbb3fb249311eef9f601626b)): ?>
<?php $component = $__componentOriginal6384af2cfbb3fb249311eef9f601626b; ?>
<?php unset($__componentOriginal6384af2cfbb3fb249311eef9f601626b); ?>
<?php endif; ?>
                    <div class="mt-4">
                        <div id="featured_existing_container">
                            <?php if($prefillFeatured): ?>
                                <div class="relative group" id="existing_image_container_0">
                                    <img src="<?php echo e($prefillFeatured); ?>" alt="Featured" class="w-full h-40 object-cover rounded-lg border border-gray-200 dark:border-gray-800">
                                    <button type="button" onclick="removeExistingImage(0)"
                                            class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-7 h-7 flex items-center justify-center text-xs hover:bg-red-600 shadow-lg transition-colors">
                                        <i class="fas fa-times"></i>
                                    </button>
                                    <input type="hidden" name="images[]" value="<?php echo e($prefillFeatured); ?>" id="existing_image_0">
                                </div>
                            <?php endif; ?>
                        </div>
                        <div id="featured_preview" class="mt-4 hidden">
                            <div class="relative group">
                                <img id="featured_preview_img" src="" alt="Featured Preview" class="w-full h-40 object-cover rounded-lg border border-green-300">
                                <button type="button" onclick="clearFeaturedPreview()"
                                        class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-7 h-7 flex items-center justify-center text-xs hover:bg-red-600 shadow-lg transition-colors">
                                    <i class="fas fa-times"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="p-6 bg-gray-50 dark:bg-gray-900 rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-800 hover:border-blue-400 dark:hover:border-blue-600 transition-colors">
                    <?php if (isset($component)) { $__componentOriginal6384af2cfbb3fb249311eef9f601626b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal6384af2cfbb3fb249311eef9f601626b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.file-upload','data' => ['name' => 'image_gallery_upload[]','id' => 'image_gallery_upload','label' => 'Gallery Images','accept' => 'image/*','multiple' => true,'onchange' => 'previewGalleryImages(this)']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.file-upload'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'image_gallery_upload[]','id' => 'image_gallery_upload','label' => 'Gallery Images','accept' => 'image/*','multiple' => true,'onchange' => 'previewGalleryImages(this)']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal6384af2cfbb3fb249311eef9f601626b)): ?>
<?php $attributes = $__attributesOriginal6384af2cfbb3fb249311eef9f601626b; ?>
<?php unset($__attributesOriginal6384af2cfbb3fb249311eef9f601626b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal6384af2cfbb3fb249311eef9f601626b)): ?>
<?php $component = $__componentOriginal6384af2cfbb3fb249311eef9f601626b; ?>
<?php unset($__componentOriginal6384af2cfbb3fb249311eef9f601626b); ?>
<?php endif; ?>
                    <div id="gallery_existing_preview" class="grid grid-cols-2 md:grid-cols-4 gap-4 mt-4">
                        <?php $__currentLoopData = $prefillGallery; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $image): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php $realIndex = $index + 1; ?>
                            <div class="relative group" id="existing_image_container_<?php echo e($realIndex); ?>">
                                <img src="<?php echo e($image); ?>" alt="Gallery <?php echo e($realIndex); ?>" class="w-full h-32 object-cover rounded-lg border border-gray-200 dark:border-gray-800">
                                <button type="button" onclick="removeExistingImage(<?php echo e($realIndex); ?>)"
                                        class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-7 h-7 flex items-center justify-center text-xs hover:bg-red-600 shadow-lg transition-colors">
                                    <i class="fas fa-times"></i>
                                </button>
                                <input type="hidden" name="images[]" value="<?php echo e($image); ?>" id="existing_image_<?php echo e($realIndex); ?>">
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                    <div id="gallery_new_preview" class="grid grid-cols-2 md:grid-cols-4 gap-4 mt-4"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="mt-8 flex flex-col sm:flex-row items-stretch sm:items-center justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-800">
    <a href="<?php echo e(route('admin.products.index')); ?>" class="btn-danger">
        <i class="fas fa-times mr-2"></i>Cancel
    </a>
    <button type="submit" class="btn-primary">
        <i class="fas fa-save mr-2"></i><?php echo e($item ? 'Update Product' : 'Create Product'); ?>

    </button>
</div>
<?php /**PATH /Users/mac/Documents/e-com/resources/views/admin/products/_form.blade.php ENDPATH**/ ?>