/* ========== search.css - Стили для поиска ========== */

/* ===== РАЗДЕЛЕНИЕ ПК И МОБИЛЬНОЙ ВЕРСИИ ===== */
@media (min-width: 768px) {
    .mobile-search-row { display: none !important; }
    .desktop-search { display: flex !important; }
    .search-overlay { display: none !important; }
}

@media (max-width: 767px) {
    .desktop-search { display: none !important; }
    .mobile-search-row { display: block !important; }
    .search-overlay { display: block !important; }
}


/* Поисковый попап (ПК) */
.search-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.search-popup::-webkit-scrollbar { width: 4px; }
.search-popup::-webkit-scrollbar-track { background: #f0f0f0; border-radius: 4px; }
.search-popup::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.search-popup.active { 
    opacity: 1; 
    visibility: visible; 
    transform: translateY(0); 
}

/* Оверлей */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.search-overlay.active { 
    opacity: 1; 
    visibility: visible; 
}

/* Секции попапа */
.search-popup-section { 
    padding: 16px; 
    border-bottom: 1px solid #f0f0f0; 
}

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

.search-popup-title {
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== ЭЛЕМЕНТЫ ПОИСКА ===== */
.search-popup-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.15s;
    font-family: inherit;
    text-decoration: none;
}

.search-popup-item:hover { 
    background: #f8f8f8; 
}

.search-popup-item .item-text {
    flex: 1;
    text-align: left;
}

/* ===== ИКОНКИ ПОДСКАЗОК ===== */

/* Бренд */
.suggestion-brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0f0f5;
    position: relative;
}

.suggestion-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
    display: block;
}

.suggestion-brand-logo .brand-placeholder {
    display: none;
    font-size: 16px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    line-height: 1;
    user-select: none;
}

.suggestion-brand-logo.no-logo {
    background: #f0f0f5;
}

.suggestion-brand-logo.no-logo img {
    display: none !important;
}

.suggestion-brand-logo.no-logo .brand-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Категория */
.suggestion-category-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #d4f5ed;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.suggestion-category-icon svg {
    width: 20px;
    height: 20px;
    stroke: #16a34a;
    display: block;
}

/* Товар */
.suggestion-product-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #fef3e2;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.suggestion-product-icon svg {
    width: 20px;
    height: 20px;
    stroke: #e67e22;
    display: block;
}

/* Метки типов */
.suggestion-type {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
    background: #f0f0f0;
    color: #888;
    margin-left: auto;
    user-select: none;
}

.suggestion-type.brand { 
    background: #e8f0fe; 
    color: #2563eb; 
}

.suggestion-type.category { 
    background: #d4f5ed; 
    color: #16a34a; 
}

.suggestion-type.product { 
    background: #fef3e2; 
    color: #e67e22; 
}

/* ===== МОБИЛЬНЫЙ ПОИСК ===== */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-search-overlay.active { 
    opacity: 1; 
    visibility: visible; 
    transform: translateY(0); 
}

.mobile-search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-search-back {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.mobile-search-back:hover {
    background: #f5f5f5;
}

.mobile-search-back svg {
    display: block;
}

.mobile-search-input-wrap { 
    flex: 1; 
}

.mobile-search-input {
    width: 100%;
    padding: 12px 0;
    font-size: 16px;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    color: #333;
}

.mobile-search-input::placeholder {
    color: #999;
}

.mobile-search-clear {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #999;
    font-size: 20px;
    display: none;
    border-radius: 50%;
    transition: background 0.2s;
}

.mobile-search-clear:hover {
    background: #f5f5f5;
}

.mobile-search-clear.visible { 
    display: block; 
}

.mobile-search-body { 
    padding: 16px; 
    height: calc(100% - 60px); 
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.search-show-more {
    background: none;
    border: none;
    color: #dd1847;
    font-size: 14px;
    padding: 12px;
    width: 100%;
    cursor: pointer;
    margin-top: 8px;
    font-family: inherit;
    transition: opacity 0.15s;
    border-radius: 8px;
}

.search-show-more:hover { 
    opacity: 0.8;
    background: #fdf2f5;
}

/* ========== СТРАНИЦА РЕЗУЛЬТАТОВ ПОИСКА ========== */
.search-page { 
    max-width: 1400px; 
    margin: 120px auto 60px; 
    padding: 0 20px; 
}

.search-header { 
    margin-bottom: 24px; 
}

.search-header h1 { 
    font-size: 28px; 
    font-weight: 700; 
    margin-bottom: 8px; 
    color: #333;
}

.search-header h1 span { 
    color: #dd1847; 
}

.search-stats { 
    font-size: 14px; 
    color: #666; 
    margin-bottom: 24px; 
}

.search-section { 
    margin-bottom: 24px; 
}

.search-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-query-bar { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap; 
}

.search-query-tag {
    padding: 8px 16px;
    background: #f5f5f5;
    border-radius: 30px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
    color: #555;
}

.search-query-tag:hover { 
    background: #fdf2f5; 
    color: #dd1847; 
    transform: translateY(-1px); 
}

.search-query-tag.popular { 
    background: #fff; 
    border: 1px solid #e5e5e5; 
}

.did-you-mean {
    background: #fef9e6;
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 24px;
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #666;
}

.did-you-mean.active {
    display: flex;
}

.did-you-mean a { 
    color: #dd1847; 
    font-weight: 600; 
    text-decoration: none; 
}

.did-you-mean a:hover {
    text-decoration: underline;
}

/* Сетка товаров */
.products-grid { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 20px 16px; 
    margin-top: 20px; 
}

.product-search-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
    border: 1px solid #f0f0f0;
}

.product-search-card:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 12px 24px rgba(0,0,0,0.08); 
    border-color: #e0e0e0;
}

