/*
 * Лаборатория Кошмарского — онлайн-помощник soser.net
 * v1.0.3
 */

/* ===== ЯРЛЫК ВНИЗУ СПРАВА ===== */
.soser-tab {
    position: fixed;
    right: 25px;
    bottom: 0;
    padding: 10px 18px;
    background: #7A191F;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 0 8px rgba(0, 0, 0, .2);
    z-index: 100;
}

.soser-tab:hover {
    background: #5E1217;
    color: #ffffff;
    text-decoration: none;
}

.soser-tab i {
    margin-right: 6px;
}

.soser-tab__badge {
    display: none;
    position: absolute;
    top: -9px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #17191B;
    color: #ffffff;
    border: 2px solid #D8D4CD;
    border-radius: 10px;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

.soser--open .soser-tab {
    display: none;
}

/* ===== ВСПЛЫВАЮЩАЯ ПОДСКАЗКА ===== */
.soser-teaser {
    display: none;
    position: fixed;
    right: 25px;
    bottom: 52px;
    width: 280px;
    padding: 12px 30px 12px 12px;
    background: #E6E2DC;
    border: 1px solid #ACA69D;
    border-radius: 3px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
    font-size: 13px;
    line-height: 1.45;
    color: #1C1A18;
    cursor: pointer;
    z-index: 100;
}

.soser-teaser.show {
    display: flex;
    align-items: flex-start;
}

/* Хвостик-треугольник снизу: рамка из двух псевдоэлементов (серый под светлым) */
.soser-teaser::before,
.soser-teaser::after {
    content: '';
    position: absolute;
    right: 40px;
    border: 8px solid transparent;
    border-bottom: 0;
}

.soser-teaser::before {
    bottom: -8px;
    border-top-color: #ACA69D;
}

.soser-teaser::after {
    bottom: -7px;
    border-top-color: #E6E2DC;
}

.soser-teaser__avatar {
    flex: 0 0 auto;
    margin-right: 10px;
}

.soser-teaser__text {
    margin: 0;
    /* длинное сообщение обрезаем до 4 строк с многоточием */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.soser-teaser__close {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 5px;
    background: none;
    border: 0;
    color: #5A5650;
    font-size: 12px;
    cursor: pointer;
}

.soser-teaser__close:hover {
    color: #7A191F;
}

.soser--open .soser-teaser {
    display: none;
}

/* ===== АВАТАРЫ ===== */
.soser-head__avatar,
.soser-teaser__avatar,
.soser-msg__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #C6C1B9;
    color: #7A191F;
    font-size: 16px;
    overflow: hidden;
}

.soser-head__avatar img,
.soser-teaser__avatar img,
.soser-msg__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== ОКНО ЧАТА ===== */
.soser-panel {
    display: none;
    position: fixed;
    right: 25px;
    bottom: 0;
    width: 350px;
    height: 480px;
    max-height: calc(100% - 20px);
    flex-direction: column;
    background: #D8D4CD;
    border: 1px solid #ACA69D;
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 0 14px rgba(0, 0, 0, .25);
    font-family: 'Open Sans', Arial, Helvetica, sans-serif;
    z-index: 100;
}

.soser--open .soser-panel {
    display: flex;
}

.soser-head {
    display: flex;
    align-items: center;
    padding: 10px 8px 10px 12px;
    background: #7A191F;
    color: #ffffff;
    border-radius: 3px 3px 0 0;
}

.soser-head__avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin-right: 10px;
    background: #D8D4CD;
    border: 2px solid #5E1217;
    font-size: 19px;
}

.soser-head__info {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.3;
}

.soser-head__name {
    font-size: 15px;
    font-weight: 700;
}

.soser-head__sub {
    font-size: 12px;
    color: #E8CFCF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.soser-head__status {
    font-size: 11px;
    color: #E8CFCF;
}

.soser-head__status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 5px;
    border-radius: 50%;
    background: #7FA886;
    vertical-align: 0;
}

.soser-head__btn {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    margin-left: 2px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 3px;
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
}

.soser-head__btn:hover {
    background: #5E1217;
}

/* ===== СООБЩЕНИЯ ===== */
.soser-list {
    flex: 1 1 auto;
    padding: 14px 12px 6px;
    overflow-y: auto;
    /* на iOS прокрутка внутри блока без этого идет рывками */
    -webkit-overflow-scrolling: touch;
}

.soser-msg {
    display: flex;
    align-items: flex-end;
    margin-bottom: 12px;
}

