<div class="d-flex justify-content-between align-items-center mb-4">
    <h4 class="mb-0"><i class="fas fa-shield-alt me-2"></i><?= lang('admin.roles') ?></h4>
    <a href="/admin/roles/create" class="btn btn-primary"><i class="fas fa-plus me-1"></i>Create Role</a>
</div>
<div class="card">
    <div class="card-body">
        <table id="roles-table" class="table table-striped w-100"
               data-url="/admin/roles/datatable"
               data-columns='[{"data":"id"},{"data":"code"},{"data":"name"},{"data":"name_ar"},{"data":"users"},{"data":"permissions"},{"data":"system"},{"data":"active"},{"data":"actions","orderable":false}]'>
            <thead><tr><th>#</th><th>Code</th><th>Name</th><th>Arabic</th><th>Users</th><th>Perms</th><th>System</th><th>Status</th><th>Actions</th></tr></thead>
        </table>
    </div>
</div>
<?php $__view->push('scripts') ?>
<script>
$(function(){
    DataTableHelper.init('roles-table');
    $(document).on('click','.btn-delete-role',function(){
        if(!confirm('Delete this role?')) return;
        $.post('/admin/roles/'+$(this).data('id')+'/delete',{_token:'<?= csrf_token() ?>'},function(r){
            if(r.success){FormHelper.showToast('success',r.message);DataTableHelper.reload('roles-table');}
            else FormHelper.showToast('error',r.message);
        },'json');
    });
});
</script>
<?php $__view->endPush() ?>