/* Z-Index Fix for Mega Menu Overlapping Issues */
/* ============================================== */

/* Ensure all page sections stay below navigation */
section.hero,
.hero,
.page-header,
.hero-section,
[class*="hero"] {
    position: relative;
    z-index: 1 !important;
}

/* Ensure all regular sections have low z-index */
section:not(.navbar):not(.nav):not([class*="nav"]) {
    position: relative;
    z-index: 1 !important;
}

/* Navigation and mega menu should be highest (except modals/cart) */
.navbar,
nav.navbar,
#navbar,
.navigation,
[class*="navbar"] {
    z-index: var(--z-navigation, 10000) !important;
    position: fixed !important;
    top: 0 !important;
}

/* Mega menu dropdowns */
.mega-menu-dropdown,
.nav-menu-mega .mega-menu-dropdown,
[class*="mega-menu-dropdown"] {
    z-index: var(--z-mega-menu, 10001) !important;
    position: absolute !important;
}

/* Ensure dropdown is above navbar */
.nav-item-mega {
    position: relative;
    z-index: auto;
}

.nav-item-mega:hover {
    z-index: 10002 !important;
}

/* Fix for modern navigation placeholder */
#modern-nav-placeholder,
#navigation-placeholder {
    position: relative;
    z-index: 10000 !important;
}

/* Overlay for mega menu (if any) */
.mega-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9999 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.nav-item-mega:hover ~ .mega-menu-overlay,
.mega-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Ensure content doesn't overlap with fixed navbar */
body {
    padding-top: 0 !important;
}

main,
.main-content,
#content {
    position: relative;
    z-index: 1 !important;
    margin-top: 80px; /* Height of navbar */
}

/* Fix for any absolute positioned elements in hero */
.hero .container,
.hero-content,
.hero-gradient {
    position: relative;
    z-index: 2 !important;
}

/* Background elements should be lowest */
.hero-gradient,
.gradient-overlay,
.background-animation,
[class*="background"],
[class*="gradient-orb"],
.grid-overlay,
.particle {
    z-index: 0 !important;
}

/* Animations and decorative elements */
.animated-bg,
.hero-bg,
.section-bg {
    z-index: 0 !important;
}

/* Sticky elements */
.sticky-nav,
.fixed-nav {
    z-index: 10000 !important;
}

/* Mobile menu */
.mobile-menu,
.mobile-menu-toggle,
.mobile-nav {
    z-index: 10003 !important;
}

/* Ensure dropdowns in mobile don't get cut off */
@media (max-width: 768px) {
    .mega-menu-dropdown {
        position: fixed !important;
        top: 80px !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        width: 100% !important;
        min-width: auto !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
}

/* Fix for any iframes or embedded content */
iframe {
    position: relative;
    z-index: 1 !important;
}

/* Ensure footer stays at bottom layer */
footer,
.footer {
    position: relative;
    z-index: 1 !important;
}

/* Priority order reference:
   11000+ = Cart/Shopping
   10003  = Mobile menu
   10002  = Active mega menu item
   10001  = Mega menu dropdown
   10000  = Navigation bar
   9999   = Modals/Overlays
   100    = General overlays
   10     = Content
   2      = Hero content
   1      = Sections/Hero backgrounds
   0      = Backgrounds/Decorations
   -1     = Deep backgrounds
*/

/* Debug helper (remove in production) */
/*
.navbar::after {
    content: 'z: ' attr(style);
    position: fixed;
    top: 100px;
    right: 10px;
    background: red;
    color: white;
    padding: 5px;
    font-size: 12px;
}
*/
