/* Premium Mega Menu Styles */

/* Fix for Navbar Layout Drop */
/* Ensure the nav-outer floats right to stay on the same line as logo */
/* Fix for Navbar Layout Drop - Flexbox Approach */
@media (min-width: 1024px) {

    .header-style-one .header-upper .auto-container,
    .sticky-header .auto-container {
        position: static !important;
        /* Critical: Pass positioning up to header root */
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .header-style-one .mobile-nav-toggler {
        display: none;
    }

    .header-style-one .nav-outer,
    .sticky-header .pull-right {
        position: static !important;
        float: none;
        width: auto;
        display: flex;
        align-items: center;
        margin-left: auto;
    }

    /* Ensure legacy clearfix pseudo-elements don't break flex */
    .header-style-one .nav-outer::before,
    .header-style-one .nav-outer::after,
    .sticky-header .pull-right::before,
    .sticky-header .pull-right::after {
        display: none;
    }

    .header-style-one .logo-box,
    .sticky-header .logo {
        float: none;
        padding: 15px 0;
        margin-right: 20px;
    }

    /* Reset inner elements to be flex items */
    .header-style-one .main-menu,
    .sticky-header .main-menu {
        position: static !important;
        float: none;
        margin-left: 0;
        display: block;
        /* Ensure it's a block that becomes a flex item */
    }

    .header-style-one .outer-box,
    .sticky-header .outer-box {
        float: none;
        display: flex;
        align-items: center;
        margin-left: 20px;
        padding: 0;
        /* Remove padding to let flexbox center it precisely */
    }

    /* Force Sticky Header Nav List layout */
    .sticky-header .main-menu .navigation {
        position: static !important;
        display: flex !important;
        align-items: center;
        margin: 0;
    }

    .sticky-header .main-menu .navigation>li {
        position: static !important;
        float: none;
        display: block;
        margin: 0 10px;
        border: none !important;
    }

    /* Prevent wrapping in the sticky header container */
    .sticky-header .auto-container {
        flex-wrap: nowrap !important;
    }

    .sticky-header .pull-right {
        float: none !important;
        display: flex !important;
        align-items: center;
        white-space: nowrap;
    }

    /* Fix outer box alignment */
    .sticky-header .outer-box {
        margin-left: 15px;
        flex-shrink: 0;
    }

    /* Hide the side-widget hamburger button in sticky header for clean look */
    .sticky-header .nav-btn {
        display: none !important;
    }
}

/* Mega Menu Logic */
.main-menu .navigation>li.has-mega-menu {
    position: static;
    /* Allows mega menu to be relative to the header container */
}

.main-menu .navigation>li.has-mega-menu>.mega-menu {
    position: absolute;
    left: 0;
    top: 100%;
    width: 100%;
    background: #ffffff;
    box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    border-top: 3px solid #ff5e14;
    transform: translateY(20px);
    padding: 0;
    white-space: normal !important;
    /* Force reset white-space */

    /* Robust full-width positioning */
    width: 100%;
    left: 0;
    right: 0;
}

.main-menu .navigation>li.has-mega-menu:hover>.mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Inner Container for Mega Menu Content to stay within grid */
.mega-menu-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 15px;
    white-space: normal !important;
}

.mega-menu-content {
    width: 100%;
}

.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    /* 5 Columns */
    gap: 20px;
}

.mega-menu-item {
    background: #f8f9fa;
    padding: 20px 10px;
    /* Reduced side padding to fit 5 cols better */
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #eee;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    /* Force no underline */
}

.mega-menu-item:hover {
    background: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px);
    border-color: #ff5e14;
}

.mega-menu-item .icon {
    font-size: 32px;
    color: #ff5e14;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    display: block;
}

.mega-menu-item:hover .icon {
    transform: scale(1.1);
}

.mega-menu-item h4 {
    font-size: 15px;
    /* Slightly smaller font to prevent wrap */
    font-weight: 600;
    margin: 0;
    color: #222429;
    line-height: 1.3;
}

.mega-menu-item h4 a {
    color: #222429;
    background: none;
    /* remove anchor bg if any */
}

.mega-menu-item:hover h4 a {
    color: #ff5e14;
}

/* Anchor tag cover fix */
.mega-menu-item>a {
    display: none;
    /* If there was an outer anchor, styling handled above */
}

/* Responsive */
@media (max-width: 1023px) {
    .header-style-one .nav-outer {
        float: none;
        /* Reset on mobile/tablet */
    }

    .main-menu .navigation>li.has-mega-menu>.mega-menu {
        position: relative;
        top: 0;
        width: 100%;
        box-shadow: none;
        border-top: none;
        display: none;
        padding: 0;
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .main-menu .navigation>li.has-mega-menu.dropdown:hover>.mega-menu {
        display: block;
    }

    .mega-menu-inner {
        padding: 0;
        width: 100%;
        max-width: none;
    }

    .mega-menu-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 15px;
    }
}

@media (max-width: 767px) {
    .mega-menu-grid {
        grid-template-columns: 1fr;
    }
}