/* Meilisearch Autocomplete - Fixed Version */

/* Main dropdown container */
.meilisearch-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #BBB;
    border-top: 3px solid #8EB4D0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 9999;
    display: none;
    width: 100%;
    opacity: 1;
    transition: opacity 0.15s ease-in-out;
}

.meilisearch-autocomplete.open {
    display: block;
}

/* Bootstrap 3 style container with clearfix */
.meilisearch-autocomplete-wrapper {
    position: relative;
    display: flex;
    min-height: 200px;
}

.meilisearch-autocomplete-wrapper:before,
.meilisearch-autocomplete-wrapper:after {
    content: " ";
    display: table;
}

.meilisearch-autocomplete-wrapper:after {
    clear: both;
}

/* Left column - Suggestions and Categories (25%) */
.meilisearch-autocomplete-left-column {
    width: 25%;
    background-color: #f9f9f9;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
}

/* Right column - Products (75%) */
.meilisearch-autocomplete-right-column {
    width: 75%;
    padding: 15px;
    overflow-y: auto;
}

/* Suggestions section */
.meilisearch-autocomplete-section-amasty_pages,
.meilisearch-autocomplete-section-suggestions {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
}

/* Categories section */
.meilisearch-autocomplete-section-categories {
    padding: 10px 15px;
    width: 33%;
    box-sizing: border-box;
}

/* Pages section */
.meilisearch-autocomplete-section-pages {
    padding: 10px 15px;
}

/* Products section */
.meilisearch-autocomplete-section-products {
    width: 50%;
    box-sizing: border-box;
    padding: 10px 15px;
}

/* Section titles */
.meilisearch-autocomplete-section-title {
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    font-size: 0.8em;
    margin-bottom: 5px;
    padding: 4px 0;
    background-color: transparent;
    text-align: left;
}

/* Categories styling */
.meilisearch-autocomplete-category,
.meilisearch-autocomplete-amasty_page {
    display: block;
    padding: 3px 0;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
    border-radius: 3px;
    margin-bottom: 2px;
    text-align: left;
}

.meilisearch-autocomplete-category:hover,
.meilisearch-autocomplete-amasty_page:hover {
    background-color: transparent;
    text-decoration: none;
    padding-left: 5px;
}

.meilisearch-autocomplete-category-name {
    font-weight: 500;
    color: #333;
    text-align: left;
    display: block;
}

.meilisearch-autocomplete-suggestion-query {
    font-weight: 500;
    color: #333;
    text-align: left;
    display: block;
}

/* Products grid - Flexbox layout */
.meilisearch-autocomplete-section-products .meilisearch-autocomplete-hits {
    display: flex;
    flex-wrap: wrap;
    margin: -5px;
}

.meilisearch-autocomplete-section-products .meilisearch-autocomplete-hit {
    width: 20%; /* 5 columns */
    padding: 5px;
    box-sizing: border-box;
}

.meilisearch-autocomplete-product {
    display: block;
    text-decoration: none;
    height: 100%;
    transition: all 0.2s;
    text-align: center;
    border: 1px solid transparent;
    border-radius: 4px;
    background-color: #fff;
}

.meilisearch-autocomplete-product:hover {
    background-color: #f9f9f9;
    text-decoration: none;
    border-color: #ddd;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.meilisearch-autocomplete-product:hover .meilisearch-autocomplete-product-image img {
    opacity: 0.8;
}

/* Product image */
.meilisearch-autocomplete-product-image {
    margin-bottom: 10px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.meilisearch-autocomplete-product-image img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
}

/* Product details */
.meilisearch-autocomplete-product-details {
    text-align: center;
}

.meilisearch-autocomplete-product-name {
    font-size: 0.85em;
    color: #333;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    min-height: 2.6em;
}

.meilisearch-autocomplete-product-price {
    font-size: 1em;
    color: #8BC34A; /* Using your site's green */
    font-weight: bold;
}

/* Highlight search terms */
.meilisearch-autocomplete em {
    background-color: #CFEAFA;
    font-style: normal;
    font-weight: bold;
}

