<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Departments | 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;
        }
    </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')); ?>" class="active">
                    <i class="fas fa-users"></i> Departments
                </a>
            </li>
            <li>
                <a href="<?php echo e(route('admin.menu')); ?>">
                    <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">Departments / Ministries</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 Department
            </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; ?>

        <div class="card border-0 shadow-sm">
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover mb-0">
                        <thead style="background: var(--secondary-color); color: white;">
                            <tr>
                                <th class="py-3">Name</th>
                                <th class="py-3">Slug</th>
                                <th class="py-3">Age Group</th>
                                <th class="py-3">Meeting Time</th>
                                <th class="py-3">Status</th>
                                <th class="py-3 text-end">Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="py-3"><?php echo e($department->name); ?></td>
                                <td class="py-3"><code><?php echo e($department->slug); ?></code></td>
                                <td class="py-3"><?php echo e($department->age ?? '-'); ?></td>
                                <td class="py-3"><?php echo e($department->meeting ?? '-'); ?></td>
                                <td class="py-3">
                                    <?php if($department->is_active): ?>
                                        <span class="badge bg-success">Active</span>
                                    <?php else: ?>
                                        <span class="badge bg-secondary">Inactive</span>
                                    <?php endif; ?>
                                </td>
                                <td class="py-3 text-end">
                                    <a href="<?php echo e(route('admin.departments.edit', $department->id)); ?>" class="btn btn-sm btn-outline-primary">
                                        <i class="fas fa-edit"></i>
                                    </a>
                                    <form action="<?php echo e(route('admin.departments.destroy', $department->id)); ?>" method="POST" class="d-inline">
                                        <?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>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- Create Modal -->
    <div class="modal fade" id="createModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header" style="background: var(--secondary-color); color: white;">
                    <h5 class="modal-title">Add New Department</h5>
                    <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
                </div>
                <form action="<?php echo e(route('admin.departments')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Name</label>
                                <input type="text" name="name" class="form-control" required>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Meeting Time</label>
                                <input type="text" name="meeting" class="form-control" placeholder="e.g., Sundays at 9:00 AM">
                            </div>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Description</label>
                            <textarea name="description" class="form-control" rows="3" required></textarea>
                        </div>
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Activities</label>
                                <textarea name="activities" class="form-control" rows="2" placeholder="e.g., Sunday School, Bible Study"></textarea>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Age Group</label>
                                <input type="text" name="age" class="form-control" placeholder="e.g., Ages 3-12">
                            </div>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Image Filename</label>
                            <input type="text" name="image" class="form-control" placeholder="e.g., children_ministry.jpeg">
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="is_active" id="is_active_create" value="1" checked>
                            <label class="form-check-label" for="is_active_create">
                                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 Department</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/departments/index.blade.php ENDPATH**/ ?>