/* Mega Menu Styles */
.mega-menu-wrapper {
    position: relative !important;
}

.mega-menu {
    display: inline-block;
    width: auto;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    margin-top: 0;
    padding: 20px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
    border-top: 3px solid #007bff;
    position: absolute;
    left: 50%; /* center the mega menu horizontally relative to the wrapper */
    transform: translateX(-39%);
    background: white;
    z-index: 1000;
    max-width: calc(100vw - 32px); /* avoid overflowing viewport */
    overflow-x: auto; /* allow horizontal scroll when many columns added */
    -webkit-overflow-scrolling: touch;
}

/* UL/LI based mega menu styles */
.mega-menu-list,
.mega-sublist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-menu-list {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: nowrap; /* keep columns in a single row; menu will scroll if too wide */
}

.mega-menu-column {
    display: block;
}

.mega-sublist {
    margin-top: 8px;
}

.mega-sublist li {
    margin: 6px 0;
}

.mega-menu .row {
    display: flex;
    margin: 0;
    gap: 15px;
    width: auto;
}

.mega-menu-column {
    padding: 0 25px;
    border-right: 1px solid #eee;
    white-space: nowrap;
}

.mega-menu-column:last-child {
    border-right: none;
}

.mega-menu-column .dropdown-header {
    color: #007bff;
    font-weight: bold;
    font-size: 14px;
    padding: 0 0 10px 0;
    border-bottom: 2px solid #eee;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.mega-menu-item {
    display: block;
    padding: 8px 0;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 14px;
}

.mega-menu-column:last-child {
    border-right: none;
}

.mega-menu-item:hover {
    color: #007bff;
    transform: translateX(5px);
}

.mega-menu-item i {
    width: 20px;
    margin-right: 8px;
    color: #666;
}

.mega-menu-item:hover {
    color: #007bff;
    transform: translateX(5px);
}

.mega-menu-item:hover i {
    color: #007bff;
}

/* Responsive Styles */
@media (max-width: 991px) {
    /* Ensure the mega menu becomes part of the collapsed navbar flow */
    .mega-menu-wrapper {
        position: static !important;
    }

    /* When in mobile, the dropdown should be static and full width inside the collapse */
    .navbar-collapse .dropdown-menu,
    .navbar-collapse .mega-menu {
        position: static !important;
        width: 100% !important;
        left: auto !important;
        right: auto !important;
        transform: none !important; /* reset centering transform on mobile */
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* Make the UL-based menu stack vertically */
    .mega-menu-list {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        width: 100%;
    }

    .mega-menu-column {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #eee;
        padding: 12px 15px;
        box-sizing: border-box;
        background: #fff;
    }

    .mega-menu-column:last-child {
        border-bottom: none;
    }

    /* Sublist items should wrap nicely on small screens */
    .mega-sublist {
        margin-top: 8px;
    }

    .mega-sublist li {
        margin: 8px 0;
    }

    .mega-menu-item {
        padding: 8px 0;
        white-space: normal;
        display: block;
    }

    .mega-menu-column .dropdown-header {
        padding: 0 0 8px 0;
        margin-bottom: 8px;
        white-space: normal;
    }
}