/* ============================================================
   NAVBAR CONTAINER
   ============================================================ */

   .navbar-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 5dvh;

    background-color: var(--background-color5);
    border-bottom: 0.2dvw solid var(--border-color);

    z-index: 100;
}

/* ============================================================
   NAV SECTIONS
   ============================================================ */

.navlink-left,
.navlink-middle,
.navlink-right {
    display: flex;
    align-items: center;
}

.navlink-left {
    width: 15%;
    justify-content: center;
}

.navlink-middle {
    width: 70%;
    justify-content: center;
    gap: 1.5rem;
}

.navlink-right {
    width: 15%;
    justify-content: center;
    gap: 0.75rem;
}

/* ============================================================
   BASE NAV LINKS
   ============================================================ */

.navlink-button {
    position: relative;
    text-decoration: none;
    color: var(--text-color4);
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    transition: color 0.25s ease;
}

.navlink-button:hover {
    color: var(--text-color3);
}

/* ============================================================
   DROPDOWN WRAPPER
   ============================================================ */

.nav-dropdown {
    display: flex;
    align-items: center;
}

/* ============================================================
   DROPDOWN MENU (FIXED, TRUE VISUAL CENTERING)
   ============================================================ */

.navlink-dropdown-menu {
    position: fixed;

    /* Position will be set dynamically by JavaScript based on trigger button */
    /* Fallback to navbar bottom if JavaScript hasn't set it yet */
    top: var(--nav-dropdown-top, var(--navbar-bottom, calc(7dvh + 4.5dvh + 5dvh)));
    margin-top: 0 !important;
    margin-bottom: 0 !important;

    /* TRUE CENTERING (scrollbar-safe) */
    left: 0;
    right: 1.5%;
    margin-left: auto;
    margin-right: auto;

    /* Width based on usable viewport */
    width: 95%;
    max-width: 95%;

    /* Hidden state */
    transform: translateY(0);
    opacity: 0;
    pointer-events: none;

    /* Background gradient (top fades) - start solid at top to match navbar */
    background: linear-gradient(
        to top,
        color-mix(in srgb, var(--background-color5) 100%, transparent) 0%,
        color-mix(in srgb, var(--background-color5) 100%, transparent) 95%,
        color-mix(in srgb, var(--background-color5) 5%, transparent) 100%
    );

    border: 1px solid var(--border-color2);
    border-top: 0.2dvw solid var(--border-color);
    border-radius: 0 0 0.35rem 0.35rem;

    /* No top padding to ensure it touches navbar bottom */
    padding: 0 1rem 0.5rem 1rem;
    padding-top: 0 !important;

    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);

    z-index: 1000;

    display: flex;
    justify-content: space-evenly;
    align-items: center;
    gap: 1.5rem;

    transform-origin: top center;

    /* Hide animation (0.3s) */
    transition-property: opacity, transform;
    transition-duration: 0.6s;
    transition-timing-function: ease;
}

/* ============================================================
   OPEN STATE (SHOW ANIMATION 0.5s)
   ============================================================ */

.navlink-dropdown-menu.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition-duration: 0.6s;
    margin-top: 0 !important;
    /* Inline style from JavaScript will override this fallback */
    /* top is set dynamically by positionDropdownFromButton() */
}

/* ============================================================
   MANAGEMENT DROPDOWN - WRAPPING ENABLED
   ============================================================ */

.management-dropdown-menu {
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    align-items: flex-start;
}

.management-dropdown-menu .navlink-button {
    flex: 0 0 auto;
    min-width: fit-content;
}

/* ============================================================
   SHOP DROPDOWN - NESTED STRUCTURE
   ============================================================ */

/* Shop dropdown menu - work within standard flex layout */
/* Similar to management dropdown but for nested category/product structure */
.shop-nav-dropdown-menu {
    /* Override base justify-content: space-evenly and align-items: center */
    /* Use flex-start to align content left (matching Resources behavior) */
    justify-content: flex-start !important;
    align-items: flex-start !important;
    align-content: flex-start !important;
    flex-wrap: wrap;
    /* Ensure content is visible */
    min-height: auto;
    overflow: visible;
}

/* Shop nav content - takes full width within flex container */
/* This wrapper allows the nested structure to work within the flex system */
.shop-nav-dropdown-menu .shop-nav-content {
    display: block;
    width: 100%;
    flex: 1 1 100%;
    min-width: 100%;
    min-height: auto; /* Allow content to determine height */
    overflow: visible; /* Ensure content is not clipped */
    /* Ensure proper alignment within flex container */
    align-self: stretch;
    /* 1rem padding alignment - content aligns with parent's 1rem padding */
    padding-left: 0; /* Parent already has 1rem padding */
}

