.ai-chat {
    --ai-chat-navy: #07163c;
    --ai-chat-red: #e30613;
    position: relative;
    width: 150px;
    flex: 0 0 auto;
    z-index: 10000;
    font-family: Montserrat, Arial, sans-serif;
}

.ai-chat,
.ai-chat * {
    box-sizing: border-box;
}

.ai-chat button,
.ai-chat textarea {
    font: inherit;
}

.ai-chat .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ai-chat__launcher {
    position: relative;
    display: flex;
    width: 150px;
    height: 50px;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    color: var(--ai-chat-navy);
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(110deg, #4987ff, #c270f4 25%, #ff6f7d 50%, #ffc52d 75%, #46bea3) border-box;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
}

.ai-chat__launcher[hidden] {
    display: none;
}

.ai-chat__launcher--wide {
    display: none;
}

.ai-chat__launcher::before {
    display: none;
}

.ai-chat__avatar {
    position: relative;
    z-index: 1;
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    overflow: hidden;
    background: #f1f2f5;
    border: 0;
    border-radius: 50%;
}

.ai-chat__avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ai-chat__launcher-copy {
    position: relative;
    z-index: 1;
    display: grid;
    min-width: 0;
    flex: 1;
    grid-template-columns: 1fr auto;
    font-size: 9px;
    line-height: 1.2;
}

.ai-chat__launcher-copy strong {
    grid-column: 1;
    color: var(--ai-chat-red);
    font-size: 11px;
    font-weight: 700;
}

.ai-chat__launcher-copy span {
    grid-column: 1;
    white-space: nowrap;
}

.ai-chat__launcher-copy b {
    display: grid;
    width: 20px;
    height: 20px;
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    place-items: center;
    color: #fff;
    background: var(--ai-chat-red);
    border-radius: 50%;
    font-size: 0;
    font-weight: 400;
    line-height: 1;
}

.ai-chat__launcher-copy b svg {
    width: 10px;
    height: 10px;
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat__mobile-copy {
    display: none;
}

.ai-chat__dialog {
    position: fixed;
    right: 24px;
    bottom: 28px;
    display: flex;
    width: min(390px, calc(100vw - 24px));
    height: min(650px, calc(100vh - 40px));
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e6e8ee;
    border-radius: 24px;
    box-shadow: 0 16px 48px rgba(7, 22, 60, .24);
}

.ai-chat__dialog[hidden] {
    display: none;
}

.ai-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    color: #fff;
    background: var(--ai-chat-navy);
}

.ai-chat__header img {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    object-fit: contain;
    border-radius: 50%;
}

.ai-chat__header div {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.ai-chat__header strong {
    font-size: 17px;
}

.ai-chat__header span {
    margin-top: 2px;
    color: #cdd4e5;
    font-size: 12px;
}

.ai-chat__reset,
.ai-chat__close {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    padding: 0;
    color: #fff;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.ai-chat__reset svg,
.ai-chat__close svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat__reset:hover,
.ai-chat__close:hover {
    background: rgba(255, 255, 255, .12);
}

.ai-chat__messages {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 18px 14px;
    background: #f6f7fa;
}

.ai-chat__message {
    max-width: 84%;
    padding: 11px 14px;
    border-radius: 18px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.45;
}

.ai-chat__message--assistant {
    align-self: flex-start;
    color: var(--ai-chat-navy);
    background: #fff;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 3px rgba(7, 22, 60, .08);
}

.ai-chat__message--assistant a {
    color: var(--ai-chat-red);
    font-weight: 600;
    text-decoration: underline;
}

.ai-chat__message--user {
    align-self: flex-end;
    color: #fff;
    background: var(--ai-chat-navy);
    border-bottom-right-radius: 5px;
}

.ai-chat__status {
    min-height: 22px;
    padding: 3px 16px;
    color: #72798b;
    background: #fff;
    font-size: 12px;
}

.ai-chat__form {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 14px;
    background: #fff;
    border-top: 1px solid #eceef3;
}

.ai-chat__form textarea {
    width: 0;
    min-height: 44px;
    min-width: 0;
    max-height: 120px;
    flex: 1;
    resize: none;
    padding: 11px 14px;
    color: var(--ai-chat-navy);
    background: #f6f7fa;
    border: 1px solid #dfe2ea;
    border-radius: 16px;
    outline: none;
}

.ai-chat__form textarea:focus {
    border-color: var(--ai-chat-navy);
}

.ai-chat__form button {
    position: relative;
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    color: #fff;
    background: var(--ai-chat-red);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
}

.ai-chat__form button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat__form button:disabled,
.ai-chat__form textarea:disabled {
    cursor: not-allowed;
    opacity: .55;
}

@media (min-width: 1920px) {
    .ai-chat__launcher--wide {
        position: fixed;
        display: flex;
        top: 250px;
        left: 0;
        width: 142px;
        min-width: 142px;
        height: 326px;
        flex-direction: column;
        gap: 14px;
        padding: 20px 12px 18px 20px;
        overflow: hidden;
        background: #fff;
        border: 0;
        border-radius: 0 20px 20px 0;
        box-shadow: 0 10px 32px rgba(7, 22, 60, .2);
    }

    .ai-chat__launcher--wide[hidden] {
        display: none;
    }

    .ai-chat__launcher--wide::before {
        content: "";
        position: absolute;
        display: block;
        top: 0;
        bottom: 0;
        left: 0;
        width: 8px;
        height: auto;
        background: linear-gradient(180deg, #4987ff 0%, #c270f4 26%, #ff6f7d 50%, #ffc52d 72%, #46bea3 100%);
        border: 0;
        border-radius: 0;
        transform: none;
    }

    .ai-chat__launcher--wide .ai-chat__avatar {
        width: 96px;
        height: 96px;
        flex-basis: 96px;
        background: #f1f2f5;
        box-shadow: none;
    }

    .ai-chat__launcher--wide .ai-chat__mobile-copy {
        position: relative;
        z-index: 1;
        display: flex;
        width: 100%;
        flex: 1;
        flex-direction: column;
        align-items: flex-start;
        color: var(--ai-chat-navy);
        text-align: left;
    }

    .ai-chat__launcher--wide .ai-chat__mobile-copy strong {
        color: var(--ai-chat-red);
        font-size: 18px;
        line-height: 1.2;
    }

    .ai-chat__launcher--wide .ai-chat__mobile-copy span {
        margin-top: 16px;
        font-size: 16px;
        font-weight: 600;
        line-height: 1.45;
    }

    .ai-chat__launcher--wide .ai-chat__mobile-copy i {
        width: 64px;
        height: 2px;
        margin-top: 16px;
        background: #dfe2ea;
    }

    .ai-chat__launcher--wide .ai-chat__mobile-copy b {
        display: grid;
        width: 44px;
        height: 44px;
        margin-top: auto;
        place-items: center;
        color: #fff;
        background: var(--ai-chat-red);
        border-radius: 12px;
        font-size: 0;
        font-style: normal;
        font-weight: 400;
        line-height: 1;
    }

    .ai-chat__launcher--wide .ai-chat__mobile-copy b svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 3;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .ai-chat__dialog {
        right: 24px;
        bottom: 28px;
    }
}

@media (max-width: 991px) {
    .ai-chat {
        width: 50px;
    }

    .ai-chat__launcher {
        width: 50px;
        min-width: 50px;
        justify-content: center;
        padding: 4px;
    }

    .ai-chat__launcher-copy {
        display: none;
    }

    .ai-chat__dialog {
        right: 12px;
        bottom: 72px;
        width: calc(100vw - 24px);
        height: calc(100dvh - 88px);
        border-radius: 20px;
    }
}

/* SulpakDos redesign */
.ai-chat__backdrop {
    position: fixed;
    z-index: 9998;
    inset: 0;
    background: rgba(0, 0, 0, .58);
}

.ai-chat__backdrop[hidden] {
    display: none;
}

.ai-chat__dialog {
    z-index: 9999;
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: min(752px, calc(100vw - 48px));
    height: min(654px, calc(100dvh - 64px));
    overflow: hidden;
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(115deg, #3d8bff 0%, #d94eff 24%, #ff5575 46%, #ffc52d 72%, #20cf9f 100%) border-box;
    border: 3px solid transparent;
    border-radius: 22px;
    box-shadow: 0 18px 52px rgba(0, 0, 0, .24);
    transform: translate(-50%, -50%);
}

.ai-chat__header {
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    left: 0;
    height: 0;
    padding: 0;
    background: transparent;
}

.ai-chat__header > img,
.ai-chat__header > div,
.ai-chat__reset {
    display: none;
}

.ai-chat__close {
    position: absolute;
    top: 24px;
    right: 22px;
    width: 40px;
    height: 40px;
    color: #17213d;
}

.ai-chat__close:hover {
    background: #f4f5f7;
}

.ai-chat__messages {
    gap: 14px;
    padding: 29px 72px 18px 24px;
    background: transparent;
}

.ai-chat__message-row {
    display: flex;
    max-width: 100%;
    align-items: flex-start;
    align-self: flex-start;
    gap: 13px;
}

.ai-chat__message-avatar {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    object-fit: contain;
}

.ai-chat__message {
    max-width: min(520px, calc(100% - 61px));
    padding: 13px 17px;
    color: #17213d;
    background: #fff;
    border: 1px solid #e5e6e9;
    border-radius: 13px;
    box-shadow: 0 1px 5px rgba(7, 22, 60, .05);
    font-size: 14px;
    line-height: 1.45;
}

.ai-chat__message-row .ai-chat__message {
    max-width: calc(100% - 61px);
}

.ai-chat__message--assistant {
    border-bottom-left-radius: 13px;
    box-shadow: 0 1px 5px rgba(7, 22, 60, .05);
}

.ai-chat__message--user {
    max-width: 76%;
    color: #fff;
    background: var(--ai-chat-red);
    border-color: var(--ai-chat-red);
    border-bottom-right-radius: 5px;
}

.ai-chat__quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: stretch;
    padding: 2px 0 4px 61px;
}

.ai-chat__quick-reply {
    max-width: 100%;
    padding: 9px 14px;
    color: #17213d;
    background: #fff;
    border: 1px solid #e5e6e9;
    border-radius: 999px;
    box-shadow: 0 1px 4px rgba(7, 22, 60, .05);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.ai-chat__quick-reply:hover:not(:disabled) {
    color: var(--ai-chat-red);
    background: #fff7f7;
    border-color: #f3b6ba;
}

.ai-chat__quick-reply:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.ai-chat__status {
    min-height: 0;
    padding: 0 24px;
    background: transparent;
}

.ai-chat__status:not(:empty) {
    min-height: 22px;
    padding-top: 3px;
}

.ai-chat__form {
    width: auto;
    min-height: 68px;
    align-items: center;
    margin: 0 22px 25px;
    padding: 8px 9px 8px 18px;
    background: #fff;
    border: 1px solid #e4e5e8;
    border-radius: 22px;
    box-shadow: 0 1px 5px rgba(7, 22, 60, .04);
}

.ai-chat__form textarea {
    min-height: 42px;
    padding: 10px 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    font-size: 14px;
}

.ai-chat__form textarea:focus {
    border-color: transparent;
}

.ai-chat__form button {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    border-radius: 50%;
}

.ai-chat__form button svg {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 25px;
    height: 25px;
    fill: currentColor;
    stroke: none;
    transform: translate(-50%, -50%);
}

@media (max-width: 991px) {
    .ai-chat {
        --ai-chat-viewport-height: 100dvh;
        --ai-chat-viewport-top: 0px;
        width: 64px;
    }

    body.ai-chat-open .header__mobile {
        display: none;
    }

    .ai-chat__launcher {
        width: 64px;
        min-width: 64px;
        height: 76px;
        flex-direction: column;
        gap: 0;
        padding: 3px 4px 4px;
        border-radius: 13px;
    }

    .ai-chat__launcher::after {
        content: attr(data-ai-label);
        color: #17213d;
        font-size: 13px;
        font-weight: 600;
        line-height: 18px;
    }

    .ai-chat__launcher .ai-chat__avatar {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }

    .ai-chat__backdrop {
        display: none;
    }

    .ai-chat__dialog {
        top: var(--ai-chat-mobile-top, 122px);
        right: 12px;
        bottom: auto;
        left: 12px;
        width: auto;
        height: min(560px, calc(var(--ai-chat-viewport-height) + var(--ai-chat-viewport-top) - var(--ai-chat-mobile-top, 122px) - 20px));
        max-height: calc(var(--ai-chat-viewport-height) - 20px);
        border-width: 1.5px;
        border-radius: 20px;
        box-shadow: 0 10px 30px rgba(7, 22, 60, .12);
        transform: none;
    }

    .ai-chat--keyboard-open .ai-chat__dialog {
        top: calc(var(--ai-chat-viewport-top) + 8px);
        height: calc(var(--ai-chat-viewport-height) - 16px);
        max-height: none;
    }

    .ai-chat__header {
        position: relative;
        display: flex;
        height: 96px;
        flex: 0 0 96px;
        gap: 12px;
        padding: 15px 18px;
        color: #17213d;
        background:
            linear-gradient(#fff, #fff) padding-box,
            linear-gradient(90deg, #3d8bff, #d94eff 25%, #ff5575 48%, #ffc52d 72%, #20cf9f) border-box;
        border-bottom: 1.5px solid transparent;
    }

    .ai-chat__header > img {
        display: block;
        width: 58px;
        height: 58px;
        flex-basis: 58px;
    }

    .ai-chat__header > div {
        display: flex;
    }

    .ai-chat__header strong {
        color: var(--ai-chat-red);
        font-size: 18px;
    }

    .ai-chat__header span {
        color: #17213d;
        font-size: 12px;
    }

    .ai-chat__close {
        position: static;
        width: 36px;
        height: 36px;
        flex-basis: 36px;
        margin-left: auto;
        color: #17213d;
    }

    .ai-chat__messages {
        padding: 26px 18px 14px;
    }

    .ai-chat__message-row {
        gap: 10px;
    }

    .ai-chat__message-avatar {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }

    .ai-chat__message {
        max-width: 82%;
        padding: 12px 14px;
        font-size: 14px;
    }

    .ai-chat__message-row .ai-chat__message {
        max-width: calc(100% - 58px);
    }

    .ai-chat__status {
        padding-right: 17px;
        padding-left: 17px;
    }

    .ai-chat__quick-replies {
        gap: 7px;
        padding-left: 58px;
    }

    .ai-chat__quick-reply {
        padding: 8px 12px;
        font-size: 12px;
    }

    .ai-chat__form {
        min-height: 56px;
        margin: 0 16px 27px;
        padding: 5px 6px 5px 16px;
        border-radius: 16px;
    }

    .ai-chat__form textarea {
        min-height: 40px;
        /* iOS zooms the page when a focused form control is below 16px. */
        font-size: 16px;
    }

    .ai-chat__form button {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }
}

@media (max-width: 420px) {
    .ai-chat__dialog {
        right: 8px;
        left: 8px;
    }

    .ai-chat__header {
        height: 82px;
        flex-basis: 82px;
        padding: 11px 13px;
    }

    .ai-chat__header > img {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
    }

    .ai-chat__header strong {
        font-size: 16px;
    }

    .ai-chat__messages {
        padding: 20px 14px 12px;
    }

    .ai-chat__form {
        margin: 0 12px 16px;
    }
}
