/* hdt_aiagent — чат-консультант.
   Все классы с префиксом hdt-ai, чтобы не столкнуться со стилями темы.
   Фирменный цвет приходит из шаблона переменной --hdt-accent и работает
   акцентом: кнопкой вызова и подсветкой, а не заливкой половины окна. */

.hdt-ai {
    --hdt-bg: #ffffff;
    --hdt-ink: #16191d;
    --hdt-muted: #767d85;
    --hdt-line: #e6e8eb;
    --hdt-field: #f4f5f7;
}

/* Плашка про куки живёт в том же нижнем углу. Поднимаем её над виджетом:
   согласие с куками покупатель должен видеть первым. */
.cookie-notice { z-index: 99999 !important; }

/* Видео-виджет стоял в том же углу и спорил с кнопкой чата, уводим влево. */
.sm-window-content-wrapper.bottom-right,
.sm-window .sm-window-content-wrapper {
    left: 24px !important;
    right: auto !important;
}
.sm-window { left: 0 !important; right: auto !important; }

/* Пока открыт чат, посторонние всплывашки убираем: на телефоне видео-виджет
   ложится поверх панели и закрывает поле ввода. */
body.hdt-ai-open .smt-app,
body.hdt-ai-open .sm-window,
body.hdt-ai-open .cookie-notice { display: none !important; }

/* Любой элемент, обёрнутый этим классом, открывает чат. */
.hdt-ai-open-chat { cursor: pointer; }

/* ------------------------------------------------------------ кнопка вызова */

.hdt-ai__launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Кнопка вызова: иконка чата и надпись. На телефоне надпись прячется и
   остаётся круглая кнопка, чтобы не перекрывать пол-экрана. */
.hdt-ai__fab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 0 22px 0 18px;
    border: 0;
    border-radius: 28px;
    background: var(--hdt-accent);
    color: var(--hdt-accent-text);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(16, 19, 23, .22);
    transition: transform .18s ease, box-shadow .18s ease;
    font-family: inherit;
    text-align: left;
}
.hdt-ai__fab:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(16, 19, 23, .28); }
.hdt-ai__fab:active { transform: translateY(0); }

/* По кнопке время от времени пробегает светлая полоска: взгляд цепляется
   за движение, а кнопка при этом не мигает и не раздражает. Блик лежит
   отдельным слоем поверх фона и не мешает нажатию. */
.hdt-ai__fab { overflow: hidden; }
.hdt-ai__fab::after {
    content: "";
    position: absolute;
    top: -60%;
    left: -75%;
    width: 45%;
    height: 220%;
    pointer-events: none;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, .55) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: skewX(-18deg);
    animation: hdt-ai-shine 3.6s ease-in-out infinite;
}
@keyframes hdt-ai-shine {
    0%        { left: -75%; }
    45%, 100% { left: 135%; }
}
@media (prefers-reduced-motion: reduce) {
    .hdt-ai__fab::after { animation: none; display: none; }
}

.hdt-ai__fab-icon { flex: none; line-height: 0; }
.hdt-ai__fab-text {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    max-width: 180px;
}

.hdt-ai__photo {
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: #e3e6ea;
}
.hdt-ai__photo--head { width: 40px; height: 40px; }
.hdt-ai__photo--row { width: 28px; height: 28px; }