/* Horizontal categories container */
.shop-nav-categories {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    /* Ensure content is visible */
    min-height: auto;
    width: 100%;
}

/* Individual category column */
.shop-nav-category {
    min-width: 200px;
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
}

/* Category header */
.shop-nav-category-header {
    font-weight: 700;
    font-size: 1.386rem;
    color: var(--text-color4, #ffffffd7);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 0.15rem solid var(--border-color2, #3a8a3493);
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
}

.shop-nav-category-header:hover {
    color: var(--text-color3, #062303);
}

/* Products list (vertical) */
.shop-nav-products {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Individual product link */
.shop-nav-product {
    padding: 0.5rem 0.75rem;
    color: var(--text-color4, #ffffffd7);
    text-decoration: none;
    font-size: 1.134rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: block;
}

.shop-nav-product:hover {
    background-color: var(--background-color3, #e4e3e3);
    color: var(--text-color3, #062303);
}

/* ============================================================
   DROPDOWN LINKS
   ============================================================ */

.navlink-dropdown-menu .navlink-button {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
}

.navlink-dropdown-menu .navlink-button:hover {
    color: var(--text-color3);
}

/* ============================================================
   USER BUTTONS
   ============================================================ */

.user-button {
    text-decoration: none;
    color: var(--text-color4);
    font-weight: 500;
}

.user-button:hover {
    color: var(--text-color3);
}

/* ============================================================
   CHAT / CIRCLE BUTTON
   ============================================================ */

.circle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    background-color: var(--background-color5);
    color: var(--text-color3);

    border-radius: 50%;
    border: 1px solid var(--border-color3);

    padding: 0.4rem;
    text-decoration: none;

    -webkit-text-stroke: 0.9px var(--text-outline-color);
    text-shadow: 2px 2px 4px var(--shadow-color2);

    transition: transform 0.3s ease, background-color 0.3s ease;
}

.circle-button:hover {
    background-color: var(--background-color6);
    transform: scale(1.1);
}

/* ============================================================
   HAMBURGER MENU TOGGLE (MOBILE)
   ============================================================ */

.hamburger-menu-toggle {
    display: none !important;
    flex-direction: column;
    justify-content: space-around;
    width: 2.5rem;
    height: 2.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    position: relative;
    gap: 0.25rem;
    visibility: hidden;
}

.hamburger-menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: var(--text-color4);
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-menu-toggle:hover span {
    background-color: var(--text-color3);
}

.hamburger-menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(0.5rem, 0.5rem);
}

.hamburger-menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(0.5rem, -0.5rem);
}

/* ============================================================
   MOBILE NAVIGATION MENU
   ============================================================ */

.mobile-nav-menu {
    display: none !important;
    position: fixed;
    top: var(--navbar-bottom, var(--nav-dropdown-top, 0));
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100vh - var(--navbar-bottom, var(--nav-dropdown-top, 0)));
    background-color: var(--background-color5);
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow-y: auto;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    visibility: hidden;
    margin-top: 0 !important;
}

.mobile-nav-menu.is-open {
    transform: translateY(0);
    opacity: 1;
}

.mobile-nav-content {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1.5rem;
}

.mobile-nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color2);
}

.mobile-nav-section:last-child {
    border-bottom: none;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    color: var(--text-color4);
    text-decoration: none;
    font-weight: 500;
    font-size: 1.26rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    min-height: 44px;
}

.mobile-nav-link:hover,
.mobile-nav-link:focus {
    background-color: var(--background-color4);
    color: var(--text-color3);
}

.mobile-nav-dropdown {
    display: flex;
    flex-direction: column;
}