.product-search-image { 
    aspect-ratio: 1; 
    background: #f8f8f8; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.product-search-image img { 
    max-width: 100%; 
    max-height: 100%; 
    object-fit: contain;
    transition: transform 0.3s;
}

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

.product-search-info { 
    padding: 12px; 
}

.product-search-brand { 
    font-size: 11px; 
    color: #999; 
    text-transform: uppercase; 
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.product-search-name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #333;
}

.product-search-price { 
    font-size: 18px; 
    font-weight: 700; 
    color: #dd1847; 
}

.product-search-price-old { 
    font-size: 13px; 
    color: #bbb; 
    text-decoration: line-through; 
    margin-left: 8px; 
    font-weight: 400; 
}

/* Загрузчик */
.search-loader { 
    text-align: center; 
    padding: 40px; 
    display: none; 
}

.search-loader.active { 
    display: block; 
}

.search-loader svg { 
    animation: spin 1s linear infinite; 
}

@keyframes spin { 
    from { transform: rotate(0deg); } 
    to { transform: rotate(360deg); } 
}

/* Кнопка "Загрузить ещё" */
.search-load-more { 
    text-align: center; 
    padding: 40px; 
}

.load-more-btn {
    padding: 12px 32px;
    background: #f5f5f5;
    border: none;
    border-radius: 40px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    color: #555;
}

.load-more-btn:hover { 
    background: #dd1847; 
    color: white; 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(221, 24, 71, 0.3);
}

/* Пустой результат */
.search-empty { 
    text-align: center; 
    padding: 60px 20px; 
    color: #999; 
}

.search-empty svg { 
    width: 64px; 
    height: 64px; 
    margin-bottom: 16px; 
    opacity: 0.5; 
}

.search-empty h3 {
    font-size: 18px;
    color: #666;
    margin-bottom: 8px;
}

.search-empty p {
    font-size: 14px;
    color: #999;
}

/* Подсветка совпадений */
.search-highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 1200px) {
    .products-grid { 
        grid-template-columns: repeat(4, 1fr); 
    }
}

@media (max-width: 992px) {
    .products-grid { 
        grid-template-columns: repeat(3, 1fr); 
    }
    
    .search-page { 
        margin-top: 110px; 
    }
}

@media (max-width: 768px) {
    .search-page { 
        margin-top: 100px; 
        padding: 0 12px; 
    }
    
    .products-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 12px; 
    }
    
    .product-search-info { 
        padding: 8px; 
    }
    
    .product-search-name { 
        font-size: 12px; 
    }
    
    .product-search-price { 
        font-size: 15px; 
    }
    
    .search-header h1 { 
        font-size: 22px; 
    }
    
    .search-popup {
        border-radius: 12px;
        max-height: 400px;
    }
    
    .suggestion-brand-logo {
        width: 36px;
        height: 36px;
    }
    
    .suggestion-category-icon,
    .suggestion-product-icon {
        width: 36px;
        height: 36px;
    }
    
    .suggestion-category-icon svg,
    .suggestion-product-icon svg {
        width: 18px;
        height: 18px;
    }
}

@media (min-width: 1024px) {
    .products-grid { 
        grid-template-columns: repeat(5, 1fr); 
    }
}

@media (max-width: 480px) {
    .product-search-price { 
        font-size: 14px; 
    }
    
    .product-search-name { 
        font-size: 12px; 
    }
    
    .product-search-brand { 
        font-size: 10px; 
    }
    
    .search-popup-item {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .search-popup-section {
        padding: 12px;
    }
}

@media (max-width: 360px) {
    .product-search-price { 
        font-size: 13px; 
    }
    
    .product-search-name { 
        font-size: 11px; 
    }
    
    .product-search-brand { 
        font-size: 9px; 
    }
}

/* Анимации для появления элементов */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-popup-item {
    opacity: 0;
    animation: fadeInUp 0.3s ease forwards;
}

.search-popup-item:nth-child(1) { animation-delay: 0s; }
.search-popup-item:nth-child(2) { animation-delay: 0.05s; }
.search-popup-item:nth-child(3) { animation-delay: 0.1s; }
.search-popup-item:nth-child(4) { animation-delay: 0.15s; }
.search-popup-item:nth-child(5) { animation-delay: 0.2s; }
.search-popup-item:nth-child(6) { animation-delay: 0.25s; }
.search-popup-item:nth-child(7) { animation-delay: 0.3s; }
.search-popup-item:nth-child(8) { animation-delay: 0.35s; }

/* Стили для активного элемента (навигация с клавиатуры) */
.search-popup-item:focus-visible {
    outline: 2px solid #dd1847;
    outline-offset: -2px;
    background: #fdf2f5;
}
.header-search { flex: 1; position: relative; }
.header-search svg { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); stroke: #999; width: 20px; height: 20px; }
.header-search input { width: 100%; padding: 16px 16px 16px 46px; border: none; border-radius: 20px; font-size: 15px; background: #f5f5f5; outline: none; }
.header-search input:focus { background: #fff; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-icon-btn { width: 50px; height: 50px; border: none; background: #f5f5f5; border-radius: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); transition: all 0.15s; position: relative; flex-shrink: 0; }
.header-icon-btn:hover { background: #fdf2f5; color: var(--red); }
.header-icon-btn svg { width: 22px; height: 22px; }
.mobile-search-row { display: none; padding: 0 0 8px; }
.mobile-search-row .header-search input { padding: 14px 14px 14px 42px; font-size: 16px; border-radius: 20px; background: #f5f5f5; border: none; }
