/**
 * Navigation Hover Fix CSS
 * Prevents menu interference and improves hover zones
 */

/* Improve z-index stacking for menu items */
.menu-item {
    position: relative;
    z-index: 100;
}

.destinations-menu {
    z-index: 1000;
}

.menu-item-has-children:not(.destinations-menu) {
    z-index: 1001;
}

.menu-item-has-children:not(.destinations-menu).hover,
.menu-item-has-children:not(.destinations-menu):hover {
    z-index: 1003;
}

/* Improve dropdown positioning and hover zones */
.menu-item-has-children .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    /* Auto-size to longest item while keeping a sensible minimum */
    width: max-content;
    min-width: 220px;
    /* Prevent overflow off-screen on very long items */
    max-width: calc(100vw - 40px);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
    margin-top: 0;
}

.menu-item-has-children:hover .sub-menu,
.menu-item-has-children.hover .sub-menu,
.menu-item-has-children .sub-menu.show-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    z-index: 1004;
}

/* Create a hover bridge between menu item and dropdown */
.menu-item-has-children::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
    z-index: 1002;
    background: transparent;
    pointer-events: auto;
}

/* Special handling for Activities menu to prevent interference */
.menu-item-has-children[data-menu="activities"]::after,
.activities-menu-item::after {
    height: 15px;
    z-index: 1005;
}

/* Prevent All Destinations mega menu from blocking other dropdowns */
.destinations-menu .mega-menu-container {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 900px;
    max-width: calc(100vw - 40px);
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 999; /* Lower than regular dropdowns */
    margin-top: 10px;
    overflow: hidden;
    pointer-events: none;
}

.destinations-menu.active .mega-menu-container,
.destinations-menu:hover .mega-menu-container {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Ensure regular dropdowns always appear above mega menu */
.menu-item-has-children:not(.destinations-menu) .sub-menu {
    z-index: 1010 !important;
}

/* Improve hover zones for menu links */
.menu-item-link {
    display: block;
    padding: 15px 20px;
    transition: all 0.2s ease;
    position: relative;
}

/* Add hover delays to prevent accidental menu switching */
.menu-item-has-children,
.destinations-menu {
    transition: all 0.1s ease;
}

/* Safe navigation area for dropdowns */
.menu-item-has-children .navigation-corridor {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 15px;
    z-index: 1003;
    background: transparent;
    pointer-events: auto;
}

/* Prevent menu interference during navigation */
.menu-navigation-active .destinations-menu:not(.active) .mega-menu-container {
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Improved sub-menu item styling */
.sub-menu li {
    border-bottom: 1px solid #f0f0f0;
}

.sub-menu li:last-child {
    border-bottom: none;
}

.sub-menu li a {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.2s ease;
    /* Keep items on one line so the submenu can size to the longest */
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
}

.sub-menu li a:hover {
    background-color: #f8f8f8;
    color: #007cba;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .menu-item-has-children .sub-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: transparent;
        min-width: auto;
        width: 100%;
        transform: none;
        margin-top: 0;
    }
    
    .menu-item-has-children::after,
    .navigation-corridor {
        display: none;
    }
    
    .sub-menu li a {
        padding-left: 30px;
        background-color: rgba(0,0,0,0.05);
    }
}

/* Remove any conflicting styles from other navigation files */
.header_wrapper .menu-item-has-children .sub-menu {
    display: none;
}

.header_wrapper .menu-item-has-children:hover .sub-menu,
.header_wrapper .menu-item-has-children.hover .sub-menu,
.header_wrapper .menu-item-has-children .sub-menu.show-dropdown {
    display: block;
}