<?php $pageTitle = 'Support'; ?>
<div class="row g-4">
    <div class="col-lg-6">
        <div class="card-cix">
            <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-plus-circle text-orange me-2"></i> New Support Ticket</h5></div>
            <form method="POST" action="<?= base_url('student/support') ?>">
                <?= csrf_field() ?>
                <div class="form-group-cix"><label class="form-label-cix">Subject</label><input type="text" name="subject" class="form-control-cix" required></div>
                <div class="form-group-cix"><label class="form-label-cix">Category</label>
                    <select name="category" class="form-control-cix">
                        <option value="general">General Inquiry</option>
                        <option value="payment">Payment Issue</option>
                        <option value="technical">Technical Issue</option>
                        <option value="academic">Academic Support</option>
                    </select>
                </div>
                <div class="form-group-cix"><label class="form-label-cix">Message</label><textarea name="message" class="form-control-cix" rows="4" required></textarea></div>
                <button type="submit" class="btn-cix btn-cix-primary"><i class="fas fa-paper-plane"></i> Submit Ticket</button>
            </form>
        </div>
    </div>
    <div class="col-lg-6">
        <div class="card-cix">
            <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-headset text-orange me-2"></i> My Tickets</h5></div>
            <?php if (empty($tickets)): ?>
                <div class="empty-state"><i class="fas fa-ticket-alt"></i><h5>No Tickets</h5><p>You haven't submitted any support tickets.</p></div>
            <?php else: ?>
                <?php foreach ($tickets as $ticket): ?>
                <div style="padding:0.75rem;border-bottom:1px solid var(--border);">
                    <div class="d-flex justify-content-between align-items-center mb-1">
                        <strong><?= e($ticket['subject']) ?></strong>
                        <span class="badge-cix badge-<?= $ticket['status'] ?>"><?= ucfirst($ticket['status']) ?></span>
                    </div>
                    <p class="text-secondary small mb-0"><?= e(substr($ticket['message'], 0, 100)) ?>...</p>
                    <small class="text-secondary"><?= time_elapsed($ticket['created_at']) ?></small>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>
</div>
