

<?php $__env->startSection('title', 'Menu Items - ' . $category->name); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-7xl mx-auto">
    <!-- Back to Categories -->
    <div class="mb-6">
        <a href="<?php echo e(route('admin.categories')); ?>" 
           class="text-gold hover:text-dark-gold">
            <i class="fas fa-arrow-left mr-2"></i> Back to Categories
        </a>
    </div>
    
    <!-- Category Info -->
    <div class="bg-white rounded-lg shadow p-6 mb-8">
        <div class="flex items-center justify-between">
            <div>
                <h2 class="text-2xl font-bold"><?php echo e($category->name); ?></h2>
                <p class="text-gray-600"><?php echo e($category->description); ?></p>
            </div>
            <div>
                <span class="px-4 py-2 rounded-lg 
                    <?php echo e($category->is_active ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'); ?>">
                    <?php echo e($category->is_active ? 'Active' : 'Inactive'); ?>

                </span>
            </div>
        </div>
    </div>
    
    <!-- Add Item Form -->
    <div class="bg-white rounded-lg shadow p-6 mb-8">
        <h3 class="text-xl font-bold mb-6">Add New Menu Item</h3>
        
        <form action="<?php echo e(route('admin.items.store', $category->id)); ?>" method="POST">
            <?php echo csrf_field(); ?>
            
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Item Name *</label>
                    <input type="text" name="name" required
                           class="w-full p-3 border rounded-lg"
                           placeholder="Example: Sate Ayam">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Price *</label>
                    <input type="number" name="price" required min="0" step="1000"
                           class="w-full p-3 border rounded-lg"
                           placeholder="Example: 25000">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Display Order</label>
                    <input type="number" name="order" value="0"
                           class="w-full p-3 border rounded-lg">
                </div>
                
                <div class="md:col-span-3">
                    <label class="block text-sm font-medium text-gray-700 mb-2">Description</label>
                    <textarea name="description" rows="2"
                              class="w-full p-3 border rounded-lg"
                              placeholder="Describe this menu item"></textarea>
                </div>
                <div class="flex items-center">
    <input type="checkbox" name="is_active" id="is_active" value="1" checked
           class="h-5 w-5 text-gold rounded">
    <label for="is_active" class="ml-2 text-gray-700">Available for order</label>
</div>
            </div>
            
            <div class="mt-6">
                <button type="submit"
                        class="px-6 py-3 bg-gold text-black font-semibold rounded-lg hover:bg-dark-gold transition">
                    Add Menu Item
                </button>
            </div>
        </form>
    </div>
    
    <!-- Items List -->
    <div class="bg-white rounded-lg shadow overflow-hidden">
        <div class="px-6 py-4 border-b flex justify-between items-center">
            <h3 class="text-xl font-bold">Menu Items (<?php echo e($items->count()); ?>)</h3>
            <span class="text-sm text-gray-500">in <?php echo e($category->name); ?></span>
        </div>
        
        <?php if($items->isEmpty()): ?>
        <div class="p-8 text-center text-gray-500">
            <i class="fas fa-utensils text-4xl mb-4"></i>
            <p>No menu items yet. Add your first item above.</p>
        </div>
        <?php else: ?>
        <div class="overflow-x-auto">
            <table class="w-full">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">#</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Name</th>
                        <th class="px6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Price</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-200">
                    <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td class="px-6 py-4">
                            <span class="px-3 py-1 bg-gray-100 rounded-full"><?php echo e($item->order); ?></span>
                        </td>
                        <td class="px-6 py-4">
                            <h4 class="font-medium"><?php echo e($item->name); ?></h4>
                        </td>
                        <td class="px-6 py-4">
                            <p class="text-sm text-gray-600"><?php echo e($item->description); ?></p>
                        </td>
                        <td class="px-6 py-4">
                            <span class="font-bold text-gold"><?php echo e($item->formatted_price); ?></span>
                        </td>
                                           <td class="px-6 py-4">
    <?php if($item->is_active): ?>
        <span class="px-3 py-1 bg-green-100 text-green-800 rounded-full text-sm font-medium">
            <i class="fas fa-check-circle mr-1"></i> Available
        </span>
    <?php else: ?>
        <span class="px-3 py-1 bg-red-100 text-red-800 rounded-full text-sm font-medium">
            <i class="fas fa-times-circle mr-1"></i> Unavailable
        </span>
    <?php endif; ?>
</td>
                        <td class="px-6 py-4">
    <div class="flex space-x-2">
        <!-- Toggle Availability Button -->
        <form action="<?php echo e(route('admin.items.toggle', $item->id)); ?>" method="POST">
    <?php echo csrf_field(); ?>
    <button type="submit"
            class="px-3 py-1 rounded text-white 
                   <?php echo e($item->is_active ? 'bg-red-500 hover:bg-red-600' : 'bg-green-500 hover:bg-green-600'); ?>"
            title="<?php echo e($item->is_active ? 'Mark as Unavailable' : 'Mark as Available'); ?>">
        <?php if($item->is_active): ?>
            <i class="fas fa-times"></i>
        <?php else: ?>
            <i class="fas fa-check"></i>
        <?php endif; ?>
    </button>
</form>
        <!-- Edit Button -->
        <a href="<?php echo e(route('admin.items.edit', $item->id)); ?>"
           class="px-3 py-1 bg-yellow-500 text-white rounded hover:bg-yellow-600">
            <i class="fas fa-edit"></i>
        </a>
        
        <!-- Delete Button -->
        <form action="<?php echo e(route('admin.items.delete', $item->id)); ?>" 
              method="POST"
              onsubmit="return confirm('Delete this menu item?')">
            <?php echo csrf_field(); ?>
            <?php echo method_field('DELETE'); ?>
            <button type="submit"
                    class="px-3 py-1 bg-red-500 text-white rounded hover:bg-red-600">
                <i class="fas fa-trash"></i>
            </button>
        </form>
    </div>
</td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
        <?php endif; ?>
    </div>
</div>

<script>
function editItem(id) {
    // Simple edit - reload with form
    window.location.href = `/admin/items/${id}/edit`;
}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\tesmenu\resources\views/admin/menu-items.blade.php ENDPATH**/ ?>