<?php
$currentPage = basename($_SERVER['PHP_SELF'] ?? '');
$items = [
 ['key'=>'home','label'=>'Trang chủ','icon'=>'🏠','href'=>'student-home.php','pages'=>['student-home.php']],
 ['key'=>'learning','label'=>'Đang học','icon'=>'📚','href'=>'student-learning.php','pages'=>[
   'student-learning.php','student-books.php','student-grades.php','student-units.php',
   'student-lessons.php','student-activities.php','student-word-list.php',
   'student-flashcards.php','student-listen-repeat.php','student-practice.php','student-games.php'
 ]],
 ['key'=>'ranking','label'=>'Xếp hạng','icon'=>'🏆','href'=>'student-ranking.php','pages'=>['student-ranking.php']],
 ['key'=>'profile','label'=>'Hồ sơ','icon'=>'👤','href'=>'student-profile.php','pages'=>['student-profile.php']]
];

if ($activeStudentNav === '') {
    foreach ($items as $item) {
        if (in_array($currentPage,$item['pages'],true)) {
            $activeStudentNav = $item['key'];
            break;
        }
    }
}
?>
<nav class="student-nav" aria-label="Điều hướng học sinh">
<?php foreach($items as $item): $active=$activeStudentNav===$item['key']; ?>
<a class="student-nav__item<?=$active?' is-active':''?>" href="<?=htmlspecialchars($item['href'],ENT_QUOTES,'UTF-8')?>" <?=$active?'aria-current="page"':''?>>
<span class="student-nav__icon" aria-hidden="true"><?=htmlspecialchars($item['icon'],ENT_QUOTES,'UTF-8')?></span>
<span class="student-nav__label"><?=htmlspecialchars($item['label'],ENT_QUOTES,'UTF-8')?></span>
</a>
<?php endforeach; ?>
</nav>
