in this codes header (<?php
// includes/header.php

// Enable error reporting for debugging (Remove or comment out in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Start the session if not already started
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

// Include authentication and database connection
require_once __DIR__ . '/auth.php';
require_once __DIR__ . '/db_connect.php';

// Ensure the user is authenticated
if (!isset($_SESSION['user_id'])) {
    header("Location: /public/login.php");
    exit();
}

$user_id = $_SESSION['user_id'];
$last_order_id = 0;

// Fetch the last pending order ID to initialize polling
$initial_pending_sql = "
    SELECT o.id 
    FROM orders o
    WHERE o.status = 'Pending' 
    ORDER BY o.id DESC 
    LIMIT 1
";
$initial_result = $conn->query($initial_pending_sql);
if ($initial_result && $initial_result->num_rows > 0) {
    $row = $initial_result->fetch_assoc();
    $last_order_id = intval($row['id']);
}

// Fetch the logged-in user's profile information
$username = 'User'; // Default username
$profile_image = '/assets/images/user-placeholder.png'; // Default profile image

$stmt = $conn->prepare("SELECT username, profile_image FROM users WHERE id = ?");
if ($stmt) {
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $result_user = $stmt->get_result();
    if ($result_user && $result_user->num_rows === 1) {
        $user = $result_user->fetch_assoc();
        $username = htmlspecialchars($user['username'], ENT_QUOTES, 'UTF-8');
        if (!empty($user['profile_image']) && file_exists(__DIR__ . '/../' . $user['profile_image'])) {
            // Append file modification time to prevent caching
            $mod_time = filemtime(__DIR__ . '/../' . $user['profile_image']);
            $profile_image = '/' . htmlspecialchars($user['profile_image'], ENT_QUOTES, 'UTF-8') . '?v=' . $mod_time;
        }
    }
    $stmt->close();
} else {
    // Log error or handle accordingly
    error_log("Failed to prepare statement for fetching user data.");
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Meta Tags for Responsiveness and Accessibility -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard</title>
    
    <!-- Tailwind CSS -->
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
    <!-- Bootstrap JS Bundle with Popper (Loaded Defer for Performance) -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" defer></script>
    <!-- Alpine.js for Interactivity -->
    <script src="https://cdn.jsdelivr.net/npm/alpinejs@3.10.3/dist/cdn.min.js" defer></script>
    
    <!-- Custom Styles for Notification Links and Dropdowns -->
    <style>
        .notification-link {
            display: block;
            color: inherit;
            text-decoration: none;
        }
        .notification-link:hover {
            background-color: #4a5568; /* Tailwind's gray-700 */
        }
        .notification-badge {
            position: absolute;
            top: 0;
            right: 0;
            width: 0.75rem;
            height: 0.75rem;
            background-color: #f56565; /* Tailwind's red-500 */
            border-radius: 9999px;
            animation: pulse 2s infinite;
        }
        @keyframes pulse {
            0%, 100% { transform: scale(0.75); opacity: 1; }
            50% { transform: scale(1.25); opacity: 0.5; }
        }
    </style>
</head>
<body class="bg-gray-100">

    <!-- Audio Element for New Order Alert -->
    <audio id="newOrderAudio" src="/assets/audio/you_have_a_new_order.mp3" preload="auto"></audio>

    <!-- Header -->
    <header class="bg-gray-800 text-white py-4 border-b-4 border-yellow-400 shadow-lg fixed top-0 left-0 right-0 z-50">
        <div class="container mx-auto px-4 flex justify-between items-center">
            <!-- Logo -->
            <div class="flex items-center">
                <a href="/public/dashboard.php" class="flex items-center">
                    <img src="/assets/img/logo.png" alt="Kaak Alia Logo" class="h-12 w-auto mr-2">
                    <span class="text-xl font-bold">Admin Panel</span>
                </a>
            </div>

            <!-- Navigation Links (Desktop) -->
            <nav class="hidden md:flex space-x-4">
                <a href="/public/orders/add_order.php" class="flex items-center bg-yellow-400 text-gray-800 px-4 py-2 rounded-lg hover:bg-yellow-300 shadow transition-all duration-300">
                    <i class="bi bi-plus-circle-fill mr-2"></i> Add Order
                </a>
                <a href="/public/orders/view_orders.php" class="flex items-center bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-400 shadow transition-all duration-300">
                    <i class="bi bi-eye-fill mr-2"></i> View Orders
                </a>
                <a href="/public/products/manage_products.php" class="flex items-center bg-green-400 text-white px-4 py-2 rounded-lg hover:bg-green-300 shadow transition-all duration-300">
                    <i class="bi bi-box-seam-fill mr-2"></i> Manage Products
                </a>
                <a href="/public/users/manage_users.php" class="flex items-center bg-orange-500 text-white px-4 py-2 rounded-lg hover:bg-orange-400 shadow transition-all duration-300">
                    <i class="bi bi-people-fill mr-2"></i> Manage Users
                </a>
                <a href="/public/reports/generate_reports.php" class="flex items-center bg-pink-500 text-white px-4 py-2 rounded-lg hover:bg-pink-400 shadow transition-all duration-300">
                    <i class="bi bi-bar-chart-fill mr-2"></i> Reports
                </a>
            </nav>

            <!-- Right Side Icons -->
            <div class="flex items-center space-x-4">
                <!-- Notifications Dropdown -->
                <div class="relative" x-data="{ open: false }">
                    <button @click="open = !open" class="relative text-white hover:text-yellow-400 focus:outline-none" aria-haspopup="true" aria-expanded="false" aria-controls="notification-menu" aria-label="Notifications">
                        <i class="bi bi-bell-fill text-2xl"></i>
                        <?php if ($last_order_id > 0): ?>
                            <!-- Notification Badge -->
                            <span class="absolute top-0 right-0 inline-block w-3 h-3 bg-red-500 rounded-full"></span>
                        <?php endif; ?>
                    </button>
                    <!-- Dropdown Menu -->
                    <div x-show="open" @click.away="open = false" id="notification-menu" class="absolute right-0 mt-2 w-80 bg-gray-800 text-white rounded-lg shadow-lg z-50">
                        <div class="py-2 px-4 border-b border-yellow-400">
                            <h3 class="text-lg font-semibold">Notifications</h3>
                        </div>
                        <ul class="max-h-64 overflow-y-auto" id="notificationsList">
                            <?php
                            // Fetch the latest 5 pending orders with their items
                            $notifications_sql = "
                                SELECT DISTINCT o.id, o.order_date, c.name AS customer_name
                                FROM orders o
                                JOIN customers c ON o.customer_id = c.id
                                JOIN order_items oi ON oi.order_id = o.id
                                WHERE o.status = 'Pending'
                                ORDER BY o.id DESC
                                LIMIT 5
                            ";
                            $notifications_result = $conn->query($notifications_sql);
                            if ($notifications_result && $notifications_result->num_rows > 0):
                                while($notification = $notifications_result->fetch_assoc()):
                            ?>
                                    <li class="px-4 py-2 hover:bg-gray-700 cursor-pointer">
                                        <a href="/public/orders/view_order_customer.php?order_id=<?= htmlspecialchars($notification['id'], ENT_QUOTES, 'UTF-8') ?>" class="notification-link flex items-center">
                                            <span class="inline-block w-2 h-2 bg-red-500 rounded-full mr-2"></span>
                                            New Order: <?= htmlspecialchars($notification['customer_name'], ENT_QUOTES, 'UTF-8'); ?> placed on <?= date("d M Y, h:i A", strtotime($notification['order_date'])) ?>
                                        </a>
                                    </li>
                            <?php
                                endwhile;
                            else:
                            ?>
                                <li class="px-4 py-2 text-gray-400">No new notifications</li>
                            <?php endif; ?>
                        </ul>
                        <div class="py-2 px-4 border-t border-yellow-400 text-center">
                            <a href="/public/notifications.php" class="text-yellow-400 hover:underline">View All</a>
                        </div>
                    </div>
                </div>

                <!-- User Profile Dropdown with Subcategories -->
                <div class="relative" x-data="{ open: false }">
                    <button @click="open = !open" class="flex items-center focus:outline-none" aria-haspopup="true" aria-expanded="false" aria-controls="profile-menu">
                        <img src="<?= $profile_image ?>" alt="User Avatar" class="h-10 w-10 rounded-full border-2 border-white hover:border-yellow-400 transition-colors duration-300">
                        <span class="ml-2 hidden lg:inline-block">
                            <?= $username ?>
                        </span>
                        <i class="bi bi-caret-down-fill ml-1 hidden lg:inline-block"></i>
                    </button>
                    <!-- Dropdown Menu -->
                    <div x-show="open" @click.away="open = false" id="profile-menu" class="absolute right-0 mt-2 w-56 bg-gray-800 text-white rounded-lg shadow-lg z-50">
                        <!-- Workspace Dropdown -->
                        <div class="relative group">
                            <button class="w-full flex items-center px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 rounded-t-lg focus:outline-none">
                                <i class="bi bi-briefcase-fill mr-2"></i> WorkSpace
                                <i class="bi bi-caret-down-fill ml-auto"></i>
                            </button>
                            <!-- Submenu for Workspace -->
                            <div class="absolute left-0 mt-0 w-full bg-yellow-400 text-gray-800 rounded-b-lg shadow-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 z-50">
                                <a href="/workspace/business_development.php" class="block px-4 py-2 hover:bg-yellow-300 flex items-center">
                                    <i class="bi bi-graph-up mr-2"></i> Business Development
                                </a>
                                <a href="/workspace/project_management.php" class="block px-4 py-2 hover:bg-yellow-300 flex items-center">
                                    <i class="bi bi-kanban mr-2"></i> Project Management
                                </a>
                                <a href="/workspace/marketing.php" class="block px-4 py-2 hover:bg-yellow-300 flex items-center">
                                    <i class="bi bi-megaphone-fill mr-2"></i> Marketing
                                </a>
                                <!-- Add more subcategories here if needed -->
                            </div>
                        </div>

                        <a href="/public/drivers/drivers_list.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
                            <i class="bi bi-car-front mr-2"></i> Drivers
                        </a>

                        <a href="/includes/user_settings.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
                            <i class="bi bi-gear-fill mr-2"></i> Settings
                        </a>
                        <a href="/public/about_kaakalia/index_en.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
                            <i class="bi bi-info-circle mr-2"></i> About Kaak Alia
                        </a>
                        
                        <a href="/public/logout.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
                            <i class="bi bi-box-arrow-right mr-2"></i> Logout
                        </a>
                    </div>
                </div>

                <!-- Mobile Menu Button -->
                <div class="md:hidden">
                    <button id="mobile-menu-button" class="text-white focus:outline-none" aria-label="Toggle Mobile Menu">
                        <i class="bi bi-list text-2xl"></i>
                    </button>
                </div>
            </div>
        </header>

        <!-- Mobile Navigation Menu -->
        <nav id="mobile-menu" class="hidden md:hidden mt-16">
            <ul class="flex flex-col space-y-2 p-4 bg-gray-800">
                <li>
                    <a href="/public/orders/add_order.php" class="flex items-center bg-yellow-400 text-gray-800 px-4 py-2 rounded-lg hover:bg-yellow-300 transition-all duration-300">
                        <i class="bi bi-plus-circle-fill mr-2"></i> Add Order
                    </a>
                </li>
                <li>
                    <a href="/public/orders/view_orders.php" class="flex items-center bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-400 transition-all duration-300">
                        <i class="bi bi-eye-fill mr-2"></i> View Orders
                    </a>
                </li>
                <li>
                    <a href="/public/products/manage_products.php" class="flex items-center bg-green-400 text-white px-4 py-2 rounded-lg hover:bg-green-300 transition-all duration-300">
                        <i class="bi bi-box-seam-fill mr-2"></i> Manage Products
                    </a>
                </li>
                <li>
                    <a href="/public/users/manage_users.php" class="flex items-center bg-orange-500 text-white px-4 py-2 rounded-lg hover:bg-orange-400 transition-all duration-300">
                        <i class="bi bi-people-fill mr-2"></i> Manage Users
                    </a>
                </li>
                <li>
                    <a href="/public/reports/generate_reports.php" class="flex items-center bg-pink-500 text-white px-4 py-2 rounded-lg hover:bg-pink-400 transition-all duration-300">
                        <i class="bi bi-bar-chart-fill mr-2"></i> Reports
                    </a>
                </li>
                
                <!-- Mobile Workspace Dropdown -->
                <li class="relative">
                    <button class="w-full flex items-center justify-between bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300 focus:outline-none">
                        <span class="flex items-center">
                            <i class="bi bi-briefcase-fill mr-2"></i> WorkSpace
                        </span>
                        <i class="bi bi-chevron-down"></i>
                    </button>
                    <!-- Submenu -->
                    <ul class="hidden flex-col pl-8 mt-2 space-y-2">
                        <li>
                            <a href="/workspace/business_development.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
                                <i class="bi bi-graph-up mr-2"></i> Business Development
                            </a>
                        </li>
                        <li>
                            <a href="/workspace/project_management.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
                                <i class="bi bi-kanban mr-2"></i> Project Management
                            </a>
                        </li>
                        <li>
                            <a href="/workspace/marketing.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
                                <i class="bi bi-megaphone-fill mr-2"></i> Marketing
                            </a>
                        </li>
                        <!-- Add more subcategories here if needed -->
                    </ul>
                </li>

                <!-- Additional Mobile Links -->
                <li>
                    <a href="/public/notifications.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
                        <i class="bi bi-bell-fill mr-2"></i> Notifications
                    </a>
                </li>
                <li>
                    <a href="/includes/user_settings.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
                        <i class="bi bi-gear-fill mr-2"></i> Settings
                    </a>
                </li>
                <li>
                    <a href="/public/about_kaakalia/index_en.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
                        <i class="bi bi-info-circle mr-2"></i> About Kaak Alia
                    </a>
                </li>
            </ul>
        </nav>

    <!-- JavaScript for Real-Time Notifications and Mobile Menu Toggle -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Mobile Menu Toggle
            const mobileMenuButton = document.getElementById('mobile-menu-button');
            const mobileMenu = document.getElementById('mobile-menu');

            mobileMenuButton.addEventListener('click', function() {
                mobileMenu.classList.toggle('hidden');
            });

            // Mobile Submenu Toggle
            const mobileSubmenuButtons = mobileMenu.querySelectorAll('li.relative > button');
            mobileSubmenuButtons.forEach(button => {
                button.addEventListener('click', function() {
                    const submenu = this.nextElementSibling;
                    if (submenu) {
                        submenu.classList.toggle('hidden');
                        this.querySelector('i.bi-chevron-down').classList.toggle('bi-chevron-up');
                    }
                });
            });

            let lastOrderId = <?= $last_order_id ?>;
            const audio = document.getElementById('newOrderAudio');

            // Function to fetch new orders
            function fetchNewOrders() {
                fetch(`/includes/get_new_orders.php?last_order_id=${lastOrderId}`)
                    .then(response => response.json())
                    .then(data => {
                        if (data.orders && data.orders.length > 0) {
                            data.orders.forEach(order => {
                                // Update lastOrderId if needed
                                if (order.id > lastOrderId) {
                                    lastOrderId = order.id;
                                }

                                // Create a new notification item
                                const notificationsList = document.getElementById('notificationsList');
                                const li = document.createElement('li');
                                li.className = 'px-4 py-2 hover:bg-gray-700 cursor-pointer';
                                
                                // Create a link to the order details page
                                const a = document.createElement('a');
                                a.href = `/public/orders/view_order_customer.php?order_id=${encodeURIComponent(order.id)}`;
                                a.className = 'notification-link flex items-center';
                                a.innerHTML = `
                                    <span class="inline-block w-2 h-2 bg-red-500 rounded-full mr-2"></span>
                                    New Order: ${sanitizeHTML(order.customer_name)} placed on ${sanitizeHTML(order.order_date)}
                                `;

                                li.appendChild(a);
                                // Insert the new notification at the top
                                notificationsList.insertBefore(li, notificationsList.firstChild);

                                // Play the audio alert
                                if (audio) {
                                    audio.play().catch(function(error) {
                                        console.log('Audio playback failed:', error);
                                    });
                                }

                                // Optionally, update the notification badge
                                const bellIcon = document.querySelector('header .bi-bell-fill');
                                const existingBadge = bellIcon.parentNode.querySelector('.notification-badge');
                                if (!existingBadge) {
                                    const badge = document.createElement('span');
                                    badge.className = 'notification-badge';
                                    bellIcon.parentNode.appendChild(badge);
                                }
                            });
                        }
                    })
                    .catch(error => {
                        console.error('Error fetching new orders:', error);
                    });
            }

            // Function to sanitize HTML to prevent XSS
            function sanitizeHTML(str) {
                var temp = document.createElement('div');
                temp.textContent = str;
                return temp.innerHTML;
            }

            // Poll every 10 seconds for new orders
            setInterval(fetchNewOrders, 10000); // 10000 ms = 10 seconds

            // Fetch immediately on page load
            fetchNewOrders();
        });
    </script>
</body>
</html>), maek the workspace catogiores flexlibel and make it better and ux design better and make it cool, andtype full codes please and this new path of bussines develeopment (/public/workspace/business_development/index.php) and remove (                                <a href="/workspace/project_management.php" class="block px-4 py-2 hover:bg-yellow-300 flex items-center">
                                    <i class="bi bi-kanban mr-2"></i> Project Management
                                </a>
                                <a href="/workspace/marketing.php" class="block px-4 py-2 hover:bg-yellow-300 flex items-center">
                                    <i class="bi bi-megaphone-fill mr-2"></i> Marketing
                                </a>
                                <!-- Add more subcategories here if needed -->
)