<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Menu Management | CAC Gambia Admin</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #ff6b35;
            --secondary-color: #004e64;
            --sidebar-width: 250px;
        }
        body {
            background: #f5f6fa;
        }
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            width: var(--sidebar-width);
            height: 100vh;
            background: linear-gradient(180deg, var(--secondary-color), #001a2b);
            color: white;
            padding: 20px;
            z-index: 1000;
        }
        .sidebar-brand {
            font-size: 1.4rem;
            font-weight: 700;
            padding: 15px 0;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            margin-bottom: 30px;
        }
        .sidebar-menu {
            list-style: none;
            padding: 0;
        }
        .sidebar-menu li {
            margin-bottom: 5px;
        }
        .sidebar-menu a {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            color: rgba(255,255,255,0.8);
            text-decoration: none;
            border-radius: 8px;
            transition: all 0.3s;
        }
        .sidebar-menu a:hover, .sidebar-menu a.active {
            background: var(--primary-color);
            color: white;
        }
        .sidebar-menu i {
            width: 30px;
        }
        .main-content {
            margin-left: var(--sidebar-width);
            padding: 30px;
        }
        .menu-item-card {
            border-left: 4px solid var(--primary-color);
        }
        .submenu {
            margin-left: 30px;
            border-left: 2px dashed #dee2e6;
        }
    </style>
