/* ==========================================
   ПОИСК — адаптировано под темы
========================================== */

/* ==========================================
   ДЕСКТОПНЫЙ ПОИСК
========================================== */

.header-search {
    display: flex;
    align-items: center;
    position: relative;
    margin-left: 10px;
}

.search-toggle {
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: 0.3s;
}

.search-toggle:hover {
    color: var(--accent);
}

.search-toggle img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
    transition: 0.3s;
}

[data-theme="cobalt"] .search-toggle img {
    filter: brightness(0) invert(0.9) sepia(0.5) hue-rotate(180deg) saturate(2);
}

.search-toggle:hover img {
    filter: brightness(0) invert(0.8) sepia(1) hue-rotate(-20deg) saturate(3);
}

.search-box {
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: 0.35s;
}

.search-box.active {
    width: 320px;
    opacity: 1;
    margin-left: 12px;
}

.search-box input {
    width: 100%;
    padding: 12px 18px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    outline: none;
    font-size: 15px;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: 0.3s;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ==========================================
   РЕЗУЛЬТАТЫ ПОИСКА
========================================== */

.search-results {
    position: absolute;
    top: 55px;
    right: 0;
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    overflow: hidden;
    display: none;
    box-shadow: 0 10px 30px var(--shadow-color);
    z-index: 9999;
}

.search-results.show {
    display: block;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
    min-height: 82px;
    cursor: pointer;
    transition: 0.25s;
    border-bottom: 1px solid var(--border-light);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: var(--bg-secondary);
}

.search-image img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border-light);
}

.search-info {
    flex: 1;
    text-align: left;
}

.search-name {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: bold;
}

.search-category {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 5px;
}

.search-price {
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

/* ==========================================
   ДЕСКТОПНАЯ / МОБИЛЬНАЯ ВЕРСИЯ
========================================== */

.desktop-search {
    display: flex;
}

.mobile-search {
    display: none;
}

/* ==========================================
   АДАПТИВ (МОБИЛЬНЫЙ ПОИСК)
========================================== */

@media (max-width: 768px) {
    .header-search {
        flex: 1;
        margin: 0 10px;
    }

    .search-toggle {
        display: none;
    }

    .search-box {
        width: 100%;
        opacity: 1;
        overflow: visible;
    }

    .search-box.active {
        width: 100%;
        margin-left: 0;
    }

    .search-box input {
        width: 100%;
        height: 42px;
        padding: 0 16px;
        border: 1px solid var(--border-color);
        border-radius: 22px;
        outline: none;
        font-size: 15px;
        background: var(--bg-input);
        color: var(--text-primary);
    }

    .search-box input:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 4px var(--accent-light);
    }

    .search-box input::placeholder {
        color: var(--text-muted);
    }

    .search-results {
        width: 100%;
        right: auto;
        left: 0;
        top: 50px;
    }

    .desktop-search {
        display: none;
    }

    .mobile-search {
        display: block;
        position: static;
        flex: 1;
        width: 100%;
        margin: 0 10px;
        min-width: 0;
    }

    .mobile-search input {
        width: 100%;
        height: 42px;
        padding: 0 16px;
        border: 1px solid var(--border-color);
        border-radius: 22px;
        outline: none;
        font-size: 15px;
        background: var(--bg-input);
        color: var(--text-primary);
    }

    .mobile-search input:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 4px var(--accent-light);
    }

    .mobile-search input::placeholder {
        color: var(--text-muted);
    }

    /* ===== Поиск на весь экран (мобильный) ===== */
    .mobile-search .search-results {
        position: fixed;
        top: 90px;
        left: 10px;
        right: 10px;
        width: auto;
        max-height: 70vh;
        overflow-y: auto;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 18px;
        box-shadow: 0 15px 40px var(--shadow-color);
        z-index: 99999;
    }

    .mobile-search .search-item {
        padding: 14px 16px;
        min-height: 70px;
    }

    .mobile-search .search-image img {
        width: 56px;
        height: 56px;
    }

    .mobile-search .search-name {
        font-size: 15px;
    }

    .mobile-search .search-price {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .mobile-search .search-results {
        top: 80px;
        left: 8px;
        right: 8px;
        max-height: 60vh;
        border-radius: 14px;
    }

    .mobile-search .search-item {
        padding: 12px 14px;
        min-height: 60px;
        gap: 12px;
    }

    .mobile-search .search-image img {
        width: 48px;
        height: 48px;
        border-radius: 10px;
    }

    .mobile-search .search-name {
        font-size: 14px;
    }

    .mobile-search .search-price {
        font-size: 14px;
    }

    .mobile-search .search-category {
        font-size: 12px;
    }
}