/* Поиск по каталогу в шапке (views/layouts/header1.php, web/js/site-search.js) и страница /search */

.site-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}
.site-search-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}
/* Ширины поля по брейкпоинтам задают старые правила .header1-line2-inner-search input[type="text"] в app.css/media.css */
.header1-line2-inner-search .site-search input[type="text"].js-ss-input {
    padding-right: 44px;
    color: #0a3d3c;
    font-family: "Rubik Regular";
    transition: box-shadow .15s ease, background-color .15s ease;
}
.header1-line2-inner-search .site-search input[type="text"].js-ss-input:focus {
    background-color: #fff;
    box-shadow: 0 0 0 2px #0a6a69;
}
.site-search.is-open input[type="text"].js-ss-input {
    background-color: #fff;
}

.site-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: rgba(10, 106, 105, .1);
    color: #0a6a69;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.site-search-clear[hidden] {
    display: none;
}
.site-search-clear:hover {
    background: rgba(10, 106, 105, .18);
}

/* Загрузка: вместо лупы (фон поля, 17px в 20px от левого края) крутится кольцо — текст не перекрывает */
.site-search-spinner {
    position: absolute;
    left: 20px;
    top: 50%;
    width: 17px;
    height: 17px;
    margin-top: -8.5px;
    border-radius: 50%;
    border: 2px solid rgba(10, 106, 105, .2);
    border-top-color: #0a6a69;
    opacity: 0;
    pointer-events: none;
}
.site-search.is-loading .site-search-spinner {
    opacity: 1;
    animation: ss-spin .7s linear infinite;
}
.header1-line2-inner-search .site-search.is-loading input[type="text"].js-ss-input {
    background-image: none;
}
@keyframes ss-spin {
    to { transform: rotate(360deg); }
}

.site-search-cancel {
    display: none;
}

/* ---------- Панель подсказок ---------- */
.site-search-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 600px;
    max-width: calc(100vw - 32px);
    max-height: min(72vh, 640px);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 130;
    background: #fff;
    border-radius: 18px;
    border: 1px solid rgba(10, 106, 105, .08);
    box-shadow: 0 24px 60px -12px rgba(8, 60, 59, .28), 0 4px 14px rgba(8, 60, 59, .06);
    padding: 6px 0;
    color: #0a3d3c;
    font-family: "Rubik Regular", sans-serif;
    text-align: left;
    animation: ss-in .14s ease-out;
}
.site-search-panel[hidden] {
    display: none;
}
@keyframes ss-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}
.site-search.is-loading .site-search-panel > * {
    opacity: .55;
    transition: opacity .2s;
}

.ss-section {
    padding: 10px 18px 8px;
}
.ss-section + .ss-section {
    border-top: 1px solid #eef3f1;
}
/* Блок «Вы искали» скрыт, пока истории нет, — разделитель под ним не нужен */
.ss-section[hidden] + .ss-section {
    border-top: 0;
}
.ss-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #7c9796;
}
.ss-head-count {
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #eef6f3;
    color: #0a6a69;
    font-size: 12px;
    letter-spacing: 0;
    text-align: center;
}
.ss-head-link {
    border: 0;
    background: none;
    padding: 0;
    color: #0a6a69;
    font: inherit;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    cursor: pointer;
}
.ss-head-link:hover {
    text-decoration: underline;
}

/* Разделы — «таблетки» */
.ss-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ss-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef6f3;
    color: #0a6a69 !important;
    font: 14px/1.2 "Rubik Regular", sans-serif;
    text-decoration: none !important;
    transition: background-color .12s;
}
.ss-chip:hover {
    background: #daeae4;
}
.ss-chip.is-active {
    background: #0a6a69;
    color: #fff !important;
}
.ss-chip.is-active .ss-chip-parent {
    color: rgba(255, 255, 255, .75);
}
.ss-chip.is-active .ss-chip-count {
    color: rgba(255, 255, 255, .75);
}
.ss-chip-parent {
    color: #7c9796;
    font-size: 12px;
}
.ss-chip-count {
    color: #7c9796;
    font-size: 12px;
}
.ss-chip-count:before {
    content: "· ";
}

