<?php $pageTitle = 'Students'; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
    <p class="text-secondary mb-0">Manage all students</p>
</div>
<div class="card-cix mb-4">
    <form method="GET" action="<?= base_url('admin/students') ?>" class="row g-3 align-items-end">
        <div class="col-md-6"><label class="form-label-cix">Search</label><input type="text" name="search" class="form-control-cix" placeholder="Student #, name, email, phone..." value="<?= e($search ?? '') ?>"></div>
        <div class="col-md-2"><button type="submit" class="btn-cix btn-cix-primary"><i class="fas fa-search"></i> Search</button></div>
    </form>
</div>
<div class="card-cix">
    <div class="table-responsive">
        <table class="table-cix">
            <thead><tr><th>#</th><th>Student #</th><th>Name</th><th>Email</th><th>Package</th><th>Enrollment</th><th>Status</th><th>Actions</th></tr></thead>
            <tbody>
            <?php if (!empty($students)): ?>
                <?php foreach ($students as $i => $s): ?>
                <tr>
                    <td><?= ($pagination['offset'] ?? 0) + $i + 1 ?></td>
                    <td style="color:var(--secondary);font-weight:600;"><?= e($s['student_number']) ?></td>
                    <td><strong><?= e($s['first_name'] . ' ' . $s['last_name']) ?></strong></td>
                    <td class="text-secondary small"><?= e($s['email']) ?></td>
                    <td><?= e($s['package_name'] ?? '-') ?></td>
                    <td><span class="badge-cix badge-<?= $s['enrollment_status'] ?>"><?= ucfirst($s['enrollment_status']) ?></span></td>
                    <td><span class="badge-cix <?= $s['is_active'] ? 'badge-active' : 'badge-rejected' ?>"><?= $s['is_active'] ? 'Active' : 'Inactive' ?></span></td>
                    <td><a href="<?= base_url('admin/student/' . $s['id']) ?>" class="btn-cix btn-cix-sm btn-cix-primary"><i class="fas fa-eye"></i></a></td>
                </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr><td colspan="8" class="text-center text-secondary p-4">No students found</td></tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
