<div class="row justify-content-center"><div class="col-lg-8"><div class="card">
    <div class="card-header"><h5 class="mb-0"><?= $cardType ? lang('cards.edit_card_type') : lang('cards.create_card_type') ?></h5></div>
    <div class="card-body">
        <form method="POST" action="<?= $formAction ?>" data-ajax="true">
            <?= csrf_field() ?>
            <div class="row g-3">
                <div class="col-md-4"><label class="form-label">Code <span class="text-danger">*</span></label><input type="text" name="type_code" class="form-control" value="<?= e($cardType['type_code'] ?? '') ?>" required><div class="invalid-feedback" data-field="type_code"></div></div>
                <div class="col-md-4"><label class="form-label">Name (EN) <span class="text-danger">*</span></label><input type="text" name="name_en" class="form-control" value="<?= e($cardType['name_en'] ?? '') ?>" required><div class="invalid-feedback" data-field="name_en"></div></div>
                <div class="col-md-4"><label class="form-label">Name (AR) <span class="text-danger">*</span></label><input type="text" name="name_ar" class="form-control" value="<?= e($cardType['name_ar'] ?? '') ?>" required><div class="invalid-feedback" data-field="name_ar"></div></div>
                <div class="col-md-4"><label class="form-label">Applicable To <span class="text-danger">*</span></label>
                    <select name="applicable_to" class="form-select" required>
                        <?php foreach(['member','dependent','guest','staff'] as $v): ?><option value="<?= $v ?>" <?= selected($v, $cardType['applicable_to'] ?? 'member') ?>><?= ucfirst($v) ?></option><?php endforeach; ?>
                    </select></div>
                <div class="col-md-4"><label class="form-label">Validity (months)</label><input type="number" name="validity_months" class="form-control" value="<?= e($cardType['validity_months'] ?? '') ?>"></div>
                <div class="col-md-4"><label class="form-label">Fee <span class="text-danger">*</span></label><input type="number" step="0.01" name="fee" class="form-control" value="<?= e($cardType['fee'] ?? '0') ?>" required></div>
                <div class="col-md-4"><label class="form-label">Replacement Fee <span class="text-danger">*</span></label><input type="number" step="0.01" name="replacement_fee" class="form-control" value="<?= e($cardType['replacement_fee'] ?? '0') ?>" required></div>
                <div class="col-md-8">
                    <div class="d-flex gap-4 mt-4">
                        <div class="form-check"><input type="checkbox" name="has_photo" class="form-check-input" id="has_photo" <?= checked(1, $cardType['has_photo'] ?? 1) ?>><label class="form-check-label" for="has_photo">Photo</label></div>
                        <div class="form-check"><input type="checkbox" name="has_barcode" class="form-check-input" id="has_barcode" <?= checked(1, $cardType['has_barcode'] ?? 1) ?>><label class="form-check-label" for="has_barcode">Barcode</label></div>
                        <div class="form-check"><input type="checkbox" name="has_qr_code" class="form-check-input" id="has_qr" <?= checked(1, $cardType['has_qr_code'] ?? 0) ?>><label class="form-check-label" for="has_qr">QR Code</label></div>
                        <div class="form-check"><input type="checkbox" name="has_rfid" class="form-check-input" id="has_rfid" <?= checked(1, $cardType['has_rfid'] ?? 0) ?>><label class="form-check-label" for="has_rfid">RFID</label></div>
                        <div class="form-check"><input type="checkbox" name="is_active" class="form-check-input" id="is_active" <?= checked(1, $cardType['is_active'] ?? 1) ?>><label class="form-check-label" for="is_active">Active</label></div>
                    </div>
                </div>
            </div>
            <div class="mt-4 d-flex gap-2">
                <button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i><?= lang('common.save') ?></button>
                <a href="/card-types" class="btn btn-secondary"><?= lang('common.cancel') ?></a>
            </div>
        </form>
    </div>
</div></div></div>