/* Плавающий виджет чатбота (china). Цвета — из переменных site.scss. */
.site-chat {
    --chat-primary: var(--primary, #0D2843);
    --chat-accent: var(--red, #e40e11);
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 70;
    font-family: inherit;
    font-size: 14px;
}

.site-chat__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: 0;
    border-radius: 28px;
    background: var(--chat-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    cursor: pointer;
}

.site-chat__toggle svg {
    width: 22px;
    height: 22px;
}

.site-chat.is-open .site-chat__toggle {
    display: none;
}

.site-chat__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 380px;
    height: min(600px, calc(100vh - 40px));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
    overflow: hidden;
}

.site-chat__resize {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    touch-action: none;
}

/* уголок-«хват» в шапке */
.site-chat__resize::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    border-top: 2px solid rgba(255, 255, 255, .6);
    border-left: 2px solid rgba(255, 255, 255, .6);
    border-top-left-radius: 3px;
}

.site-chat__resize:hover::before {
    border-color: #fff;
}

.site-chat.is-resizing {
    user-select: none;
}

.site-chat__panel[hidden] {
    display: none;
}

.site-chat__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 12px 22px;
    background: var(--chat-primary);
    color: #fff;
}

.site-chat__header > div {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.site-chat__header small {
    opacity: .75;
    font-size: 12px;
}

.site-chat__new,
.site-chat__close {
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.site-chat__new {
    font-size: 12px;
    text-decoration: underline;
    opacity: .85;
}

.site-chat__close {
    font-size: 26px;
    line-height: 1;
    padding: 0 4px;
}

.site-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.site-chat__welcome p {
    margin: 0 0 10px;
}

.site-chat__examples {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.site-chat__example {
    border: 1px solid #d0d4da;
    background: #fff;
    border-radius: 16px;
    padding: 6px 12px;
    text-align: left;
    cursor: pointer;
    color: var(--chat-primary);
}

.site-chat__example:hover {
    border-color: var(--chat-primary);
}

.site-chat__msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 12px;
    line-height: 1.45;
    word-wrap: break-word;
}

.site-chat__msg p {
    margin: 0 0 6px;
}

.site-chat__msg p:last-child {
    margin-bottom: 0;
}

.site-chat__msg a {
    color: var(--chat-accent);
}

.site-chat__msg--user {
    align-self: flex-end;
    background: var(--chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.site-chat__msg--assistant {
    align-self: flex-start;
    background: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.site-chat__msg--error {
    align-self: stretch;
    background: #fdecec;
    color: #9b1c1c;
    font-size: 13px;
}

.site-chat__time {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1;
    text-align: right;
    opacity: .55;
}

.site-chat__typing {
    color: #888;
    font-style: italic;
}

.site-chat__typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 2px;
    border-radius: 50%;
    background: #aaa;
    animation: site-chat-blink 1.2s infinite;
}

.site-chat__typing span:nth-child(2) {
    animation-delay: .2s;
}

.site-chat__typing span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes site-chat-blink {
    0%, 80%, 100% {
        opacity: .2;
    }
    40% {
        opacity: 1;
    }
}

.site-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e5e5e5;
    background: #fff;
    margin: 0;
}

.site-chat__form textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d0d4da;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    max-height: 120px;
}

.site-chat__form textarea:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.site-chat__form button {
    flex: none;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--chat-accent);
    color: #fff;
    cursor: pointer;
}

.site-chat__form button:disabled {
    opacity: .5;
    cursor: default;
}

.site-chat__form button svg {
    width: 18px;
    height: 18px;
}

.site-chat__note {
    margin: 0;
    padding: 0 10px 8px;
    background: #fff;
    color: #999;
    font-size: 11px;
}

/* Не перекрываем баннер cookie */
body:has(#cookie-dialog) .site-chat {
    bottom: 110px;
}

@media (max-width: 575px) {
    .site-chat {
        right: 12px;
        bottom: 12px;
    }

    .site-chat__toggle span {
        display: none;
    }

    .site-chat__toggle {
        padding: 14px;
    }

    .site-chat.is-open {
        inset: 0;
    }

    .site-chat__panel {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
    }

    .site-chat__resize {
        display: none;
    }
}
