<?= $this->extend('layouts/enterprise') ?>

<?= $this->section('content') ?>

<div class="row justify-content-center">
    <div class="col-lg-6">
        <div class="stat-card">
            <h1 class="h5 mb-3">Add Role</h1>

            <?php if (session()->getFlashdata('errors')): ?>
                <div class="alert alert-danger py-2 small">
                    <ul class="mb-0 ps-3">
                        <?php foreach ((array) session()->getFlashdata('errors') as $err): ?>
                            <li><?= esc(is_array($err) ? implode(', ', $err) : $err) ?></li>
                        <?php endforeach; ?>
                    </ul>
                </div>
            <?php endif; ?>

            <form action="<?= base_url('roles') ?>" method="post" novalidate>
                <?= csrf_field() ?>
                <div class="mb-3">
                    <label class="form-label">Role Name</label>
                    <input type="text" name="name" class="form-control" value="<?= esc(old('name')) ?>" required>
                </div>
                <div class="mb-4">
                    <label class="form-label">Description</label>
                    <textarea name="description" class="form-control" rows="3"><?= esc(old('description')) ?></textarea>
                </div>
                <div class="alert alert-info small">
                    <i class="fa-solid fa-circle-info me-1"></i>You'll assign permissions to this role on the next screen.
                </div>
                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary">Create Role</button>
                    <a href="<?= base_url('roles') ?>" class="btn btn-outline-secondary">Cancel</a>
                </div>
            </form>
        </div>
    </div>
</div>

<?= $this->endSection() ?>
