<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div class="flex items-center space-x-4">
            <a href="<?php echo e(route('items.show', $item)); ?>" 
               class="p-2 text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-xl transition-all duration-200 flex items-center justify-center">
                <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="M15 19l-7-7 7-7"></path>
                </svg>
            </a>
            <div>
                <h1 class="text-2xl font-bold text-gray-900">Edit Item</h1>
                <p class="text-gray-600 text-sm mt-0.5">Update <?php echo e($item->name); ?> details and pricing</p>
            </div>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="p-6">
        <div class="max-w-4xl mx-auto">
            <form method="POST" action="<?php echo e(route('items.update', $item)); ?>" class="space-y-8">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>
                
                <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                    <!-- Item Form -->
                    <div class="lg:col-span-2 space-y-6">
                        <!-- Basic Information -->
                        <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                            <div class="p-6">
                                <h3 class="text-xl font-bold text-gray-900 mb-6">Basic Information</h3>
                                <div class="space-y-6">
                                    <div>
                                        <label for="name" class="block text-sm font-medium text-gray-700 mb-2">
                                            Item Name <span class="text-red-500">*</span>
                                        </label>
                                        <input type="text" name="name" id="name" value="<?php echo e(old('name', $item->name)); ?>" required
                                               placeholder="e.g., Men's Shirt, Wedding Dress, Suit Jacket"
                                               class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent transition duration-200 <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> border-red-500 <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                        <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <p class="mt-2 text-sm text-red-600"><?php echo e($message); ?></p>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>

                                    <div>
                                        <label for="description" class="block text-sm font-medium text-gray-700 mb-2">
                                            Description (Optional)
                                        </label>
                                        <textarea name="description" id="description" rows="4" 
                                                  placeholder="Describe the item, any special care instructions, or notes..."
                                                  class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent transition duration-200 <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> border-red-500 <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><?php echo e(old('description', $item->description)); ?></textarea>
                                        <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <p class="mt-2 text-sm text-red-600"><?php echo e($message); ?></p>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>

                                    <div>
                                        <label for="category_id" class="block text-sm font-medium text-gray-700 mb-2">
                                            Category <span class="text-red-500">*</span>
                                        </label>
                                        <select name="category_id" id="category_id" required
                                                class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent transition duration-200 <?php $__errorArgs = ['category_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> border-red-500 <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                            <option value="">Select a category...</option>
                                            <?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(old('category_id', $item->category_id) == $category->id ? 'selected' : ''); ?>>
                                                    <?php echo e($category->name); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                        <?php $__errorArgs = ['category_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <p class="mt-2 text-sm text-red-600"><?php echo e($message); ?></p>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Pricing Information -->
                        <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                            <div class="p-6">
                                <h3 class="text-xl font-bold text-gray-900 mb-6">Pricing Information</h3>
                                <div class="space-y-6">
                                    <div>
                                        <label for="base_price" class="block text-sm font-medium text-gray-700 mb-2">
                                            Base Price (₦) <span class="text-red-500">*</span>
                                        </label>
                                        <div class="relative">
                                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                                <span class="text-gray-500 sm:text-sm">₦</span>
                                            </div>
                                            <input type="number" name="base_price" id="base_price" step="0.01" min="0" max="999999.99" 
                                                   value="<?php echo e(old('base_price', $item->base_price)); ?>" required
                                                   placeholder="0.00"
                                                   class="w-full pl-8 pr-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent transition duration-200 <?php $__errorArgs = ['base_price'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> border-red-500 <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                        </div>
                                        <?php $__errorArgs = ['base_price'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <p class="mt-2 text-sm text-red-600"><?php echo e($message); ?></p>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                        <p class="mt-2 text-sm text-gray-600">
                                            Current price: ₦<?php echo e(number_format($item->base_price, 2)); ?>

                                        </p>
                                    </div>

                                    <div class="bg-blue-50 border border-blue-200 rounded-xl p-4">
                                        <h4 class="text-sm font-semibold text-blue-900 mb-2">Price Change Impact</h4>
                                        <div class="text-sm text-blue-800 space-y-1" x-data="priceComparison(<?php echo e($item->base_price); ?>)">
                                            <div>Current effective price: ₦<?php echo e(number_format($item->effective_price, 2)); ?></div>
                                            <div x-show="getNewPrice() !== <?php echo e($item->base_price); ?>">
                                                New effective price: <span x-text="'₦' + getNewPrice().toLocaleString('en-NG', { minimumFractionDigits: 2, maximumFractionDigits: 2 })"></span>
                                            </div>
                                            <div x-show="getNewPrice() !== <?php echo e($item->base_price); ?>" class="font-semibold" :class="getPriceChangeClass()">
                                                <span x-text="getPriceChangeText()"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Item Status -->
                        <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                            <div class="p-6">
                                <h3 class="text-xl font-bold text-gray-900 mb-6">Item Status</h3>
                                <div class="space-y-4">
                                    <div class="flex items-center">
                                        <input type="checkbox" name="is_active" id="is_active" value="1" 
                                               <?php echo e(old('is_active', $item->is_active) ? 'checked' : ''); ?>

                                               class="rounded border-gray-300 text-blue-600 shadow-sm focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50">
                                        <label for="is_active" class="ml-3 text-sm font-medium text-gray-700">
                                            Active (available for orders)
                                        </label>
                                    </div>
                                    <p class="text-sm text-gray-600">
                                        Current status: 
                                        <span class="px-2 py-1 text-xs font-medium rounded-full <?php echo e($item->is_active ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'); ?>">
                                            <?php echo e($item->is_active ? 'Active' : 'Inactive'); ?>

                                        </span>
                                    </p>
                                    <?php if($item->orderItems()->exists()): ?>
                                        <div class="bg-yellow-50 border border-yellow-200 rounded-lg p-3">
                                            <p class="text-sm text-yellow-800">
                                                <strong>Note:</strong> This item has been used in <?php echo e($item->orderItems()->count()); ?> order(s). 
                                                Deactivating it will prevent it from being used in new orders, but won't affect existing orders.
                                            </p>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Preview & Actions -->
                    <div class="lg:col-span-1">
                        <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100 sticky top-6">
                            <div class="p-6">
                                <h3 class="text-xl font-bold text-gray-900 mb-6">Preview</h3>
                                
                                <div class="space-y-4" x-data="itemPreview()">
                                    <div class="p-4 bg-gray-50 rounded-xl">
                                        <div class="flex items-center mb-3">
                                            <div class="w-10 h-10 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-xl flex items-center justify-center text-white font-bold text-sm">
                                                <span x-text="getInitial()"><?php echo e(strtoupper(substr($item->name, 0, 1))); ?></span>
                                            </div>
                                            <div class="ml-3">
                                                <div class="text-sm font-medium text-gray-900" x-text="getName()"><?php echo e($item->name); ?></div>
                                                <div class="text-xs text-gray-500" x-text="getCategory()"><?php echo e($item->category->name); ?></div>
                                            </div>
                                        </div>
                                        <div class="text-lg font-bold text-gray-900" x-text="getPrice()">₦<?php echo e(number_format($item->base_price, 2)); ?></div>
                                        <div class="text-xs text-gray-500">Base price</div>
                                    </div>

                                    <div class="text-sm text-gray-600">
                                        <h4 class="font-semibold mb-2">Effective Pricing:</h4>
                                        <ul class="space-y-1">
                                            <li>• Regular: <span x-text="getPrice()">₦<?php echo e(number_format($item->base_price, 2)); ?></span></li>
                                            <li>• With color separation: <span x-text="getPriceWithSeparation()">₦<?php echo e(number_format($item->base_price * 1.1, 2)); ?></span></li>
                                            <li>• With hanging: <span x-text="getPriceWithHanging()">₦<?php echo e(number_format($item->base_price * 1.05, 2)); ?></span></li>
                                        </ul>
                                    </div>

                                    <div class="bg-gray-50 p-3 rounded-lg">
                                        <div class="text-xs text-gray-600 mb-1">Usage Statistics</div>
                                        <div class="text-sm font-medium text-gray-900"><?php echo e($item->orderItems->sum('quantity')); ?> items ordered</div>
                                        <div class="text-sm font-medium text-gray-900">₦<?php echo e(number_format($item->orderItems->sum('total_price'), 2)); ?> total revenue</div>
                                    </div>
                                </div>
                                
                                <div class="mt-8 pt-6 border-t border-gray-200">
                                    <div class="flex space-x-3">
                                        <a href="<?php echo e(route('items.show', $item)); ?>" 
                                           class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-700 font-semibold py-3 px-4 rounded-xl transition-all duration-200 text-center">
                                            Cancel
                                        </a>
                                        <button type="submit" 
                                                class="flex-1 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white font-semibold py-3 px-4 rounded-xl transition-all duration-200 ease-in-out transform hover:scale-105 shadow-lg hover:shadow-xl">
                                            Update Item
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script>
        function itemPreview() {
            return {
                getName() {
                    const name = document.getElementById('name')?.value || '<?php echo e($item->name); ?>';
                    return name.length > 20 ? name.substring(0, 20) + '...' : name;
                },
                
                getInitial() {
                    const name = document.getElementById('name')?.value || '<?php echo e($item->name); ?>';
                    return name.charAt(0).toUpperCase();
                },
                
                getCategory() {
                    const select = document.getElementById('category_id');
                    const selectedOption = select?.options[select.selectedIndex];
                    return selectedOption?.text || '<?php echo e($item->category->name); ?>';
                },
                
                getPrice() {
                    const price = parseFloat(document.getElementById('base_price')?.value || <?php echo e($item->base_price); ?>);
                    return '₦' + price.toLocaleString('en-NG', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
                },
                
                getPriceWithSeparation() {
                    const price = parseFloat(document.getElementById('base_price')?.value || <?php echo e($item->base_price); ?>);
                    const withSeparation = price * 1.1;
                    return '₦' + withSeparation.toLocaleString('en-NG', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
                },
                
                getPriceWithHanging() {
                    const price = parseFloat(document.getElementById('base_price')?.value || <?php echo e($item->base_price); ?>);
                    const withHanging = price * 1.05;
                    return '₦' + withHanging.toLocaleString('en-NG', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
                }
            }
        }

        function priceComparison(originalPrice) {
            return {
                getNewPrice() {
                    return parseFloat(document.getElementById('base_price')?.value || originalPrice);
                },
                
                getPriceChangeClass() {
                    const newPrice = this.getNewPrice();
                    if (newPrice > originalPrice) return 'text-green-600';
                    if (newPrice < originalPrice) return 'text-red-600';
                    return 'text-gray-600';
                },
                
                getPriceChangeText() {
                    const newPrice = this.getNewPrice();
                    const difference = newPrice - originalPrice;
                    const percentage = originalPrice > 0 ? (difference / originalPrice) * 100 : 0;
                    
                    if (difference > 0) {
                        return `Increase: ₦${difference.toFixed(2)} (+${percentage.toFixed(1)}%)`;
                    } else if (difference < 0) {
                        return `Decrease: ₦${Math.abs(difference).toFixed(2)} (${percentage.toFixed(1)}%)`;
                    }
                    return 'No change';
                }
            }
        }
        
        // Update preview when inputs change
        document.addEventListener('DOMContentLoaded', function() {
            const inputs = ['name', 'category_id', 'base_price'];
            inputs.forEach(id => {
                const element = document.getElementById(id);
                if (element) {
                    element.addEventListener('input', () => {
                        element.dispatchEvent(new Event('change'));
                    });
                }
            });
        });
    </script>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\xampp\htdocs\slarry\resources\views/items/edit.blade.php ENDPATH**/ ?>