/* Чат на сайте. Опирается на переменные темы (--primary, --card, --ink, --line,
   --muted) и подхватывает тёмное оформление витрины (класс .dark на <html>). */

.web-chat {
    position: fixed;
    bottom: 20px;
    z-index: 8500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.web-chat--right { right: 20px; }
.web-chat--left { left: 20px; align-items: flex-start; }

.web-chat__button {
    position: relative;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--primary, #4652ff);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: var(--shadow-pop, 0 12px 28px rgba(16, 24, 40, .22));
    transition: transform .15s, filter .15s;
}

.web-chat__button:hover { filter: brightness(1.06); transform: translateY(-1px); }

.web-chat__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger, #ff0638);
    color: #fff;
    font-size: 12px;
    line-height: 20px;
}

.web-chat__badge[hidden] { display: none; }

.web-chat__window {
    display: flex;
    flex-direction: column;
    width: 340px;
    max-height: min(70vh, 560px);
    border-radius: var(--radius, 12px);
    background: var(--card, #fff);
    color: var(--ink, #2d2d32);
    border: 1px solid var(--line, #e8e8e8);
    box-shadow: var(--shadow-pop, 0 18px 44px rgba(16, 24, 40, .18));
    overflow: hidden;
    animation: web-chat-in .2s ease-out;
}

.web-chat__window[hidden] { display: none; }

@keyframes web-chat-in {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.web-chat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--primary, #4652ff);
    color: #fff;
}

.web-chat__title { font-weight: 600; font-size: 15px; }

.web-chat__close {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    opacity: .85;
}

.web-chat__close:hover { opacity: 1; }

.web-chat__log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    overflow-y: auto;
}

.web-chat__msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.web-chat__msg--shop {
    align-self: flex-start;
    background: var(--surface, #f4f5f7);
    border-bottom-left-radius: 4px;
}

.web-chat__msg--mine {
    align-self: flex-end;
    background: var(--primary, #4652ff);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Кнопки частых вопросов: покупателю не надо придумывать вопрос */
.web-chat__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.web-chat__quick-btn {
    padding: 6px 11px;
    border: 1px solid var(--line, #e8e8e8);
    border-radius: 999px;
    background: var(--card, #fff);
    color: inherit;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.web-chat__quick-btn:hover { border-color: var(--primary, #4652ff); color: var(--primary, #4652ff); }

/* «Магазин думает»: покупатель видит, что его услышали */
.web-chat__typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 10px;
    font-size: 13px;
    color: var(--muted, #8d8d8d);
}

.web-chat__typing[hidden] { display: none; }

.web-chat__dots { display: inline-flex; gap: 3px; }

.web-chat__dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--muted, #8d8d8d);
    animation: web-chat-dot 1.1s infinite ease-in-out;
}

.web-chat__dots i:nth-child(2) { animation-delay: .15s; }
.web-chat__dots i:nth-child(3) { animation-delay: .3s; }

@keyframes web-chat-dot {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}

html.dark .web-chat__quick-btn { background: var(--card, #1b1c21); border-color: var(--line, #2c2e35); }

/* Вложения: фото и видео смотрят прямо в переписке, файлы скачивают */
.web-chat__msg-text + .web-chat__file { margin-top: 6px; }

.web-chat__file {
    display: block;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
}

.web-chat__file--image img,
.web-chat__file--video {
    display: block;
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    object-fit: cover;
}

.web-chat__file--doc {
    font-size: 13px;
    text-decoration: underline;
    word-break: break-all;
    color: inherit;
}

/* Найденные товары: узнать глазом, увидеть цену, положить в корзину */
.web-chat__products {
    display: grid;
    gap: 6px;
}

.web-chat__product {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--line, #e8e8e8);
    border-radius: var(--radius-sm, 8px);
    background: var(--card, #fff);
    color: inherit;
    text-decoration: none;
    transition: border-color .15s;
}

.web-chat__product:hover { border-color: var(--primary, #4652ff); }

.web-chat__product-photo {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    object-fit: contain;
    border-radius: 6px;
    background: var(--surface, #f4f5f7);
}

.web-chat__product-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.web-chat__product-name {
    font-size: 13px;
    line-height: 1.35;
    /* Название в две строки: третья вытесняет цену за край окна */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.web-chat__product-price { font-size: 13px; font-weight: 600; }
.web-chat__product-out { font-size: 12px; color: var(--muted, #8d8d8d); }

.web-chat__product-buy {
    flex: 0 0 auto;
    align-self: center;
    padding: 6px 10px;
    border: 1px solid var(--primary, #4652ff);
    border-radius: var(--radius-sm, 8px);
    background: transparent;
    color: var(--primary, #4652ff);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.web-chat__product-buy:hover:not(:disabled) { background: var(--primary, #4652ff); color: #fff; }
.web-chat__product-buy:disabled { opacity: .65; cursor: default; }

html.dark .web-chat__product { background: var(--card, #1b1c21); border-color: var(--line, #2c2e35); }
html.dark .web-chat__product-photo { background: var(--surface, #24262d); }

.web-chat__contact {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--line, #e8e8e8);
    background: var(--surface, #f8f9fb);
}

.web-chat__contact[hidden] { display: none; }

.web-chat__contact-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.web-chat__contact-hide {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: var(--muted, #8d8d8d);
    font-size: 14px;
    line-height: 1;
    padding: 2px;
    cursor: pointer;
}

.web-chat__contact-hide:hover { color: var(--ink, #2d2d32); }

.web-chat__note { margin: 0; flex: 1 1 auto; font-size: 13px; color: var(--muted, #8d8d8d); }

.web-chat__input,
.web-chat__field {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line, #e8e8e8);
    border-radius: var(--radius-sm, 8px);
    background: var(--card, #fff);
    color: inherit;
    font: inherit;
    font-size: 14px;
    resize: none;
}

.web-chat__input:focus,
.web-chat__field:focus { outline: none; border-color: var(--primary, #4652ff); }

.web-chat__form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 12px 14px;
    border-top: 1px solid var(--line, #e8e8e8);
}

.web-chat__send {
    flex: 0 0 auto;
    padding: 9px 14px;
    border: none;
    border-radius: var(--radius-sm, 8px);
    background: var(--primary, #4652ff);
    color: #fff;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.web-chat__send:hover { filter: brightness(1.06); }

html.dark .web-chat__window {
    background: var(--card, #1b1c21);
    color: var(--ink, #e8e8ea);
    border-color: var(--line, #2c2e35);
}

html.dark .web-chat__msg--shop { background: var(--surface, #24262d); }
html.dark .web-chat__contact { background: var(--surface, #24262d); border-color: var(--line, #2c2e35); }
html.dark .web-chat__form { border-color: var(--line, #2c2e35); }
html.dark .web-chat__input,
html.dark .web-chat__field { background: var(--card, #1b1c21); border-color: var(--line, #2c2e35); }

@media (max-width: 480px) {
    .web-chat { bottom: 14px; }
    .web-chat--right { right: 14px; }
    .web-chat--left { left: 14px; }

    .web-chat__window {
        width: calc(100vw - 28px);
        max-height: 72vh;
    }
}
