<?php $__env->startSection('content'); ?>
<div class="d-flex align-items-center justify-content-between mt-3 mb-3">
    <div>
        <h3 class="mb-0 fw-bold"><i class="fas fa-sitemap me-2"></i>Menús</h3>
        <small class="text-muted">Administración de menús y submenús (solo Super Admin)</small>
    </div>
    <a href="<?php echo e(route('admin.menu.create')); ?>" class="btn btn-primary">
        <i class="fas fa-plus me-2"></i>Nuevo
    </a>
</div>

<div class="card shadow-sm border-0">
    <div class="card-header bg-white d-flex justify-content-between align-items-center">
        <div class="fw-bold">Listado</div>
        <small class="text-muted">Menús principales: <?php echo e($roots->count()); ?></small>
    </div>

    <div class="table-responsive">
        <table class="table table-hover align-middle mb-0">
            <thead class="table-light">
                <tr>
                    <th style="width:70px;">ID</th>
                    <th>Nombre</th>
                    <th style="width:180px;">route_name / url</th>
                    <th style="width:220px;">route_pattern</th>
                    <th style="width:90px;">Orden</th>
                    <th style="width:120px;">Estado</th>
                    <th class="text-end" style="width:220px;">Acciones</th>
                </tr>
            </thead>
            <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $roots; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $parent): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td class="fw-semibold"><?php echo e($parent->id); ?></td>
                    <td>
                        <div class="fw-semibold">
                            <i class="<?php echo e($parent->icon ?? 'fas fa-folder'); ?> me-2"></i><?php echo e($parent->nombre); ?>

                        </div>
                        <small class="text-muted">Menú principal</small>
                    </td>
                    <td class="text-muted">
                        <?php if($parent->route_name): ?>
                            <div><code><?php echo e($parent->route_name); ?></code></div>
                        <?php elseif($parent->url): ?>
                            <div><code><?php echo e($parent->url); ?></code></div>
                        <?php else: ?>
                            —
                        <?php endif; ?>
                    </td>
                    <td class="text-muted"><?php echo e($parent->route_pattern ?: '—'); ?></td>
                    <td><?php echo e($parent->orden); ?></td>
                    <td>
                        <?php if($parent->estado === 'AC'): ?>
                            <span class="badge bg-success">Activo</span>
                        <?php else: ?>
                            <span class="badge bg-secondary">Inactivo</span>
                        <?php endif; ?>
                    </td>
                    <td class="text-end">
                        <a href="<?php echo e(route('admin.menu.edit', $parent)); ?>" class="btn btn-sm btn-outline-secondary">
                            <i class="fas fa-pen me-1"></i>Editar
                        </a>
                        <form action="<?php echo e(route('admin.menu.destroy', $parent)); ?>" method="POST" class="d-inline" onsubmit="return confirm('¿Eliminar? Se marcará estado=EL (incluye submenús).')">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('DELETE'); ?>
                            <button type="submit" class="btn btn-sm btn-outline-danger">
                                <i class="fas fa-trash me-1"></i>Eliminar
                            </button>
                        </form>
                    </td>
                </tr>

                <?php $__currentLoopData = $parent->children; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td class="fw-semibold"><?php echo e($child->id); ?></td>
                        <td>
                            <div class="ps-4">
                                <i class="<?php echo e($child->icon ?? 'fas fa-link'); ?> me-2"></i><?php echo e($child->nombre); ?>

                                <span class="badge bg-light text-dark ms-2">Submenú</span>
                            </div>
                        </td>
                        <td class="text-muted">
                            <?php if($child->route_name): ?>
                                <div><code><?php echo e($child->route_name); ?></code></div>
                            <?php elseif($child->url): ?>
                                <div><code><?php echo e($child->url); ?></code></div>
                            <?php else: ?>
                                —
                            <?php endif; ?>
                        </td>
                        <td class="text-muted"><?php echo e($child->route_pattern ?: '—'); ?></td>
                        <td><?php echo e($child->orden); ?></td>
                        <td>
                            <?php if($child->estado === 'AC'): ?>
                                <span class="badge bg-success">Activo</span>
                            <?php else: ?>
                                <span class="badge bg-secondary">Inactivo</span>
                            <?php endif; ?>
                        </td>
                        <td class="text-end">
                            <a href="<?php echo e(route('admin.menu.edit', $child)); ?>" class="btn btn-sm btn-outline-secondary">
                                <i class="fas fa-pen me-1"></i>Editar
                            </a>
                            <form action="<?php echo e(route('admin.menu.destroy', $child)); ?>" method="POST" class="d-inline" onsubmit="return confirm('¿Eliminar? Se marcará estado=EL (incluye submenús).')">
                                <?php echo csrf_field(); ?>
                                <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="btn btn-sm btn-outline-danger">
                                    <i class="fas fa-trash me-1"></i>Eliminar
                                </button>
                            </form>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="7" class="text-center text-muted py-5">
                        No hay menús registrados. Ejecuta migraciones/seeders.
                    </td>
                </tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__env->stopSection(); ?>

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