.soser-msg__avatar {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    margin-right: 8px;
    font-size: 13px;
}

.soser-msg__body {
    max-width: 78%;
}

.soser-msg__bubble {
    padding: 8px 11px;
    font-size: 13px;
    line-height: 1.45;
    border-radius: 3px;
    /* переносим длинные слова пользователя, иначе «ааааааааааа» растянет окно */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.soser-msg--bot .soser-msg__bubble {
    background: #E6E2DC;
    border: 1px solid #C6C1B9;
    color: #1C1A18;
}

.soser-msg--user {
    justify-content: flex-end;
}

.soser-msg--user .soser-msg__bubble {
    background: #7A191F;
    color: #ffffff;
}

.soser-msg__time {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    color: #5A5650;
}

.soser-msg--user .soser-msg__time {
    text-align: right;
}

/* ===== КАРТОЧКА ТОВАРА В ЧАТЕ ===== */
.soser-card {
    margin-top: 6px;
    padding: 9px 11px;
    background: #ffffff;
    border: 1px solid #ACA69D;
    border-left: 3px solid #7A191F;
    border-radius: 3px;
    font-size: 13px;
}

.soser-card__name {
    font-weight: 700;
}

.soser-card__price {
    margin: 2px 0 7px;
    color: #5A5650;
}

.soser-card__price b {
    color: #7A191F;
}

.soser-card__btn {
    padding: 4px 12px;
    background: #7A191F;
    border: 0;
    border-radius: 3px;
    color: #ffffff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.soser-card__btn:hover {
    background: #5E1217;
}

/* ===== «ПЕЧАТАЕТ...» ===== */
.soser-typing {
    display: none;
    padding: 0 12px 6px 48px;
    font-size: 11px;
    color: #5A5650;
}

.soser-typing.show {
    display: block;
}

.soser-typing__dots i {
    display: inline-block;
    width: 4px;
    height: 4px;
    margin-left: 3px;
    border-radius: 50%;
    background: #5A5650;
    animation: soser-dot 1.2s infinite;
}

/* Каждая следующая точка стартует позже — получается «бегущая волна» */
.soser-typing__dots i:nth-child(2) {
    animation-delay: .2s;
}

.soser-typing__dots i:nth-child(3) {
    animation-delay: .4s;
}

@keyframes soser-dot {
    0%, 60%, 100% {
        opacity: .25;
    }
    30% {
        opacity: 1;
    }
}

/* ===== ПОЛЕ ВВОДА ===== */
.soser-form {
    display: flex;
    flex: 0 0 auto;
    border-top: 1px solid #ACA69D;
    background: #ffffff;
}

.soser-form__input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px;
    border: 0;
    background: transparent;
    color: #1C1A18;
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.soser-form__send {
    flex: 0 0 auto;
    width: 46px;
    background: none;
    border: 0;
    color: #7A191F;
    font-size: 16px;
    cursor: pointer;
}

.soser-form__send:hover {
    color: #5E1217;
}

.soser-foot {
    padding: 4px 10px;
    background: #C6C1B9;
    color: #5A5650;
    font-size: 10px;
    text-align: center;
}

/* ===== ПОКА ВИСИТ БАННЕР COOKIE =====
   Класс cookie-open ставит main.js. Поднимаем подсказку и окно над баннером, чтобы не закрывать «Принять» */
.cookie-open .soser-teaser {
    bottom: 130px;
}

.cookie-open .soser-panel {
    bottom: 120px;
    max-height: calc(100% - 140px);
    border-bottom: 1px solid #ACA69D;
    border-radius: 4px;
}

/* ===== МОБИЛЬНЫЕ ===== */
@media (max-width: 600px) {
    .soser-tab {
        right: 10px;
        padding: 8px 12px;
        font-size: 13px;
    }

    .soser-teaser {
        right: 10px;
        bottom: 46px;
        width: calc(100% - 20px);
        max-width: 320px;
    }

    .soser-panel {
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    .soser-head {
        border-radius: 0;
    }

    /* Баннер cookie на телефоне выше. Окно чата здесь и так во весь экран, его не двигаем */
    .cookie-open .soser-teaser {
        bottom: 235px;
    }

    .cookie-open .soser-panel {
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    /* при шрифте меньше 16px iOS сам увеличивает страницу, когда фокус попадает в поле */
    .soser-form__input {
        font-size: 16px;
    }
}

