<?php $__env->startSection('title', 'Create Subcategory'); ?>
<?php $__env->startSection('page-title', 'Create Subcategory: ' . $category->name); ?>

<?php $__env->startSection('content'); ?>
<div class="bg-white rounded-xl shadow-lg border border-gray-100 p-4 md:p-8">
    <div class="mb-4 md:mb-6 pb-4 border-b border-gray-200">
        <h3 class="text-xl md:text-2xl font-bold text-gray-800">Create New Subcategory</h3>
        <p class="text-gray-500 text-xs md:text-sm mt-1">Fill in the details below to create a new subcategory</p>
        <div class="mt-3 p-3 bg-gradient-to-r from-blue-50 to-indigo-50 rounded-lg border border-blue-200">
            <p class="text-xs md:text-sm text-blue-800 font-medium">
                <i class="bi bi-info-circle-fill mr-2"></i><strong>Parent Category:</strong> <?php echo e($category->name); ?>

            </p>
        </div>
    </div>
    
    <form method="POST" action="<?php echo e(route('admin.categories.subcategories.store', $category)); ?>" enctype="multipart/form-data">
        <?php echo csrf_field(); ?>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 md:gap-6">
            <?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' => 'Subcategory Name','value' => old('name'),'required' => true,'placeholder' => 'Enter subcategory 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' => 'Subcategory Name','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('name')),'required' => true,'placeholder' => 'Enter subcategory 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' => 'name_km','label' => 'Subcategory Name (Khmer)','value' => old('name_km'),'placeholder' => 'Enter subcategory 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' => 'Subcategory Name (Khmer)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('name_km')),'placeholder' => 'Enter subcategory 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 (isset($component)) { $__componentOriginal530746098e8865a2469fd5685420112b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal530746098e8865a2469fd5685420112b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.text-input','data' => ['name' => 'code','label' => 'Code','value' => old('code'),'required' => true,'placeholder' => 'e.g., cotton-bedding-sets']] + (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' => 'code','label' => 'Code','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('code')),'required' => true,'placeholder' => 'e.g., cotton-bedding-sets']); ?>
<?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="md:col-span-2">
                <label class="block text-gray-700 dark:text-gray-300 text-sm font-semibold mb-2">Subcategory Image</label>
                <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">
                    <!-- Image Upload -->
                    <div class="mb-4">
                        <?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_upload','id' => 'image_upload','label' => 'Upload Image','accept' => 'image/*','helpText' => 'Max size: 5MB. Formats: JPEG, PNG, JPG, GIF, WEBP','onchange' => 'previewImage(this, \'image_preview\')']] + (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_upload','id' => 'image_upload','label' => 'Upload Image','accept' => 'image/*','help-text' => 'Max size: 5MB. Formats: JPEG, PNG, JPG, GIF, WEBP','onchange' => 'previewImage(this, \'image_preview\')']); ?>
<?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>
                    
                    <!-- Image Preview -->
                    <div id="image_preview_container" class="hidden">
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Preview</label>
                        <div class="relative inline-block">
                            <img id="image_preview" src="" alt="Preview" class="max-w-xs h-40 object-cover rounded-lg border-2 border-gray-200 dark:border-gray-800 shadow-md">
                            <button type="button" onclick="clearImagePreview('image_preview', 'image_upload')" 
                                    class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-8 h-8 flex items-center justify-center text-sm hover:bg-red-600 shadow-lg transition-colors">
                                <i class="bi bi-x-lg"></i>
                            </button>
                        </div>
                    </div>
                    
                    <!-- Or Image URL -->
                    <?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' => 'image','id' => 'image_url','label' => 'Or Enter Image URL','value' => old('image'),'placeholder' => 'https://example.com/image.jpg','onchange' => 'previewImageUrl(this, \'image_preview\')']] + (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' => 'image','id' => 'image_url','label' => 'Or Enter Image URL','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('image')),'placeholder' => 'https://example.com/image.jpg','onchange' => 'previewImageUrl(this, \'image_preview\')']); ?>
<?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>
            </div>

            <?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'),'rows' => '3','class' => 'md:col-span-2','placeholder' => 'Enter subcategory 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')),'rows' => '3','class' => 'md:col-span-2','placeholder' => 'Enter subcategory 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; ?>

            <?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'),'rows' => '3','class' => 'md:col-span-2','placeholder' => 'Enter subcategory 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')),'rows' => '3','class' => 'md:col-span-2','placeholder' => 'Enter subcategory 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; ?>
        </div>

        <div class="mt-6 md:mt-8 flex flex-col sm:flex-row items-stretch sm:items-center justify-end gap-3 sm:gap-4 pt-4 md:pt-6 border-t border-gray-200 dark:border-gray-800">
            <a href="<?php echo e(route('admin.categories.subcategories', $category)); ?>" class="btn-danger">
                <i class="bi bi-x-lg mr-2"></i>Cancel
            </a>
            <button type="submit" class="btn-primary">
                <i class="bi bi-check2-circle mr-2"></i>Create Subcategory
            </button>
        </div>
    </form>
</div>

<script>
function previewImage(input, previewId) {
    if (input.files && input.files[0]) {
        const reader = new FileReader();
        reader.onload = function(e) {
            document.getElementById(previewId).src = e.target.result;
            document.getElementById('image_preview_container').classList.remove('hidden');
            document.getElementById('image_url').value = '';
        };
        reader.readAsDataURL(input.files[0]);
    }
}

function previewImageUrl(input, previewId) {
    if (input.value) {
        document.getElementById(previewId).src = input.value;
        document.getElementById('image_preview_container').classList.remove('hidden');
        document.getElementById('image_upload').value = '';
    }
}

function clearImagePreview(previewId, uploadId) {
    document.getElementById(previewId).src = '';
    document.getElementById('image_preview_container').classList.add('hidden');
    document.getElementById(uploadId).value = '';
    document.getElementById('image_url').value = '';
}
</script>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/mac/Documents/e-com/resources/views/admin/categories/create-subcategory.blade.php ENDPATH**/ ?>