/* --- Navbar --- */
#navbar {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    padding: 20px 0;
    background-color: transparent;
    transition: background-color 0.4s ease, padding 0.4s ease;
    /* color: white; */
}
/* --- New Cart Icon and Badge Styling --- */

/* Base icon container */
.dynamic-cart-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit; /* Inherit text color */
}

/* The Dustbin Icon (Can be an emoji or custom image/SVG) */
.dustbin-icon {
    font-size: 24px; /* Adjust size as needed */
    filter: grayscale(100%); /* Use filter to simulate silver/gray tone */
    /* If you were using a custom SVG/Font-icon, you'd apply silver colors here */
}

/* The Dynamic Cart Count Badge */
.cart-count {
    position: absolute;
    top: -8px; /* Move badge slightly above and to the right of the icon */
    right: -8px; 
    padding: 2px 7px;
    border-radius: 50%; /* Make it circular (or use a higher value for a pill shape) */
    background-color: #000000; /* High-contrast background (e.g., Red) */
    color: #ffffff; /* White text */
    font-size: 12px;
    font-weight: bold;
    min-width: 15px; /* Ensures space even for a single digit */
    text-align: center;
    line-height: 1.2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); /* Adds depth for "realistic" badge */
    transition: transform 0.2s ease-out;
    
    /* Initially hide the badge if the count is 0 */
    display: none; 
}

/* Show the badge only when it contains a number greater than 0 */
.dynamic-cart-icon[data-cart-count]:not([data-cart-count="0"]) .cart-count {
    display: block;
}

#navbar.scrolled {
    background: linear-gradient(180deg, #ffffff,rgba(255, 255, 255, 0.927), #ffffffa8);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Update the .nav-container to put links/icons on the far edges */
.nav-container {
    display: flex;
    justify-content: space-between; /* Pushes links to the left, icons to the right */
    align-items: center;
    position: relative; /* CRITICAL: Allows absolute positioning of the logo */
    
}

/* New rule for perfect horizontal centering of the logo */
.logo {
    position: absolute; /* Takes the logo out of the normal flow */
    left: 50%; /* Moves the left edge to the center of the container */
    transform: translateX(-50%); /* Moves the logo back by half its width for true center */
    z-index: 1002; /* Ensure it stays above links/icons if they overlap */
    /* Existing logo styles remain below... */
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 3px;
}

.logo img {
    width: 200px;
    height: auto;
    object-fit: contain;
}

.nav-links ul {
    display: flex;
    gap: 30px;
}

.nav-links a {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: -5px;
    left: 0;
    background-color: var(--black);
    transition: width 0.3s;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-icons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.icon {
    font-size: 1.2rem;
    color: black;
}

.hamburger {
    display: none;
    cursor: pointer;
    z-index: 1001;
}

/* Hamburger styling */
.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background-color: var(--black);
    transition: all 0.3s ease-in-out;
}

/* --- Login Button Styles (Desktop/Base) --- */
.login-btn {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 15px;
    padding: 6px 18px;
    border: 1px solid var(--black);
    transition: all 0.3s ease;
    background-color: transparent;
}

/* Invert colors on hover */
.login-btn:hover {
    background-color: var(--white);
    color: var(--black);
}

/* --- Desktop Account Dropdown Styles --- */

/* Base style for the personalized button content */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Specific styling for the logged-in button container */
.account-dropdown-container .login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 0; /* Override the default margin-right for cleaner spacing */
}

/* Arrow icon */
.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
}

/* Rotate arrow on hover/open */
.account-dropdown-container:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Container */
.account-dropdown-container {
    position: relative;
    display: inline-block;
}

/* Dropdown Menu Itself (Hidden by Default) */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 90%;
    background-color: white;
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 100;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
    border: 1px solid #ddd;
}

/* Dropdown Links */
.dropdown-menu a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 14px;
}

.dropdown-menu a:hover {
    background-color: #f1f1f1;
}

