<?php $pageTitle = 'Teacher Dashboard'; ?>
<div class="row g-3 mb-4">
    <div class="col-md-3"><div class="kpi-card"><div class="kpi-icon orange"><i class="fas fa-book"></i></div><div><div class="kpi-value"><?= (int)$myCourses ?></div><div class="kpi-label">My Courses</div></div></div></div>
    <div class="col-md-3"><div class="kpi-card"><div class="kpi-icon blue"><i class="fas fa-clipboard-check"></i></div><div><div class="kpi-value"><?= (int)$pendingMarking ?></div><div class="kpi-label">Pending Marking</div></div></div></div>
    <div class="col-md-3"><div class="kpi-card"><div class="kpi-icon green"><i class="fas fa-laptop-code"></i></div><div><div class="kpi-value"><?= (int)$activeTests ?></div><div class="kpi-label">Active Tests</div></div></div></div>
</div>
<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-clipboard-list text-orange me-2"></i> Recent Test Attempts</h5></div>
            <?php if (empty($recentAttempts)): ?>
                <div class="empty-state"><i class="fas fa-inbox"></i><h5>No Attempts</h5><p>No recent test attempts.</p></div>
            <?php else: ?>
            <div class="table-responsive"><table class="table-cix">
                <thead><tr><th>Student</th><th>Test</th><th>Score</th><th>Status</th></tr></thead>
                <tbody>
                <?php foreach ($recentAttempts as $a): ?>
                <tr><td><?= e($a['first_name'] . ' ' . $a['last_name']) ?></td><td><?= e($a['test_title']) ?></td><td style="color:var(--secondary);font-weight:700"><?= e($a['score']) ?>%</td><td><span class="badge-cix <?= $a['passed'] ? 'badge-active' : 'badge-rejected' ?>"><?= $a['passed'] ? 'Passed' : 'Failed' ?></span></td></tr>
                <?php endforeach; ?>
                </tbody>
            </table></div>
            <?php endif; ?>
        </div>
    </div>
    <div class="col-lg-6">
        <div class="card-cix">
            <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-bullhorn text-orange me-2"></i> Announcements</h5></div>
            <?php if (empty($announcements)): ?>
                <div class="empty-state"><i class="fas fa-bell"></i><h5>No Announcements</h5></div>
            <?php else: ?>
                <?php foreach ($announcements as $ann): ?>
                <div style="padding:0.75rem;border-bottom:1px solid var(--border);">
                    <h6 class="mb-1"><?= e($ann['title']) ?></h6>
                    <p class="text-secondary small mb-0"><?= e(substr($ann['content'], 0, 120)) ?></p>
                    <small class="text-secondary"><?= time_elapsed($ann['created_at']) ?></small>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>
</div>
