<?php
$current_url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$menuItems = [
 ['label' => 'Dashboard', 'icon' => 'fa-gauge-high', 'url' => '/dashboard'],
 ['label' => 'My Courses', 'icon' => 'fa-graduation-cap', 'url' => '/student/courses'],
 ['label' => 'Study Materials', 'icon' => 'fa-book-open-reader', 'url' => '/student/materials'],
 ['label' => 'Fees & Ledger', 'icon' => 'fa-wallet', 'url' => '/student/fees'],
 ['label' => 'My Profile', 'icon' => 'fa-user-circle', 'url' => '/student/profile'],
];
?>
<div class="flex flex-col h-full bg-emerald-700">
 <!-- Sidebar Header -->
 <div class="h-16 flex items-center justify-between px-6 border-b border-emerald-600/50 flex-none">
 <div class="flex items-center gap-3">
 <?php if(!empty($siteSettings['institute_logo'])): ?>
 <img src="<?php echo url($siteSettings['institute_logo']); ?>" class="h-8 w-8 rounded-lg object-contain bg-white/10 p-1">
 <?php else: ?>
 <div class="h-9 w-9 bg-white/20 rounded-lg flex items-center justify-center text-white border border-white/20">
 <i class="fa-solid fa-graduation-cap"></i>
 </div>
 <?php endif; ?>
 <span class="font-black text-white tracking-tighter text-lg truncate max-w-[120px]">
 <?php echo strtoupper($siteSettings['institute_name'] ?? 'STUDENT'); ?>
 </span>
 </div>
 <!-- Close Button (Mobile Only) -->
 <button @click="mobileSidebar = false" class="lg:hidden h-8 w-8 flex items-center justify-center rounded-lg bg-white/10 text-white hover:bg-white/20 transition-all border border-white/10">
 <i class="fa-solid fa-xmark"></i>
 </button>
 </div>

 <!-- Navigation -->
 <nav class="flex-1 overflow-y-auto p-4 space-y-1 custom-scrollbar">
 <?php foreach ($menuItems as $item): ?>
 <a href="<?php echo url($item['url']); ?>"
 class="flex items-center gap-3 px-4 py-3 rounded-lg transition-all duration-200 group <?php echo ($current_url === $item['url'] || ($item['url'] === '/dashboard' && $current_url === '/')) ? 'bg-white text-emerald-700' : 'text-emerald-100 hover:bg-white/10 hover:text-white'; ?>">
 <div class="w-5 h-5 flex items-center justify-center">
 <i class="fa-solid <?php echo $item['icon']; ?> <?php echo ($current_url === $item['url'] || ($item['url'] === '/dashboard' && $current_url === '/')) ? 'text-emerald-700' : 'text-emerald-300 group-hover:text-white'; ?> text-sm"></i>
 </div>
 <span class="text-xs font-bold"><?php echo $item['label']; ?></span>
 </a>
 <?php endforeach; ?>
 </nav>

 <!-- Sidebar Footer -->
 <div class="p-4 border-t border-emerald-600/50 flex-none">
 <a href="<?php echo url('/logout'); ?>" class="flex items-center gap-3 px-4 py-3 rounded-lg text-emerald-100 hover:bg-red-500 hover:text-white transition-all group border border-transparent hover:border-red-400">
 <div class="w-5 h-5 flex items-center justify-center">
 <i class="fa-solid fa-power-off text-sm"></i>
 </div>
 <span class="text-xs font-bold uppercase tracking-widest">Sign Out</span>
 </a>
 </div>
</div>
