<?php
// Helper: render course table
function renderCourseTable($title, $icon, $courses, $extraCols = null) {
    $typeClass = function($type) {
        $t = strtolower($type);
        if (str_contains($t,'advanced') || str_contains($t,'advance')) return 'course-type-adv';
        if (str_contains($t,'diploma')) return 'course-type-dip';
        return 'course-type-cert';
    };
    echo '<div class="ibvte-course-table-wrap mb-5">';
    echo '<div class="course-section-title"><i class="fas '.$icon.' me-2"></i>'.htmlspecialchars($title).'</div>';
    echo '<div class="table-responsive"><table class="table table-bordered ibvte-course-table">';
    echo '<thead><tr><th>S.No.</th><th>Course Code</th><th>Course Name</th><th>Type</th><th>Duration</th><th>Eligibility</th><th>Mode</th><th>Assessment</th></tr></thead><tbody>';
    foreach($courses as $c) {
        $type = $c[3] ?? '';
        echo '<tr>';
        echo '<td>'.$c[0].'</td>';
        echo '<td><small class="text-muted">'.$c[1].'</small></td>';
        echo '<td><strong>'.htmlspecialchars($c[2]).'</strong></td>';
        echo '<td><span class="'.$typeClass($type).'">'.htmlspecialchars($type).'</span></td>';
        echo '<td>'.$c[4].'</td>';
        echo '<td>'.$c[5].'</td>';
        echo '<td>'.$c[6].'</td>';
        echo '<td>'.($c[7] ?? '-').'</td>';
        echo '</tr>';
    }
    echo '</tbody></table></div></div>';
}
?>
