<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard</title>
    <!-- Optimized CSS imports -->
    <link rel="stylesheet" href="../../boostrap/1.css">
    <link rel="stylesheet" href="../../boostrap/2.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:ital,wght@0,100..700;1,100..700&family=Montserrat:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <link rel="icon" href="favicon.png" type="image/png">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css" rel="stylesheet">
    <meta name="theme-color" content="var(--primary)">
    
    <style>
        :root {
            --secondary: #3a0ca3;
            --accent: #7209b7;
            --success: #4cc9f0;
            --warning: #f72585;
            --dark: #2b2d42;
            --light: #f8f9fa;
            --gray: #adb5bd;
            --hover: rgba(67, 97, 238, 0.1);
            --border-radius: 12px;
            --shadow: 0 10px 30px rgba(0,0,0,0.08);
            --shadow-lg: 0 20px 40px rgba(0,0,0,0.12);
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            --gradient-primary: linear-gradient(135deg, #4361ee, #3a0ca3);
            --gradient-secondary: linear-gradient(135deg, #7209b7, #f72585);
            --gradient-accent: linear-gradient(135deg, #4cc9f0, #4361ee);
        }
        a{
  text-decoration:none;
}
a:hover{
  text-decoration:none;
}
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            color: var(--dark);
            padding-top: 80px;
            min-height: 100vh;
            transition: var(--transition);
        }
        
        /* Enhanced Navbar */
        .main-navbar {
            background: white;
            position: fixed;
            top: 0;
            left: 250px;
            width: calc(100% - 250px);
            height: 80px;
            z-index: 999;
            box-shadow: var(--shadow);
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .nav-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 30px;
            height: 100%;
            max-width: 100%;
        }
        
        .nav-left {
            display: flex;
            align-items: center;
            gap: 20px;
        }
        
        .nav-toggle {
            border: none;
            color: var(--primary);
            width: 45px;
            height: 45px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: var(--transition);
            display:none;
        }
        
        .nav-toggle:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(67, 97, 238, 0.4);
        }
        
        .nav-brand {
            display: flex;
            align-items: center;
            text-decoration: none;
            color: var(--dark);
            font-weight: 700;
            font-size: 22px;
            gap: 15px;
        }
        
        .nav-logo {
            width: 50px;
            height: 50px;
            border-radius: 12px;
            object-fit: contain;
            padding: 8px;
            box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
            margin-left:25px;
        }
        
        /* Admin Icons Container */
        .admin-icons-container {
            display: flex;
            align-items: center;
            gap: 20px;
        }
        
        .icon-wrapper {
            position: relative;
            width: 45px;
            height: 45px;
            background: white;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: var(--transition);
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
            border: 1px solid rgba(0,0,0,0.05);
        }
        
        .icon-wrapper:hover {
            background: var(--gradient-primary);
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(67, 97, 238, 0.3);
        }
        
        .icon-wrapper:hover i {
            color: white;
        }
        
        .icon-wrapper i {
            font-size: 18px;
            color: var(--dark);
            transition: var(--transition);
        }
        
        .notification-badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background: var(--gradient-secondary);
            color: white;
            border-radius: 50%;
            width: 22px;
            height: 22px;
            font-size: 11px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            box-shadow: 0 3px 8px rgba(247, 37, 133, 0.3);
            border: 2px solid white;
        }
        
        /* User Dropdown */
        .user-dropdown {
            position: relative;
        }
        
        .user-dropdown-toggle {
            background: var(--gradient-primary);
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 20px;
            border-radius: 50px;
            transition: var(--transition);
            box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
            color: white;
        }
        
        .user-dropdown-toggle:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(67, 97, 238, 0.4);
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: white;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            font-weight: 700;
            font-size: 16px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        
        .user-info {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }
        
        .user-name {
            font-weight: 600;
            font-size: 14px;
            color: white;
        }
        
        .user-role {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.8);
            font-weight: 400;
        }
        
        .user-chevron {
            font-size: 12px;
            transition: transform 0.3s;
            color: white;
        }
        
        .user-dropdown-toggle.active .user-chevron {
            transform: rotate(180deg);
        }
        
        .user-dropdown-menu {
            position: absolute;
            top: calc(100% + 15px);
            right: 0;
            background: white;
            border-radius: 16px;
            box-shadow: var(--shadow-lg);
            min-width: 250px;
            z-index: 1000;
            display: none;
            padding: 15px 0;
            margin-top: 5px;
            opacity: 0;
            transform: translateY(-10px);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            border: 1px solid rgba(0,0,0,0.05);
        }
        
        .user-dropdown-menu.active {
            display: block;
            opacity: 1;
            transform: translateY(0);
        }
        
        .user-dropdown-header {
            padding: 15px 20px;
            border-bottom: 1px solid rgba(0,0,0,0.05);
            margin-bottom: 10px;
        }
        
        .user-dropdown-item {
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 15px 20px;
            color: var(--dark);
            text-decoration: none;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
        }
        
        .user-dropdown-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 4px;
            background: var(--gradient-primary);
            transform: translateX(-100%);
            transition: transform 0.3s;
        }
        
        .user-dropdown-item:hover {
            background: rgba(67, 97, 238, 0.05);
        }
        
        .user-dropdown-item:hover::before {
            transform: translateX(0);
        }
        
        .user-dropdown-item i {
            width: 20px;
            color: var(--primary);
            font-size: 16px;
            transition: var(--transition);
        }
        
        .user-dropdown-item:hover i {
            transform: scale(1.1);
        }
        
        .user-dropdown-divider {
            height: 1px;
            background: linear-gradient(to right, transparent, rgba(0,0,0,0.1), transparent);
            margin: 10px 20px;
        }
        
        .user-dropdown-item.logout {
            color: var(--warning);
        }
        
        .user-dropdown-item.logout i {
            color: var(--warning);
        }
        
        /* Mobile Admin Icons */
        .mobile-admin-icons {
            display: none;
            align-items: center;
            gap: 15px;
        }
        
        .mobile-user-toggle {
            width: 45px;
            height: 45px;
            background: var(--gradient-primary);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 600;
            font-size: 16px;
            cursor: pointer;
            box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
        }
        
        /* Enhanced Sidebar */
        #sidebar {
            width: 280px;
            position: fixed;
            left: 0;
            top: 0;
            height: 100vh;
            background: var(--primary) ;
            transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: var(--shadow-lg);
            z-index: 1000;
            overflow-y: auto;
            color: white;
            padding-bottom: 20px;
        }
        
        #sidebar::-webkit-scrollbar {
            width: 6px;
        }
        
        #sidebar::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.1);
        }
        
        #sidebar::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.3);
            border-radius: 3px;
        }
        
        #sidebar.active {
            transform: translateX(0);
        }
        
        .sidebar-header {
            padding: 15px;
            text-align: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .sidebar-close {
            position: absolute;
            top: 25px;
            right: 25px;
            background: rgba(255, 255, 255, 0.1);
            border: none;
            color: white;
            width: 35px;
            height: 35px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: var(--transition);
            display
        }
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            background: white;
            display: flex;
            justify-content: space-around;
            align-items: center;
            box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
            z-index: 1000;
            padding: 10px 0;
            display: none;
        }
        
        .bottom-nav-link {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-decoration: none;
            color: #777;
            font-size: 14px;
            transition: var(--transition);
        }
        
        .bottom-nav-link.active, .bottom-nav-link:hover {
            color: var(--primary);
        }
        
        .bottom-nav-icon {
            font-size: 18px;
            margin-bottom: 3px;
            color:var(--primary);
        }
        
        .sidebar-close:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: rotate(90deg);
        }
        
        .sidebar-profile {
            text-align: center;
            padding-bottom: 20px;
        }
        
        .sidebar-profile-img {
            width: 100px;
            height: 100px;
            border-radius: 20px;
            border: 1px solid rgba(255, 255, 255, 0.3);
            object-fit: cover;
            margin-bottom: 15px;
            background: white;
            padding: 5px;
            box-shadow: 0 8px 25px rgba(0,0,0,0.2);
        }
        
        .sidebar-profile-name {
            font-weight: 700;
            font-size: 18px;
            margin-bottom: 5px;
            color: white;
        }
        
        .sidebar-profile-role {
            background: rgba(255, 255, 255, 0.2);
            color: white;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 500;
            display: inline-block;
            backdrop-filter: blur(10px);
        }
        
        .sidebar-profile-id {
            font-size: 13px;
            opacity: 0.8;
            margin-top: 8px;
            color: rgba(255, 255, 255, 0.9);
        }
        
        .sidebar-nav {
            padding: 20px 0;
        }
        
        .sidebar-nav-item {
            list-style: none;
            margin-bottom: 5px;
        }
        
        .sidebar-nav-link {
            display: flex;
            align-items: center;
            padding: 15px 25px;
            text-decoration: none;
            color: rgba(255, 255, 255, 0.9);
            transition: var(--transition);
            position: relative;
            overflow: hidden;
            border-left: 1px solid transparent;
        }
        
        .sidebar-nav-link::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 4px;
            background: white;
            transform: translateX(-100%);
            transition: transform 0.3s;
        }
        
        .sidebar-nav-link:hover, .sidebar-nav-link.active {
            background: var(--hover);
            color: white;
            border-left: 2px solid var(--hover);
        }
        
        .sidebar-nav-link:hover::before, .sidebar-nav-link.active::before {
            transform: translateX(0);
        }
        
        .sidebar-nav-link i {
            margin-right: 15px;
            width: 20px;
            text-align: center;
            font-size: 18px;
            transition: var(--transition);
        }
        
        .sidebar-nav-link:hover i, .sidebar-nav-link.active i {
            transform: scale(1.1);
        }
        
        .sidebar-nav-text {
            flex: 1;
            font-weight: 500;
            font-size: 15px;
        }
        
        .sidebar-chevron {
            font-size: 12px;
            transition: transform 0.3s;
        }
        
        .sidebar-nav-link.active .sidebar-chevron {
            transform: rotate(180deg);
        }
        
        .sidebar-dropdown {
            padding-left: 0;
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            background: rgba(0, 0, 0, 0.1);
        }
        
        .sidebar-dropdown.active {
            max-height: 500px;
        }
        
        .sidebar-dropdown-item {
            list-style: none;
        }
        
        .sidebar-dropdown-link {
            display: flex;
            align-items: center;
            padding: 12px 25px 12px 55px;
            text-decoration: none;
            color: rgba(255, 255, 255, 0.8);
            font-size: 14px;
            transition: var(--transition);
            position: relative;
        }
        
        .sidebar-dropdown-link::before {
            content: '';
            position: absolute;
            left: 40px;
            top: 50%;
            width: 6px;
            height: 6px;
            background: white;
            border-radius: 50%;
            transform: translateY(-50%);
            opacity: 0;
            transition: opacity 0.3s;
        }
        
        .sidebar-dropdown-link:hover {
            background: rgba(255, 255, 255, 0.05);
            color: white;
            padding-left: 60px;
        }
        
        .sidebar-dropdown-link:hover::before {
            opacity: 1;
        }
        
        .sidebar-dropdown-link i {
            margin-right: 12px;
            font-size: 14px;
            width: 20px;
            text-align: center;
        }
        
        /* Overlay for mobile */
        .sidebar-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 999;
            display: none;
            backdrop-filter: blur(3px);
            transition: opacity 0.3s;
        }
        
        .sidebar-overlay.active {
            display: block;
            opacity: 1;
        }
        
        /* Content Area */
        .content {
            margin-left: 280px;
            padding: 30px;
            transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            min-height: calc(100vh - 80px);
        }
        
        /* Responsive Styles */
        @media (max-width: 1200px) {
            .main-navbar {
                left: 0;
                width: 100%;
            }
            
            .content {
                margin-left: 0;
            }
            
            #sidebar {
                transform: translateX(-100%);
            }
            
            #sidebar.active {
                transform: translateX(0);
            }
            
            .nav-toggle {
                display: flex;
                
            }
        }
        
        @media (max-width: 768px) {
            .nav-container {
                padding: 0 15px;
            }
            
            .nav-brand {
                font-size: 18px;
            }
            
            .nav-logo {
                width: 40px;
                height: 40px;
            }
            
            .admin-icons-container {
                display: none;
            }
            
            .mobile-admin-icons {
                display: flex;
            }
            
            .user-info {
                display: none;
            }
            
            .user-dropdown-toggle {
                padding: 8px;
            }
            
            .user-dropdown-menu {
                min-width: 200px;
                right: 10px;
            }
            
            .content {
                padding: 20px;
            }
            
            #sidebar {
                width: 280px;
            }
            
            .main-navbar {
                height: 70px;
            }
            
            body {
                padding-top: 70px;
            }
        }
        
        @media (max-width: 480px) {
            .nav-brand span {
                display: none;
            }
            
            .mobile-admin-icons {
                gap: 10px;
            }
            
            .icon-wrapper {
                width: 40px;
                height: 40px;
            }
            
            .mobile-user-toggle {
                width: 40px;
                height: 40px;
                font-size: 14px;
                background: var(--primary);
            }
            
            .user-dropdown-menu {
                min-width: 180px;
                right: 5px;
            }
        }
        
        /* Animation for page load */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animated {
            animation: fadeIn 0.5s ease-out;
        }
    </style>
