<?php $pageTitle = 'My Results'; ?>
<div class="mb-4"><p class="text-secondary">Your test results and scores</p></div>
<?php if (empty($results)): ?>
    <div class="empty-state"><i class="fas fa-chart-line"></i><h5>No Results Yet</h5><p>Complete some tests to see your results here.</p></div>
<?php else: ?>
<div class="card-cix">
    <div class="table-responsive">
        <table class="table-cix">
            <thead><tr><th>Test</th><th>Course</th><th>Score</th><th>Pass Mark</th><th>Status</th><th>Date</th></tr></thead>
            <tbody>
            <?php foreach ($results as $r): ?>
            <tr>
                <td><strong><?= e($r['test_title']) ?></strong></td>
                <td class="text-secondary"><?= e($r['course_title']) ?></td>
                <td style="color:var(--secondary);font-weight:700;"><?= e($r['score']) ?>%<small class="text-secondary"> (<?= e($r['score']) ?>/<?= e($r['max_score']) ?>)</small></td>
                <td><?= e($r['pass_mark']) ?>%</td>
                <td><span class="badge-cix <?= $r['passed'] ? 'badge-active' : 'badge-rejected' ?>"><?= $r['passed'] ? 'Passed' : 'Failed' ?></span></td>
                <td class="text-secondary small"><?= e($r['ended_at']) ?></td>
            </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>
<?php endif; ?>
