/*
 * MMLiveSearch Modern UI
 * Version: 3.0.1
 * Author: mazein (redesigned)
 */

/* ========================================
   Основной контейнер результатов
   ======================================== */
.mmlivesearch__result {
    position: absolute;
    top: 100%;
    width: 100%;
    max-height: 70vh;
    z-index: 510;
    border-radius: 8px;
    overflow: hidden;
    left: 0;
    margin-top: 8px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #2c3e50;
    animation: mmls-fadeIn 0.2s ease-out;
}

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

/* ========================================
   Прокрутка результатов
   ======================================== */
.mmlivesearch__result {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Кастомный скроллбар для WebKit браузеров */
.mmlivesearch__result::-webkit-scrollbar {
    width: 8px;
}

.mmlivesearch__result::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 0 8px 8px 0;
}

.mmlivesearch__result::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.mmlivesearch__result::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ========================================
   Заголовок / Title
   ======================================== */
.mmlivesearch__result .title {
    padding: 12px 16px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 1px solid #e9ecef;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
}

.mmlivesearch__result .title strong {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   Элементы результата
   ======================================== */
.mmlivesearch__result span.search_sel {
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    position: relative;
    background: #fff;
    text-align: left;
    transition: all 0.15s ease;
    border-bottom: 1px solid #f1f3f5;
}

.mmlivesearch__result span.search_sel:last-child {
    border-bottom: none;
}

.mmlivesearch__result span.search_sel:hover {
    background: linear-gradient(to right, #f8f9fa 0%, #ffffff 100%);
    padding-left: 20px;
}

.mmlivesearch__result span.search_sel.selected {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.mmlivesearch__result span.search_sel.selected .mmls__price {
    background: #e3f2fd;
}

/* ========================================
   Иконки
   ======================================== */
.mmlivesearch__result span.search_sel .im {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    overflow: hidden;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.mmlivesearch__result span.search_sel .im img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Маленькие иконки для истории и категорий */
.mmlivesearch__result span.search_sel.history .im,
.mmlivesearch__result span.search_sel.tosearch .im,
.mmlivesearch__result span.search_sel.tocategory .im {
    width: 32px;
    height: 32px;
    background: #f8f9fa;
}

.mmlivesearch__result span.search_sel.history .im img,
.mmlivesearch__result span.search_sel.tosearch .im img,
.mmlivesearch__result span.search_sel.tocategory .im img {
    opacity: 0.6;
}

/* ========================================
   Текст результата
   ======================================== */
.mmlivesearch__result span.search_sel .w {
    display: table-cell;
    vertical-align: middle;
    text-align: left;
}

.mmlivesearch__result span.search_sel .w > div:first-child,
.mmlivesearch__result span.search_sel .w > a {
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    line-height: 1.4;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

/* Подсветка найденных слов */
.mmlivesearch__result span.search_sel .w strong {
    font-weight: 600;
    color: #2196f3;
}

/* Дополнительная информация (категория, артикул) */
.mmlivesearch__result span.search_sel .w .mmls-meta {
    font-size: 12px;
    color: #868e96;
    margin-top: 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mmlivesearch__result span.search_sel .w .mmls-meta span {
    display: inline-flex;
    align-items: center;
}

.mmlivesearch__result span.search_sel .w .mmls-meta span:not(:last-child)::after {
    content: "•";
    margin-left: 8px;
    color: #cbd5e0;
}

/* ========================================
   Цены
   ======================================== */
.mmlivesearch__result .mmls__price {
    position: absolute;
    font-weight: 600;
    font-size: 15px;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    color: #2c3e50;
    white-space: nowrap;
}

.mmlivesearch__result span.search_sel:hover .mmls__price {
    background: transparent;
}

/* Старая цена */
.mmlivesearch__result .mmls__price .price-old {
    text-decoration: line-through;
    color: #868e96;
    font-size: 12px;
    font-weight: 400;
    display: block;
    margin-bottom: 2px;
}

/* Цена со скидкой */
.mmlivesearch__result .mmls__price .price-new {
    color: #e74c3c;
    font-weight: 700;
}

/* ========================================
   Кнопки действий
   ======================================== */
.mmlivesearch__result span.all_products {
    width: 100%;
    padding: 14px 16px;
    text-align: center !important;
    background: #f8f9fa;
    color: #2196f3;
    font-weight: 600;
    font-size: 14px;
    border-top: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.15s ease;
    display: block;
}

.mmlivesearch__result span.all_products:hover {
    background: #e3f2fd;
    color: #1976d2;
}

/* Нет результатов */
.mmlivesearch__result span.no_find {
    width: 100%;
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    text-align: center;
    color: #868e96;
    font-size: 14px;
}

.mmlivesearch__result span.no_find::before {
    content: "🔍";
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* ========================================
   Кнопка очистки истории
   ======================================== */
.mmlivesearch__result .clearMMLiveSearch {
    color: #868e96;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 4px;
    transition: all 0.15s ease;
    border: 1px solid #e9ecef;
    background: #fff;
}

.mmlivesearch__result .clearMMLiveSearch:hover {
    background: #f8f9fa;
    color: #495057;
    border-color: #cbd5e0;
    text-decoration: none;
}

/* ========================================
   Индикатор загрузки
   ======================================== */
.mmlsloader {
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196f3;
    border-radius: 50%;
    display: block;
    margin: 15px auto;
    position: absolute;
    left: 50%;
    animation: mmlsanimloader 0.8s linear infinite;
}

@keyframes mmlsanimloader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Типы элементов (категории, товары, поиск)
   ======================================== */
/* История */
.mmlivesearch__result span.search_sel.history {
    padding: 10px 16px;
}

.mmlivesearch__result span.search_sel.history .w > div:first-child {
    font-size: 13px;
    color: #495057;
}

/* Товары */
.mmlivesearch__result span.search_sel.toproduct {
    padding: 12px 16px;
}

/* Поиск */
.mmlivesearch__result span.search_sel.tosearch {
    padding: 10px 16px;
}

/* Категории */
.mmlivesearch__result span.search_sel.tocategory .w > div:first-child {
    color: #6c757d;
}

/* ========================================
   Адаптивность для мобильных устройств
   ======================================== */
@media (max-width: 768px) {
    .mmlivesearch__result {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100% !important;
        max-height: 85vh;
        margin-top: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .mmlivesearch__result span.search_sel {
        padding: 14px 16px;
        min-height: 60px;
    }

    .mmlivesearch__result span.search_sel .im {
        width: 56px;
        height: 56px;
    }

    .mmlivesearch__result span.search_sel .w {
        padding-right: 80px;
    }

    .mmlivesearch__result .mmls__price {
        font-size: 14px;
        right: 12px;
    }

    /* Добавляем индикатор для свайпа вниз */
    .mmlivesearch__result::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        background: #cbd5e0;
        border-radius: 2px;
        margin: 8px auto 4px;
        position: sticky;
        top: 0;
        z-index: 2;
    }
}


/* ========================================
   Дополнительные улучшения
   ======================================== */
/* Анимация при появлении элементов */
.mmlivesearch__result span.search_sel {
    animation: mmls-slideIn 0.15s ease-out backwards;
}

.mmlivesearch__result span.search_sel:nth-child(1) { animation-delay: 0.02s; }
.mmlivesearch__result span.search_sel:nth-child(2) { animation-delay: 0.04s; }
.mmlivesearch__result span.search_sel:nth-child(3) { animation-delay: 0.06s; }
.mmlivesearch__result span.search_sel:nth-child(4) { animation-delay: 0.08s; }
.mmlivesearch__result span.search_sel:nth-child(5) { animation-delay: 0.10s; }

@keyframes mmls-slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Фокус для accessibility */
.mmlivesearch__result span.search_sel:focus {
    outline: 2px solid #2196f3;
    outline-offset: -2px;
}

/* Улучшенная типографика */
.mmlivesearch__result {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/*mmlivesearch*/