/* Заготовка, пока панель грузится в первый раз */
.ss-skeleton .ss-chip {
    width: var(--w, 90px);
    color: transparent !important;
    background: linear-gradient(90deg, #eef6f3 0%, #f7fbf9 50%, #eef6f3 100%);
    background-size: 200% 100%;
    animation: ss-shimmer 1.1s ease-in-out infinite;
}
.ss-skeleton .ss-head span {
    display: inline-block;
    width: 120px;
    height: 10px;
    border-radius: 5px;
    background: #eef6f3;
}
@keyframes ss-shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

/* Товары */
.ss-list {
    list-style: none;
    margin: 0 -10px;
    padding: 0;
}
.ss-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 0 0;
    border-radius: 14px;
    transition: background-color .12s;
}
.ss-item:hover {
    background: #f3f8f6;
}
.ss-item.is-active {
    background: #e8f2ee;
    box-shadow: inset 3px 0 0 #0a6a69;
}
.ss-item-link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 0 7px 10px;
    color: inherit !important;
    text-decoration: none !important;
}
.ss-thumb {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    overflow: hidden;
    background: #f2f8f2;
    color: #9db7b5;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ss-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ss-item-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.ss-item-name {
    color: #000;
    font-size: 15px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ss-item-meta {
    color: #7c9796;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.site-search-panel mark,
.search-page mark {
    padding: 0 1px;
    border-radius: 3px;
    background: rgba(250, 183, 47, .35);
    color: inherit;
}

.ss-item-side {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.ss-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    white-space: nowrap;
}
.ss-price b {
    font-family: "Rubik Medium", sans-serif;
    font-weight: normal;
    font-size: 15px;
    color: #000;
}
.ss-price s {
    font-size: 12px;
    color: #9aaead;
}
.ss-buy {
    position: relative;
    width: 104px;
    display: flex;
    justify-content: flex-end;
}
.ss-buy-btn {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: #0a6a69;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background-color .12s, transform .12s;
}
.ss-buy-btn:hover {
    background: #08807e;
}
.ss-buy-btn:active {
    transform: scale(.94);
}
.ss-stepper {
    display: none;
    align-items: center;
    height: 38px;
    border-radius: 12px;
    background: #eef6f3;
    overflow: hidden;
}
.ss-item.in_cart .ss-buy-btn {
    display: none;
}
.ss-item.in_cart .ss-stepper {
    display: flex;
}
.ss-stepper a {
    width: 32px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a6a69 !important;
    font-size: 18px;
    text-decoration: none !important;
}
.ss-stepper a:hover {
    background: #daeae4;
}
/* Поле количества — сбрасываем стили поля поиска шапки (.header1-line2-inner-search input[type="text"]) */
.header1-line2-inner-search .ss-stepper input[type="text"].product_cart_inp,
.ss-stepper input {
    width: 40px !important;
    height: 38px;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    background: transparent none !important;
    box-shadow: none !important;
    text-align: center;
    font: 15px "Rubik Medium", sans-serif;
    color: #0a3d3c;
    outline: none;
}

/* «Все результаты» */
.ss-all {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 12px 4px;
    padding: 0 16px;
    height: 46px;
    border-radius: 14px;
    background: #0a6a69;
    color: #fff !important;
    font: 15px "Rubik Regular", sans-serif;
    text-decoration: none !important;
    box-shadow: 0 -8px 16px 4px #fff;
    transition: background-color .12s;
}
.ss-all:hover {
    background: #08807e;
}
.ss-all.is-active {
    background: #08807e;
    box-shadow: 0 -8px 16px 4px #fff, inset 0 0 0 2px rgb(250, 183, 47);
}
.ss-all svg {
    margin-left: auto;
}
.ss-all-count {
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .2);
    font-size: 13px;
}

/* Недавние запросы */
.ss-recent-list {
    list-style: none;
    margin: 0 -10px;
    padding: 0;
}
.ss-recent-item {
    display: flex;
    align-items: center;
    border-radius: 12px;
}
.ss-recent-item:hover,
.ss-recent-item.is-active {
    background: #f3f8f6;
}
.ss-recent-link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: #0a3d3c !important;
    font-size: 15px;
    text-decoration: none !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.ss-recent-link svg {
    flex: 0 0 auto;
    color: #9db7b5;
}
.ss-recent-remove {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin-right: 4px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: #9db7b5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.ss-recent-remove:hover {
    background: #e6efec;
    color: #0a6a69;
}

.ss-tip {
    padding: 6px 18px 10px;
    color: #7c9796;
    font-size: 13px;
    line-height: 1.4;
}
.ss-note {
    margin: 8px 14px 4px;
    padding: 9px 12px;
    border-radius: 12px;
    background: #fff6df;
    color: #6b5313;
    font-size: 13px;
    line-height: 1.35;
}
.ss-empty {
    padding: 22px 18px 10px;
    text-align: center;
}
.ss-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #eef6f3;
    color: #0a6a69;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ss-empty-title {
    font-size: 16px;
    color: #000;
    line-height: 1.3;
    word-break: break-word;
}
.ss-empty-text {
    margin-top: 4px;
    font-size: 14px;
    color: #7c9796;
}
.ss-empty + .ss-section .ss-chips {
    justify-content: center;
}

