.ai-chat-widget {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 1050;
    font-family: inherit;
}

.ai-chat-widget__toggle {
    width: 50px;
    height: 50px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background-color: var(--main-color-one);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    font-size: 25px;
    line-height: 50px;
    text-align: center;
}

.ai-chat-widget__toggle:focus,
.ai-chat-widget__toggle:active {
    outline: 0;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.back-to-top {
    bottom: 96px;
}

.ai-chat-widget__panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    display: flex;
    width: min(360px, calc(100vw - 32px));
    height: min(520px, calc(100vh - 120px));
    overflow: hidden;
    flex-direction: column;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.ai-chat-widget__header {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 16px;
    color: #172033;
    border-bottom: 1px solid #edf0f5;
    font-weight: 600;
}

.ai-chat-widget__close,
.ai-chat-widget__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.ai-chat-widget__close {
    width: 36px;
    height: 36px;
    color: #5f6b7a;
}

.ai-chat-widget__messages {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding: 14px;
    background: #f7f9fc;
}

.ai-chat-widget__message {
    max-width: 86%;
    padding: 9px 11px;
    border-radius: 8px;
    color: #182230;
    background: #fff;
    font-size: 14px;
    line-height: 1.42;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ai-chat-widget__message p,
.ai-chat-widget__message ul,
.ai-chat-widget__message ol {
    margin: 0 0 8px;
}

.ai-chat-widget__message p:last-child,
.ai-chat-widget__message ul:last-child,
.ai-chat-widget__message ol:last-child {
    margin-bottom: 0;
}

.ai-chat-widget__message ul,
.ai-chat-widget__message ol {
    padding-left: 18px;
}

.ai-chat-widget__message li {
    margin-bottom: 0;
}

.ai-chat-widget__message a {
    color: inherit;
    text-decoration: underline;
}

.ai-chat-widget__typing {
    display: inline-flex;
    min-width: 34px;
    min-height: 18px;
    align-items: center;
    gap: 5px;
    vertical-align: middle;
}

.ai-chat-widget__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #697586;
    animation: ai-chat-typing 1.1s ease-in-out infinite;
}

.ai-chat-widget__typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-chat-widget__typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ai-chat-typing {
    0%,
    70%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    35% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.ai-chat-widget__message--user {
    align-self: flex-end;
    color: #fff;
    background: #364771;
}

.ai-chat-widget__message--assistant {
    align-self: flex-start;
}

.ai-chat-widget__message--error {
    align-self: flex-start;
    color: #8a1f11;
    background: #fff0ec;
}

.ai-chat-widget__form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px;
    border-top: 1px solid #edf0f5;
    background: #fff;
}

.ai-chat-widget__input {
    min-height: 44px;
    max-height: 120px;
    flex: 1;
    resize: none;
    border: 1px solid #d6dbe3;
    border-radius: 8px;
    padding: 9px 10px;
    color: #172033;
    font: inherit;
    line-height: 1.35;
}

.ai-chat-widget__input:focus {
    outline: 2px solid rgba(255, 180, 0, 0.35);
    border-color: #ffb400;
}

.ai-chat-widget__send {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 50%;
    color: #fff;
    background: #ffb400;
}

.ai-chat-widget__send:disabled,
.ai-chat-widget__input:disabled {
    cursor: wait;
    opacity: 0.65;
}

@media (max-width: 575px) {
    .ai-chat-widget {
        right: 20px;
        bottom: 20px;
    }

    .ai-chat-widget__toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
        line-height: 40px;
    }

    .back-to-top {
        right: 20px;
        bottom: 88px;
    }

    .ai-chat-widget__panel {
        width: calc(100vw - 32px);
        height: min(520px, calc(100vh - 104px));
    }
}
