<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>E&SE Kotli - District School Management System</title>
    
    <!-- Meta tags for SEO -->
    <meta name="description" content="District School Management System for Kotli AJK - School information, registration, notifications, and educational resources">
    <meta name="keywords" content="school management, Kotli, education, AJK, district schools, teacher registration">
    <meta property="og:title" content="E&SE Kotli - District School Management System">
    <meta property="og:description" content="Official portal for school management in Kotli district">
    <meta property="og:image" content="images/Header.jpg">
    
    <!-- Favicon -->
    <link rel="icon" href="images/favicon.ico" type="image/x-icon">
    
    <!-- Bootstrap 5 -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Montserrat:wght@400;600;700&display=swap" rel="stylesheet">
    
    <!-- Animate.css -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
    
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --accent-color: #f39c12;
            --light-color: #ecf0f1;
            --dark-color: #2c3e50;
            --success-color: #27ae60;
        }
        
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        
        html {
            scroll-behavior: smooth;
            font-size: 16px;
        }
        
        body {
            font-family: 'Poppins', sans-serif;
            color: #333;
            line-height: 1.6;
            background-color: #f9f9f9;
            padding-top: 0 !important;
            width: 100%;
            min-width: 320px;
            max-width: 100vw;
            overflow-x: hidden;
        }
        
        /* Fluid typography */
        @media (min-width: 768px) {
            html {
                font-size: calc(16px + (20 - 16) * (100vw - 768px) / (1920 - 768));
            }
        }
        
        @media (min-width: 1920px) {
            html {
                font-size: 20px;
            }
        }
		
        /* Active dropdown item */
		.dropdown-menu .dropdown-item.active {
			background-color: var(--accent-color) !important;
			color: #fff !important;
			font-weight: 600;
		}

        /* Navigation - Mobile Optimized */
        .navbar {
            background-color: var(--primary-color);
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            padding: 0.5rem 1rem;
            position: fixed;
            top: 0;
            width: 100%;
            z-index: 1030;
        }
        
        .navbar-brand img {
            height: 35px;
            width: auto;
        }
        
        .nav-link {
            color: white !important;
            font-weight: 400;
            padding: 0.5rem 0.8rem;
            border-radius: 4px;
            transition: all 0.3s ease;
            font-size: 0.90rem;
        }
        
        .nav-link:hover, .nav-link:focus {
            background-color: rgba(255,255,255,0.1);
            color: var(--accent-color) !important;
        }
		
		/* Style for active dropdown-toggle */
		.navbar-dark .navbar-nav .nav-link.dropdown-toggle.active,
		.navbar-dark .navbar-nav .nav-link.dropdown-toggle.active:hover,
		.navbar-dark .navbar-nav .nav-link.dropdown-toggle.active:focus {
			color: #ffcc00 !important;
			font-weight: bold;
		}
		
		.navbar-dark .navbar-nav .nav-link.dropdown-toggle.active::after {
			content: " ▼";
			font-size: 0.6rem;
			color: #ffcc00;
		}
		
		/* For the "Log In" button (outline-light) */
		.btn-outline-light:hover, .btn-outline-light:focus {
			background-color: var(--accent-color);
			color: var(--dark-color);
			border-color: var(--accent-color);
		}

		/* For the "Register" button (primary) */
		.btn-primary:hover, .btn-primary:focus {
			background-color: #e67e22; /* Darker orange */
			border-color: #e67e22;
		}
		
		/* For dropdown items inside these buttons */
		.dropdown-menu .dropdown-item:hover {
			background-color: var(--secondary-color);
			color: white;
		}
        
        /* Search Button and Searched Text - Mobile Optimized */
        .search-input {
            width: 200px;
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
            border-right: none;
            font-size: 0.875rem;
        }
        
        .search-btn {
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;
            background-color: var(--accent-color);
            color: white;
            font-size: 0.875rem;
            transition: all 0.3s ease;
        }
        
        .search-btn:hover {
            background-color: #e67e22;
            transform: translateY(-1px);
        }
        
        /* Highlight the Searched Text */
        mark.highlighted {
            background-color: yellow;
            color: black;
            padding: 0 2px;
            border-radius: 3px;
        }
        
        /* Active nav item styles */
        .navbar-dark .navbar-nav .nav-link.active,
        .navbar-dark .navbar-nav .nav-link.show,
        .navbar-dark .navbar-nav .nav-item.show .nav-link {
            color: #ffcc00 !important;
            font-weight: bold;
            background-color: transparent !important;
            position: relative;
        }

        .navbar-dark .navbar-nav .nav-link.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 60%;
            height: 3px;
            background: #ffcc00;
            border-radius: 2px;
        }
        
        /* Hover states */
        .navbar-dark .navbar-nav .nav-link.active:hover,
        .navbar-dark .navbar-nav .nav-link.active:focus {
            color: #ffdb4d !important;
        }
        
        /* Dropdown Styles */
        .dropdown-menu {
            background-color: white;
            border: none;
            border-radius: 8px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.15);
            display: none;
            position: absolute;
            z-index: 1000;
            min-width: 200px;
            animation: dropdownFade 0.3s ease;
            border-top: 3px solid var(--accent-color);
        }

        @keyframes dropdownFade {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .dropdown-menu.show {
            display: block;
        }
        
        /* Ensure dropdowns are positioned correctly */
        .dropdown {
            position: relative;
        }
        
        /* For the "Register" button (primary) */
        .btn-primary {
            background: linear-gradient(to right, var(--accent-color), #e67e22);
            border: none;
            transition: all 0.3s ease;
        }
        
        .btn-primary:hover, .btn-primary:focus {
            background: linear-gradient(to right, #e67e22, #d35400);
            border-color: #e67e22;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        
        /* For dropdown items inside these buttons */
        .dropdown-item {
            padding: 0.6rem 1rem;
            transition: all 0.2s ease;
            color: #333;
            display: block;
            text-decoration: none;
            border-radius: 4px;
            margin: 2px 5px;
        }
        
        .dropdown-item:hover {
            background-color: var(--secondary-color);
            color: white;
            transform: translateX(5px);
        }
        
        /* Navbar Actions Container - Mobile Optimized */
        .nav-actions {
            display: flex;
            align-items: center;
            flex-wrap: nowrap;
            gap: 0.5rem;
        }
        
        /* Button group for login/register */
        .btn-group-mobile {
            display: flex;
            gap: 0.3rem;
        }
        
        .btn-group-mobile .btn {
            white-space: nowrap;
            flex-shrink: 0;
            border-radius: 6px !important;
        }
        
        /* Logo Table Styles - Mobile Optimized */
        .logo-custom-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 56px; /* Height of navbar */
            background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            border: none !important;
            position: relative;
            overflow: hidden;
        }

        .logo-custom-table::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(to right, #2e7d32, #3498db, #f39c12);
        }
        
        .logo-custom-table td {
            padding: 1rem;
            vertical-align: middle;
            border: none !important;
            transition: all 0.3s ease;
        }

        .logo-custom-table:hover td {
            background: rgba(0,0,0,0.01);
        }
        
        .logo-col-1, .logo-col-3 {
            text-align: center;
            width: 15%;
        }
        
        .logo-col-2 {
            text-align: center;
            width: 70%;
        }
        
        .logo-col-2 p {
            margin: 0.2rem 0;
            line-height: 1.1;
            font-family: 'Montserrat', sans-serif;
        }
        
        .main-title {
            font-size: clamp(1.5rem, 3.5vw, 2.5rem);
            font-weight: 800;
            background: linear-gradient(to right, #006600, #009900);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
            white-space: nowrap;
            margin-bottom: 0.5rem;
        }
        
        .sub-title {
            font-size: clamp(1rem, 2vw, 1.5rem);
            color: var(--dark-color);
            font-weight: 500;
        }
        
        .logo-custom-table img {
            max-width: 100%;
            height: auto;
            display: block;
            transition: transform 0.3s ease;
        }

        .logo-custom-table:hover img {
            transform: scale(1.05);
        }
        
        /* Simple dropdown arrow */
        .dropdown-toggle::after {
            display: inline-block;
            margin-left: 0.255em;
            vertical-align: 0.255em;
            content: "";
            border-top: 0.3em solid;
            border-right: 0.3em solid transparent;
            border-bottom: 0;
            border-left: 0.3em solid transparent;
            transition: transform 0.3s ease;
        }

        .dropdown-toggle.show::after {
            transform: rotate(-180deg);
        }

        /* Loading animation */
        .loading {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(255,255,255,.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: spin 1s ease-in-out infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* Scroll to top button */
        .scroll-top {
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 50px;
            height: 50px;
            background: var(--accent-color);
            color: white;
            border: none;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            cursor: pointer;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.3s ease;
            z-index: 1000;
            box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        }

        .scroll-top.visible {
            opacity: 1;
            transform: translateY(0);
        }

        .scroll-top:hover {
            background: #e67e22;
            transform: translateY(-5px) scale(1.1);
        }

        /* Add this to animated elements */
        .animate__animated {
            will-change: transform, opacity;
        }
        
        /* ========== MOBILE RESPONSIVE STYLES ========== */
        
        /* Large Tablets and Small Desktops */
        @media (max-width: 992px) {
            .navbar-nav {
                padding-top: 1rem;
            }
            
            .nav-item {
                margin-bottom: 0.5rem;
            }
            
            .nav-actions {
                margin: 1rem 0;
                justify-content: flex-start;
            }
            
            .logo-col-2 p {
                margin: 0.1rem 0;
                line-height: 1;
            }
            
            .main-title {
                font-size: clamp(1.3rem, 3.5vw, 2rem);
            }
            
            .sub-title {
                font-size: clamp(0.9rem, 1.8vw, 1.3rem);
            }
            
            /* Improve dropdown positioning */
            .dropdown-menu {
                position: static !important;
                float: none !important;
                width: 100% !important;
                margin-top: 0.5rem !important;
                box-shadow: none;
                border: 1px solid rgba(0,0,0,0.1);
            }
        }
        
        /* Tablets */
        @media (max-width: 768px) {
            .logo-custom-table td {
                padding: 0.75rem;
            }
            
            .logo-col-1, .logo-col-3 {
                width: 20%;
            }
            
            .logo-col-2 {
                width: 60%;
            }
            
            .main-title {
                font-size: clamp(1.2rem, 3vw, 1.8rem);
                white-space: normal;
                line-height: 1.2;
            }
            
            .sub-title {
                font-size: clamp(0.8rem, 1.6vw, 1.1rem);
            }
            
            /* Adjust search bar for tablets */
            .search-input {
                width: 180px;
            }
            
            .nav-actions {
                gap: 0.4rem;
            }
        }
        
        /* Mobile Phones */
        @media (max-width: 576px) {
            .navbar {
                padding: 0.4rem 0.75rem;
            }
            
            .navbar-brand img {
                height: 30px;
            }
            
            .navbar-toggler {
                padding: 0.2rem 0.4rem;
                font-size: 0.9rem;
            }
            
            /* Logo table mobile layout */
            .logo-custom-table {
                display: block;
                margin-top: 50px; /* Adjusted for smaller navbar */
            }
            
            .logo-custom-table tbody {
                display: flex;
                flex-direction: column;
                align-items: center;
            }
            
            .logo-custom-table tr {
                display: flex;
                flex-direction: column;
                align-items: center;
                width: 100%;
            }
            
            .logo-custom-table td {
                width: 100% !important;
                text-align: center !important;
                padding: 0.5rem;
            }
            
            .logo-col-2 {
                order: -1;
                margin-bottom: 0.5rem;
            }
            
            .main-title {
                font-size: 1.3rem;
                line-height: 1.3;
                margin-bottom: 0.3rem;
            }
            
            .sub-title {
                font-size: 0.9rem;
            }
            
            .logo-col-1, .logo-col-3 {
                width: 40%;
                padding: 0.3rem;
            }
            
            .logo-custom-table img {
                max-height: 60px;
                margin: 0 auto;
            }
            
            /* Mobile navigation actions - buttons in single line */
            .nav-actions {
                flex-direction: column;
                width: 100%;
                gap: 0.5rem;
                margin: 0.5rem 0;
                align-items: stretch;
            }
            
            /* Button group stays in single line */
            .btn-group-mobile {
                display: flex;
                gap: 0.3rem;
                justify-content: center;
            }
            
            .btn-group-mobile .btn {
                padding: 0.4rem 0.8rem;
                font-size: 0.85rem;
                white-space: nowrap;
                flex: 1;
            }
            
            .input-group {
                width: 100% !important;
                margin-top: 0.5rem;
                flex: 1;
                min-width: 150px;
            }
            
            .search-input {
                width: 100%;
                font-size: 0.85rem;
            }
            
            /* Improve dropdown menus for mobile */
            .dropdown-menu {
                position: static !important;
                transform: none !important;
                width: 100%;
                margin-top: 0.5rem;
            }
        }
        
        /* Small Mobile Phones */
        @media (max-width: 380px) {
            .navbar {
                padding: 0.3rem 0.5rem;
            }
            
            .main-title {
                font-size: 1.1rem;
            }
            
            .sub-title {
                font-size: 0.8rem;
            }
            
            .logo-custom-table td {
                padding: 0.3rem;
            }
            
            .logo-custom-table img {
                max-height: 50px;
            }
            
            .nav-link {
                font-size: 0.9rem;
                padding: 0.4rem 0.6rem;
            }
            
            /* Adjust button sizes for very small screens */
            .btn-group-mobile .btn {
                font-size: 0.75rem;
                padding: 0.3rem 0.6rem;
            }
            
            .input-group {
                min-width: 120px;
            }
            
            .search-input {
                font-size: 0.8rem;
            }
        }
        
        /* Extra Small Screens */
        @media (max-width: 320px) {
            /* Ensure buttons stay in single line with smaller text */
            .btn-group-mobile .btn {
                font-size: 0.7rem;
                padding: 0.25rem 0.5rem;
            }
            
            .nav-actions {
                gap: 0.3rem;
            }
            
            .input-group {
                min-width: 110px;
            }
            
            .main-title {
                font-size: 1rem;
            }

            .btn-group-mobile {
                flex-direction: column;
                gap: 0.3rem;
            }

            .btn-group-mobile .btn {
                width: 100%;
            }
        }
        
        /* Fix for very tall screens */
        @media (max-height: 500px) and (orientation: landscape) {
            .navbar-collapse {
                max-height: 70vh;
                overflow-y: auto;
            }
        }
    </style>
</head>

<body>
    <!-- Scroll to top button -->
    <button class="scroll-top" id="scrollTop" aria-label="Scroll to top">
        <i class="fas fa-chevron-up"></i>
    </button>

    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark fixed-top">
        <div class="container-fluid">
            <a class="navbar-brand d-lg-none" href="#">
                <img src="images/Head_Logo1.png" alt="District Kotli Logo" loading="lazy">
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="mainNav">
                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                    <li class="nav-item">
                        <a class="nav-link <?php echo $current_page == 'index.php' ? 'active' : ''; ?>" href="index.php">Home</a>
                    </li>
                    
                    <!-- Summary Dropdown -->
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" data-dropdown="summary">Summary</a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item <?php echo $current_page == 'schools_info.php' ? 'active' : ''; ?>" href="schools_info.php"><i class="fas fa-school me-2"></i>Schools</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'teacher&staff_info.php' ? 'active' : ''; ?>" href="teacher&staff_info.php"><i class="fas fa-chalkboard-teacher me-2"></i>Teachers & Staff</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'students_info.php' ? 'active' : ''; ?>" href="students_info.php"><i class="fas fa-user-graduate me-2"></i>Students</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'overall_info.php' ? 'active' : ''; ?>" href="overall_info.php"><i class="fas fa-chart-pie me-2"></i>Overall Summary</a></li>
                        </ul>
                    </li>
                    
                    <li class="nav-item">
                        <a class="nav-link <?php echo $current_page == 'org_chart.php' ? 'active' : ''; ?>" href="org_chart.php">Org Chart</a>
                    </li>
                    
                    <!-- Private Schools Dropdown -->
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" data-dropdown="private_schools">Private Schools</a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item <?php echo $current_page == 'reg_schools.php' ? 'active' : ''; ?>" href="reg_schools.php"><i class="fas fa-check-circle me-2"></i>Registered</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'unreg_schools.php' ? 'active' : ''; ?>" href="unreg_schools.php"><i class="fas fa-clock me-2"></i>Unregistered</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'blacklist_schools.php' ? 'active' : ''; ?>" href="blacklist_schools.php"><i class="fas fa-ban me-2"></i>Blacklist</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'reg_procedure.php' ? 'active' : ''; ?>" href="reg_procedure.php"><i class="fas fa-file-alt me-2"></i>Procedure</a></li>
                        </ul>
                    </li>
                    
                    <li class="nav-item">
                        <a class="nav-link <?php echo $current_page == 'notification_show.php' ? 'active' : ''; ?>" href="notification_show.php">Notifications</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link <?php echo $current_page == 'gallery_show.php' ? 'active' : ''; ?>" href="gallery_show.php">Gallery</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link <?php echo $current_page == 'contact_us.php' ? 'active' : ''; ?>" href="contact_us.php">Contact</a>
                    </li>
                    
                    <!-- More Dropdown Menu -->
                    <li class="nav-item dropdown" id="moreDropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" data-dropdown="more">More</a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="http://ebekotli.dsisajk.net/index.php"><i class="fas fa-school me-2"></i>Elementary Board</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'examinations.php' ? 'active' : ''; ?>" href="examinations.php"><i class="fas fa-file-alt me-2"></i>Examinations</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'admissions.php' ? 'active' : ''; ?>" href="admissions.php"><i class="fas fa-user-graduate me-2"></i>Admissions</a></li>
                            <li><a class="dropdown-item <?php echo $current_page == 'fort.php' ? 'active' : ''; ?>" href="fort.php"><i class="fas fa-shield-alt me-2"></i>FORT</a></li>
                        </ul>
                    </li>
                </ul>

                <div class="nav-actions">
                    <!-- Login/Register buttons in a single line group -->
                    <div class="btn-group-mobile">
                        <div class="dropdown" id="loginDropdown">
                            <button class="btn btn-outline-light btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fas fa-sign-in-alt me-1"></i>Log In
                            </button>
                            <ul class="dropdown-menu">
                                <li><a class="dropdown-item <?php echo $current_page == 'login.php' ? 'active' : ''; ?>" href="login.php"><i class="fas fa-school me-2"></i>School Login</a></li>
                                <li><a class="dropdown-item <?php echo $current_page == 'login_emp.php' ? 'active' : ''; ?>" href="login_emp.php"><i class="fas fa-user-tie me-2"></i>Employee Login</a></li>
                            </ul>
                        </div>
                        
                        <div class="dropdown" id="registerDropdown">
                            <button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fas fa-user-plus me-1"></i>Register
                            </button>
                            <ul class="dropdown-menu">
                                <li><a class="dropdown-item <?php echo $current_page == 'register.php' ? 'active' : ''; ?>" href="register.php"><i class="fas fa-school me-2"></i>School Registration</a></li>
                                <li><a class="dropdown-item <?php echo $current_page == 'register_emp.php' ? 'active' : ''; ?>" href="register_emp.php"><i class="fas fa-user-tie me-2"></i>Employee Registration</a></li>
                            </ul>
                        </div> 
                    </div>
                    
                    <div class="input-group input-group-sm">
                        <input type="text" class="form-control search-input" placeholder="Search Site..." id="searchInput" aria-label="Search website">
                        <button class="btn search-btn" id="searchBtn" aria-label="Search"><i class="fas fa-search"></i></button>
                    </div>
                </div>
            </div>
        </div>
    </nav>

    <!-- Logo Table -->
    <a href="index.php" style="display: block; text-decoration: none;">
        <table class="logo-custom-table" role="presentation">
            <tbody>
                <tr>
                    <td class="logo-col-1">
                        <img src="images/Head_Logo1.png" alt="District Kotli Logo" loading="lazy" width="120" height="120">
                    </td>
                    <td class="logo-col-2">
                        <div class="main-title">DISTRICT SCHOOLS INFORMATION SYSTEM</div>
                        <p class="sub-title"><strong>A Project of Elementary &amp; Secondary Education</strong></p>
                        <p class="sub-title">District Kotli AJ&amp;K</p>
                    </td>
                    <td class="logo-col-3">
                        <img src="images/Head_Logo2.png" alt="Government of AJK Logo" loading="lazy" width="120" height="120">
                    </td>
                </tr>
            </tbody>
        </table>
    </a>

<script>
// BULLETPROOF JAVASCRIPT - MULTIPLE METHODS TO ENSURE IT WORKS
// Method 1: Run immediately when script loads
(function() {
    highlightActiveDropdown();
})();

// Method 2: Run when DOM is fully loaded
document.addEventListener('DOMContentLoaded', function() {
    highlightActiveDropdown();
    initScrollToTop();
    initSearch();
    enableLazyLoading();
    initializeAllDropdowns(); // ADDED THIS LINE
});

// Method 3: Run when window is fully loaded (including images)
window.addEventListener('load', function() {
    highlightActiveDropdown();
});

// Method 4: Run after a short delay to ensure everything is ready
setTimeout(highlightActiveDropdown, 100);

// Main function - FROM CODE 1 (WORKING VERSION)
function highlightActiveDropdown() {
    try {
        // Get current page
        const currentPage = window.location.pathname.split('/').pop().toLowerCase();
        console.log('Current page:', currentPage);
        
        // Define pages for each dropdown
        const summaryPages = [
            'schools_info.php',
            'teacher&staff_info.php', 
            'students_info.php',
            'overall_info.php'
        ].map(p => p.toLowerCase());
        
        const privateSchoolPages = [
            'reg_schools.php',
            'unreg_schools.php',
            'blacklist_schools.php',
            'reg_procedure.php'
        ].map(p => p.toLowerCase());
        
        const morePages = [
            'elementary_board.php',
            'examinations.php',
            'admissions.php',
            'fort.php'
        ].map(p => p.toLowerCase());
        
        // 1. First, highlight all regular nav links
        document.querySelectorAll('.nav-link:not(.dropdown-toggle)').forEach(link => {
            try {
                const href = link.getAttribute('href');
                if (href) {
                    const linkPage = href.split('/').pop().toLowerCase();
                    if (linkPage === currentPage) {
                        link.classList.add('active');
                    }
                }
            } catch(e) {
                console.error('Error processing nav link:', e);
            }
        });
        
        // 2. Highlight dropdown menu items
        document.querySelectorAll('.dropdown-item').forEach(item => {
            try {
                const href = item.getAttribute('href');
                if (href) {
                    const itemPage = href.split('/').pop().toLowerCase();
                    if (itemPage === currentPage) {
                        item.classList.add('active');
                        console.log('Highlighted menu item:', item.textContent);
                    }
                }
            } catch(e) {
                console.error('Error processing dropdown item:', e);
            }
        });
        
        // 3. Check if we need to highlight Summary dropdown
        if (summaryPages.includes(currentPage)) {
            console.log('This is a Summary page');
            
            // Method A: Find by data-dropdown attribute
            let summaryToggle = document.querySelector('a[data-dropdown="summary"]');
            
            // Method B: If not found, search by text
            if (!summaryToggle) {
                document.querySelectorAll('.nav-link.dropdown-toggle').forEach(toggle => {
                    if (toggle.textContent.trim().toLowerCase() === 'summary') {
                        summaryToggle = toggle;
                    }
                });
            }
            
            if (summaryToggle) {
                summaryToggle.classList.add('active');
                summaryToggle.setAttribute('aria-current', 'page');
                console.log('SUCCESS: Highlighted Summary dropdown');
            } else {
                console.warn('Could not find Summary dropdown toggle');
            }
        }
        
        // 4. Check if we need to highlight Private Schools dropdown
        if (privateSchoolPages.includes(currentPage)) {
            console.log('This is a Private Schools page');
            
            // Method A: Find by data-dropdown attribute
            let privateToggle = document.querySelector('a[data-dropdown="private_schools"]');
            
            // Method B: If not found, search by text
            if (!privateToggle) {
                document.querySelectorAll('.nav-link.dropdown-toggle').forEach(toggle => {
                    if (toggle.textContent.trim().toLowerCase() === 'private schools') {
                        privateToggle = toggle;
                    }
                });
            }
            
            if (privateToggle) {
                privateToggle.classList.add('active');
                privateToggle.setAttribute('aria-current', 'page');
                console.log('SUCCESS: Highlighted Private Schools dropdown');
            } else {
                console.warn('Could not find Private Schools dropdown toggle');
            }
        }
        
        // 5. Check if we need to highlight More dropdown
        if (morePages.includes(currentPage)) {
            console.log('This is a More page');
            
            // Method A: Find by data-dropdown attribute
            let moreToggle = document.querySelector('a[data-dropdown="more"]');
            
            // Method B: If not found, search by text
            if (!moreToggle) {
                document.querySelectorAll('.nav-link.dropdown-toggle').forEach(toggle => {
                    if (toggle.textContent.trim().toLowerCase() === 'more') {
                        moreToggle = toggle;
                    }
                });
            }
            
            if (moreToggle) {
                moreToggle.classList.add('active');
                moreToggle.setAttribute('aria-current', 'page');
                console.log('SUCCESS: Highlighted More dropdown');
            } else {
                console.warn('Could not find More dropdown toggle');
            }
        }
        
        // 6. Force style application for all active dropdown toggles
        document.querySelectorAll('.nav-link.dropdown-toggle.active').forEach(toggle => {
            toggle.style.color = '#ffcc00';
            toggle.style.fontWeight = 'bold';
        });
        
    } catch(error) {
        console.error('Error in highlightActiveDropdown:', error);
    }
}

// ADDED FROM CODE 1: Initialize all dropdowns with hover functionality
function initializeAllDropdowns() {
    // Handle all dropdown toggles
    document.querySelectorAll('.dropdown-toggle').forEach(function(toggle) {
        toggle.addEventListener('click', function(e) {
            e.preventDefault();
            e.stopPropagation();
            
            // Get the dropdown menu
            let menu;
            if (this.tagName === 'BUTTON') {
                // For button dropdowns (Login, Register)
                menu = this.nextElementSibling;
            } else {
                // For nav link dropdowns (Summary, Private Schools, More)
                menu = this.parentElement.querySelector('.dropdown-menu');
            }
            
            if (menu) {
                // Toggle current menu
                const isShowing = menu.classList.contains('show');
                
                // Close all other dropdowns first
                document.querySelectorAll('.dropdown-menu.show').forEach(function(otherMenu) {
                    if (otherMenu !== menu) {
                        otherMenu.classList.remove('show');
                    }
                });
                
                // Toggle current menu
                if (!isShowing) {
                    menu.classList.add('show');
                    this.classList.add('show');
                } else {
                    menu.classList.remove('show');
                    this.classList.remove('show');
                }
            }
        });
    });
    
    // Close dropdowns when clicking outside
    document.addEventListener('click', function(e) {
        if (!e.target.closest('.dropdown') && !e.target.closest('.nav-item.dropdown')) {
            document.querySelectorAll('.dropdown-menu.show').forEach(function(menu) {
                menu.classList.remove('show');
            });
            document.querySelectorAll('.dropdown-toggle.show').forEach(function(toggle) {
                toggle.classList.remove('show');
            });
        }
    });
    
    // Close dropdowns when clicking a dropdown item
    document.querySelectorAll('.dropdown-item').forEach(function(item) {
        item.addEventListener('click', function() {
            document.querySelectorAll('.dropdown-menu.show').forEach(function(menu) {
                menu.classList.remove('show');
            });
            document.querySelectorAll('.dropdown-toggle.show').forEach(function(toggle) {
                toggle.classList.remove('show');
            });
        });
    });
    
    // Hover support for desktop - ADDED FROM CODE 1
    if (window.innerWidth > 992) {
        document.querySelectorAll('.nav-item.dropdown').forEach(function(dropdown) {
            dropdown.addEventListener('mouseenter', function() {
                const menu = this.querySelector('.dropdown-menu');
                const toggle = this.querySelector('.dropdown-toggle');
                if (menu) {
                    menu.classList.add('show');
                    if (toggle) toggle.classList.add('show');
                }
            });
            
            dropdown.addEventListener('mouseleave', function() {
                const menu = this.querySelector('.dropdown-menu');
                const toggle = this.querySelector('.dropdown-toggle');
                if (menu) {
                    menu.classList.remove('show');
                    if (toggle) toggle.classList.remove('show');
                }
            });
        });
        
        // Also add hover support for the login/register dropdown buttons in nav-actions
        document.querySelectorAll('.nav-actions .dropdown').forEach(function(dropdown) {
            dropdown.addEventListener('mouseenter', function() {
                const menu = this.querySelector('.dropdown-menu');
                const toggle = this.querySelector('.dropdown-toggle');
                if (menu) {
                    menu.classList.add('show');
                    if (toggle) toggle.classList.add('show');
                }
            });
            
            dropdown.addEventListener('mouseleave', function() {
                const menu = this.querySelector('.dropdown-menu');
                const toggle = this.querySelector('.dropdown-toggle');
                if (menu) {
                    menu.classList.remove('show');
                    if (toggle) toggle.classList.remove('show');
                }
            });
        });
    }
}

// Initialize scroll to top button
function initScrollToTop() {
    const scrollTopBtn = document.getElementById('scrollTop');
    if (!scrollTopBtn) return;
    
    window.addEventListener('scroll', function() {
        if (window.pageYOffset > 300) {
            scrollTopBtn.classList.add('visible');
        } else {
            scrollTopBtn.classList.remove('visible');
        }
    });
    
    scrollTopBtn.addEventListener('click', function() {
        window.scrollTo({
            top: 0,
            behavior: 'smooth'
        });
    });
}

// Initialize search functionality
function initSearch() {
    const searchBtn = document.getElementById('searchBtn');
    const searchInput = document.getElementById('searchInput');
    
    if (!searchBtn || !searchInput) return;
    
    // Handle search button click
    searchBtn.addEventListener('click', function(e) {
        e.preventDefault();
        performSearch();
    });
    
    // Handle Enter key in search input
    searchInput.addEventListener('keypress', function(e) {
        if (e.key === 'Enter') {
            e.preventDefault();
            performSearch();
        }
    });
    
    function performSearch() {
        const searchTerm = searchInput.value.trim();
        if (searchTerm) {
            window.location.href = `search_site.php?query=${encodeURIComponent(searchTerm)}`;
        } else {
            alert('Please enter a search term');
        }
    }
}

// Enable lazy loading for all images
function enableLazyLoading() {
    document.querySelectorAll('img').forEach(img => {
        if (!img.loading) {
            img.loading = 'lazy';
        }
    });
}

// Handle window resize to reinitialize hover for desktop
let resizeTimeout;
window.addEventListener('resize', function() {
    clearTimeout(resizeTimeout);
    resizeTimeout = setTimeout(function() {
        // Reinitialize hover functionality on resize
        if (window.innerWidth > 992) {
            document.querySelectorAll('.nav-item.dropdown').forEach(function(dropdown) {
                dropdown.addEventListener('mouseenter', function() {
                    const menu = this.querySelector('.dropdown-menu');
                    const toggle = this.querySelector('.dropdown-toggle');
                    if (menu) {
                        menu.classList.add('show');
                        if (toggle) toggle.classList.add('show');
                    }
                });
                
                dropdown.addEventListener('mouseleave', function() {
                    const menu = this.querySelector('.dropdown-menu');
                    const toggle = this.querySelector('.dropdown-toggle');
                    if (menu) {
                        menu.classList.remove('show');
                        if (toggle) toggle.classList.remove('show');
                    }
                });
            });
        }
    }, 250);
});
</script>

<?php include 'visitor_counter.php'; ?>