</head>
<body>
    <div class="sidebar">
        <div class="sidebar-brand">
            <i class="fas fa-church me-2"></i>CAC Gambia
        </div>
        <ul class="sidebar-menu">
            <li>
                <a href="<?php echo e(route('admin.dashboard')); ?>">
                    <i class="fas fa-home"></i> Dashboard
                </a>
            </li>
            <li>
                <a href="<?php echo e(route('admin.departments')); ?>">
                    <i class="fas fa-users"></i> Departments
                </a>
            </li>
            <li>
                <a href="<?php echo e(route('admin.menu')); ?>" class="active">
                    <i class="fas fa-bars"></i> Menu Management
                </a>
            </li>
            <li>
                <a href="#">
                    <i class="fas fa-newspaper"></i> Content
                </a>
            </li>
            <li>
                <a href="#">
                    <i class="fas fa-images"></i> Media
                </a>
            </li>
            <li>
                <a href="#">
                    <i class="fas fa-cog"></i> Settings
                </a>
            </li>
            <li class="mt-5">
                <a href="<?php echo e(route('admin.logout')); ?>" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                    <i class="fas fa-sign-out-alt"></i> Logout
                </a>
                <form id="logout-form" action="<?php echo e(route('admin.logout')); ?>" method="POST" style="display: none;">
                    <?php echo csrf_field(); ?>
                </form>
            </li>
        </ul>
    </div>

    <div class="main-content">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2 class="mb-0">Menu Management</h2>
            <button class="btn btn-primary" style="background: var(--primary-color); border: none;" data-bs-toggle="modal" data-bs-target="#createModal">
                <i class="fas fa-plus me-2"></i>Add Menu Item
            </button>
        </div>

        <?php if(session('success')): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <?php echo e(session('success')); ?>

                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        <?php endif; ?>

        <?php if($menuItems->isEmpty()): ?>
            <div class="card border-0 shadow-sm">
                <div class="card-body text-center py-5">
                    <i class="fas fa-bars fa-3x text-muted mb-3"></i>
                    <h5>No menu items yet</h5>
                    <p class="text-muted">Click "Add Menu Item" to create your first menu item.</p>
                </div>
            </div>
        <?php else: ?>
            <div class="card border-0 shadow-sm">
                <div class="card-body p-0">
                    <?php $__currentLoopData = $menuItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="p-3 border-bottom menu-item-card">
                        <div class="d-flex justify-content-between align-items-center">
                            <div class="d-flex align-items-center">
                                <?php if($item->icon): ?>
                                    <i class="<?php echo e($item->icon); ?> me-3" style="color: var(--primary-color);"></i>
                                <?php else: ?>
                                    <i class="fas fa-link me-3 text-muted"></i>
                                <?php endif; ?>
                                <div>
                                    <h5 class="mb-0"><?php echo e($item->name); ?></h5>
                                    <small class="text-muted"><?php echo e($item->url); ?></small>
                                </div>
                            </div>
                            <div class="d-flex align-items-center">
                                <?php if($item->is_active): ?>
                                    <span class="badge bg-success me-2">Active</span>
                                <?php else: ?>
                                    <span class="badge bg-secondary me-2">Inactive</span>
                                <?php endif; ?>
                                <span class="badge bg-light text-dark me-2">Order: <?php echo e($item->order); ?></span>
                                <a href="<?php echo e(route('admin.menu.edit', $item->id)); ?>" class="btn btn-sm btn-outline-primary">
                                    <i class="fas fa-edit"></i>
                                </a>
                                <form action="<?php echo e(route('admin.menu.destroy', $item->id)); ?>" method="POST" class="d-inline ms-1">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure?')">
                                        <i class="fas fa-trash"></i>
                                    </button>
                                </form>
                            </div>
                        </div>
                        
                        <?php if($item->children->count() > 0): ?>
                        <div class="submenu mt-2">
                            <?php $__currentLoopData = $item->children; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="d-flex justify-content-between align-items-center py-2 border-bottom">
                                <div class="d-flex align-items-center">
                                    <?php if($child->icon): ?>
                                        <i class="<?php echo e($child->icon); ?> me-3" style="color: var(--primary-color);"></i>
                                    <?php else: ?>
                                        <i class="fas fa-link me-3 text-muted"></i>
                                    <?php endif; ?>
                                    <div>
                                        <span class="fw-bold"><?php echo e($child->name); ?></span>
                                        <small class="text-muted ms-2"><?php echo e($child->url); ?></small>
                                    </div>
                                </div>
                                <div class="d-flex align-items-center">
                                    <?php if($child->is_active): ?>
                                        <span class="badge bg-success me-2">Active</span>
                                    <?php else: ?>
                                        <span class="badge bg-secondary me-2">Inactive</span>
                                    <?php endif; ?>
                                    <a href="<?php echo e(route('admin.menu.edit', $child->id)); ?>" class="btn btn-sm btn-outline-primary">
                                        <i class="fas fa-edit"></i>
                                    </a>
                                    <form action="<?php echo e(route('admin.menu.destroy', $child->id)); ?>" method="POST" class="d-inline ms-1">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure?')">
                                            <i class="fas fa-trash"></i>
                                        </button>
                                    </form>
                                </div>
                            </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                        <?php endif; ?>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
        <?php endif; ?>
    </div>

    <!-- Create Modal -->
    <div class="modal fade" id="createModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header" style="background: var(--secondary-color); color: white;">
                    <h5 class="modal-title">Add Menu Item</h5>
                    <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
                </div>
                <form action="<?php echo e(route('admin.menu')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="modal-body">
                        <div class="mb-3">
                            <label class="form-label">Name</label>
                            <input type="text" name="name" class="form-control" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Slug</label>
                            <input type="text" name="slug" class="form-control" placeholder="e.g., home">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">URL</label>
                            <input type="text" name="url" class="form-control" placeholder="/" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Icon (FontAwesome class)</label>
                            <input type="text" name="icon" class="form-control" placeholder="e.g., fas fa-home">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Parent Item</label>
                            <select name="parent_id" class="form-select">
                                <option value="">None (Top Level)</option>
                                <?php $__currentLoopData = $allMenuItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $menuItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($menuItem->id); ?>"><?php echo e($menuItem->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Order</label>
                            <input type="number" name="order" class="form-control" value="0" min="0">
                        </div>
                        <div class="form-check">
                            <input type="hidden" name="is_active" value="0">
                            <input class="form-check-input" type="checkbox" name="is_active" id="is_active" value="1" checked>
                            <label class="form-check-label" for="is_active">
                                Active
                            </label>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                        <button type="submit" class="btn btn-primary" style="background: var(--primary-color); border: none;">Create</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php /**PATH C:\xampp\htdocs\cacthegambia\cacthegambia\resources\views/admin/menu/index.blade.php ENDPATH**/ ?>