/* ---------- Страница /search ---------- */
.search-page-form {
    position: relative;
    display: flex;
    gap: 10px;
    max-width: 720px;
    margin-top: 24px;
}
.search-page-form-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #0a6a69;
    pointer-events: none;
}
.search-page-form input {
    flex: 1 1 auto;
    min-width: 0;
    height: 54px;
    padding: 0 18px 0 50px;
    border-radius: 16px;
    border: 0;
    background: rgba(10, 106, 105, .102);
    font: 17px "Rubik Regular", sans-serif;
    color: #0a3d3c;
    outline: none;
    -webkit-appearance: none;
}
.search-page-form input:focus {
    background: #fff;
    box-shadow: 0 0 0 2px #0a6a69;
}
.search-page-form button {
    flex: 0 0 auto;
    height: 54px;
    padding: 0 28px;
    border: 0;
    border-radius: 16px;
    background: rgb(250, 183, 47);
    color: #0a6a69;
    font: 17px "Rubik Regular", sans-serif;
    cursor: pointer;
}
.search-page-note {
    max-width: 720px;
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #fff6df;
    color: #6b5313;
    font-size: 14px;
}
.search-page-summary {
    margin-top: 22px;
    color: #7c9796;
    font-size: 15px;
}
.search-page-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.search-page .razdel-block1 {
    margin-top: 10px;
}
.search-page-empty {
    margin: 40px 0 80px;
    max-width: 720px;
}
.search-page-empty-title {
    font: 22px "Rubik Medium", sans-serif;
    color: #000;
    word-break: break-word;
}
.search-page-empty-text {
    margin-top: 8px;
    color: #7c9796;
    font-size: 16px;
}
.search-page-empty .search-page-cats {
    margin-top: 22px;
}

/* ---------- Телефон: поиск на весь экран ---------- */
@media (max-width: 767px) {
    .body-search-open .header1-line2-inner-search {
        top: 0;
        bottom: 0;
        height: auto;
        padding: 10px 15px 0;
        align-items: stretch;
        background: #fff;
        border-top: 0;
        z-index: 1000;
    }
    .body-search-open .header1-line2-inner-search .site-search {
        flex-wrap: wrap;
        align-content: flex-start;
        height: 100%;
        gap: 10px;
    }
    .header1-line2-inner-search .site-search input[type="text"].js-ss-input {
        width: 100% !important; /* старое правило для вошедших (.auth-user) задаёт 200px */
        height: 44px;
        border-radius: 12px;
        font-size: 16px; /* меньше 16px — iOS увеличивает страницу при фокусе */
    }
    .body-search-open .site-search-field {
        flex: 1 1 0;
    }
    .site-search-cancel {
        display: block;
        flex: 0 0 auto;
        height: 44px;
        padding: 0 2px;
        border: 0;
        background: none;
        color: #0a6a69;
        font: 16px "Rubik Regular", sans-serif;
        cursor: pointer;
    }
    .site-search-panel,
    .site-search-panel[hidden] {
        display: block;
        position: static;
        flex: 1 0 100%;
        width: auto;
        max-width: none;
        max-height: none;
        height: calc(100% - 54px);
        margin: 0 -15px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid #eef3f1;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        animation: none;
    }
    .ss-section {
        padding-left: 15px;
        padding-right: 15px;
    }
    /* Над товарами на телефоне — не больше четырёх разделов, иначе список уезжает вниз */
    .ss-section .ss-chips .ss-chip:nth-child(n+5) {
        display: none;
    }
    .ss-empty + .ss-section .ss-chips .ss-chip:nth-child(n+5),
    .ss-tip ~ .ss-chip,
    .js-ss-recent ~ .ss-section .ss-chip:nth-child(n+5) {
        display: inline-flex;
    }
    .ss-list,
    .ss-recent-list {
        margin: 0 -7px;
    }
    .ss-item-side {
        gap: 8px;
    }
    .ss-price b {
        font-size: 14px;
    }
    .ss-buy {
        width: auto;
    }
    .ss-item-name {
        font-size: 14px;
    }
    .ss-thumb {
        flex-basis: 48px;
        width: 48px;
        height: 48px;
    }
    .ss-all {
        margin: 8px 15px 0;
        height: 50px;
    }
    body.ss-lock {
        overflow: hidden;
    }
    .search-page-form button {
        padding: 0 18px;
    }
    .search-page-form input,
    .search-page-form button {
        height: 48px;
        font-size: 16px;
    }
    .search-page-empty-title {
        font-size: 18px;
    }
}
