<section class="features-section">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <div class="text-center mb-4"><h2>Apply to <span style="color:var(--secondary)">CIX Orbit Academy</span></h2><p class="text-secondary">Fill in the form below to start your application. You will receive your student number via email.</p></div>
                <?php if (!empty($error)): ?><div class="alert-cix alert-cix-error"><i class="fas fa-exclamation-circle"></i> <?= $error ?></div><?php endif; ?>
                <?php if (!empty($success)): ?><div class="alert-cix alert-cix-success"><i class="fas fa-check-circle"></i> <?= $success ?></div><?php endif; ?>
                <div class="card-cix">
                    <form method="POST" action="<?= base_url('apply') ?>">
                        <?= csrf_field() ?>
                        <div class="row g-3">
                            <div class="col-md-6"><label class="form-label-cix">First Name *</label><input type="text" name="first_name" class="form-control-cix" required value="<?= e(old('first_name')) ?>"></div>
                            <div class="col-md-6"><label class="form-label-cix">Surname *</label><input type="text" name="last_name" class="form-control-cix" required value="<?= e(old('last_name')) ?>"></div>
                            <div class="col-md-6"><label class="form-label-cix">Email *</label><input type="email" name="email" class="form-control-cix" required value="<?= e(old('email')) ?>"></div>
                            <div class="col-md-6"><label class="form-label-cix">Phone *</label><input type="tel" name="phone" class="form-control-cix" required value="<?= e(old('phone')) ?>"></div>
                            <div class="col-md-6"><label class="form-label-cix">WhatsApp</label><input type="tel" name="whatsapp" class="form-control-cix" value="<?= e(old('whatsapp')) ?>"></div>
                            <div class="col-md-6"><label class="form-label-cix">ID / Passport Number</label><input type="text" name="id_passport" class="form-control-cix" value="<?= e(old('id_passport')) ?>"></div>
                            <div class="col-md-6"><label class="form-label-cix">Province</label>
                                <select name="province" class="form-control-cix"><option value="">Select Province</option>
                                <?php foreach (['Eastern Cape','Free State','Gauteng','KwaZulu-Natal','Limpopo','Mpumalanga','North West','Northern Cape','Western Cape'] as $p): ?>
                                <option value="<?= $p ?>" <?= old('province') === $p ? 'selected' : '' ?>><?= $p ?></option>
                                <?php endforeach; ?>
                                </select>
                            </div>
                            <div class="col-md-6"><label class="form-label-cix">Town</label><input type="text" name="town" class="form-control-cix" value="<?= e(old('town')) ?>"></div>
                            <div class="col-md-6"><label class="form-label-cix">Highest Education Level</label>
                                <select name="highest_education" class="form-control-cix">
                                <option value="">Select</option>
                                <?php foreach (['Below Matric','Matric','Diploma','Bachelor Degree','Honours','Masters','PhD','Other'] as $e): ?>
                                <option value="<?= $e ?>" <?= old('highest_education') === $e ? 'selected' : '' ?>><?= $e ?></option>
                                <?php endforeach; ?>
                                </select>
                            </div>
                            <div class="col-md-6"><label class="form-label-cix">Interested Course / Package</label>
                                <select name="interested_package" class="form-control-cix"><option value="">Select Package</option>
                                <?php if (!empty($packages)): foreach ($packages as $p): ?>
                                <option value="<?= $p['id'] ?>"><?= e($p['name']) ?> - R<?= number_format($p['price'], 0) ?></option>
                                <?php endforeach; endif; ?>
                                </select>
                            </div>
                            <div class="col-md-6"><label class="form-label-cix">Password *</label><input type="password" name="password" class="form-control-cix" required minlength="8"></div>
                            <div class="col-12"><label class="d-flex align-items-start gap-2" style="cursor:pointer"><input type="checkbox" name="consent" value="1" required style="margin-top:4px;accent-color:var(--secondary)"><span class="text-secondary small">I consent to CIX Connect processing my personal information in accordance with the POPIA Act and the academy's privacy policy. I understand that my data will be used for academic and administrative purposes.</span></label></div>
                            <div class="col-12"><button type="submit" class="btn-cix btn-cix-accent btn-cix-lg w-100"><i class="fas fa-paper-plane me-1"></i> Submit Application</button></div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