</head>
<body class="animated">

    <!-- Enhanced Navbar -->
    <nav class="main-navbar">
        <div class="nav-container">
            <div class="nav-left">
                <button class="nav-toggle" onclick="toggleSidebar()">
                    <i class="fas fa-bars"></i>
                </button>
                <a href="#" class="nav-brand">
                    <img src="../logo.png" alt="logo" class="nav-logo">
                    <span>
                        <?php
                        $select=mysqli_query($conn,"SELECT sname FROM admin");
                        while ($row=mysqli_fetch_array($select)) {
                            echo htmlspecialchars($row['sname']);
                        }
 $email = $_SESSION['email'];
    $query = mysqli_query($conn, "SELECT * FROM staff WHERE email='$email' LIMIT 1"); 
    if($query && mysqli_num_rows($query) > 0) {
        $studentRow = mysqli_fetch_array($query);
        $email = htmlspecialchars($studentRow['email']);
        $imagepro = $studentRow['image'] ?? 'default.jpg';
    }
                        ?>
                    </span>
                </a>
            </div>
            
            <?php
            // Get user info for dropdown
            $userInitial = 'A';
            $userName = 'Admin';
            $userRole = 'Administrator';
            if(isset($_SESSION['email'])) {
                $email = $_SESSION['email'];
                $query = mysqli_query($conn, "SELECT * FROM staff WHERE email='$email'");
                if($query && mysqli_num_rows($query) > 0) {
                    while($row = mysqli_fetch_array($query)) {
                        $userName = htmlspecialchars($row['staffname']);
                        $userInitial = strtoupper(substr($userName, 0, 1));
                        $userRole = $_SESSION['role'] ?? 'Administrator';
                    }
                }
            }

