/* Основной контейнер */
body.chat-lock-scroll {
    overflow: hidden;
    touch-action: none; /* помогает на мобильных */
}
#chat-widget.chat-widget {
    position: fixed;
    background: linear-gradient(
        to right,
        rgba(18, 19, 22, 1),
        rgba(14, 41, 85, 1)
    );
    box-shadow: 0px 0px 10px rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: visible;
    line-height: 1.3;
    font-size: 16px;
    font-weight: 300 !important;
    max-height: calc(100vh - 30px);
}

#chat-widget {
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: #6b3d9f rgb(6, 10, 40);
    /* Firefox */
    overflow-y: auto;
}

/* WebKit (Chrome, Safari, Edge) */
#chat-widget::-webkit-scrollbar {
    width: 8px;
}

#chat-widget::-webkit-scrollbar-track {
    background: rgba(6, 40, 28, 1);
    border-radius: 4px;
}

#chat-widget::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #ec6aa9, #6b3d9f);
    border-radius: 4px;
}

#chat-widget::-webkit-scrollbar-thumb:hover {
    background: rgba(20, 60, 120, 1);
    /* немного светлее при наведении */
}

#chat-widget.chat-widget b {
    font-weight: 400 !important;
}

/* Шапка */
.chat-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 15px;
    color: #fff;
    gap: 15px;
    border-radius: 10px 10px 0 0;
}

.chat-header__img {
    width: 60px;
    height: 60px;
    background-color: #fff;
    padding: 0;
    border-radius: 50%;
}

/* Кнопка "свернуть" */
.chat-header__toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
    color: #fff;
    display: flex;
    gap: 10px;

}
.chat-header__toggle-img_minsize {
    display: none;
}

.chat-header__toggle:hover .fill {
    fill: #7c49b6;
}

.chat-header__toggle:hover .stroke {
    stroke: #7c49b6;
}

.chat-header__toggle-img_open {
    display: none;
}

/* Область контента */
.chat-body {
    display: block;
    overflow-y: auto;
    border-radius: 0 0 10px 10px;
    position: relative;
    overflow: hidden;
    min-width: 300px;
    max-width: calc(100vw - 80px);
    max-height: calc(100vh - 150px);
    resize: none;
}
.chat-body.fullscreen {
    width: calc(100vw - 80px) !important;
    height: calc(100vh - 150px) !important;
}

.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
    z-index: 10;
}

/* Вся внутренняя часть */
.chat-box {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Сообщения */

.chat-messages {
    flex: 1;
    padding: 10px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    color: #fff;
    background: linear-gradient(
        to right,
        rgba(6, 40, 28, 1),
        rgba(40, 23, 51, 1)
    );
    overflow-x: hidden;
}

.chat-messages hr {
    background-color: #ffffff;
    margin: 2em 0 0.5em;
}

.chat-message {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 24px;
    max-width: 80%;
    word-break: break-word;
}

.chat-message.assistant {
    background: #486b68;
    align-self: flex-start;
    border-radius: 0px 24px 24px;
}

.chat-message.user {
    background: #2c7998;
    align-self: flex-end;
}

.chat-message.typing {
    /*min-height: 40px;*/
    width: 100%;
    display: flex;
    align-items: center;
}

.typing {
    position: relative;
}

.typing .dot {
    content: "";
    animation: blink 1.5s infinite;
    animation-fill-mode: both;
    height: 5px;
    width: 5px;
    position: absolute;
    background: #fff;
    border-radius: 50%;
    text-align: left;
}

.typing .dot-2 {
    animation-delay: 0.2s;
    margin-left: 10px;
    /* 10px * 1.5 */
}

.typing .dot-3 {
    animation-delay: 0.4s;
    margin-left: 20px;
    /* 10px * 3 */
}

@keyframes blink {
    0% {
        opacity: 0.1;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0.1;
    }
}

/* Ввод и кнопки */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 2px 0 6px #48355e91;
    padding: 5px 12px;
    border-top: 1px solid #48355e;
}

.chat-input {
    flex: 1;
    box-sizing: border-box;
    width: 100%;
    margin: 0 !important;
    padding: 10px 15px !important;
    font-family: inherit;
    font-size: 16px !important;
    color: #fff !important;
    background-color: transparent !important;
    border: 0 !important;
    outline: 0 !important;
    resize: none;
    overflow: hidden;
    resize: none;
    overflow-y: auto;
    height: calc(1.2em * 4);
    line-height: 1.2em;
    min-height: calc(1.2rem * 4);
    border-radius: 0 !important;
}

textarea::placeholder {
    color: #d2d2d2 !important;
}

.chat-send-wrap {
    display: inline-block;
    padding: 2px;
    border-radius: 16px !important;
    background: linear-gradient(to right, #dd60a5, #7c49b6, #1886c2) !important;
}

.chat-send {
    all: unset;
    display: block;
    background: #121316 !important;
    white-space: nowrap;
    color: #fff !important;
    padding: 20px 11px !important;
    box-sizing: border-box;
    cursor: pointer;
    border-radius: 12px !important;
    min-width: 100px;
    text-align: center;
    border: none !important;
    font-size: 16px !important;
}

.chat-send:hover {
    background: #004b54;
}

.chat-reset-wrap {
    width: 100%;
    border-top: 1px solid #0f2954;
    display: flex;
}

.chat-reset {
    all: unset;
    padding: 5px;
    white-space: nowrap;
    color: #fff;
    cursor: pointer;
    text-align: right;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;

    width: auto;
    margin-left: auto;
}

.chat-reset__text {
    font-size: 14px;
}

.chat-reset:hover .chat-reset__text {
    color: #afebff;
}

.chat-reset:hover .fill {
    fill: #afebff;
}

.chat-reset:hover .stroke {
    stroke: #afebff;
}

.custom-tooltip {
    position: absolute;
    top: 10px;
    left: calc(100% - 10px);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    z-index: 10000;
}

.chat-widget.minify {
    border-radius: 50% !important;
    cursor: pointer;
    background: transparent !important;
    box-shadow: none !important;
}

.chat-widget.minify .chat-header {
    border-radius: 50%;
    padding: 5px;
    gap: 10px;
    border-radius: 40px;
    transition: transform 0.4s ease;
    border: 1px solid #bbbbbb;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.7);
    background: linear-gradient(to right, #743c5a, #5f3f5d, #083e59) !important;
}

.chat-widget.minify:hover .chat-header {
    transform: scale(1.15);
}

.chat-widget.minify .chat-header__img {
    width: 80px;
    height: 80px;
}

.chat-widget.minify:hover .custom-tooltip {
    /*opacity: 1;*/
}

.chat-widget.minify .chat-header__text {
    font-size: 14px;
    margin-right: 10px;
    font-weight: 400 !important;
}

.chat-widget.minify .chat-header__toggle {
    display: none;
}

@media (max-width: 768px) {
    #chat-widget.chat-widget {
        left: 5vw !important;
    }

    .chat-widget {
        width: 90vw !important;
        max-width: 500px !important;
    }

    .chat-body {
        width: 90vw !important;
        max-width: 500px !important;
    }
    .chat-body.fullscreen {
        width: 90vw !important;
        height: calc(100dvh - 130px) !important;
    }

    .chat-widget.minify {
        width: auto !important;
    }

    .chat-widget.minify .chat-header__text {
        display: none;
    }

    .chat-widget.minify .chat-header {
        border-radius: 50%;
    }

    .chat-widget.minify:hover .chat-header {
        transform: none;
    }
}

html[dir="rtl"] .chat-header__toggle {
    margin-left: 0;
    margin-right: auto;
}