/* Подсказка у кнопки: показывается один раз на несколько секунд. */
.hdt-ai__hint {
    position: relative;
    max-width: 230px;
    padding: 12px 30px 12px 14px;
    background: var(--hdt-bg);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 19, 23, .16);
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--hdt-ink);
    animation: hdt-hint-in .22s ease-out;
}
.hdt-ai__hint[hidden] { display: none; }
.hdt-ai__hint-close {
    position: absolute;
    top: 4px;
    right: 6px;
    border: 0;
    background: none;
    color: var(--hdt-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}
@keyframes hdt-hint-in {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ панель */

/* Панель, а не модальное окно: страница остаётся доступной, затемнения нет. */
.hdt-ai__panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    width: 460px;
    height: min(700px, 78vh);
    background: var(--hdt-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 60px rgba(16, 19, 23, .28), 0 2px 8px rgba(16, 19, 23, .1);
    font-family: inherit;
    animation: hdt-panel-in .2s ease-out;
    transition: width .22s ease;
}
.hdt-ai__panel[hidden] { display: none; }
/* Когда в разговоре появились карточки, панель становится шире: товар
   должен читаться, а не сжиматься в полоску. */
.hdt-ai__panel--wide { width: 660px; }

@keyframes hdt-panel-in {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .hdt-ai__panel, .hdt-ai__hint { animation: none; }
}

/* шапка */
.hdt-ai__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px 13px 16px;
    background: #1c1f23;
    color: #fff;
    flex: none;
}
.hdt-ai__who { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.hdt-ai__name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.hdt-ai__status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, .6);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hdt-ai__status i {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #35c759;
    flex: none;
}
.hdt-ai__close {
    border: 0;
    background: none;
    color: rgba(255, 255, 255, .65);
    cursor: pointer;
    padding: 6px;
    line-height: 0;
    flex: none;
    border-radius: 8px;
}
.hdt-ai__close:hover { color: #fff; background: rgba(255, 255, 255, .1); }

/* лента сообщений */
.hdt-ai__log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px 6px;
    background: var(--hdt-field);
    -webkit-overflow-scrolling: touch;
}
/* Сообщения прижаты к низу обёрткой, а не контейнером: так и низ на месте,
   и прокрутка вверх работает. */
.hdt-ai__log-inner {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100%;
}
.hdt-ai__log-inner > * { flex: none; }

.hdt-ai__log::-webkit-scrollbar { width: 8px; }
.hdt-ai__log::-webkit-scrollbar-thumb {
    background: #cfd4d9;
    border-radius: 8px;
    border: 2px solid var(--hdt-field);
}
.hdt-ai__log::-webkit-scrollbar-thumb:hover { background: #b6bcc3; }

.hdt-ai__row { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.hdt-ai__row--me { flex-direction: row-reverse; }
.hdt-ai__row-ava { flex: none; width: 28px; height: 28px; line-height: 0; }
.hdt-ai__row--me .hdt-ai__row-ava { display: none; }

.hdt-ai__msg {
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.45;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.hdt-ai__msg--bot {
    max-width: 80%;
    background: var(--hdt-bg);
    color: var(--hdt-ink);
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 2px rgba(16, 19, 23, .07);
}
/* Телефон в ответе продавца: заметен и нажимается. */
.hdt-ai__tel {
    display: inline-block;
    /* Оранжевый на всех витринах. Фирменный цвет тут не годится: на helikon
       он лаймовый, и номер на нём читается плохо. */
    background: #f26722;
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
    padding: 0 6px;
    border-radius: 6px;
    white-space: nowrap;
}
.hdt-ai__tel:hover,
.hdt-ai__tel:focus {
    background: #ff7a35;
    color: #ffffff;
    text-decoration: none;
}
.hdt-ai__tel:focus-visible { outline: 2px solid #1b1b1a; outline-offset: 1px; }

.hdt-ai__msg--me {
    max-width: 72%;
    background: var(--hdt-accent);
    color: var(--hdt-accent-text);
    border-bottom-right-radius: 5px;
}

/* «печатает» */
.hdt-ai__typing {
    display: inline-flex;
    gap: 6px;
    /* Точки подпрыгивают вверх, поэтому равняем по низу: иначе прыжок
       съедается выравниванием по центру и выглядит дрожанием. */
    align-items: flex-end;
    padding: 16px 18px 18px;
    min-height: 0;
}
.hdt-ai__typing i {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #8d959e;
    /* Прыжок должен быть виден: 9 точек вверх при размере 9 — это ровно
       на свою высоту. Прежние 6 пикселей при светло-сером цвете читались
       как неподвижные точки. */
    animation: hdt-ai-dot 1.25s infinite cubic-bezier(.36, .05, .28, 1);
    will-change: transform;
}
.hdt-ai__typing i:nth-child(2) { animation-delay: .18s; }
.hdt-ai__typing i:nth-child(3) { animation-delay: .36s; }
/* Точки подпрыгивают по очереди, как в мессенджерах. */
@keyframes hdt-ai-dot {
    0%, 60%, 100% { opacity: .4;  transform: translateY(0) scale(.86); }
    30%           { opacity: 1;   transform: translateY(-9px) scale(1.08); }
}
/* При «уменьшении движения» в системе индикатор раньше замирал совсем, и
   покупатель не понимал, думает продавец или всё повисло. Прыжок убираем,
   но мигание оставляем: это единственный признак, что ответ готовится. */
@media (prefers-reduced-motion: reduce) {
    .hdt-ai__typing i {
        animation: hdt-ai-dot-soft 1.4s infinite ease-in-out;
        transform: none;
    }
}
@keyframes hdt-ai-dot-soft {
    0%, 60%, 100% { opacity: .3; }
    30%           { opacity: 1; }
}

/* ------------------------------------------------------------ карточки */

/* Лента с прокруткой вбок: показываем не больше трёх товаров, чтобы чат
   не превращался в каталог. Соседняя карточка выглядывает краем и тем
   подсказывает, что список можно листать. */
.hdt-ai__cards {
    display: flex;
    gap: 10px;
    margin: 0 0 12px 36px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.hdt-ai__cards::-webkit-scrollbar { height: 4px; }
.hdt-ai__cards::-webkit-scrollbar-thumb { background: #d3d7dc; border-radius: 4px; }

.hdt-ai__card {
    flex: none;
    width: 176px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--hdt-bg);
    border: 1px solid var(--hdt-line);
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.hdt-ai__card:hover { border-color: #c9ced4; box-shadow: 0 6px 18px rgba(16, 19, 23, .09); }

.hdt-ai__card-pic {
    width: 100%;
    /* Кадр в каталоге квадратный, а рамка была 188 на 112 — отсюда серые поля
       по бокам у каждой карточки. Держим рамку квадратной и заполняем её
       целиком: полей не остаётся, а квадратному кадру нечего обрезать. */
    aspect-ratio: 1 / 1;
    height: auto;
    object-fit: cover;
    object-position: center;
    background: #fff;
    border-radius: 10px;
    display: block;
}
/* Браузеры без aspect-ratio: рамка остаётся прежней высоты, но уже без полей. */
@supports not (aspect-ratio: 1 / 1) {
    .hdt-ai__card-pic { height: 170px; }
}
.hdt-ai__card-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.32;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}
.hdt-ai__card-price { font-weight: 700; font-size: 15px; }
.hdt-ai__card-size { font-size: 11.5px; color: var(--hdt-muted); }
.hdt-ai__card-size--yes { color: #2e9e4f; }
.hdt-ai__card-go {
    margin-top: 2px;
    text-align: center;
    padding: 7px 10px;
    border-radius: 9px;
    background: var(--hdt-field);
    font-size: 12.5px;
    font-weight: 600;
}
.hdt-ai__card:hover .hdt-ai__card-go { background: var(--hdt-accent); color: var(--hdt-accent-text); }

/* ------------------------------------------------------------ подсказки и ввод */

.hdt-ai__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px;
    background: var(--hdt-field);
    flex: none;
}
.hdt-ai__chips:not(:empty) { padding: 2px 16px 10px; }
.hdt-ai__chip {
    border: 1px solid #dfe2e6;
    background: var(--hdt-bg);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 12.5px;
    cursor: pointer;
    color: #3c4249;
    font-family: inherit;
    transition: border-color .15s ease;
}
.hdt-ai__chip:hover { border-color: #b7bcc2; }
.hdt-ai__chip--call { border-color: var(--hdt-accent); font-weight: 600; }

.hdt-ai__form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px 14px 14px;
    background: var(--hdt-field);
    border-top: 1px solid var(--hdt-line);
    flex: none;
}
.hdt-ai__input {
    flex: 1;
    height: 44px;
    min-height: 44px;
    max-height: 110px;
    padding: 11px 16px;
    border: 1px solid #dfe2e6;
    border-radius: 22px;
    font-size: 15px;
    font-family: inherit;
    line-height: 20px;
    outline: none;
    background: var(--hdt-bg);
    resize: none;
    overflow-y: auto;
    box-sizing: border-box;
}
.hdt-ai__input:focus { border-color: #b7bcc2; }
.hdt-ai__send {
    flex: none;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--hdt-accent);
    color: var(--hdt-accent-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s ease;
}
.hdt-ai__send:disabled { opacity: .45; cursor: default; }

/* ------------------------------------------------------------ телефон */

@media (max-width: 760px) {
    .hdt-ai__launcher { right: 16px; bottom: 16px; }
    .hdt-ai__fab { padding: 0; width: 56px; justify-content: center; border-radius: 50%; }
    .hdt-ai__fab-text { display: none; }
    .hdt-ai__hint { max-width: 190px; font-size: 13px; }

    /* На телефоне чат занимает весь экран: в маленьком окне клавиатура
       и карточки съедают всё место. */
    .hdt-ai__panel {
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: auto;
        height: 100%;
        border-radius: 0;
    }
    .hdt-ai__panel--wide { width: auto; }
    .hdt-ai__log { padding: 14px 12px 4px; }
    .hdt-ai__cards { margin-left: 0; }
    .hdt-ai__card { width: 60vw; max-width: 210px; }
    .hdt-ai__chips, .hdt-ai__form { padding-left: 12px; padding-right: 12px; }
    .hdt-ai__msg--bot { max-width: 88%; }
    .hdt-ai__msg--me { max-width: 80%; }

    /* На узком экране адрес не влезал в строку и обрывался на «4 эта…».
       Пусть переносится: лишняя строка в шапке дешевле потерянного адреса. */
    .hdt-ai__status {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        align-items: flex-start;
    }
    .hdt-ai__status i { margin-top: 4px; }
}

@supports (height: 100dvh) {
    @media (max-width: 760px) {
        .hdt-ai__panel { height: 100dvh; }
    }
}
