<header id="header" class="header d-flex align-items-center sticky-top">
    <div class="container position-relative d-flex align-items-center justify-content-between">

        <!-- Logo -->
<img src="admin/img/logo.png" alt="Logo" class="site-logo img-fluid mb-0" style="height: 100px;">


        <!-- Navigation Menu -->
        <nav id="navmenu" class="navmenu">
            <ul>
                <li><a href="#hero" class="active">Home</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#menu">Menu</a></li>
                <li><a href="#events">Events</a></li>
                <li><a href="#chefs">Chefs</a></li>
                <li><a href="#gallery">Gallery</a></li>

                <!-- Cart -->
                <li>
                    <a href="#" class="logo d-flex align-items-center me-auto me-xl-0 position-relative" id="cart-link">
                        <img src="assets/img/cart.png" alt="Cart" width="40" height="40">
                        <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-info text-dark" id="cart-count">
                            0
                        </span>
                    </a>
                </li>
            </ul>
            <i class="mobile-nav-toggle d-xl-none bi bi-list"></i>
        </nav>

        <!-- Book a Table -->
        <a class="btn-getstarted" href="index.php#book-a-table">Book a Table</a>

        <!-- User Login/Logout -->
        <div class="ms-3">
        <?php if (isset($_SESSION['user_id'])): ?>
            <span class="me-2 text-dark">
                Hi, <?= isset($_SESSION['user_name']) ? htmlspecialchars($_SESSION['user_name']) : 'User' ?>
            </span>
            <a class="btn btn-outline-danger" href="logout.php">Logout</a>
        <?php else: ?>
            <a class="btn btn-outline-primary" href="register.php">Login/Register</a>
        <?php endif; ?>
        </div>

    </div>
</header>

<script>
document.getElementById('cart-link').addEventListener('click', function(e) {
    <?php if (!isset($_SESSION['user_id'])): ?>
        e.preventDefault();
        window.location.href = 'login.php';
    <?php else: ?>
        var cartModal = new bootstrap.Modal(document.getElementById('cartModal'));
        cartModal.show();
    <?php endif; ?>
});
</script>
