<?php($item = $pageContent ?? null)

<!-- Form Content -->
<div class="p-6 space-y-6">
    <!-- Section Field -->
    <x-admin.select-input 
        name="section" 
        label="Section" 
        required 
        placeholder="-- Select Section --"
    >
        @foreach($sections as $section)
            @php
                $isDisabled = in_array($section, $existingSections) && (!$item || $item->section !== $section);
            ?>
            <option value="<?php echo e($section); ?>" 
                    <?php echo e($isDisabled ? 'disabled' : ''); ?>

                    <?php echo e(old('section', $item?->section) === $section ? 'selected' : ''); ?>>
                <?php echo e(Str::headline($section)); ?><?php echo e($isDisabled ? ' (Already exists)' : ''); ?>

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

    <?php if($existingSections): ?>
        <div class="p-3 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-md">
            <p class="text-xs text-amber-800 dark:text-amber-200">
                <i class="fas fa-info-circle mr-1"></i>
                <strong>Note:</strong> Sections marked "(Already exists)" are disabled to prevent duplicates.
            </p>
        </div>
    <?php endif; ?>

    <!-- Title English -->
    <?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' => 'title_en','label' => 'Title (English)','value' => old('title_en', $item?->title_en),'placeholder' => 'Enter title in English']] + (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' => 'title_en','label' => 'Title (English)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('title_en', $item?->title_en)),'placeholder' => 'Enter title in English']); ?>
<?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; ?>

    <!-- Title Khmer -->
    <?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' => 'title_km','label' => 'Title (ភាសាខ្មែរ)','value' => old('title_km', $item?->title_km),'placeholder' => 'Enter title 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' => 'title_km','label' => 'Title (ភាសាខ្មែរ)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('title_km', $item?->title_km)),'placeholder' => 'Enter title 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; ?>

    <!-- Description English -->
    <?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_en','label' => 'Description (English)','value' => old('description_en', $item?->description_en),'rows' => '5','placeholder' => 'Enter description in English...']] + (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_en','label' => 'Description (English)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('description_en', $item?->description_en)),'rows' => '5','placeholder' => 'Enter description in English...']); ?>
<?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; ?>

    <!-- Description Khmer -->
    <?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 (ភាសាខ្មែរ)','value' => old('description_km', $item?->description_km),'rows' => '5','placeholder' => 'Enter 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 (ភាសាខ្មែរ)','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('description_km', $item?->description_km)),'rows' => '5','placeholder' => 'Enter 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; ?>

    <!-- Image -->
    <div>
        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
            Image
        </label>
        <?php if($item?->image): ?>
            <div class="mb-4" id="current_image_container">
                <div class="relative inline-block">
                    <img src="<?php echo e(asset('storage/' . $item->image)); ?>" alt="<?php echo e($item->section); ?>" class="w-40 h-40 object-cover rounded-lg border border-gray-300 dark:border-gray-700">
                    <button type="button" onclick="document.getElementById('remove_image').value = 1; document.getElementById('current_image_container').style.display = 'none'; document.getElementById('new_image_input').style.display = 'block';" 
                            class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                <input type="hidden" name="remove_image" id="remove_image" value="0">
            </div>
        <?php endif; ?>
        <?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','id' => 'new_image_input','accept' => 'image/*','helpText' => 'Max file size: 2MB. Supported formats: JPEG, PNG, JPG, GIF','style' => ''.e($item?->image ? 'display:none' : '').'']] + (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','id' => 'new_image_input','accept' => 'image/*','help-text' => 'Max file size: 2MB. Supported formats: JPEG, PNG, JPG, GIF','style' => ''.e($item?->image ? 'display:none' : '').'']); ?>
<?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>

    <?php if($item): ?>
        <!-- Metadata -->
        <div class="pt-6 border-t border-gray-200 dark:border-gray-800">
            <div class="grid grid-cols-2 gap-4 text-sm">
                <div>
                    <p class="text-gray-600 dark:text-gray-400">Created by</p>
                    <p class="text-gray-900 dark:text-white font-medium"><?php echo e($item->createdBy?->name ?? 'System'); ?></p>
                </div>
                <div>
                    <p class="text-gray-600 dark:text-gray-400">Last updated</p>
                    <p class="text-gray-900 dark:text-white font-medium"><?php echo e($item->updated_at->format('M d, Y H:i')); ?></p>
                </div>
            </div>
        </div>
    <?php endif; ?>
</div>

<!-- Form Actions -->
<div class="px-6 py-4 bg-gray-50 dark:bg-gray-900 border-t border-gray-200 dark:border-gray-800 flex items-center justify-end gap-3">
    <a href="<?php echo e(route('admin.page-content.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 Page Content' : 'Create Page Content'); ?>

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