/**
 * Frontend CSS for WooCommerce Advanced Search
 * 
 * @package WooSearch_SC
 * @since 1.0.0
 */

/* Autocomplete Wrapper */
.woo-search-sc-autocomplete-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Autocomplete Container */
.woo-search-sc-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

/* Autocomplete Suggestions List */
.woo-search-sc-suggestions {
    list-style: none;
    margin: 0;
    padding: 0;
}

.woo-search-sc-suggestions li {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #eee;
}

.woo-search-sc-suggestions li:last-child {
    border-bottom: none;
}

/* Suggestion Links */
.woo-search-sc-suggestion {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s ease;
}

.woo-search-sc-suggestion:hover,
.woo-search-sc-suggestion:focus {
    background-color: #f8f9fa;
    color: #333;
    text-decoration: none;
}

/* Suggestion Image */
.suggestion-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Suggestion Content */
.suggestion-content {
    flex: 1;
    min-width: 0;
}

.suggestion-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-price {
    color: #666;
    font-size: 0.9em;
}

/* Loading State */
.woo-search-sc-loading {
    padding: 15px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Search Suggestions (No Results) */
.woo-search-sc-suggestions {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #0073aa;
}

.woo-search-sc-suggestions h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.1em;
}

.woo-search-sc-suggestions ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.woo-search-sc-suggestions li {
    margin: 0 0 8px 0;
    padding: 0;
}

.woo-search-sc-suggestions a {
    color: #0073aa;
    text-decoration: none;
    font-weight: 500;
}

.woo-search-sc-suggestions a:hover {
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .woo-search-sc-autocomplete {
        max-height: 300px;
    }
    
    .woo-search-sc-suggestion {
        padding: 10px 12px;
    }
    
    .suggestion-image {
        width: 40px;
        height: 40px;
        margin-right: 10px;
    }
    
    .suggestion-title {
        font-size: 0.9em;
    }
    
    .suggestion-price {
        font-size: 0.8em;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .woo-search-sc-autocomplete {
        background: #2c3338;
        border-color: #50575e;
        color: #f0f0f1;
    }
    
    .woo-search-sc-suggestion {
        color: #f0f0f1;
    }
    
    .woo-search-sc-suggestion:hover,
    .woo-search-sc-suggestion:focus {
        background-color: #1e1e1e;
        color: #f0f0f1;
    }
    
    .suggestion-title {
        color: #f0f0f1;
    }
    
    .suggestion-price {
        color: #a7aaad;
    }
    
    .woo-search-sc-suggestions li {
        border-bottom-color: #50575e;
    }
    
    .woo-search-sc-loading {
        color: #a7aaad;
    }
    
    .woo-search-sc-suggestions {
        background: #2c3338;
        border-left-color: #72aee6;
    }
    
    .woo-search-sc-suggestions h3 {
        color: #f0f0f1;
    }
    
    .woo-search-sc-suggestions a {
        color: #72aee6;
    }
}

/* High DPI / Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .suggestion-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Focus States for Accessibility */
.woo-search-sc-suggestion:focus {
    outline: 2px solid #005caa;
    outline-offset: -2px;
}

/* Animation for Smooth Appearance */
.woo-search-sc-autocomplete {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.woo-search-sc-autocomplete:not([style*="display: none"]) {
    opacity: 1;
    transform: translateY(0);
}

/* Search Form Enhancements */
.woo-search-sc-search-form {
    position: relative;
}

.woo-search-sc-search-form .woo-search-sc-loading {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    padding: 0;
    font-size: 12px;
    color: #666;
}

/* Integration with Popular Themes */

/* Storefront Theme */
.storefront .woo-search-sc-autocomplete {
    font-family: inherit;
}

/* Astra Theme */
.ast-header-search .woo-search-sc-autocomplete-wrapper {
    width: 100%;
}

/* Twenty Twenty-One */
.wp-block-search .woo-search-sc-autocomplete-wrapper {
    width: 100%;
}

/* WooCommerce Blocks */
.wp-block-woocommerce-product-search .woo-search-sc-autocomplete-wrapper {
    width: 100%;
}

/* Ensure compatibility with flex layouts */
.woo-search-sc-autocomplete-wrapper {
    flex: 1;
    min-width: 0;
}
