<?php $pageTitle = 'Courses'; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
    <p class="text-secondary mb-0">Manage all courses</p>
    <a href="<?= base_url('admin/course-create') ?>" class="btn-cix btn-cix-accent btn-cix-sm"><i class="fas fa-plus"></i> New Course</a>
</div>
<div class="card-cix">
    <div class="table-responsive">
        <table class="table-cix">
            <thead><tr><th>Course</th><th>Category</th><th>Level</th><th>Creator</th><th>Status</th><th>Actions</th></tr></thead>
            <tbody>
            <?php if (empty($courses)): ?>
                <tr><td colspan="6" class="text-center text-secondary p-4">No courses yet</td></tr>
            <?php else: ?>
                <?php foreach ($courses as $c): ?>
                <tr>
                    <td><strong><?= e($c['title']) ?></strong><br><small class="text-secondary"><?= e($c['subtitle'] ?? '') ?></small></td>
                    <td><?= e($c['category_name'] ?? '-') ?></td>
                    <td><?= e($c['level_name'] ?? '-') ?></td>
                    <td class="text-secondary"><?= e(($c['first_name'] ?? '') . ' ' . ($c['last_name'] ?? '')) ?></td>
                    <td><span class="badge-cix <?= $c['is_published'] ? 'badge-active' : 'badge-pending' ?>"><?= $c['is_published'] ? 'Published' : 'Draft' ?></span></td>
                    <td>
                        <a href="<?= base_url('admin/modules/' . $c['id']) ?>" class="btn-cix btn-cix-sm btn-cix-primary" title="Modules"><i class="fas fa-layer-group"></i></a>
                        <a href="<?= base_url('admin/course-edit/' . $c['id']) ?>" class="btn-cix btn-cix-sm btn-cix-outline" title="Edit"><i class="fas fa-edit"></i></a>
                    </td>
                </tr>
                <?php endforeach; ?>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
