/* Mega Menu Styles */
.mega-menu {
    width: 800px;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    left: 50% !important;
    transform: translateX(-50%) !important;
    background-color: #155724;
    /* Institutional Dark Green */
    margin-top: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mega-menu .dropdown-header {
    font-size: 0.95rem;
    font-weight: 700;
    color: #34ce57 !important;
    /* Light Green for headers */
    padding-left: 0;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mega-menu ul.list-unstyled li {
    margin-bottom: 8px;
}

.mega-menu a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.9rem;
    display: block;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.mega-menu a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
    padding-left: 12px;
}

/* FIX: Nested Dropdowns Support */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -5px;
    margin-left: 0;
    border-radius: 4px;
}

/* FIX: Mega Menu styling when nested inside another dropdown */
.dropdown-menu .mega-menu {
    left: 100% !important;
    top: 0 !important;
    transform: none !important;
    margin-top: -10px !important;
    margin-left: 0 !important;
}

/* Ensure submenu arrow rotates on hover/active */
.dropdown-submenu:hover>.dropdown-item i {
    transform: rotate(-90deg);
}

/* FIX: Show nested dropdown on hover */
.dropdown-submenu:hover>.dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    display: block;
    /* Ensure it's treated as block */
}

/* FIX: Disable transition for nested menus to prevent overlap/ghosting */
.dropdown-submenu .dropdown-menu {
    transition: none !important;
}

@media (max-width: 991px) {
    .mega-menu {
        width: 100%;
        position: static !important;
        transform: none !important;
        box-shadow: none;
        background-color: transparent;
    }

    .mega-menu a {
        padding-left: 20px;
    }

    /* Fix nested menus in mobile */
    .dropdown-submenu .dropdown-menu {
        position: static;
        margin-left: 15px;
        margin-top: 0;
        border: none;
        box-shadow: none;
        background: transparent;
        padding-top: 0;
    }

    .dropdown-menu .mega-menu {
        position: static !important;
        width: 100% !important;
        border: none;
        padding-top: 10px;
    }
}