<?php $pageTitle = 'Support Tickets'; ?>
<div class="mb-4"><p class="text-secondary">Manage student support tickets</p></div>
<div class="card-cix mb-4">
    <form method="GET" action="<?= base_url('admin/support-tickets') ?>" class="row g-3 align-items-end">
        <div class="col-md-3"><label class="form-label-cix">Status</label><select name="status" class="form-control-cix"><option value="">All</option><option value="open" <?= ($status ?? '') === 'open' ? 'selected' : '' ?>>Open</option><option value="in_progress" <?= ($status ?? '') === 'in_progress' ? 'selected' : '' ?>>In Progress</option><option value="resolved" <?= ($status ?? '') === 'resolved' ? 'selected' : '' ?>>Resolved</option><option value="closed" <?= ($status ?? '') === 'closed' ? 'selected' : '' ?>>Closed</option></select></div>
        <div class="col-md-2"><button type="submit" class="btn-cix btn-cix-primary"><i class="fas fa-filter"></i></button></div>
    </form>
</div>
<div class="card-cix">
    <div class="table-responsive">
        <table class="table-cix"><thead><tr><th>Subject</th><th>Student</th><th>#</th><th>Status</th><th>Date</th></tr></thead>
        <tbody><?php if (empty($tickets)): ?><tr><td colspan="5" class="text-center text-secondary p-4">No tickets</td></tr>
        <?php else: foreach ($tickets as $t): ?>
        <tr><td><strong><?= e($t['subject']) ?></strong></td><td><?= e(($t['first_name'] ?? '') . ' ' . ($t['last_name'] ?? '')) ?></td>
        <td class="text-secondary"><?= e($t['student_number'] ?? '-') ?></td>
        <td><span class="badge-cix badge-<?= $t['status'] ?>"><?= ucfirst($t['status']) ?></span></td>
        <td class="text-secondary small"><?= time_elapsed($t['created_at']) ?></td></tr>
        <?php endforeach; endif; ?></tbody></table>
    </div>
</div>
