/* catalog/view/theme/YOUR_THEME/stylesheet/livesearch.css */

/* ===== Обёртка ===== */
.livesearch-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    font-family: inherit;
    z-index: 9999;
}

/* ===== Форма ===== */
.livesearch-form {
    width: 100%;
}

.livesearch-input-wrap {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.livesearch-input-wrap:focus-within {
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.12);
}

.livesearch-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 14px;
    font-size: 16px;
    color: #333;
    background: transparent;
    min-width: 0;
}

.livesearch-input::placeholder {
    color: #aaa;
}

.livesearch-clear {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #aaa;
    padding: 0 8px;
    line-height: 1;
    display: none;
    transition: color 0.2s;
}

.livesearch-clear:hover { color: #e53935; }

.livesearch-submit {
    background: #e53935;
    border: none;
    cursor: pointer;
    padding: 10px 14px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    min-width: 44px;
}

.livesearch-submit:hover { background: #c62828; }

/* ===== Дропдаун ===== */
.livesearch-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
    display: none;
    z-index: 9999;
    max-height: 80vh;
    overflow-y: auto;
}

.livesearch-dropdown.active {
    display: block;
    animation: lsFadeIn 0.18s ease;
}

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

/* ===== Секции ===== */
.ls-section {
    padding: 0;
}

.ls-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #999;
    padding: 12px 16px 6px;
    border-top: 1px solid #f0f0f0;
}

.ls-section:first-child .ls-section-title {
    border-top: none;
}

/* ===== Подсказки ===== */
.ls-suggestions-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.ls-suggestions-list li {
    padding: 0;
}

.ls-suggestions-list li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}

.ls-suggestions-list li a:hover {
    background: #fef0f0;
    color: #e53935;
}

.ls-suggestions-list li a .ls-suggest-icon {
    color: #bbb;
    flex-shrink: 0;
}

.ls-suggestions-list li a mark {
    background: none;
    color: #e53935;
    font-weight: 700;
    padding: 0;
}

/* ===== Категории ===== */
.ls-cat-list {
    list-style: none;
    margin: 0;
    padding: 4px 0 8px;
}

.ls-cat-list li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}

.ls-cat-list li a:hover {
    background: #fef0f0;
}

.ls-cat-info {
    display: flex;
    flex-direction: column;
}

.ls-cat-name {
    font-weight: 600;
    color: #222;
    font-size: 14px;
}

.ls-cat-path {
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}

.ls-cat-count {
    font-size: 12px;
    color: #aaa;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Товары ===== */
.ls-products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #f0f0f0;
    margin: 0;
}

.ls-product-card {
    background: #fff;
    padding: 12px 10px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background 0.15s;
    position: relative;
}

.ls-product-card:hover {
    background: #fef9f9;
}

.ls-product-img-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.ls-product-img-wrap img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 6px;
}

/* Бейдж скидки */
.ls-discount-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: #e53935;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1.4;
}

.ls-product-name {
    font-size: 12px;
    color: #333;
    text-align: center;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
    width: 100%;
}

.ls-product-prices {
    text-align: center;
    width: 100%;
}

.ls-product-old-price {
    font-size: 11px;
    color: #bbb;
    text-decoration: line-through;
    display: block;
    line-height: 1.2;
}

.ls-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #e53935;
    display: block;
    line-height: 1.3;
}

.ls-product-price.no-special {
    color: #222;
}

/* ===== "Показать все" ===== */
.ls-show-all {
    border-top: 1px solid #f0f0f0;
    text-align: center;
    padding: 12px;
}

.ls-show-all a {
    color: #e53935;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s;
}

.ls-show-all a:hover {
    color: #c62828;
    text-decoration: underline;
}

/* ===== Пусто ===== */
.ls-empty {
    text-align: center;
    padding: 32px 16px;
    color: #999;
}

.ls-empty-icon { font-size: 32px; margin-bottom: 8px; }
.ls-empty-text { font-size: 15px; font-weight: 600; color: #555; }
.ls-empty-sub  { font-size: 13px; margin-top: 4px; }

/* ===== Лоадер ===== */
.ls-loader {
    text-align: center;
    padding: 24px;
}

.ls-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #f0f0f0;
    border-top-color: #e53935;
    border-radius: 50%;
    animation: lsSpin 0.7s linear infinite;
}

@keyframes lsSpin {
    to { transform: rotate(360deg); }
}

/* ===== Скроллбар дропдауна ===== */
.livesearch-dropdown::-webkit-scrollbar {
    width: 5px;
}
.livesearch-dropdown::-webkit-scrollbar-track { background: #f5f5f5; }
.livesearch-dropdown::-webkit-scrollbar-thumb { 
    background: #ddd; 
    border-radius: 3px; 
}

/* ======================== */
/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
/* ======================== */

/* Планшеты и большие телефоны (до 768px) */
@media (max-width: 768px) {
    .livesearch-wrapper {
        max-width: 100%;
    }
    
    .livesearch-input {
        font-size: 16px; /* чтобы не срабатывал зум на iOS */
        padding: 12px 14px;
    }
    
    .livesearch-submit {
        padding: 12px 14px;
    }
    
    .livesearch-dropdown {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 70vh;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }
    
    .ls-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ls-product-img-wrap,
    .ls-product-img-wrap img {
        width: 100px;
        height: 100px;
    }
    
    .ls-product-card {
        padding: 10px 8px;
    }
    
    .ls-product-name {
        font-size: 13px;
    }
    
    .ls-suggestions-list li a {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .ls-cat-list li a {
        padding: 11px 16px;
    }
}

/* Маленькие телефоны (до 480px) */
@media (max-width: 480px) {
    .livesearch-input {
        font-size: 14px;
        padding: 10px 10px;
    }
    
    .livesearch-submit {
        padding: 10px 10px;
        min-width: 40px;
    }
    
    .livesearch-dropdown {
        max-height: 60vh;
    }
    
    .ls-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1px;
    }
    
    .ls-product-img-wrap,
    .ls-product-img-wrap img {
        width: 70px;
        height: 70px;
    }
    
    .ls-product-card {
        padding: 8px 6px;
    }
    
    .ls-product-name {
        font-size: 11px;
        -webkit-line-clamp: 2;
    }
    
    .ls-product-price {
        font-size: 12px;
    }
    
    .ls-product-old-price {
        font-size: 10px;
    }
    
    .ls-discount-badge {
        font-size: 9px;
        padding: 1px 4px;
        top: -3px;
        left: -3px;
    }
    
    .ls-section-title {
        font-size: 10px;
        padding: 10px 12px 4px;
    }
    
    .ls-suggestions-list li a {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .ls-cat-list li a {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .ls-show-all {
        padding: 10px;
    }
    
    .ls-show-all a {
        font-size: 13px;
    }
    
    .ls-empty {
        padding: 24px 12px;
    }
}

/* Очень маленькие экраны (до 360px) */
@media (max-width: 360px) {
    .ls-products-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .ls-product-img-wrap,
    .ls-product-img-wrap img {
        width: 60px;
        height: 60px;
    }
    
    .ls-product-name {
        font-size: 10px;
    }
    
    .ls-product-price {
        font-size: 11px;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-height: 500px) and (orientation: landscape) {
    .livesearch-dropdown {
        max-height: 50vh;
    }
}