/* Custom Mega Menu Styles */
#mainmenu>li ul.mega.custom-mega-menu {
    width: 100vw;
    max-width: 1200px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0;
    padding-top: 30px;
    /* This padding acts as the unbreakable invisible hover bridge */
    margin-top: 0;
    /* Removing the margin that caused the disconnect */
    background: transparent;
    box-shadow: none;
    border: none;
    transition: all 0.3s ease;
}

/* Ensure the wrapper doesn't have its own background/border */
#mainmenu>li ul.mega.custom-mega-menu .sb-menu {
    border: none;
    background: transparent;
    border-radius: 0;
}

#mainmenu li ul.mega.custom-mega-menu .custom-mega-content {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    text-align: left;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid #f0f0f0;
}

.dark-scheme #mainmenu li ul.mega.custom-mega-menu .custom-mega-content,
.dark-scheme #mainmenu>li ul.mega.custom-mega-menu {
    background: transparent;
}

.dark-scheme #mainmenu li ul.mega.custom-mega-menu .custom-mega-content {
    background: #1a1a2e;
    border-color: rgba(255, 255, 255, 0.05);
}

.custom-mega-content .mega-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #111;
}

.dark-scheme .custom-mega-content .mega-title {
    color: #fff;
}

.custom-mega-content .mega-subtitle {
    font-size: 13px;
    color: #666;
    margin-bottom: 20px;
}

.dark-scheme .custom-mega-content .mega-subtitle {
    color: #999;
}

.mega-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.mega-grid.two-cols {
    grid-template-columns: 1fr 1fr;
}

.mega-item {
    display: flex !important;
    align-items: flex-start;
    padding: 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none !important;
    width: 100% !important;
    position: relative;
    overflow: hidden;
}

.dark-scheme .mega-item {
    background: transparent;
    border-color: transparent;
}

/* Subtle hover background */
.mega-item:not(.no-hover):hover {
    background: #f8f9fa !important;
    border-color: #ebebeb !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03) !important;
    transform: translateY(-2px);
}

.dark-scheme .mega-item:not(.no-hover):hover {
    background: rgba(255, 255, 255, 0.03) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
}

.mega-icon {
    width: 48px;
    height: 48px;
    background: #f4f6fa;
    color: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 18px;
    flex-shrink: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(var(--primary-color-rgb), 0.1);
}

.dark-scheme .mega-icon {
    background: rgba(var(--primary-color-rgb), 0.1);
    border-color: rgba(var(--primary-color-rgb), 0.2);
}

/* Gradient hover on icon */
.mega-item:hover .mega-icon {
    background: linear-gradient(var(--primary-gradient));
    color: #fff;
    transform: scale(1.08) rotate(3deg);
    border-color: transparent;
    box-shadow: 0 6px 15px rgba(var(--primary-color-rgb), 0.25);
}

.mega-text {
    display: flex;
    flex-direction: column;
}

.mega-item-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--heading-font-color) !important;
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.dark-scheme .mega-item-title {
    color: #fff !important;
}

.mega-item-desc {
    font-size: 13px;
    color: #6c757d !important;
    line-height: 1.5;
    font-weight: 400;
}

.dark-scheme .mega-item-desc {
    color: #a0a0a0 !important;
}

/* Highlight title text slightly on hover but keep it very clean */
.mega-item:hover .mega-item-title {
    color: var(--primary-color) !important;
}

.mega-highlight {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.04) 0%, rgba(var(--primary-color-rgb), 0.1) 100%);
    padding: 30px;
    border-radius: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid rgba(var(--primary-color-rgb), 0.08);
}

.dark-scheme .mega-highlight {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.08) 0%, rgba(var(--primary-color-rgb), 0.18) 100%);
    border-color: rgba(var(--primary-color-rgb), 0.15);
}

.mega-highlight h6 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--heading-font-color);
}

.dark-scheme .mega-highlight h6 {
    color: #fff;
}

.mega-highlight p {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 20px;
    line-height: 1.5;
}

.dark-scheme .mega-highlight p {
    color: #a0a0a0;
}

/* Ensure global dark-theme mega-menu container background is properly set to the dark scheme variable */
.dark-scheme #mainmenu li ul.mega.custom-mega-menu .custom-mega-content {
    background: var(--bg-dark-2);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}