<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>إدارة الأدوار<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/roles/create" class="btn btn-primary">+ دور جديد</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card">
    <div class="table-responsive">
        <table class="data-table">
            <thead>
                <tr>
                    <th>كود الدور</th>
                    <th>الاسم (عربي)</th>
                    <th>الاسم (إنجليزي)</th>
                    <th>نظامي</th>
                    <th>الصلاحيات</th>
                    <th>الموظفون</th>
                    <th>الإجراءات</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($roles as $role): ?>
                <tr>
                    <td><code><?= e($role['role_code']) ?></code></td>
                    <td><?= e($role['name_ar']) ?></td>
                    <td><?= e($role['name_en'] ?? '—') ?></td>
                    <td><?= $role['is_system'] ? '<span style="color:#059669;">نعم</span>' : 'لا' ?></td>
                    <td><?= (int) $role['perm_count'] ?></td>
                    <td><?= (int) $role['emp_count'] ?></td>
                    <td>
                        <a href="/roles/<?= (int) $role['id'] ?>/edit" class="btn btn-sm btn-outline">تعديل</a>
                    </td>
                </tr>
                <?php endforeach; ?>
                <?php if (empty($roles)): ?>
                <tr><td colspan="7" style="text-align:center;padding:40px;color:#6B7280;">لا توجد أدوار</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__template->endSection(); ?>