/* Footer */
.meilisearch-autocomplete-footer {
    clear: both;
    padding: 15px;
    text-align: center;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
    order: 3; /* Ensure footer is always last on mobile */
}

.meilisearch-autocomplete-footer a {
    color: #8BC34A; /* Using your site's green */
    font-weight: 600;
    text-decoration: none;
}

.meilisearch-autocomplete-footer a:hover {
    text-decoration: underline;
}

/* Responsive breakpoints */
@media (min-width: 992px) {
    /* Desktop layout is handled by flexbox above */
}

@media (min-width: 768px) and (max-width: 991px) {
    /* Tablet */
    .meilisearch-autocomplete-section-products .meilisearch-autocomplete-hit {
        width: 25%; /* 4 columns on tablet */
    }
}

@media (max-width: 767px) {
    /* Mobile - stack vertically with products first */
    .meilisearch-autocomplete-wrapper {
        flex-direction: column;
    }
    
    .meilisearch-autocomplete-left-column,
    .meilisearch-autocomplete-right-column {
        width: 100%;
    }
    
    /* Use flexbox order to show products first on mobile */
    .meilisearch-autocomplete-right-column {
        order: 1;
        border-bottom: 1px solid #eee;
    }
    
    .meilisearch-autocomplete-left-column {
        order: 2;
        border-right: none;
    }
    
    .meilisearch-autocomplete-section-products .meilisearch-autocomplete-hit {
        width: 50%; /* 2 columns on mobile */
    }
}

@media (max-width: 480px) {
    .meilisearch-autocomplete-section-products .meilisearch-autocomplete-hit {
        width: 50%; /* 2 columns on small mobile */
    }
    
    /* Adjust image and text sizes for smaller screens */
    .meilisearch-autocomplete-product-image {
        height: 70px;
    }
    
    .meilisearch-autocomplete-product-name {
        font-size: 0.8em;
    }
    
    .meilisearch-autocomplete-product-price {
        font-size: 0.9em;
    }
}

/* Suggestions styling */
.meilisearch-autocomplete-suggestion {
    display: block;
    padding: 3px 0;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
    border-radius: 3px;
    margin-bottom: 2px;
    text-align: left;
}

.meilisearch-autocomplete-suggestion:hover {
    background-color: transparent;
    text-decoration: none;
    padding-left: 5px;
}

/* Loading state */
.meilisearch-autocomplete-loading {
    padding: 20px;
    text-align: center;
    color: #999;
}


/* No results */
.meilisearch-autocomplete-no-results {
    padding: 40px;
    text-align: center;
    color: #666;
}

/* Box model for all elements */
.meilisearch-autocomplete *,
.meilisearch-autocomplete *:before,
.meilisearch-autocomplete *:after {
    box-sizing: border-box;
}

.meilisearch-autocomplete a {
    cursor: pointer;
}

