<?php
// Assuming school_name, school_logo_path, username, photo are passed or available from session
// For demonstration, let's include mock variables if they aren't directly available in admin_navbar.php
if (!isset($school_name)) {
    $school_name = "Divine Reports"; // Default for navbar if not set
}
if (!isset($school_logo_path)) {
    $school_logo_path = "images/logo.png"; // Default for navbar if not set
}
if (!isset($username)) {
    $username = "Admin User"; // Default for navbar if not set
}
if (!isset($photo)) {
    $photo = 'https://via.placeholder.com/80/cccccc/FFFFFF?text=AD'; // Default for navbar if not set
}
?>

<nav class="bg-white p-4 flex items-center justify-between shadow-md">
    <div class="flex items-center">
        <button id="menuToggle" class="text-gray-500 hover:text-gray-700 focus:outline-none mr-4">
            <i class="fas fa-bars text-xl"></i>
        </button>
        <img src="<?php echo htmlspecialchars($school_logo_path); ?>" alt="School Logo" class="h-10 w-10 mr-2">
        <span class="text-xl font-bold text-gray-800"><?php echo htmlspecialchars($school_name); ?></span>
    </div>

    <div class="relative hidden sm:block flex-grow max-w-md mx-4">
        <input type="text" placeholder="Search..." class="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-md leading-5 bg-gray-50 placeholder-gray-500 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm shadow-inner">
        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
            <i class="fas fa-search text-gray-400"></i>
        </div>
    </div>

    <div class="relative" id="userDropdownContainer">
        <div class="flex items-center cursor-pointer" id="userDropdownToggle">
            <img src="<?php echo htmlspecialchars($photo); ?>" alt="User Photo" class="h-10 w-10 rounded-full border-2 border-gray-300 object-cover">
            <span class="ml-2 font-medium text-gray-700 hidden sm:inline"><?php echo htmlspecialchars($username); ?></span>
        </div>
        <div id="userDropdownMenu" class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-20 opacity-0 pointer-events-none transition-opacity duration-200">
            <a href="profile.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100"><i class="fas fa-user-circle mr-2"></i> Profile</a>
            <a href="settings.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100"><i class="fas fa-cog mr-2"></i> Settings</a>
            <a href="logout.php" class="block px-4 py-2 text-sm text-red-600 hover:bg-red-100 hover:text-red-800"><i class="fas fa-sign-out-alt mr-2"></i> Logout</a>
        </div>
    </div>
</nav>