/*
 * ship_chat.css — виджет онлайн-чата сайта ship-shops.ru (интеграция с amoCRM/amojo).
 * Плавающий пузырь в правом нижнем углу + панель чата. Разметку строит ship_chat.js.
 * На мобиле пузырь поднят над нижней панелью .ship-mbar (z-index 100, высота ~64px).
 */

.shc-fab {
    position: fixed;
    right: 20px;
    /* Выше Аспровской кнопки «наверх» (#scrollToTop: fixed bottom:23px, высота 44px,
       верх ~67px) — чтобы пузырь чата её не перекрывал при прокрутке. */
    bottom: 76px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #E8A2E1;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform .15s ease, box-shadow .15s ease;
}
.shc-fab:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(0, 0, 0, .3); }
.shc-fab svg { width: 28px; height: 28px; fill: #fff; }
.shc-fab.shc-hidden { display: none; }

/* Аспровская кнопка «наверх» (#scrollToTop) по умолчанию на right:73px и налезает
   на фото товаров. Двигаем к правому краю и центрируем под пузырём чата
   (пузырь 60px @ right:20 → центр 44px-кнопки: 20 + (60-44)/2 = 28px). */
#scrollToTop { right: 28px !important; }

.shc-fab__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #d5001c;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
    display: none;
}
.shc-fab__badge.shc-on { display: block; }

/* --- Панель --------------------------------------------------------------- */
.shc-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: inherit;
}
.shc-panel.shc-open { display: flex; }

.shc-head {
    background: #E8A2E1;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
}
.shc-head__title { font-size: 16px; font-weight: 700; }
.shc-head__sub { font-size: 12px; color: rgba(255, 255, 255, .9); margin-top: 2px; }
.shc-head__close {
    background: none; border: none; color: #fff; cursor: pointer;
    font-size: 24px; line-height: 1; padding: 0 4px;
}

.shc-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    background: #faf4f8;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shc-msg {
    max-width: 80%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.shc-msg--out {
    align-self: flex-end;
    background: #DC8FD4;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.shc-msg--in {
    align-self: flex-start;
    background: #fff;
    color: #222;
    border: 1px solid #e3e5e9;
    border-bottom-left-radius: 4px;
}
.shc-msg__sender { font-size: 11px; font-weight: 700; opacity: .7; margin-bottom: 3px; }
.shc-msg__img { display: block; max-width: 100%; border-radius: 10px; margin-top: 4px; cursor: pointer; }
.shc-msg__meta { font-size: 10px; opacity: .7; margin-top: 4px; text-align: right; }
.shc-msg--in .shc-msg__meta { text-align: left; }

.shc-intro {
    align-self: center;
    text-align: center;
    color: #8a8f98;
    font-size: 13px;
    padding: 20px 10px;
}

/* --- Контакты гостя (необязательные) -------------------------------------- */
.shc-contacts {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-top: 1px solid #eceef1;
    background: #fff;
    display: none;
    gap: 6px;
}
.shc-contacts.shc-on { display: flex; }
.shc-contacts input {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #d7dade;
    border-radius: 8px;
    font-size: 13px;
}

/* --- Ввод ----------------------------------------------------------------- */
.shc-foot {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eceef1;
    background: #fff;
}
.shc-foot__attach {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    border: none; background: #f0f1f4; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.shc-foot__attach svg { width: 20px; height: 20px; fill: #6b6f76; }
.shc-foot__text {
    flex: 1 1 auto;
    resize: none;
    max-height: 96px;
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid #d7dade;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.3;
    font-family: inherit;
}
.shc-foot__send {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    border: none; background: #E8A2E1; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.shc-foot__send:disabled { opacity: .5; cursor: default; }
.shc-foot__send svg { width: 20px; height: 20px; fill: #fff; }

.shc-preview {
    flex: 0 0 auto;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #eceef1;
    background: #fff;
    font-size: 13px;
    color: #555;
}
.shc-preview.shc-on { display: flex; }
.shc-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.shc-preview button { background: none; border: none; color: #d5001c; cursor: pointer; font-size: 13px; }

/* --- Мобильные ------------------------------------------------------------ */
@media (max-width: 991px) {
    /* Поднимаем над нижней панелью .ship-mbar (высота ~64px) */
    .shc-fab { bottom: calc(74px + env(safe-area-inset-bottom, 0px)); right: 14px; }
    .shc-panel {
        right: 0; left: 0; bottom: 0;
        width: 100%; max-width: 100%;
        height: 100%; max-height: 100%;
        border-radius: 0;
    }
}
