/* Sticky Search Fix - Ensures proper sticky behavior */

/* Reset any parent overflow constraints that might prevent sticky */
body,
html {
    overflow-x: hidden;
    overflow-y: auto !important;
}

/* Ensure parent containers don't block sticky */
body > div,
body > main,
body > section,
.main-content,
.page-content,
.content-wrapper,
.wrapper,
.container {
    overflow: visible !important;
    overflow-y: visible !important;
}

/* Desktop Sticky Fix */
@media (min-width: 769px) {
    /* Force sticky behavior on desktop */
    .search-container {
        position: -webkit-sticky !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        
        /* Ensure it has a background */
        background: #f8f9fa !important;
        
        /* Add transform to create new stacking context */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        
        /* Ensure it stays on top */
        will-change: transform;
    }
    
    /* Absolutely hide mobile sticky on desktop */
    #stickyMobileSearch,
    .sticky-mobile-search-container {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        left: -9999px !important;
    }
}

/* Mobile Fixes */
@media (max-width: 768px) {
    /* Main search container should not be sticky on mobile */
    .search-container {
        position: relative !important;
        top: auto !important;
    }
    
    /* Mobile sticky container - ensure proper initial state */
    .sticky-mobile-search-container {
        display: block !important;
        position: fixed !important;
        bottom: -100px !important;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease !important;
    }
    
    /* When visible class is added */
    .sticky-mobile-search-container.visible {
        bottom: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Ensure mobile sticky has proper z-index - higher than other elements */
    .sticky-mobile-search-container {
        z-index: 1001 !important;
    }
}

/* Additional safety rules */
.sticky-mobile-search-container[style*="display: none"] {
    display: none !important;
}

/* Debug helper - remove in production */
.search-container::before {
    content: attr(data-sticky-debug);
    position: absolute;
    top: -20px;
    left: 10px;
    font-size: 10px;
    color: red;
    z-index: 9999;
    display: none;
}

/* Show debug info when needed */
body.debug-sticky .search-container::before {
    display: block;
}