/**
 * Fix for navbar dropdown menus not being clickable
 * Ensures dropdowns appear above other content
 */

/* Remove overflow hidden that might be clipping dropdowns */
#sp-menu,
.sp-megamenu-wrapper {
    overflow: visible !important;
}

/* CRITICAL: Remove overflow from all parent containers */
body,
.body-wrapper,
.body-innerwrapper,
#sp-header-wrapper,
#sp-header,
#sp-header .container,
#sp-header .container-inner {
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* Ensure the header row doesn't clip dropdowns */
#sp-header .row {
    overflow: visible !important;
}

/* Make sure dropdown menus have proper z-index */
.sp-dropdown,
.sp-dropdown-inner,
.sp-dropdown-items,
.sp-megamenu-dropdown,
.sp-dropdown .sp-dropdown-inner {
    z-index: 9999 !important;
    position: absolute !important;
}

/* Ensure parent menu items can show dropdowns */
.sp-megamenu-parent > li {
    position: relative !important;
    overflow: visible !important;
}

/* Fix hover/focus states for better interaction */
.sp-megamenu-parent > li:hover > .sp-dropdown,
.sp-megamenu-parent > li:focus-within > .sp-dropdown,
.sp-megamenu-parent > li > a:focus + .sp-dropdown,
.sp-megamenu-parent > li > span:focus + .sp-dropdown {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

/* Ensure the menu item with dropdown is interactive */
.sp-megamenu-parent > li.sp-has-child > a,
.sp-megamenu-parent > li.sp-has-child > span {
    position: relative !important;
    z-index: 10 !important;
}

/* Fix any transform or transition issues */
.sp-dropdown {
    transform: none !important;
    transition: opacity 0.2s ease, visibility 0.2s ease !important;
}

/* Ensure dropdowns are not covered by other elements */
#sp-main-body,
.sp-main-body {
    position: relative;
    z-index: 1;
}

/* Header should be above main content but below dropdowns */
/* Removed position: relative to allow sticky header to work */
#sp-header {
    z-index: 100;
}

/* Profile dropdown specific fixes */
.sp-profile-wrapper {
    position: relative !important;
    z-index: 9999 !important;
}

.sp-profile-wrapper .sp-dropdown {
    position: absolute !important;
    z-index: 99999 !important;
    right: 0 !important;
    top: 100% !important;
    width: auto !important;
    min-width: 200px !important;
    background: #fff !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    border: 1px solid #ddd !important;
    margin-top: 10px !important;
    padding: 0 !important;
    border-radius: 4px !important;
    overflow: hidden !important;
}

/* Style the dropdown items */
.sp-profile-wrapper .sp-dropdown ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.sp-profile-wrapper .sp-dropdown li {
    padding: 0 !important;
    margin: 0 !important;
    border-bottom: 1px solid #eee !important;
}

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

.sp-profile-wrapper .sp-dropdown a {
    display: block !important;
    padding: 12px 20px !important;
    color: #333 !important;
    text-decoration: none !important;
    transition: background-color 0.2s ease !important;
    white-space: nowrap !important;
}

.sp-profile-wrapper .sp-dropdown a:hover {
    background-color: #f5f5f5 !important;
    color: #000 !important;
}

/* Ensure profile dropdown is visible */
.sp-profile-wrapper:hover .sp-dropdown,
.sp-profile-wrapper:focus-within .sp-dropdown {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Make sure columns don't clip content */
.sp-column {
    overflow: visible !important;
}

/* Fix for SP Page Builder sections that might overlap */
.sppb-section {
    position: relative;
    z-index: 1;
}

/* Ensure click events work properly */
.sp-megamenu-parent > li.sp-has-child {
    cursor: pointer;
}

/* Mobile menu should not be affected */
@media (max-width: 991px) {
    #offcanvas-toggler {
        z-index: 1000;
    }
    
    .offcanvas-menu {
        z-index: 9999;
    }
}

/* Additional fixes for dropdown accessibility */
.sp-megamenu-parent > li.sp-has-child > a:after,
.sp-megamenu-parent > li.sp-has-child > span:after {
    pointer-events: none !important; /* Ensure caret doesn't block clicks */
}

/* Fix for Tools menu and other dropdowns */
.sp-megamenu-parent li.sp-has-child:hover > .sp-dropdown,
.sp-megamenu-parent li.sp-has-child:focus-within > .sp-dropdown {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Ensure all menu containers allow overflow */
#sp-header,
#sp-header .container,
#sp-header .container-inner,
#sp-header .row,
#sp-menu,
.sp-megamenu-wrapper,
.sp-megamenu-parent {
    overflow: visible !important;
}

/* Fix z-index stacking for all dropdowns */
.sp-megamenu-parent li.sp-dropdown-open > .sp-dropdown,
.sp-megamenu-parent li:hover > .sp-dropdown {
    z-index: 99999 !important;
}

/* Profile dropdown should appear above everything */
.sp-profile-wrapper .sp-dropdown {
    position: absolute !important;
    z-index: 999999 !important; /* Even higher than other dropdowns */
    overflow: visible !important;
    clip: auto !important;
    clip-path: none !important;
}

/* Ensure clickability */
.sp-dropdown a,
.sp-dropdown button,
.sp-dropdown li {
    position: relative !important;
    z-index: 1 !important;
    pointer-events: auto !important;
}

/* Fix main navigation dropdown styling */
.sp-megamenu-parent .sp-dropdown {
    background: #fff !important;
    border: 1px solid #ddd !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 200px !important;
}

.sp-megamenu-parent .sp-dropdown ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

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

.sp-megamenu-parent .sp-dropdown a {
    display: block !important;
    padding: 10px 20px !important;
    color: #333 !important;
    text-decoration: none !important;
    border-bottom: 1px solid #eee !important;
    transition: all 0.2s ease !important;
}

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

.sp-megamenu-parent .sp-dropdown a:hover {
    background-color: #f5f5f5 !important;
    color: #000 !important;
    padding-left: 25px !important;
}

/* Remove any max-height restrictions */
.sp-dropdown,
.sp-dropdown-inner,
.sp-dropdown-items {
    max-height: none !important;
    height: auto !important;
}

/* Ensure dropdowns are properly positioned */
.sp-megamenu-parent > li {
    position: relative !important;
}

.sp-megamenu-parent > li > .sp-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    margin-top: 0 !important;
}

/* Right-align dropdowns that would 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;
}

/* Debug helper - uncomment to see dropdown boundaries */
/*
.sp-dropdown {
    border: 2px solid red !important;
    background: rgba(255,0,0,0.1) !important;
}
*/