<?php include app()->basePath('app/Views/partials/header.php'); ?>

<section class="panel">
    <div class="page-head">
        <div>
            <p class="eyebrow">Suporte</p>
            <h1>Meus tickets</h1>
            <p>Acompanhe pedidos de ajuda sobre pagamentos, acesso, certificados e problemas tecnicos.</p>
        </div>
        <a class="button" href="/support/create">Novo ticket</a>
    </div>

    <div class="support-help-grid">
        <div><strong>Pagamentos</strong><span>Comprovativos, recibos, acesso apos pagamento.</span></div>
        <div><strong>Cursos</strong><span>Acesso, progresso, aulas e materiais.</span></div>
        <div><strong>Certificados</strong><span>Emissao, validacao e reemissao.</span></div>
    </div>

    <div class="table-wrap">
        <table>
            <thead><tr><th>Ticket</th><th>Categoria</th><th>Prioridade</th><th>Estado</th><th>Actualizado</th><th></th></tr></thead>
            <tbody>
                <?php if (!$tickets): ?><tr><td colspan="6">Ainda nao abriu tickets de suporte.</td></tr><?php endif; ?>
                <?php foreach ($tickets as $ticket): ?>
                    <tr>
                        <td><strong><?= e($ticket['subject']) ?></strong><span class="muted"><?= e($ticket['ticket_number']) ?></span></td>
                        <td><?= e($categories[$ticket['category']] ?? $ticket['category']) ?></td>
                        <td><span class="badge"><?= e(ucfirst($ticket['priority'])) ?></span></td>
                        <td><span class="badge <?= e($ticket['status']) ?>"><?= e($statuses[$ticket['status']] ?? $ticket['status']) ?></span></td>
                        <td><?= e(format_date($ticket['updated_at'] ?? '')) ?></td>
                        <td><a class="mini-button" href="/support/show?id=<?= e((string) $ticket['id']) ?>">Abrir</a></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</section>

<?php include app()->basePath('app/Views/partials/footer.php'); ?>
