/**
 * Fix for main navigation dropdown styling
 * Addresses the issue where dropdowns appear as unstyled text
 */

/* Primary dropdown styling for main navigation */
.sp-megamenu-wrapper .sp-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    background-color: #ffffff !important;
    border: 1px solid rgba(0,0,0,0.15) !important;
    border-radius: 4px !important;
    box-shadow: 0 6px 12px rgba(0,0,0,0.175) !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 200px !important;
    z-index: 99999 !important;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease !important;
}

/* Show dropdown on hover */
.sp-megamenu-parent > li:hover > .sp-dropdown,
.sp-megamenu-parent > li.sp-dropdown-open > .sp-dropdown {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Style dropdown inner container */
.sp-dropdown .sp-dropdown-inner {
    padding: 0 !important;
    background-color: #ffffff !important;
}

/* Style dropdown menu items container */
.sp-dropdown .sp-dropdown-items {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background-color: #ffffff !important;
}

/* Individual menu items */
.sp-dropdown .sp-dropdown-items > li {
    padding: 0 !important;
    margin: 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    background-color: #ffffff !important;
}

/* Remove border from last item */
.sp-dropdown .sp-dropdown-items > li:last-child {
    border-bottom: none !important;
}

/* Style the links */
.sp-dropdown .sp-dropdown-items > li > a {
    display: block !important;
    padding: 12px 20px !important;
    color: #333333 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    line-height: 1.42857143 !important;
    background-color: transparent !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
}

/* Hover state for links */
.sp-dropdown .sp-dropdown-items > li > a:hover,
.sp-dropdown .sp-dropdown-items > li > a:focus {
    background-color: #f5f5f5 !important;
    color: #262626 !important;
    text-decoration: none !important;
}

/* Active/current item styling */
.sp-dropdown .sp-dropdown-items > li.active > a,
.sp-dropdown .sp-dropdown-items > li.current > a {
    background-color: #337ab7 !important;
    color: #ffffff !important;
}

/* Ensure parent menu item stays highlighted when hovering dropdown */
.sp-megamenu-parent > li:hover > a,
.sp-megamenu-parent > li.sp-dropdown-open > a {
    color: #337ab7 !important;
}

/* Fix for nested dropdown structure */
.sp-dropdown ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.sp-dropdown ul li {
    padding: 0 !important;
    margin: 0 !important;
}

.sp-dropdown ul li a {
    display: block !important;
    padding: 12px 20px !important;
    color: #333333 !important;
    text-decoration: none !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid #f0f0f0 !important;
    transition: all 0.2s ease !important;
}

.sp-dropdown ul li:last-child a {
    border-bottom: none !important;
}

.sp-dropdown ul li a:hover {
    background-color: #f5f5f5 !important;
    color: #262626 !important;
    padding-left: 25px !important;
}

/* Ensure dropdowns appear above other content */
.sp-megamenu-wrapper {
    position: relative !important;
    z-index: 1000 !important;
}

/* Specific fix for Tools dropdown and similar menus */
.sp-megamenu-parent > li.item-437 > .sp-dropdown, /* Tools menu */
.sp-megamenu-parent > li.item-101 > .sp-dropdown, /* Home dropdown if exists */
.sp-megamenu-parent > li > .sp-dropdown {
    background: #ffffff !important;
    border: 1px solid #ddd !important;
    border-top: 2px solid #337ab7 !important; /* Add accent border */
}

/* Mobile responsive - hide dropdowns on mobile */
@media (max-width: 991px) {
    .sp-megamenu-wrapper .sp-dropdown {
        display: none !important;
    }
}

/* Fix dropdown arrow/caret positioning */
.sp-megamenu-parent > li.sp-has-child > a:after {
    content: "\f107" !important; /* Font Awesome down arrow */
    font-family: "Font Awesome 5 Free" !important;
    font-weight: 900 !important;
    margin-left: 5px !important;
    font-size: 12px !important;
    vertical-align: middle !important;
}

/* Rotate arrow when dropdown is open */
.sp-megamenu-parent > li.sp-dropdown-open > a:after {
    transform: rotate(180deg) !important;
    display: inline-block !important;
}

/* Additional specificity for dropdown visibility */
#sp-menu .sp-megamenu-wrapper .sp-megamenu-parent > li:hover > .sp-dropdown {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure text is readable */
.sp-dropdown * {
    color: #333333 !important;
    font-family: inherit !important;
}

/* Fix any potential text alignment issues */
.sp-dropdown-items {
    text-align: left !important;
}

/* Override any conflicting styles */
.sp-dropdown,
.sp-dropdown * {
    box-sizing: border-box !important;
}

/* Ensure dropdown width is appropriate */
.sp-dropdown {
    width: auto !important;
    min-width: 220px !important;
    max-width: 300px !important;
}

/* Special styling for mega menu columns if they exist */
.sp-dropdown.sp-dropdown-mega {
    min-width: 600px !important;
    max-width: 100% !important;
}

.sp-dropdown-mega .sp-dropdown-inner {
    display: flex !important;
    padding: 20px !important;
}

.sp-dropdown-mega .sp-dropdown-column {
    flex: 1 !important;
    padding: 0 15px !important;
}

/* Fix z-index stacking context */
/* Removed position: relative to allow sticky header to work */
#sp-header {
    z-index: 1000 !important;
}

#sp-menu {
    position: relative !important;
    z-index: 1001 !important;
}

.sp-megamenu-parent > li {
    position: relative !important;
}

.sp-megamenu-parent > li > .sp-dropdown {
    position: absolute !important;
    z-index: 1002 !important;
}