/* Dropdown Header/Greeting */
.dropdown-header {
    display: block;
    padding: 10px 16px;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

/* Separator Line */
.dropdown-divider {
    height: 1px;
    background-color: #eee;
    margin: 5px 0;
}

/* Show Dropdown on Hover */
.account-dropdown-container:hover .dropdown-menu {
    display: block;
}

/* --- 3D Cart Icon Styles --- */
.cart-3d-model {
    display: inline-flex;
    align-items: center;
    position: relative;
    perspective: 800px;
    width: 30px;
    height: 35px;
    transform: translateX(0);
}

.cylinder-container {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    animation: spinCylinder 6s linear infinite;
    left: 0;
    transform: translateZ(0);
    background-attachment: fixed;
}

.cylinder-face {
    position: absolute;
    width: 5px;
    height: 30px;
    border-bottom: 5px solid #000;
    border-top: 2px solid #000;
    background-color: #D3D3D3;
    background-image: repeating-radial-gradient(
        circle at 50% 50%,
        #D3D3D3,
        #000000 2px,
        transparent 1px,
        transparent 3px
    );
    background-size: 6px 6px;
    box-shadow:
        inset 0 0 5px rgba(0, 0, 0, 0.4),
        inset 1px 0 3px rgba(85, 85, 85, 0.6);
    backface-visibility: hidden;
    transform-origin: bottom center;
}

/* Positioning and Rotating Each Face (15 Sides) */
.cylinder-face.face-1  { transform: rotateY(0deg)   translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-2  { transform: rotateY(24deg)  translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-3  { transform: rotateY(48deg)  translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-4  { transform: rotateY(72deg)  translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-5  { transform: rotateY(96deg)  translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-6  { transform: rotateY(120deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-7  { transform: rotateY(144deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-8  { transform: rotateY(168deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-9  { transform: rotateY(192deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-10 { transform: rotateY(216deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-11 { transform: rotateY(240deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-12 { transform: rotateY(264deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-13 { transform: rotateY(288deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-14 { transform: rotateY(312deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }
.cylinder-face.face-15 { transform: rotateY(336deg) translateZ(11.77px) scaleY(1.1) skewY(-2deg) translateX(0.01px); }

.dustbin-ring {
    position: absolute;
    left: -2px;
    width: 32px;
    height: 5px;
    border-radius: 50%;
    transform-style: preserve-3d;
    background-color: #D3D3D3;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.6);
}

@keyframes spinCylinder {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

/* --- Desktop Visibility Overrides (Fix for Duplicated Links) --- */
/* Hide mobile-specific account links on large screens (Desktop) */
.nav-links li.mobile-account-separator,
.nav-links li.mobile-login-link,
.nav-links ul li:nth-child(5), /* My Profile */
.nav-links ul li:nth-child(6), /* My Orders */
.nav-links ul li:nth-child(7), /* Settings */
.nav-links ul li:nth-child(8)  /* Logout */
{
    display: none;
}

/* --- Navbar Responsiveness (MOBILE VIEW) --- */
/* --- Navbar Responsiveness (MOBILE VIEW) --- */
@media (max-width: 768px) {
    /* CRITICAL FIX: Use flex to space hamburger (left), logo (center), and icons (right) */
    .nav-container {
        /* Revert to default flex setup but remove absolute positioning effects */
        justify-content: space-between;
        position: static;
    }
    
    /* CRITICAL FIX: Revert the desktop centering method for the logo */
    .logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1002;
    }
    
    /* CRITICAL FIX: Always display hamburger icon */
    .hamburger {
        display: block;
        /* Ensure it's not absolutely positioned from its old spot */
        position: static;
        order: -1; /* Place it at the start of the flex container */
        z-index: 1001;
    }

    /* Hide the desktop login button/dropdown */
    .navbar-login,
    .account-dropdown-container {
        /* Keep login/dropdown hidden to only show cart/hamburger */
        display: none;
    }

    /* Show the Cart icon and other icons on the right */
    .nav-icons {
        display: flex;
        align-items: center;
        gap: 10px;
        order: 1; /* Place it at the end of the flex container */
    }

    /* Ensure the Cart Icon is visible and on the right */
    .cart-icon {
        display: block;
        float: none; /* remove float, flex handles positioning */
        position: absolute;
        right: 20px;
    }

    /* Hide desktop navigation links */
    .nav-links {
        /* ... existing mobile menu slide-in styles ... */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: var(--white);
        color: var(--black);
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.4s ease-out;
        overflow-y: auto; 
    }

    .nav-links.active {
        transform: translateX(0);
    }

    /* Mobile Link List Styling (LEFT ALIGNED) */
    .nav-links ul {
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        height: auto;
        padding: 40px 0;
        margin-top: 60px;
        list-style: none;
        width: 100%;
    }

    .nav-links ul li {
        width: 100%;
        padding: 10px 40px;
        display: block; 
    }

    /* Make sure the profile links are explicitly shown on mobile */
    .nav-links li.mobile-account-separator,
    .nav-links li.mobile-login-link,
    .nav-links ul li:nth-child(5), 
    .nav-links ul li:nth-child(6), 
    .nav-links ul li:nth-child(7),
    .nav-links ul li:nth-child(8)
    {
        display: block; 
    }


    .nav-links a {
        font-size: 1rem;
        font-weight: 600;
        color: var(--black);
        display: block;
        padding: 5px 0;
    }

    /* Ensure underline aligns with text (left-aligned) */
    .nav-links a::after {
        background-color: var(--black);
        left: 0;
    }

    /* Mobile Account Separator */
    .mobile-account-separator {
        width: calc(100% - 80px);
        height: 1px;
        background-color: rgba(0, 0, 0, 0.15); 
        margin: 20px 40px;
    }

    /* Highlight important links like Logout/Login */
    .mobile-login-link a,
    .nav-links ul li:last-child a {
        color: #ff0000;
        font-weight: 700;
    }

    /* Hamburger 'X' animation */
    .hamburger.active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }
    .hamburger.active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
}