<!DOCTYPE html>
<html>
<head><title>Login</title></head>
<body>
<h3>Manage Roles</h3>
<table>
    <thead>
        <tr>
            <th>Role Name</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($roles as $role): ?>
            <tr>
                <td><?= $role->name ?></td>
                <td>
                    <a href="<?= base_url('admin/manage_permissions?role_id=' . $role->id) ?>">Manage Permissions</a> |
                    <?php if ($role->id != 1): ?>  <!-- Don't allow Superadmin to be deleted -->
                        <a href="<?= base_url('admin/delete_role/' . $role->id) ?>" onclick="return confirm('Are you sure you want to delete this role?')">Delete</a>
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<a href="<?= base_url('admin/create_role') ?>">Create New Role</a>
<a href="<?= base_url('dashboard') ?>">Back to Dashboard</a>
</body>
</html>