/* Стили для поисковых подсказок */

/* Основные стили для контейнера подсказок */
.search-suggestions {
    position: fixed;
    top: auto;
    left: auto;
    right: auto;
    background: var(--white);
    border: 1px solid rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.3);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: none;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 0.5rem;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Скроллбар для подсказок */
.search-suggestions::-webkit-scrollbar {
    width: 6px;
}

.search-suggestions::-webkit-scrollbar-track {
    background: rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.1);
    border-radius: 3px;
}

.search-suggestions::-webkit-scrollbar-thumb {
    background: rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.4);
    border-radius: 3px;
}

.search-suggestions::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.6);
}

/* Стили для отдельной подсказки */
.search-suggestion {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.1);
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

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

.search-suggestion:hover,
.search-suggestion.selected {
    background: rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.08);
}


/* Изображение товара */
.suggestion-image {
    width: 40px;
    height: 40px;
    border-radius: 0.3rem;
    overflow: hidden;
    margin-right: 0.6rem;
    background: rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.suggestion-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.search-suggestion:hover .suggestion-image img {
    transform: scale(1.05);
}

/* Контент подсказки */
.suggestion-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.suggestion-title {
    font-weight: 500;
    color: var(--element-color-2, #21212D);
    margin-bottom: 0.2rem;
    line-height: 1.3;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Подсветка найденных слов */
.suggestion-title mark {
    background: linear-gradient(135deg, rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.3), rgba(var(--element-color-1-rgb, 33, 150, 243), 0.2));
    color: var(--element-color-2, #21212D);
    padding: 0.1em 0.2em;
    border-radius: 0.2em;
    font-weight: 700;
}

.suggestion-category {
    font-size: 0.875rem;
    color: var(--element-color-2, #21212D);
    opacity: 0.6;
    margin-bottom: 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Мета-информация */
.suggestion-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.875rem;
    overflow: hidden;
}

.suggestion-price {
    font-weight: 500;
    color: var(--border-heading-color);
    flex-shrink: 0;
}

.suggestion-stock {
    padding: 0.1em 0.4em;
    border-radius: 0.2rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.suggestion-stock.in-stock {
    background: rgba(34, 197, 94, 0.15);
    color: rgb(34, 197, 94);
}

.suggestion-stock.out-of-stock {
    background: rgba(239, 68, 68, 0.15);
    color: rgb(239, 68, 68);
}

/* Показать все результаты */
.search-suggestion.show-all {
    background: linear-gradient(135deg, rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.1), rgba(var(--element-color-1-rgb, 33, 150, 243), 0.05));
    border-top: 1px solid rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.2);
    border-bottom: none;
    justify-content: center;
    font-weight: 600;
    color: var(--element-color-1);
}

.search-suggestion.show-all:hover {
    background: linear-gradient(135deg, rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.2), rgba(var(--element-color-1-rgb, 33, 150, 243), 0.1));
    transform: none;
}

.show-all-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.show-all-icon {
    width: 1rem;
    height: 1rem;
}

/* Мобильные подсказки */
.search-suggestions.mobile-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-top: 0;
    max-height: 300px;
}

.mobile-suggestions .search-suggestion {
    border-bottom: 1px solid #e5e7eb;
    color: var(--main-text-color);
}

.mobile-suggestions .search-suggestion:hover,
.mobile-suggestions .search-suggestion.selected {
    background: #f3f4f6;
}

.mobile-suggestions .suggestion-title {
    color: var(--primary-blue);
}

.mobile-suggestions .suggestion-title mark {
    background: var(--primary-peach);
    color: var(--primary-blue);
}

.mobile-suggestions .suggestion-category {
    color: #6b7280;
}

.mobile-suggestions .suggestion-price {
    color: var(--border-heading-color);
}

.mobile-suggestions .search-suggestion.show-all {
    background: #f9fafb;
    color: var(--primary-blue);
    border-top: 1px solid #e5e7eb;
}

.mobile-suggestions .search-suggestion.show-all:hover {
    background: #f3f4f6;
}

/* Позиционирование контейнеров */
.search-container {
    position: relative;
}


/* Адаптивные стили */
@media (max-width: 768px) {
    .search-suggestions:not(.mobile-suggestions) {
        margin-top: 0.25rem;
        border-radius: 0.5rem;
        max-height: 300px;
    }
    
    .search-suggestion {
        padding: 0.5rem 0.75rem;
    }
    
    .suggestion-image {
        width: 40px;
        height: 40px;
        margin-right: 0.5rem;
    }
    
    .suggestion-title {
        font-size: 0.875rem;
    }
    
    .suggestion-category {
        font-size: 0.875rem;
    }
    
    .suggestion-meta {
        font-size: 0.875rem;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .search-suggestions:not(.mobile-suggestions) {
        left: -0.5rem;
        right: -0.5rem;
    }
    
    .search-suggestion {
        padding: 0.4rem 0.5rem;
    }
    
    .suggestion-image {
        width: 35px;
        height: 35px;
        margin-right: 0.4rem;
    }
    
    .suggestion-title {
        font-size: 0.8125rem;
    }
    
    .suggestion-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* Анимации загрузки */
.search-suggestions.loading::after {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--border-heading-color) 50%, 
        transparent 100%
    );
    animation: loading 1s infinite;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Состояния поля ввода при активном поиске */
.search-input:focus,
.mobile-search-input:focus {
    outline: none;
    border-color: rgba(var(--element-color-1-rgb, 33, 150, 243), 0.5);
    box-shadow: 0 0 0 3px rgba(var(--element-color-1-rgb, 33, 150, 243), 0.1);
}

/* Улучшенная доступность */
.search-suggestion[aria-selected="true"] {
    background: linear-gradient(135deg, rgba(var(--border-heading-color-rgb, 255, 207, 157), 0.15), rgba(var(--element-color-1-rgb, 33, 150, 243), 0.08));
}

/* Стили для пустого состояния */
.search-suggestions-empty {
    padding: 1rem;
    text-align: center;
    color: var(--element-color-2);
    opacity: 0.7;
    font-style: italic;
}

/* Hover эффекты для кнопок поиска */
.search-button:hover,
.mobile-search-btn:hover {
    background: var(--element-color-1);
    color: var(--white);
}

/* Темная тема (если поддерживается) */
@media (prefers-color-scheme: dark) {
    .search-suggestions {
        background: rgba(33, 41, 60, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .search-suggestion {
        border-bottom-color: rgba(255, 255, 255, 0.05);
    }
    
    .search-suggestion:hover,
    .search-suggestion.selected {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .suggestion-title {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .suggestion-category {
        color: rgba(255, 255, 255, 0.6);
    }
}