/* Ensure all hit links stretch to fill their containers */
.meilisearch-autocomplete-hit > a {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

/* Custom scrollbar for webkit browsers */
.meilisearch-autocomplete::-webkit-scrollbar {
    width: 6px;
}

.meilisearch-autocomplete::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.meilisearch-autocomplete::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.meilisearch-autocomplete::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Additional CSS for Mustache Template Styling */

/* Category count styling */
.meilisearch-autocomplete-category-count {
    font-size: 0.85em;
    color: #999;
    font-weight: normal;
    margin-left: 5px;
}

/* Suggestion count styling */
.meilisearch-autocomplete-suggestion-count {
    font-size: 0.85em;
    color: #999;
    font-weight: normal;
    margin-left: 5px;
}

/* Page styling */
.meilisearch-autocomplete-page {
    display: block;
    padding: 3px 0;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
    border-radius: 3px;
    margin-bottom: 2px;
    text-align: left;
}

.meilisearch-autocomplete-page:hover {
    background-color: transparent;
    text-decoration: none;
    padding-left: 5px;
}

.meilisearch-autocomplete-page-name {
    font-weight: 500;
    color: #333;
    text-align: left;
}

/* Page content styling */
.meilisearch-autocomplete-page-content {
    font-size: 0.8em;
    color: #666;
    margin-top: 3px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-align: left;
}

/* Suggestion description styling */
.meilisearch-autocomplete-suggestion-description {
    font-size: 0.8em;
    color: #666;
    margin-top: 3px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Attribute styling */
.meilisearch-autocomplete-attribute {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.meilisearch-autocomplete-attribute:last-child {
    border-bottom: none;
}

.attribute-label {
    font-weight: 600;
    color: #555;
    margin-right: 5px;
}

.attribute-value {
    color: #333;
}

/* Menu item styling */
.meilisearch-autocomplete-menu-item {
    padding: 8px 10px;
    color: #333;
    transition: background-color 0.2s;
    border-radius: 3px;
    margin-bottom: 2px;
}

.meilisearch-autocomplete-menu-item:hover {
    background-color: #f9f9f9;
}

/* Ensure consistent spacing in left column sections */
.meilisearch-autocomplete-left-column .meilisearch-autocomplete-hit {
    margin-bottom: 0;
}

.meilisearch-autocomplete-left-column .meilisearch-autocomplete-hit:not(:last-child) {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Better highlight styling for search terms */
.meilisearch-autocomplete em {
    background-color: #fff3cd;
    color: #856404;
    padding: 1px 0;
    border-radius: 2px;
    font-style: normal;
    font-weight: 600;
}

/* Price formatting improvements */
.meilisearch-autocomplete-product-price {
    font-size: 1.1em;
    color: #8BC34A;
    font-weight: 700;
    margin-top: 5px;
}

/* Product name improvements */
.meilisearch-autocomplete-product-name {
    font-size: 0.9em;
    color: #333;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    min-height: 2.8em;
    font-weight: 500;
}

/* Improved hover states for better UX */
.meilisearch-autocomplete-category:hover .meilisearch-autocomplete-category-name,
.meilisearch-autocomplete-suggestion:hover .meilisearch-autocomplete-suggestion-query {
    color: #8BC34A;
}

/* Loading animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.meilisearch-autocomplete-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* No Results Styling */
.meilisearch-autocomplete-no-results {
    padding: 15px 0;
    text-align: left;
    color: #666;
    font-style: italic;
}

.meilisearch-autocomplete-no-results p {
    margin: 0;
    font-size: 14px;
}

.meilisearch-autocomplete-empty .meilisearch-autocomplete-section-title {
    margin-bottom: 10px;
}

/* Responsive adjustments for templates */
@media (max-width: 767px) {
    .meilisearch-autocomplete-product-name {
        font-size: 0.85em;
        -webkit-line-clamp: 3;
        min-height: 3.6em;
    }
    
    .meilisearch-autocomplete-product-price {
        font-size: 1em;
    }
    
    .meilisearch-autocomplete-product-image {
        height: 80px;
    }
}

/* FAQ autocomplete styles */
.meilisearch-autocomplete-section-faqs {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.meilisearch-autocomplete-faq {
    display: block;
    padding: 3px 0;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}

.meilisearch-autocomplete-faq:last-child {
    border-bottom: none;
}

.meilisearch-autocomplete-faq:hover {
    background-color: #f9f9f9;
}

.meilisearch-autocomplete-faq-question {
    font-weight: normal;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.3;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meilisearch-autocomplete-faq-category {
    font-size: 0.75em;
    color: #7cd133;
    margin-bottom: 0;
    text-align: left;
}

.meilisearch-autocomplete-faq mark {
    background-color: #fff3cd;
    padding: 1px 2px;
    font-weight: 600;
}

/* === merca: widen autocomplete dropdown so 33/50/17 layout has room === */
.meilisearch-autocomplete {
    min-width: 900px;
    max-width: 95vw;
    /* anchor at right edge of search input so it sweeps left across the page */
    left: auto !important;
    right: 0 !important;
}
@media (max-width: 960px) {
    .meilisearch-autocomplete {
        min-width: 100%;
        left: 0 !important;
        right: 0 !important;
    }
}
