<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4 flex-wrap gap-2">
        <div>
            <h2 class="fw-bold text-dark mb-0"><i class="bi bi-tags-fill me-2"></i>Categorías</h2>
            <p class="text-muted mb-0">Gestiona las categorías de productos del restaurante</p>
        </div>
        <div class="d-flex gap-2">
            <a href="<?php echo e(route('categories.create')); ?>" class="btn btn-primary fw-bold shadow-sm">
                <i class="bi bi-plus-lg me-2"></i> Nueva Categoría
            </a>
        </div>
    </div>

    <div class="card border-0 shadow-sm">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead class="table-light">
                        <tr>
                            <th class="ps-4">Imagen</th>
                            <th>Nombre</th>
                            <th>Descripción</th>
                            <th>Productos</th>
                            <th>Estado</th>
                            <th class="text-end pe-4">Acciones</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="ps-4">
                                    <?php if($category->image): ?>
                                        <img src="<?php echo e(asset('storage/' . $category->image)); ?>"
                                             class="rounded shadow-sm"
                                             width="55" height="55"
                                             style="object-fit: cover;">
                                    <?php else: ?>
                                        <div class="bg-light text-secondary d-flex justify-content-center align-items-center rounded border"
                                             style="width: 55px; height: 55px;">
                                            <i class="bi bi-image fs-4"></i>
                                        </div>
                                    <?php endif; ?>
                                </td>
                                <td class="fw-bold"><?php echo e($category->name); ?></td>
                                <td class="text-muted small"><?php echo e($category->description ?? '—'); ?></td>
                                <td>
                                    <span class="badge bg-light text-dark border px-3 py-2">
                                        <?php echo e($category->products_count); ?> producto(s)
                                    </span>
                                </td>
                                <td>
                                    <form action="<?php echo e(route('categories.toggle', $category)); ?>" method="POST" class="d-inline">
                                        <?php echo csrf_field(); ?>
                                        <button type="submit"
                                                class="badge border-0 <?php echo e($category->is_active ? 'bg-success' : 'bg-secondary'); ?>"
                                                style="font-size: 0.85rem; cursor: pointer;">
                                            <?php if($category->is_active): ?>
                                                <i class="bi bi-check-circle-fill me-1"></i>Activo
                                            <?php else: ?>
                                                <i class="bi bi-x-circle-fill me-1"></i>Inactivo
                                            <?php endif; ?>
                                        </button>
                                    </form>
                                </td>
                                <td class="text-end pe-4">
                                    <a href="<?php echo e(route('categories.show', $category)); ?>"
                                       class="btn btn-sm btn-link text-secondary p-0 me-2"
                                       title="Ver detalles">
                                        <i class="bi bi-eye fs-5"></i>
                                    </a>
                                    <a href="<?php echo e(route('categories.edit', $category)); ?>"
                                       class="btn btn-sm btn-link text-dark p-0 me-2"
                                       title="Editar">
                                        <i class="bi bi-pencil-square fs-5"></i>
                                    </a>
                                    <form action="<?php echo e(route('categories.destroy', $category)); ?>"
                                          method="POST" class="d-inline"
                                          onsubmit="return confirm('¿Estás seguro de eliminar la categoría <?php echo e($category->name); ?>?\n<?php echo e($category->products_count > 0 ? 'Atención: Esta categoría tiene productos asociados y no podrá ser eliminada.' : ''); ?>');">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                        <button class="btn btn-sm btn-link text-danger p-0 border-0 bg-transparent"
                                                title="Eliminar">
                                            <i class="bi bi-trash fs-5"></i>
                                        </button>
                                    </form>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="6" class="text-center py-5 text-muted">
                                    <i class="bi bi-tags fs-1 d-block mb-3 opacity-25"></i>
                                    No hay categorías registradas.
                                    <div class="mt-3">
                                        <a href="<?php echo e(route('categories.create')); ?>" class="btn btn-outline-primary">
                                            <i class="bi bi-plus me-2"></i>Crear primera categoría
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\restaurante\resources\views/categories/index.blade.php ENDPATH**/ ?>