<?php
// Detect current page for active state
$current_page = basename($_SERVER['PHP_SELF']);
?>
<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">

  <!-- Brand / Student Profile -->
  <a href="dashboard.php" class="brand-link">
    <img src="../../<?= htmlspecialchars($student_photo ?: 'uploads/students/none.jpg') ?>"
         alt="Student Photo"
         class="brand-image img-circle elevation-3"
         style="opacity:.9; width:36px; height:36px; object-fit:cover;"
         onerror="this.onerror=null; this.src='../../uploads/students/none.jpg';">
    <span class="brand-text font-weight-light"><?= htmlspecialchars($student_name) ?></span>
  </a>

  <div class="sidebar">
    <!-- Sidebar label -->
    <div class="user-panel mt-2 mb-1 pb-2 px-3" style="border-bottom:1px solid rgba(255,255,255,0.07);">
      <p style="font-size:0.7rem; font-weight:600; letter-spacing:1px; text-transform:uppercase; color:rgba(255,255,255,0.35); margin:0; padding:6px 0 2px;">
        Navigation
      </p>
    </div>

    <nav class="mt-1">
      <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">

        <li class="nav-item">
          <a href="dashboard.php"
             class="nav-link <?= $current_page === 'dashboard.php' ? 'active' : '' ?>">
            <i class="nav-icon fas fa-home"></i>
            <p>Dashboard</p>
          </a>
        </li>

        <li class="nav-item">
          <a href="available_exams.php"
             class="nav-link <?= $current_page === 'available_exams.php' ? 'active' : '' ?>">
            <i class="nav-icon fas fa-book-open"></i>
            <p>Available Exams</p>
          </a>
        </li>

        <li class="nav-item">
          <a href="result.php"
             class="nav-link <?= $current_page === 'result.php' ? 'active' : '' ?>">
            <i class="nav-icon fas fa-chart-line"></i>
            <p>My Results</p>
          </a>
        </li>

      </ul>
    </nav>

    <!-- Bottom: logout -->
    <div class="px-3 mt-3" style="border-top:1px solid rgba(255,255,255,0.07); padding-top:12px;">
      <a href="logout.php" class="nav-link"
         style="color:rgba(255,100,80,0.85); border-radius:8px; padding:8px 14px;"
         onclick="return confirm('Are you sure you want to log out?')">
        <i class="nav-icon fas fa-sign-out-alt"></i>
        <p>Logout</p>
      </a>
    </div>
  </div>

</aside>