.mobile-nav-dropdown-toggle {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.mobile-nav-dropdown-menu {
    display: none;
    flex-direction: column;
    padding-left: 1.5rem;
    margin-top: 0.5rem;
    gap: 0.5rem;
}

.mobile-nav-dropdown-menu.is-open {
    display: flex;
}

.mobile-nav-user-section {
    gap: 1rem;
}

.mobile-nav-icons {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.mobile-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background-color: var(--background-color5);
    color: var(--text-color3);
    border-radius: 50%;
    border: 1px solid var(--border-color3);
    text-decoration: none;
    font-size: 1.575rem;
    transition: all 0.3s ease;
}

.mobile-nav-icon:hover {
    background-color: var(--background-color6);
    transform: scale(1.1);
}

/* ============================================================
   RESPONSIVE: Galaxy S23 and similar (360px - 480px)
   ============================================================ */

@media (max-width: 480px) {
    .navbar-container {
        height: auto;
        min-height: 4.5dvh;
        padding: 0.375rem 0.75rem;
        justify-content: space-between;
    }

    .hamburger-menu-toggle {
        display: flex !important;
        visibility: visible;
        width: 2.25rem;
        height: 2.25rem;
        padding: 0.375rem;
    }

    .hamburger-menu-toggle span {
        height: 2.5px;
    }

    .mobile-nav-menu {
        display: block !important;
        visibility: visible;
    }

    .mobile-nav-content {
        padding: 0.75rem;
        gap: 1rem;
    }

    .mobile-nav-section {
        padding-bottom: 0.75rem;
        gap: 0.5rem;
    }

    .mobile-nav-link {
        padding: 0.75rem 0.875rem;
        font-size: 1.18125rem;
        min-height: 44px;
    }

    .mobile-nav-icon {
        width: 40px;
        height: 40px;
        font-size: 1.4175rem;
    }
    
    /* Nav dropdown positioning fix - ensure it touches navbar */
    .navlink-dropdown-menu {
        top: var(--navbar-bottom, var(--nav-dropdown-top, 0)) !important;
        margin-top: 0 !important;
        /* Ensure it touches navbar with no gap */
        border-top: 1px solid var(--border-color2);
    }
}

/* ============================================================
   RESPONSIVE: MOBILE BREAKPOINT (< 768px)
   ============================================================ */

@media (max-width: 768px) {
    .navbar-container {
        height: auto;
        min-height: 5dvh;
        padding: 0.5rem 1rem;
        justify-content: space-between;
    }

    .hamburger-menu-toggle {
        display: flex !important;
        visibility: visible;
    }

    .navlink-left,
    .navlink-middle,
    .navlink-right {
        display: none !important;
    }

    .mobile-nav-menu {
        display: block !important;
        visibility: visible;
    }

    /* Adjust dropdown positioning for mobile */
    .navlink-dropdown-menu {
        position: static;
        width: 100%;
        max-width: 100%;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
        border: none;
        border-top: 1px solid var(--border-color2);
        box-shadow: none;
        background: var(--background-color4);
        padding: 0.5rem 0;
        flex-direction: column;
        gap: 0;
    }

    .navlink-dropdown-menu.is-open {
        display: flex;
    }

    .navlink-dropdown-menu .navlink-button {
        padding: 0.875rem 1rem;
        width: 100%;
        justify-content: flex-start;
    }

    /* Shop dropdown responsive - categories stack vertically on mobile */
    .shop-nav-categories {
        flex-direction: column;
        gap: 1rem;
    }
    
    .shop-nav-category {
        min-width: 100%;
    }
}

/* ============================================================
   RESPONSIVE: TABLET BREAKPOINT (768px - 1024px)
   ============================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .navbar-container {
        height: auto;
        min-height: 5dvh;
        padding: 0.5rem;
    }

    .hamburger-menu-toggle {
        display: none !important;
        visibility: hidden;
    }

    .mobile-nav-menu {
        display: none !important;
        visibility: hidden;
    }

    .navlink-left,
    .navlink-middle,
    .navlink-right {
        display: flex !important;
    }

    .navlink-middle {
        gap: 1rem;
    }

    .navlink-button {
        font-size: 1.134rem;
        padding: 0.25rem 0.4rem;
    }

    .navlink-dropdown-menu {
        width: 90%;
        max-width: 90%;
    }
}

/* ============================================================
   DESKTOP: ENSURE DESKTOP NAV IS VISIBLE (> 768px)
   ============================================================ */

@media (min-width: 769px) {
    .hamburger-menu-toggle {
        display: none !important;
        visibility: hidden;
    }

    .mobile-nav-menu {
        display: none !important;
        visibility: hidden;
    }

    .navlink-left,
    .navlink-middle,
    .navlink-right {
        display: flex !important;
    }

    /* Shop dropdown desktop - ensure flex properties are maintained */
    /* Also override width constraints to accommodate multiple categories */
    .shop-nav-dropdown-menu {
        justify-content: flex-start !important;
        align-items: flex-start !important;
        align-content: flex-start !important;
        flex-wrap: wrap;
        /* Override base width constraints to accommodate multiple categories */
        min-width: 600px; /* Accommodate 2-3 categories (200px each + gaps) */
        width: auto; /* Allow expansion based on content */
        max-width: 95%; /* Still respect viewport constraint */
    }
}
