/* Container & Layout */
.wc-ahs-container { 
    position: relative; 
    margin: 0 auto; 
    font-family: inherit; 
    box-sizing: border-box;
}

.wc-ahs-form { 
    display: flex; 
    width: 100%; 
}

/* Master Wrapper - Powered by CSS Variables */
.wc-ahs-input-group { 
    display: flex; 
    align-items: center; 
    width: 100%; 
    height: var(--ahs-height); 
    border: 1px solid var(--ahs-border); 
    border-radius: var(--ahs-radius); 
    background: var(--ahs-bg); 
    position: relative; 
    box-sizing: border-box;
}

/* 1. Search Input Wrapper (Dominant) */
.wc-ahs-search-wrapper { 
    flex: 1; 
    min-width: 0; 
    height: 100%; 
    position: static; 
}

/* --- Bulletproof Input Field --- */
.wc-ahs-input,
.wc-ahs-input:focus,
.wc-ahs-input:active { 
    width: 100% !important; 
    height: 100% !important; 
    border: none !important; 
    box-shadow: none !important; 
    outline: none !important; 
    border-radius: var(--ahs-radius) 0 0 var(--ahs-radius) !important;
    padding: 0 20px !important; 
    margin: 0 !important;
    font-size: 15px !important; 
    box-sizing: border-box !important; 
    background: transparent !important; 
    color: var(--ahs-text) !important;
    line-height: normal !important;
}

.wc-ahs-input::placeholder { 
    color: var(--ahs-placeholder) !important; 
}

/* 2. Category Wrapper */
.wc-ahs-category-wrapper { 
    flex: 0 0 auto;
    max-width: 180px;
    height: 100%; 
    border-left: 1px solid var(--ahs-border); 
    background: var(--ahs-cat-bg); 
}

/* --- Bulletproof Category Select --- */
.wc-ahs-select,
.wc-ahs-select:focus,
.wc-ahs-select:active { 
    width: 100% !important; 
    height: 100% !important; 
    border: none !important; 
    box-shadow: none !important; 
    outline: none !important; 
    background-color: transparent !important; 
    background: transparent !important;
    padding: 0 15px !important; 
    margin: 0 !important;
    cursor: pointer !important; 
    font-size: 13px !important; 
    font-weight: 500 !important;
    color: var(--ahs-cat-text) !important; 
    appearance: auto !important; 
}

/* 3. Button Wrapper */
.wc-ahs-button-wrapper { 
    flex: 0 0 calc(var(--ahs-height) + 10px); 
    height: 100%; 
}

.wc-ahs-submit-btn { 
    width: 100%; 
    height: 100%; 
    background: var(--ahs-btn-bg); 
    color: var(--ahs-btn-icon); 
    border: none; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: all 0.2s ease; 
    border-radius: 0 var(--ahs-radius) var(--ahs-radius) 0; 
}

/* Configurable Hover State */
.wc-ahs-submit-btn:hover { 
    background: var(--ahs-btn-hover-bg);
    color: var(--ahs-btn-hover-icon);
}

/* --- AJAX Dropdown Results --- */
.wc-ahs-results-dropdown { 
    position: absolute; 
    top: calc(100% + 4px); 
    left: 0; 
    right: 0; 
    background: #fff; 
    border: 1px solid var(--ahs-border); 
    border-radius: 4px; 
    box-shadow: 0 8px 24px rgba(0,0,0,0.12); 
    z-index: 9999; 
    max-height: 400px; 
    overflow-y: auto; 
}

.wc-ahs-results-list { list-style: none; margin: 0; padding: 0; }
.wc-ahs-result-item a, .wc-ahs-view-all a { display: flex; align-items: center; padding: 12px 15px; text-decoration: none; color: var(--ahs-text); border-bottom: 1px solid #f1f1f1; }
.wc-ahs-result-item:hover a, .wc-ahs-result-item.is-active a, .wc-ahs-view-all:hover a, .wc-ahs-view-all.is-active a { background: #f8f9fa; }
.wc-ahs-result-image { flex: 0 0 40px; margin-right: 15px; }
.wc-ahs-result-image img { width: 100%; height: auto; border-radius: 3px; object-fit: cover; }
.wc-ahs-result-details { flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
.wc-ahs-result-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-ahs-highlight { background-color: transparent; color: var(--ahs-btn-bg); font-weight: bold; }
.wc-ahs-result-price { font-size: 13px; color: #666; font-weight: 600; }
.wc-ahs-view-all a { justify-content: center; font-weight: 600; color: var(--ahs-btn-bg); background: #fcfcfc; }
.wc-ahs-message { padding: 20px; text-align: center; color: #666; font-size: 14px; display: flex; justify-content: center; align-items: center; }
.wc-ahs-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,0.1); border-left-color: var(--ahs-btn-bg); border-radius: 50%; margin-right: 10px; animation: wc-ahs-spin 1s linear infinite; }
@keyframes wc-ahs-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Bulletproof Mobile Single-Row Integrity --- */
@media screen and (max-width: 768px) {
    /* Force the wrapper into a single row */
    .wc-ahs-input-group {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        height: var(--ahs-height) !important;
        border: 1px solid var(--ahs-border) !important;
        background: var(--ahs-bg) !important;
    }
    
    /* Hide category dropdown completely if setting is enabled */
    .wc-ahs-category-wrapper.wc-ahs-hide-mobile {
        display: none !important;
    }

    /* Force search input to take remaining space without stacking */
    .wc-ahs-search-wrapper {
        flex: 1 1 auto !important;
        width: auto !important;
        height: 100% !important;
        margin-bottom: 0 !important;
        border: none !important;
        position: relative !important;
    }
    
    .wc-ahs-input {
        padding: 0 12px !important;
        font-size: 14px !important;
    }
    
    /* Lock the button width */
    .wc-ahs-button-wrapper {
        flex: 0 0 calc(var(--ahs-height) + 10px) !important;
        height: 100% !important;
    }

    .wc-ahs-submit-btn {
        border-radius: 0 var(--ahs-radius) var(--ahs-radius) 0 !important;
    }
    
    /* Allow dropdown results to anchor perfectly below the search bar */
    .wc-ahs-results-dropdown { 
        position: absolute !important; 
        top: calc(100% + 5px) !important; 
        left: 0 !important; 
        right: 0 !important; 
        width: 100% !important; 
        max-height: 60vh !important; 
    }
}