$thawi = date('H');
if ($thawi < 12) {
    $greeting = '<i class="bi bi-brightness-alt-high"></i>';
} elseif ($thawi < 17) {
    $greeting = '<i class="bi bi-brightness-high"></i>';
} else {
    $greeting = '<i class="bi bi-moon"></i>';
}
            ?>
            
            <!-- Desktop Admin Icons -->
            <div class="admin-icons-container">
                <!-- Notifications -->
                <div class="icon-wrapper" title="Notifications">
                    <i class="fas fa-bell"></i>
                    <span class="notification-badge">3</span>
                </div>
                
                <!-- Settings -->
                    <a href="account.php" class="icon-wrapper" title="Settings">
                <?php echo $greeting; ?>
                </a>
                <a href="account.php" class="icon-wrapper" title="Settings">
                    <i class="fas fa-cog"></i>
                </a>
                
                <!-- User Profile Dropdown -->
                <div class="user-dropdown">
                    <button class="user-dropdown-toggle" onclick="toggleUserDropdown('desktop')">
                        <div class="user-avatar"><?php echo $userInitial; ?></div>
                        <div class="user-info">
                            <span class="user-name"><?php echo $userName; ?></span>
                            <span class="user-role"><?php echo $userRole; ?></span>
                        </div>
                        <i class="fas fa-chevron-down user-chevron"></i>
                    </button>
                    
                    <!-- Dropdown Menu -->
                    <div class="user-dropdown-menu" id="desktop-dropdown-menu">
                        <div class="user-dropdown-header">
                            <div class="user-avatar" style="width: 50px; height: 50px; font-size: 20px;"><?php echo $userInitial; ?></div>
                            <div style="margin-top: 10px;">
                                <div style="font-weight: 600; font-size: 16px;"><?php echo $userName; ?></div>
                                <div style="font-size: 13px; color: var(--gray);"><?php echo $userRole; ?></div>
                            </div>
                        </div>
                        <a href="account.php" class="user-dropdown-item">
                            <i class="fas fa-user"></i>
                            <span>My Profile</span>
                        </a>
                        <a href="#" class="user-dropdown-item">
                            <i class="fas fa-cog"></i>
                            <span>Settings</span>
                        </a>
                        <a href="#" class="user-dropdown-item">
                            <i class="fas fa-bell"></i>
                            <span>Notifications</span>
                        </a>
                        <div class="user-dropdown-divider"></div>
                        <a href="logout.php" class="user-dropdown-item logout">
                            <i class="fas fa-sign-out-alt"></i>
                            <span>Logout</span>
                        </a>
                    </div>
                </div>
            </div>
            
            <!-- Mobile Admin Icons -->
            <div class="mobile-admin-icons">
                <div class="icon-wrapper" title="Notifications">
                    <i class="fas fa-bell"></i>
                    <span class="notification-badge">3</span>
                </div>
                
                <!-- Mobile User Dropdown -->
                <div class="user-dropdown">
                    <button class="mobile-user-toggle" onclick="toggleUserDropdown('mobile')">
                        <?php echo $userInitial; ?>
                    </button>
                    
                    <!-- Dropdown Menu for Mobile -->
                    <div class="user-dropdown-menu mobile-dropdown-menu" id="mobile-dropdown-menu">
                        <div class="user-dropdown-header">
                            <div class="user-avatar" style="width: 40px; height: 40px;"><?php echo $userInitial; ?></div>
                            <div style="margin-top: 10px;">
                                <div style="font-weight: 600; font-size: 14px;"><?php echo $userName; ?></div>
                                <div style="font-size: 12px; color: var(--gray);"><?php echo $userRole; ?></div>
                            </div>
                        </div>
                        <a href="account.php" class="user-dropdown-item">
                            <i class="fas fa-user"></i>
                            <span>My Profile</span>
                        </a>
                        <a href="#" class="user-dropdown-item">
                            <i class="fas fa-cog"></i>
                            <span>Settings</span>
                        </a>
                        <div class="user-dropdown-divider"></div>
                        <a href="logout.php" class="user-dropdown-item logout">
                            <i class="fas fa-sign-out-alt"></i>
                            <span>Logout</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </nav>

    <?php include "../../color.php";?>

    <!-- Sidebar Overlay for Mobile -->
    <div class="sidebar-overlay" onclick="toggleSidebar()"></div>

    <!-- Enhanced Sidebar -->
    <div id="sidebar">
        <div class="sidebar-header">
            <button class="sidebar-close" onclick="toggleSidebar()">
                <i class="fas fa-times"></i>
            </button>
            <div class="sidebar-profile">
                <img src="<?php echo htmlspecialchars($imagepro); ?>" alt="logo" class="sidebar-profile-img">
                <?php
                if(isset($_SESSION['email'])) {
                    $email = $_SESSION['email'];
                    $query = mysqli_query($conn, "SELECT * FROM staff WHERE email='$email'");
                    if($query && mysqli_num_rows($query) > 0) {
                        while($row = mysqli_fetch_array($query)) { 
                ?>
                <div class="sidebar-profile-name"><?php echo htmlspecialchars($row['staffname']); ?></div>
                <div class="sidebar-profile-role"><?php echo $_SESSION['role'] ?? 'User'; ?></div>
                <?php 
                        }
                    }
                }
                ?>
            </div>
        </div>
        
        <ul class="sidebar-nav">
            <!-- Dashboard -->
            <li class="sidebar-nav-item">
                <a href="dashboard" class="sidebar-nav-link">
                    <i class="fas fa-home"></i>
                    <span class="sidebar-nav-text">Dashboard</span>
                </a>
            </li>

            <!-- Student Affairs -->
            <?php if(isset($_SESSION['role']) && $_SESSION['role'] == "Student Affairs"): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('admin-dropdown8', event)">
                    <i class="fas fa-users"></i>
                    <span class="sidebar-nav-text">Student Affairs</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="admin-dropdown8" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="send.php" class="sidebar-dropdown-link">
                            <i class="fas fa-envelope"></i>
                            <span>Message</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="elibrra.com" class="sidebar-dropdown-link">
                            <i class="fas fa-book"></i>
                            <span>E-Library</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="catelogue.php" class="sidebar-dropdown-link">
                            <i class="fas fa-folder-open"></i>
                            <span>Catalogue</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="students.php" class="sidebar-dropdown-link">
                            <i class="fas fa-user-graduate"></i>
                            <span>Students</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Scholarship -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Student Affairs", "Superadmin", "Admin"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('admin-dropdown7', event)">
                    <i class="fas fa-trophy"></i>
                    <span class="sidebar-nav-text">Scholarship</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="admin-dropdown7" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="scholarship.php" class="sidebar-dropdown-link">
                            <i class="fas fa-eye"></i>
                            <span>View</span>
                        </a>
                    </li>
                    <?php if(in_array($_SESSION['role'], ["Superadmin", "Admin"])): ?>
                    <li class="sidebar-dropdown-item">
                        <a href="award.php" class="sidebar-dropdown-link">
                            <i class="fas fa-award"></i>
                            <span>Award</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="scholarreport.php" class="sidebar-dropdown-link">
                            <i class="fas fa-chart-bar"></i>
                            <span>Report</span>
                        </a>
                    </li>
                    <?php endif; ?>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Department -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Superadmin", "Admin", "hod"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('admin-dropdown10', event)">
                    <i class="fas fa-building"></i>
                    <span class="sidebar-nav-text">Department</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="admin-dropdown10" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="examhod.php" class="sidebar-dropdown-link">
                            <i class="fas fa-file-alt"></i>
                            <span>Exam</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Admin Role -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Admin", "Superadmin"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('admin-dropdown', event)">
                    <i class="fas fa-user-shield"></i>
                    <span class="sidebar-nav-text">Admin Panel</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="admin-dropdown" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="permit.php" class="sidebar-dropdown-link">
                            <i class="fas fa-check-circle"></i>
                            <span>Exam Permit</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="programs_manager.php" class="sidebar-dropdown-link">
                            <i class="fas fa-graduation_cap"></i>
                            <span>Programs</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="timetableadmin.php" class="sidebar-dropdown-link">
                            <i class="fas fa-calendar-alt"></i>
                            <span>Timetable</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="transcript.php" class="sidebar-dropdown-link">
                            <i class="fas fa-certificate"></i>
                            <span>Transcript</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="elibray.php" class="sidebar-dropdown-link">
                            <i class="fas fa-book-reader"></i>
                            <span>E-Library</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="catelogue.php" class="sidebar-dropdown-link">
                            <i class="fas fa-folder"></i>
                            <span>Catalogue</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="analysis.php" class="sidebar-dropdown-link">
                            <i class="fas fa-chart-pie"></i>
                            <span>Analysis</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="staff.php" class="sidebar-dropdown-link">
                            <i class="fas fa-chalkboard-teacher"></i>
                            <span>Staff</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="students.php" class="sidebar-dropdown-link">
                            <i class="fas fa-user-graduate"></i>
                            <span>Students</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Message -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Admin", "Superadmin"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('admin-dropdownsms', event)">
                    <i class="fas fa-comments"></i>
                    <span class="sidebar-nav-text">Messages</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="admin-dropdownsms" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="send.php" class="sidebar-dropdown-link">
                            <i class="fas fa-sms"></i>
                            <span>SMS Students</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="sendstaff.php" class="sidebar-dropdown-link">
                            <i class="fas fa-sms"></i>
                            <span>SMS Staff</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Online Class -->
            <li class="sidebar-nav-item">
                <a href="timetable.php" class="sidebar-nav-link">
                    <i class="fas fa-video"></i>
                    <span class="sidebar-nav-text">Online Class</span>
                </a>
            </li>

            <!-- Course Manager -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Admin", "Superadmin"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('admin-dropdown2', event)">
                    <i class="fas fa-book"></i>
                    <span class="sidebar-nav-text">Course Manager</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="admin-dropdown2" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="course.php" class="sidebar-dropdown-link">
                            <i class="fas fa-graduation-cap"></i>
                            <span>Courses</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="register.php" class="sidebar-dropdown-link">
                            <i class="fas fa-plus-circle"></i>
                            <span>Register</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="deregister.php" class="sidebar-dropdown-link">
                            <i class="fas fa-minus-circle"></i>
                            <span>Deregister</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Finance -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Finance", "Superadmin"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('finance-dropdown', event)">
                    <i class="fas fa-money-bill-wave"></i>
                    <span class="sidebar-nav-text">Finance</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="finance-dropdown" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="payment.php" class="sidebar-dropdown-link">
                            <i class="fas fa-credit-card"></i>
                            <span>Fees</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="balance.php" class="sidebar-dropdown-link">
                            <i class="fas fa-file-invoice-dollar"></i>
                            <span>Invoices</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Association -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Finance", "Superadmin", "Student Affairs"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('association-dropdown', event)">
                    <i class="fas fa-handshake"></i>
                    <span class="sidebar-nav-text">Association</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="association-dropdown" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="assopay.php" class="sidebar-dropdown-link">
                            <i class="fas fa-money-check-alt"></i>
                            <span>Fees</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="assoinvoice.php" class="sidebar-dropdown-link">
                            <i class="fas fa-receipt"></i>
                            <span>Invoices</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Librarian -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Librarian", "Superadmin"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('librarian-dropdown', event)">
                    <i class="fas fa-book-open"></i>
                    <span class="sidebar-nav-text">Library</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="librarian-dropdown" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="catelogue.php" class="sidebar-dropdown-link">
                            <i class="fas fa-list"></i>
                            <span>Catalogue</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="owing.php" class="sidebar-dropdown-link">
                            <i class="fas fa-exclamation-circle"></i>
                            <span>Report</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Academic -->
            <?php if(isset($_SESSION['role']) && in_array($_SESSION['role'], ["Admin", "Lecturer", "Superadmin"])): ?>
            <li class="sidebar-nav-item">
                <a href="#" class="sidebar-nav-link dropdown-toggle" onclick="toggleDropdown('academic-dropdown', event)">
                    <i class="fas fa-graduation-cap"></i>
                    <span class="sidebar-nav-text">Academic</span>
                    <i class="fas fa-chevron-down sidebar-chevron ml-auto"></i>
                </a>
                <ul id="academic-dropdown" class="sidebar-dropdown">
                    <li class="sidebar-dropdown-item">
                        <a href="timetable.php" class="sidebar-dropdown-link">
                            <i class="fas fa-calendar-check"></i>
                            <span>My Timetable</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="videos.php" class="sidebar-dropdown-link">
                            <i class="fas fa-video"></i>
                            <span>Videos</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="elibrra.com" class="sidebar-dropdown-link">
                            <i class="fas fa-book"></i>
                            <span>E-Library</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="exam_schedule.php" class="sidebar-dropdown-link">
                            <i class="fas fa-pen-alt"></i>
                            <span>Online Test</span>
                        </a>
                    </li>
                    <li class="sidebar-dropdown-item">
                        <a href="onlineclass/onlineclass.php" class="sidebar-dropdown-link">
                            <i class="fas fa-chalkboard-teacher"></i>
                            <span>Online Class</span>
                        </a>
                    </li>
                </ul>
            </li>
            <?php endif; ?>

            <!-- Clearance Verification -->
            <li class="sidebar-nav-item">
                <a href="verication.php" class="sidebar-nav-link">
                    <i class="fas fa-search"></i>
                    <span class="sidebar-nav-text">Verify Clearance</span>
                </a>
            </li>
            
            <!-- Account -->
            <li class="sidebar-nav-item">
                <a href="account.php" class="sidebar-nav-link">
                    <i class="fas fa-user-cog"></i>
                    <span class="sidebar-nav-text">My Account</span>
                </a>
            </li>
            
            <!-- Logout -->
            <li class="sidebar-nav-item">
                <a href="logout.php" class="sidebar-nav-link logout-sidebar">
                    <i class="fas fa-sign-out-alt"></i>
                    <span class="sidebar-nav-text">Logout</span>
                </a>
            </li>
        </ul>
    </div>

    <!-- Mobile Bottom Navigation -->
    <div class="bottom-nav" style="display: none;">
        <a href="dashboard" class="bottom-nav-link">
            <i class="fas fa-home bottom-nav-icon"></i>
            <span>Home</span>
        </a>
        <a href="account.php" class="bottom-nav-link">
            <i class="fas fa-user bottom-nav-icon"></i>
            <span>Account</span>
        </a>
        <a href="verication.php" class="bottom-nav-link">
            <i class="fas fa-search bottom-nav-icon"></i>
            <span>Verify</span>
        </a>
        <a href="logout.php" class="bottom-nav-link">
            <i class="fas fa-sign-out-alt bottom-nav-icon"></i>
            <span>Logout</span>
        </a>
    </div>

    <!-- Optimized JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // Toggle sidebar function
        function toggleSidebar() {
            const sidebar = document.getElementById('sidebar');
            const overlay = document.querySelector('.sidebar-overlay');
            const navbar = document.querySelector('.main-navbar');
            
            sidebar.classList.toggle('active');
            overlay.classList.toggle('active');
            document.body.classList.toggle('sidebar-open');
            
            // Add/remove overflow hidden from body
            if (sidebar.classList.contains('active')) {
                document.body.style.overflow = 'hidden';
            } else {
                document.body.style.overflow = '';
            }
        }
        
        // Toggle dropdown menus in sidebar
        function toggleDropdown(dropdownId, event) {
            if (event) {
                event.preventDefault();
                event.stopPropagation();
            }
            
            const dropdown = document.getElementById(dropdownId);
            const isActive = dropdown.classList.contains('active');
            const chevron = event.target.closest('.sidebar-nav-link').querySelector('.sidebar-chevron');
            
            // Close all other dropdowns
            document.querySelectorAll('.sidebar-dropdown').forEach(drop => {
                if (drop.id !== dropdownId) {
                    drop.classList.remove('active');
                    drop.previousElementSibling.querySelector('.sidebar-chevron').classList.remove('fa-rotate-180');
                }
            });
            
            // Toggle current dropdown
            if (!isActive) {
                dropdown.classList.add('active');
                chevron.classList.add('fa-rotate-180');
            } else {
                dropdown.classList.remove('active');
                chevron.classList.remove('fa-rotate-180');
            }
        }
        
        // Toggle user dropdown for both desktop and mobile
        function toggleUserDropdown(type) {
            event.stopPropagation();
            
            const desktopMenu = document.getElementById('desktop-dropdown-menu');
            const mobileMenu = document.getElementById('mobile-dropdown-menu');
            const desktopButton = document.querySelector('#desktop-user-dropdown .user-dropdown-toggle');
            const mobileButton = document.querySelector('#mobile-user-dropdown .mobile-user-toggle');
            
            if (type === 'desktop') {
                desktopMenu.classList.toggle('active');
                desktopButton.classList.toggle('active');
                
                // Close mobile menu if open
                if (mobileMenu && mobileMenu.classList.contains('active')) {
                    mobileMenu.classList.remove('active');
                    mobileButton.classList.remove('active');
                }
            } else if (type === 'mobile') {
                mobileMenu.classList.toggle('active');
                mobileButton.classList.toggle('active');
                
                // Close desktop menu if open
                if (desktopMenu && desktopMenu.classList.contains('active')) {
                    desktopMenu.classList.remove('active');
                    desktopButton.classList.remove('active');
                }
            }
        }
        
        // Close sidebar when clicking on overlay
        document.querySelector('.sidebar-overlay').addEventListener('click', function() {
            toggleSidebar();
        });
        
        // Close dropdowns when clicking outside
        document.addEventListener('click', function(event) {
            // Close sidebar dropdowns
            if (!event.target.closest('.sidebar-nav')) {
                document.querySelectorAll('.sidebar-dropdown').forEach(dropdown => {
                    dropdown.classList.remove('active');
                });
                document.querySelectorAll('.sidebar-chevron').forEach(chevron => {
                    chevron.classList.remove('fa-rotate-180');
                });
            }
            
            // Close user dropdowns
            if (!event.target.closest('.user-dropdown')) {
                const desktopMenu = document.getElementById('desktop-dropdown-menu');
                const mobileMenu = document.getElementById('mobile-dropdown-menu');
                const desktopButton = document.querySelector('#desktop-user-dropdown .user-dropdown-toggle');
                const mobileButton = document.querySelector('#mobile-user-dropdown .mobile-user-toggle');
                
                if (desktopMenu && desktopMenu.classList.contains('active')) {
                    desktopMenu.classList.remove('active');
                    desktopButton.classList.remove('active');
                }
                
                if (mobileMenu && mobileMenu.classList.contains('active')) {
                    mobileMenu.classList.remove('active');
                    mobileButton.classList.remove('active');
                }
            }
        });
        
        // Set active nav link based on current page
        document.addEventListener('DOMContentLoaded', function() {
            const currentPage = window.location.pathname.split('/').pop();
            const navLinks = document.querySelectorAll('.sidebar-nav-link');
            
            navLinks.forEach(link => {
                const href = link.getAttribute('href');
                if (href && (href === currentPage || href.includes(currentPage))) {
                    link.classList.add('active');
                    
                    // If it's inside a dropdown, open the parent dropdown
                    const parentDropdown = link.closest('.sidebar-dropdown');
                    if (parentDropdown) {
                        parentDropdown.classList.add('active');
                        const parentLink = parentDropdown.previousElementSibling;
                        parentLink.classList.add('active');
                        parentLink.querySelector('.sidebar-chevron').classList.add('fa-rotate-180');
                    }
                }
            });
            
            // Show mobile bottom nav on mobile
            if (window.innerWidth <= 768) {
                document.querySelector('.bottom-nav').style.display = 'flex';
            }
        });
        
        // Handle window resize
        window.addEventListener('resize', function() {
            // Show/hide bottom nav based on screen size
            if (window.innerWidth <= 768) {
                document.querySelector('.bottom-nav').style.display = 'flex';
            } else {
                document.querySelector('.bottom-nav').style.display = 'none';
                // Close sidebar on desktop if it was open from mobile
                if (window.innerWidth > 1200) {
                    const sidebar = document.getElementById('sidebar');
                    const overlay = document.querySelector('.sidebar-overlay');
                    sidebar.classList.remove('active');
                    overlay.classList.remove('active');
                    document.body.style.overflow = '';
                }
            }
        });
        
        // Add smooth scrolling to all anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                const target = document.querySelector(this.getAttribute('href'));
                if (target) {
                    target.scrollIntoView({
                        behavior: 'smooth',
                        block: 'start'
                    });
                }
            });
        });
        
        // Add loading animation
        document.addEventListener('DOMContentLoaded', function() {
            setTimeout(() => {
                document.body.classList.add('loaded');
            }, 300);
        });
    </script>
</body>
</html>