<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light bg-primary shadow-sm py-3">
  <div class="container">
    <a class="navbar-brand font-weight-bold" href="index.php">Awesome Mall</a>

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">

      <!-- Left Menu -->
      <ul class="navbar-nav me-auto">
        <li class="nav-item active"><a class="nav-link" href="index.php">Home</a></li>
        <li class="nav-item"><a class="nav-link" href="about-us.php">About</a></li>

        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="shopDropdown" role="button" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">Shop</a>
          <div class="dropdown-menu" aria-labelledby="shopDropdown">
            <a class="dropdown-item" href="index.php">All Products</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="shop-categories.php">Category Wise</a>
          </div>
        </li>

        <?php if ($_SESSION['id'] == 0) { ?>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown"
              aria-haspopup="true" aria-expanded="false">Users</a>
            <div class="dropdown-menu" aria-labelledby="userDropdown">
              <a class="dropdown-item" href="login.php">Login</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="signup.php">Sign Up</a>
            </div>
          </li>
          <li class="nav-item"><a class="nav-link" href="admin/">Admin</a></li>
        <?php } else { ?>
          <li class="nav-item"><a class="nav-link" href="my-wishlist.php">My Wishlist</a></li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="accountDropdown" role="button" data-toggle="dropdown"
              aria-haspopup="true" aria-expanded="false">My Account</a>
            <div class="dropdown-menu" aria-labelledby="accountDropdown">
              <a class="dropdown-item" href="my-orders.php">Orders</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="my-profile.php">Profile</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="change-password.php">Change Password</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="manage-addresses.php">Addresses</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="logout.php">Logout</a>
            </div>
          </li>
        <?php } ?>

        <li class="nav-item"><a class="nav-link" href="contact-us.php">Contact Us</a></li>
      </ul>

      <!-- Right: Welcome Message and Cart -->
      <ul class="navbar-nav ms-auto align-items-center">
        <?php if ($_SESSION['id'] != 0): ?>
          <li class="nav-item">
            <span class="navbar-text me-3"><strong>Welcome:</strong> <?php echo $_SESSION['username']; ?></span>
          </li>
        <?php endif; ?>

        <?php
        $uid = $_SESSION['id'];
        $ret = mysqli_query($con, "select sum(productQty) as qtyy from cart where userId='$uid'");
        $result = mysqli_fetch_array($ret);
        $cartcount = $result['qtyy'];
        ?>
        <li class="nav-item">
          <a class="btn btn-outline-dark" href="my-cart.php">
            <i class="fa fa-shopping-cart"></i> Cart
            <span class="badge badge-dark ms-1"><?php echo $cartcount ?? 0; ?></span>
          </a>
        </li>
      </ul>

    </div>
  </div>
</nav>
