<section class="report-toolbar">
    <div>
        <p class="eyebrow"><?= e(trans('common.administrator')) ?></p>
        <h1><?= e($item['id'] ? trans('page_titles.edit_programme') : trans('page_titles.add_programme')) ?></h1>
        <p class="support-copy"><?= e(trans('admin.programme_form_copy')) ?></p>
    </div>
    <div class="toolbar-actions">
        <a class="ghost-button" href="<?= e(base_url('/admin/programmes')) ?>"><?= e(trans('common.back')) ?></a>
    </div>
</section>

<section class="card table-card">
    <form method="post" action="<?= e(base_url('/admin/programmes/save')) ?>" class="stack-form">
        <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
        <input type="hidden" name="id" value="<?= e((string) ($item['id'] ?? '')) ?>">

        <div class="inline-form-grid">
            <label>
                <span><?= e(trans('common.area')) ?></span>
                <select name="area_code" required>
                    <?php foreach ($areas as $areaCode => $area): ?>
                        <option value="<?= e($areaCode) ?>" <?= ($item['area_code'] ?? '') === $areaCode ? 'selected' : '' ?>><?= e($areaCode . ' - ' . area_name($areaCode)) ?></option>
                    <?php endforeach; ?>
                </select>
            </label>
            <label>
                <span><?= e(trans('common.order')) ?></span>
                <input type="number" min="1" name="sort_order" value="<?= e((string) ($item['sort_order'] ?? 1)) ?>" required>
            </label>
            <label class="checkbox-field">
                <input type="checkbox" name="is_active" value="1" <?= !empty($item['is_active']) ? 'checked' : '' ?>>
                <span><?= e(trans('common.active')) ?></span>
            </label>
        </div>

        <div class="inline-form-grid two-wide-grid">
            <label>
                <span><?= e(trans('admin.programme_code')) ?></span>
                <input type="text" name="programme_code" value="<?= e((string) ($item['programme_code'] ?? '')) ?>">
            </label>
            <label>
                <span><?= e(trans('admin.programme_name')) ?></span>
                <input type="text" name="programme_name" value="<?= e((string) ($item['programme_name'] ?? '')) ?>" required>
            </label>
        </div>

        <label>
            <span><?= e(trans('common.description')) ?></span>
            <textarea name="description" rows="4"><?= e((string) ($item['description'] ?? '')) ?></textarea>
        </label>

        <div class="toolbar-actions">
            <button class="primary-button" type="submit"><?= e(trans('admin.save_programme')) ?></button>
        </div>
    </form>
</section>