/* Mobile Search Form Fixes */

/* Fix 1: Z-index issue - Ensure search block appears above breadcrumbs */
@media only screen and (max-width: 1024px) {
    .block.block-search.active {
        position: fixed;
        top: 80px;
        left: 10px;
        right: 10px;
        width: auto;
        z-index: 999; /* Higher than breadcrumbs and navigation */
        background: #fff;
        padding: 15px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        border-radius: 5px;
    }
    
    /* Fix 2: Make search input visible on mobile */
    .block.block-search.active #search {
        position: static !important;
        left: auto !important;
        width: 100%;
        display: block;
        visibility: visible;
        margin: 10px 0;
        padding: 10px 50px 10px 15px; /* Extra padding on right for button */
        font-size: 16px;
        border: 1px solid #ccc;
        border-radius: 25px;
        height: 45px;
        box-sizing: border-box;
    }
    
    /* Fix 3: Show and style the search submit button */
    .block.block-search.active .action.search {
        display: block !important;
        position: absolute;
        right: 8px; /* Position inside the input field */
        top: 50%;
        transform: translateY(-50%);
        background: transparent;
        border: none;
        padding: 0;
        width: 30px;
        height: 30px;
        cursor: pointer;
        margin: 0;
        z-index: 2;
    }
    
    /* Add search icon to submit button */
    .block.block-search.active .action.search span {
        display: none;
    }
    
    /* Use Font Awesome search icon for better compatibility */
    .block.block-search.active .action.search::before {
        content: "\f002"; /* Font Awesome search icon */
        font-family: "Font Awesome 6 Free", "FontAwesome";
        font-weight: 900;
        font-size: 18px;
        color: #666;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 30px;
        text-align: center;
        width: 30px;
        height: 30px;
    }
    
    /* Ensure the form and controls are properly styled */
    .block.block-search.active .form.minisearch {
        position: relative;
    }
    
    .block.block-search.active .field.search {
        position: relative;
        margin: 0;
    }
    
    .block.block-search.active .control {
        margin: 0;
        padding: 0;
        border: none;
        position: relative;
        width: 100%;
    }
    
    /* Position actions inside the control/input container */
    .block.block-search.active .actions {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        z-index: 10;
        pointer-events: auto;
    }
    
    /* Make sure control container is relatively positioned for actions */
    .block.block-search.active .control {
        position: relative !important;
    }
    
    /* Ensure actions are positioned relative to the control */
    .block.block-search.active .field.search .control {
        position: relative;
    }
    
    /* Hide the label as it's not needed on mobile */
    .block.block-search.active .label {
        display: none;
    }
    
    /* Style the search title if shown */
    .block.block-search.active .block-title {
        display: block;
        margin-bottom: 10px;
        font-size: 18px;
        font-weight: bold;
        color: #333;
    }
    
    /* Ensure proper stacking context */
    .block.block-search.active .block-content {
        position: relative;
        z-index: 1;
    }
    
    /* Search autocomplete dropdown styling */
    .block.block-search.active #search_autocomplete {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        border: 1px solid #ddd;
        border-top: none;
        border-radius: 0 0 5px 5px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        z-index: 1000;
        max-height: 300px;
        overflow-y: auto;
    }
}

/* Additional mobile optimizations for smaller screens */
@media only screen and (max-width: 480px) {
    .block.block-search.active {
        left: 5px;
        right: 5px;
        padding: 10px;
    }
    
    .block.block-search.active #search {
        font-size: 14px;
        padding: 8px 45px 8px 12px;
        height: 40px;
    }
    
    .block.block-search.active .action.search {
        width: 26px;
        height: 26px;
        right: 7px;
        top: 29px !important;
    }
    
    .block.block-search.active .action.search::before {
        font-size: 16px;
        line-height: 26px;
        width: 26px;
        height: 26px;
    }
}

/* Ensure the button is not disabled on mobile */
@media only screen and (max-width: 1024px) {
    .block.block-search.active .action.search[disabled] {
        pointer-events: auto;
        opacity: 1;
        cursor: pointer;
    }
}
