
<?php if (function_exists('can') ? can('assessments.view') : true): ?>
  <li class="<?= ($ACTIVE_MENU??'')==='coordinator'?'active':'' ?>">
    <a href="/elms/admin/coordinator/index.php">Coordinator</a>
  </li>
<?php endif; ?>


<?php



// includes/admin_sidebar.php
// Renders the left sidebar. Relies on esc() from helpers.php if present.

/* ---- tiny esc helper if helpers.php wasn’t loaded yet ---- */
if (!function_exists('esc')) {
  function esc($v){ return htmlspecialchars((string)$v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); }
}

/* ---- Compute ELMS base from the current script (go up to /elms) ----
   Example script: /elms/admin/assessments/submissions.php
   dirname(..., 3) -> /elms
-------------------------------------------------------------------- */
$script = $_SERVER['SCRIPT_NAME'] ?? '/elms/admin/dashboard.php';
$BASE   = rtrim(dirname($script, 3), '/');         // -> /elms
if ($BASE === '' || $BASE === '.') $BASE = '/elms';
$LOGO   = $BASE . '/includes/logo/edden_logo.jpg';

/* If the page didn’t set $ACTIVE_MENU, try to detect it from URL */
$ACTIVE_MENU = $ACTIVE_MENU ?? '';
if ($ACTIVE_MENU === '') {
  $uri = (string)($_SERVER['REQUEST_URI'] ?? '');
  $map = [
    'home'            => ['/admin/dashboard.php', '/admin/summary.php'],
    'institute'       => ['/admin/centres/'],
    'centres'         => ['/admin/centres/'],
    'lecturers'       => ['/admin/lecturers/'],
    'courses'         => ['/admin/courses/'],
    'Games'         => ['/admin/Games/game_builder.php'],
    'AssessmentsManage' => ['/admin/assessments/assessments'],
    'AssessmentcriteriaManage' => ['/admin/assessments/assessmentcriteria.php'],
    
    
    
    'students'        => ['/admin/students/','/admin/student/'],
    'manage-centre'   => ['/admin/centres/'],
    'centre-batches'  => ['/admin/batches/'],
    'verification'    => ['/admin/assessments/resubmit_whitelist.php'],
    'moderation'      => ['/admin/assessments/submissions.php'],
    'reports'         => ['/admin/reports/'],
  ];
  foreach ($map as $key => $needles) {
    foreach ($needles as $n) {
      if ($n !== '' && strpos($uri, $n) !== false) { $ACTIVE_MENU = $key; break 2; }
    }
  }
}

/* Helper to print a nav item (URLs are site-absolute under /elms) */
$nav = function(string $key, string $href, string $label, string $icon) use ($ACTIVE_MENU) {
  $active = ($ACTIVE_MENU === $key) ? ' is-active' : '';
  echo '<a class="eden-nav-link'.$active.'" href="'.esc($href).'">'.
         '<i class="bi '.$icon.' eden-nav-ico" aria-hidden="true"></i>'.
         '<span class="eden-nav-label">'.esc($label).'</span>'.
       '</a>';
};
?>
<style>
  :root{
    --eden-bg:#0f172a; --eden-bg2:#111c2d; --eden-accent:#2563eb; --eden-accent2:#1d4ed8;
    --eden-ink:#e5e7eb; --eden-muted:#9aa6b2; --eden-sep:rgba(255,255,255,.06);
  }
  .eden-sidebar{width:240px;min-height:100vh;background:linear-gradient(180deg,var(--eden-bg),var(--eden-bg2));color:var(--eden-ink);position:sticky;top:0;box-shadow:0 8px 30px rgba(2,8,23,.35);z-index:10}
  .eden-brand{display:flex;align-items:center;gap:.65rem;padding:14px;border-bottom:1px solid var(--eden-sep)}
  .eden-brand img{height:40px;width:auto;display:block}
  .eden-logo-text{font-weight:700;letter-spacing:.2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .eden-section-title{color:var(--eden-muted);text-transform:uppercase;font-size:.72rem;letter-spacing:.08em;padding:10px 14px 6px}
  .eden-nav{display:flex;flex-direction:column;padding:6px}
  .eden-nav-link{display:flex;align-items:center;gap:.7rem;color:var(--eden-ink);text-decoration:none;padding:.58rem .75rem;margin:2px 6px;border-radius:10px;position:relative}
  .eden-nav-link:hover{background:rgba(255,255,255,.06)}
  .eden-nav-link.is-active{background:linear-gradient(90deg, rgba(37,99,235,.18), rgba(37,99,235,.10));color:#fff}
  .eden-nav-link.is-active::before{content:"";position:absolute;left:-2px;top:8px;bottom:8px;width:3px;border-radius:3px;background:linear-gradient(180deg,var(--eden-accent),var(--eden-accent2))}
  .eden-nav-ico{width:18px;text-align:center;font-size:1.05rem}
  .eden-side-footer{padding:12px 14px;color:var(--eden-muted);font-size:.8rem;border-top:1px solid var(--eden-sep);margin-top:auto}
  @media (max-width:992px){.eden-sidebar{position:static;width:100%;min-height:auto}}
</style>

<aside class="eden-sidebar">
  <div class="eden-brand">
    <img src="<?= esc($LOGO) ?>" alt="Eden Campus Logo">
    <div class="eden-logo-text">EDEN CAMPUS</div>
  </div>

  <div class="eden-section-title">Home</div>
  <nav class="eden-nav">
    <?php $nav('home', $BASE.'/admin/dashboard.php', 'Home', 'bi-house'); ?>
  </nav>

  <div class="eden-section-title">Manage Institute</div>
  <nav class="eden-nav">
    <?php
      $nav('institute',     $BASE.'/admin/centres/',   'Overview',      'bi-buildings');
      $nav('centres',       $BASE.'/admin/centres/',   'Centres',       'bi-geo-alt');
      $nav('lecturers',     $BASE.'/admin/lecturers/', 'Lecturers',     'bi-person-badge');
      $nav('courses',       $BASE.'/admin/courses/',   'Courses',       'bi-journals');
      $nav('Games',       $BASE.'/admin/Games/game_builder.php',   'Games',       'bi-journals'); 
      $nav('AssessmentsManage',       $BASE.'/admin/assessments/',   'AssessmentsManage',       'bi-journals'); 
      $nav('AssessmentcriteriaManage',       $BASE.'/admin/assessments/assessmentcriteria.php',   'AssessmentcriteriaManage',       'bi-journals'); 
        
        
        
        
        
        
        
        
      $nav('students',      $BASE.'/admin/student/',  'Students',      'bi-people');
      $nav('manage-centre', $BASE.'/admin/centres/',   'Manage Centre', 'bi-diagram-3');
    ?>
  </nav>

  <div class="eden-section-title">Operations</div>
  <nav class="eden-nav">
    <?php
      $nav('centre-batches', $BASE.'/admin/batches/',                              'Centre Batches', 'bi-collection');
      $nav('verification',   $BASE.'/admin/assessments/resubmit_whitelist.php',   'Verification',   'bi-shield-check');
      $nav('moderation',     $BASE.'/admin/assessments/submissions.php',          'Moderation',     'bi-chat-left-text');
      $nav('reports',        $BASE.'/admin/reports/',                             'Reports',        'bi-graph-up');
    ?>
  </nav>

  <div class="eden-side-footer">
    <?= date('F d, Y h:i A') ?>
  </div>
</aside>
