

<?php $__env->startSection('title', 'Roles & Permissions'); ?>
<?php $__env->startSection('breadcrumb'); ?>
    <span class="current">Roles</span>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="page-header" style="display:flex;align-items:center;justify-content:space-between;">
    <div>
        <h1 class="page-title">
            <span class="title-icon"><i data-lucide="shield" style="width:20px;height:20px;"></i></span>
            Roles & Permissions
        </h1>
        <p class="page-subtitle">Manage user roles and system access control</p>
    </div>
    <button class="btn btn-primary" data-modal-open="modal-add-role">
        <i data-lucide="plus" style="width:14px;height:14px;"></i>
        Add Role
    </button>
</div>

<div class="admin-table-wrap">
    <div class="admin-table-header">
        <div class="admin-table-title">
            <i data-lucide="shield" class="icon" style="width:14px;height:14px;"></i>
            System Roles
        </div>
    </div>
    <div class="table-responsive">
        <table class="admin-table">
            <thead>
                <tr>
                    <th>Role</th>
                    <th>Description</th>
                    <th>Users</th>
                    <th>Permissions</th>
                    <th style="text-align:right;">Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td>
                            <div style="display:flex;align-items:center;gap:10px;">
                                <div style="width:8px;height:8px;border-radius:50%;background:var(--vsc-blue);"></div>
                                <span style="font-weight:500;color:var(--vsc-text-active);"><?php echo e($role->name); ?></span>
                            </div>
                        </td>
                        <td style="color:var(--vsc-text-secondary);font-size:12px;"><?php echo e($role->description ?? '—'); ?></td>
                        <td>
                            <span class="badge badge-blue"><?php echo e($role->users_count ?? 0); ?> users</span>
                        </td>
                        <td>
                            <div style="display:flex;gap:4px;flex-wrap:wrap;">
                                <?php $__currentLoopData = ($role->permissions ?? ['view','create','edit']); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $perm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <span class="badge badge-teal" style="font-size:9px;"><?php echo e($perm); ?></span>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </td>
                        <td>
                            <div style="display:flex;justify-content:flex-end;gap:4px;">
                                <a href="<?php echo e(route('admin.roles.edit', $role)); ?>"
                                   class="btn btn-icon btn-secondary" data-tooltip="Edit">
                                    <i data-lucide="pencil" style="width:13px;height:13px;"></i>
                                </a>
                                <?php if (! (in_array($role->name, ['Super Admin', 'Admin']))): ?>
                                    <form method="POST" action="<?php echo e(route('admin.roles.destroy', $role)); ?>">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="btn btn-icon btn-danger"
                                                data-tooltip="Delete"
                                                data-confirm-delete="Delete role <?php echo e($role->name); ?>?">
                                            <i data-lucide="trash-2" style="width:13px;height:13px;"></i>
                                        </button>
                                    </form>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="5" style="text-align:center;padding:48px;color:var(--vsc-text-secondary);">
                            <i data-lucide="shield" style="width:32px;height:32px;display:block;margin:0 auto 12px;opacity:0.3;"></i>
                            No roles configured
                        </td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>


<div class="modal-overlay" id="modal-add-role">
    <div class="modal">
        <div class="modal-header">
            <div class="modal-title">
                <i data-lucide="shield-plus" class="icon" style="width:16px;height:16px;"></i>
                Add New Role
            </div>
            <button class="modal-close" data-modal-close="modal-add-role">&times;</button>
        </div>
        <form method="POST" action="<?php echo e(route('admin.roles.store')); ?>">
            <?php echo csrf_field(); ?>
            <div class="modal-body">
                <div class="form-group">
                    <label class="form-label">Role Name</label>
                    <input type="text" name="name" class="form-control" placeholder="e.g., Data Analyst" required>
                </div>
                <div class="form-group">
                    <label class="form-label">Description</label>
                    <textarea name="description" class="form-control" rows="2" placeholder="Role description..."></textarea>
                </div>
                <div class="form-group">
                    <label class="form-label">Permissions</label>
                    <div style="display:flex;flex-wrap:wrap;gap:10px;">
                        <?php $__currentLoopData = ['view','create','edit','delete','export','manage_users','manage_settings']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $perm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <label style="display:flex;align-items:center;gap:6px;cursor:pointer;font-size:13px;color:var(--vsc-text-primary);">
                                <input type="checkbox" name="permissions[]" value="<?php echo e($perm); ?>"
                                       style="accent-color:var(--vsc-blue);">
                                <?php echo e(ucfirst(str_replace('_',' ',$perm))); ?>

                            </label>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-modal-close="modal-add-role">Cancel</button>
                <button type="submit" class="btn btn-primary">
                    <i data-lucide="plus" style="width:13px;height:13px;"></i>
                    Create Role
                </button>
            </div>
        </form>
    </div>
</div>

<?php $__env->stopSection(); ?>

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