<?php $pageTitle = 'Class Reports'; ?>
<div class="mb-4"><p class="text-secondary">Performance overview of your courses</p></div>
<?php if (empty($reports)): ?>
    <div class="empty-state"><i class="fas fa-chart-bar"></i><h5>No Data</h5><p>No course data available yet.</p></div>
<?php else: ?>
<div class="card-cix">
    <div class="table-responsive">
        <table class="table-cix">
            <thead><tr><th>Course</th><th>Students</th><th>Avg Score</th><th>Performance</th></tr></thead>
            <tbody>
            <?php foreach ($reports as $r): ?>
            <tr>
                <td><strong><?= e($r['title']) ?></strong></td>
                <td><?= (int)$r['student_count'] ?></td>
                <td style="color:var(--secondary);font-weight:700;"><?= $r['avg_score'] ? round($r['avg_score'], 1) . '%' : 'N/A' ?></td>
                <td>
                    <?php if ($r['avg_score']): ?>
                    <div class="progress-cix" style="max-width:150px;"><div class="progress-cix-bar <?= $r['avg_score'] >= 50 ? 'green' : 'orange' ?>" style="width:<?= round($r['avg_score']) ?>%"></div></div>
                    <?php else: ?>
                    <span class="text-secondary">No data</span>
                    <?php endif; ?>
                </td>
            </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>
<?php endif; ?>
