/* Search Autocomplete Styles */

.search-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 450px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 5px;
    box-sizing: border-box;
}

/* Make dropdown wider on desktop screens but stay within viewport */
@media screen and (min-width: 992px) {
    .header-search .search-autocomplete-dropdown {
        left: 0;
        right: auto;
        min-width: 500px;
        max-width: 600px;
        width: max-content;
    }
}

@media screen and (min-width: 1200px) {
    .header-search .search-autocomplete-dropdown {
        min-width: 600px;
        max-width: 700px;
    }
}

.search-autocomplete-dropdown.show {
    display: block;
}

.search-autocomplete-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: #333;
}

.search-autocomplete-item:last-child {
    border-bottom: none;
}

.search-autocomplete-item:hover {
    background-color: #fdf9ed;
}

.search-autocomplete-item-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Larger images on desktop */
@media screen and (min-width: 992px) {
    .search-autocomplete-item-image {
        width: 60px;
        height: 60px;
        margin-right: 15px;
    }
}

.search-autocomplete-item-info {
    flex: 1;
    min-width: 0;
}

/* Meta info (brand • category) - small, gray */
.search-autocomplete-item-meta {
    font-size: 11px;
    color: #999;
    margin-bottom: 3px;
    letter-spacing: 0.3px;
}

/* Legacy - for backward compatibility */
.search-autocomplete-item-category {
    font-size: 11px;
    color: #999;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-autocomplete-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-autocomplete-item-english {
    font-size: 12px;
    color: #777;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-autocomplete-item-price {
    font-size: 13px;
    color: #ff6c00;
    font-weight: 600;
}

.search-autocomplete-loading {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.search-autocomplete-no-results {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.search-autocomplete-view-all {
    display: block;
    padding: 12px;
    text-align: center;
    background: #f9f9f9;
    color: #ff6c00;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
    transition: background-color 0.2s ease;
}

.search-autocomplete-view-all:hover {
    background-color: #fdf9ed;
    color: #ff6c00;
}

/* Container positioning for header search */
.header-search-wrapper {
    position: relative;
    overflow: visible;
}

/* Ensure dropdown stays within viewport on smaller screens */
@media screen and (max-width: 991px) {
    .header-search .search-autocomplete-dropdown {
        left: 0 !important;
        right: 0 !important;
        max-width: 100%;
    }
}

/* Prevent dropdown from extending beyond header container */
.header-search {
    position: relative;
}

.header-middle .container {
    position: relative;
}

/* On pages with sidebar, ensure dropdown doesn't overflow */
@media screen and (min-width: 992px) {
    .sidebar-shop ~ * .search-autocomplete-dropdown,
    body:has(.sidebar-shop) .search-autocomplete-dropdown {
        max-width: 90vw;
    }
}

/* Mobile Search Autocomplete */
.mobile-search {
    position: relative;
}

.mobile-search .search-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 16px;
    right: 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 5px;
}

/* Search Keyword Highlight */
mark.search-highlight {
    background-color: #fff3e0;
    color: #ff6c00;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    border: none;
}

/* Match context snippet (shows why product matched) */
.search-autocomplete-item-context {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
    margin-bottom: 3px;
    line-height: 1.4;
    font-style: italic;
}

.search-autocomplete-item-context mark.search-highlight {
    font-style: normal;
}

