<div class="row justify-content-center"><div class="col-xl-8">
    <div class="card"><div class="card-header"><h5 class="mb-0">Edit: <?= e($type['name_en']) ?></h5></div><div class="card-body">
        <form method="POST" action="/api/membership-types/<?= $type['id'] ?>/update" data-ajax="true">
            <?= csrf_field() ?>
            <div class="row g-3">
                <div class="col-md-4"><label class="form-label">Type Code</label><input type="text" class="form-control" value="<?= e($type['type_code']) ?>" disabled></div>
                <div class="col-md-4"><label class="form-label">Name (EN) *</label><input type="text" name="name_en" class="form-control" value="<?= e($type['name_en']) ?>" required></div>
                <div class="col-md-4"><label class="form-label">Name (AR) *</label><input type="text" name="name_ar" class="form-control" dir="rtl" value="<?= e($type['name_ar']) ?>" required></div>
                <div class="col-md-4"><label class="form-label">Category</label><select name="category_id" class="form-select"><option value="">—</option><?php foreach ($categories as $c): ?><option value="<?= $c['id'] ?>" <?= selected($c['id'], $type['category_id']) ?>><?= e($c['name_en']) ?></option><?php endforeach; ?></select></div>
                <div class="col-md-4"><label class="form-label">Gender Restriction</label><select name="gender_restriction" class="form-select"><?php foreach (['both','male','female'] as $g): ?><option value="<?= $g ?>" <?= selected($g, $type['gender_restriction']) ?>><?= ucfirst($g) ?></option><?php endforeach; ?></select></div>
                <div class="col-md-4"><label class="form-label">Grace Period (days)</label><input type="number" name="grace_period_days" class="form-control" value="<?= $type['grace_period_days'] ?>"></div>
                <div class="col-md-3"><div class="form-check mt-4"><input type="checkbox" name="is_family_membership" value="1" class="form-check-input" <?= checked(1, $type['is_family_membership']) ?>><label class="form-check-label">Family</label></div></div>
                <div class="col-md-3"><label class="form-label">Max Deps</label><input type="number" name="max_dependents" class="form-control" value="<?= $type['max_dependents'] ?>"></div>
                <div class="col-md-3"><div class="form-check mt-4"><input type="checkbox" name="requires_sponsor" value="1" class="form-check-input" <?= checked(1, $type['requires_sponsor']) ?>><label class="form-check-label">Sponsor</label></div></div>
                <div class="col-md-3"><label class="form-label">Sponsor Count</label><input type="number" name="sponsor_count" class="form-control" value="<?= $type['sponsor_count'] ?>"></div>
                <div class="col-md-3"><div class="form-check mt-4"><input type="checkbox" name="requires_board_approval" value="1" class="form-check-input" <?= checked(1, $type['requires_board_approval']) ?>><label class="form-check-label">Board Approval</label></div></div>
                <div class="col-md-3"><label class="form-label">Sort</label><input type="number" name="sort_order" class="form-control" value="<?= $type['sort_order'] ?>"></div>
                <div class="col-md-3"><div class="form-check mt-4"><input type="checkbox" name="is_active" value="1" class="form-check-input" <?= checked(1, $type['is_active']) ?>><label class="form-check-label">Active</label></div></div>
            </div>
            <div class="mt-4"><button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i>Save</button> <a href="/membership-types" class="btn btn-secondary">Cancel</a></div>
        </form>
    </div></div>
</div></div>