/**
 * Dynamic width adjustment for dropdown menus
 * Allows dropdowns to expand to fit content rather than truncating
 */

/* Remove text truncation and allow natural width */
.sp-dropdown a,
.sp-dropdown li a,
.sp-dropdown-items > li > a {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    display: block !important;
    padding: 12px 20px !important;
}

/* Allow dropdown to expand based on content */
.sp-dropdown {
    width: auto !important;
    min-width: 220px !important;
    max-width: none !important; /* Remove max-width restriction */
}

/* Let dropdown items determine width */
.sp-dropdown-items,
.sp-dropdown ul,
.sp-dropdown .sp-dropdown-inner {
    width: auto !important;
    min-width: 100% !important;
    max-width: none !important;
}

/* Specific fix for Solutions dropdown and similar menus */
.sp-megamenu-wrapper .sp-dropdown {
    width: auto !important;
    min-width: 250px !important; /* Slightly larger minimum */
    max-width: 400px !important; /* Reasonable maximum to prevent excessive width */
}

/* Ensure list items don't force width */
.sp-dropdown li,
.sp-dropdown-items > li {
    width: auto !important;
    min-width: 100% !important;
}

/* Let content determine dropdown width */
.sp-dropdown.sp-dropdown-main {
    width: max-content !important;
    min-width: 220px !important;
    max-width: 400px !important;
}

/* Fix for menu items with long text */
.sp-dropdown a {
    padding-right: 30px !important; /* Extra padding for breathing room */
}

/* Ensure dropdown positioning accommodates wider menus */
.sp-megamenu-parent > li > .sp-dropdown {
    left: 0 !important;
}

/* Right-align dropdowns that might go off-screen */
.sp-megamenu-parent > li:last-child > .sp-dropdown,
.sp-megamenu-parent > li:nth-last-child(2) > .sp-dropdown {
    left: auto !important;
    right: 0 !important;
}

/* Handle very long menu items gracefully */
@media (min-width: 992px) {
    .sp-dropdown {
        max-width: min(400px, 50vw) !important; /* Limit to viewport width on desktop */
    }
}

/* Fallback for extremely long text */
.sp-dropdown a {
    word-break: normal !important;
    hyphens: none !important;
}

/* Specific adjustments for known long menu items */
.sp-dropdown a:contains("Process Improvement"),
.sp-dropdown a:contains("Microsoft Solutions"),
.sp-dropdown a:contains("SkunkWorks") {
    min-width: max-content !important;
}

/* Ensure inner wrapper doesn't constrain width */
.sp-dropdown > div {
    width: 100% !important;
    min-width: 100% !important;
}

/* Override any hardcoded widths */
.sp-dropdown[style*="width"] {
    width: auto !important;
    min-width: 250px !important;
}

/* Fix for nested dropdown structures */
.sp-dropdown .sp-dropdown-inner {
    display: table !important; /* Use table display for natural width */
    width: 100% !important;
}

.sp-dropdown .sp-dropdown-items {
    display: table-row-group !important;
}

.sp-dropdown .sp-dropdown-items > li {
    display: table-row !important;
}

.sp-dropdown .sp-dropdown-items > li > a {
    display: table-cell !important;
    width: auto !important;
}