/* =========================
   SUPPORT CHAT WIDGET
========================= */

.support-chat,
.support-chat * {
    box-sizing: border-box;
}

.support-chat {
    --support-chat-bottom: 104px;
    --support-chat-window-gap: 78px;
    --support-chat-top-safe: 18px;

    position: fixed;
    right: 22px;
    left: auto;
    bottom: var(--support-chat-bottom);
    z-index: 2200;
    font-family: "Montserrat", sans-serif;
    transition: bottom 0.35s ease;
}

/* если появилась кнопка scroll-top, чат поднимается выше WhatsApp */
body.scroll-top-visible .support-chat {
    --support-chat-bottom: 168px;
    bottom: var(--support-chat-bottom);
}

.support-chat__launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border: 0;
    border-radius: 22px;
    cursor: pointer;
    color: #ffffff;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.26), transparent 32%),
        linear-gradient(135deg, #123b78 0%, #1e67c8 100%);
    box-shadow:
        0 18px 38px rgba(30, 103, 200, 0.28),
        0 0 0 8px rgba(30, 103, 200, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        transform 0.28s ease,
        box-shadow 0.28s ease,
        border-radius 0.28s ease;
}

.support-chat__launcher:hover {
    transform: translateY(-4px) scale(1.03);
    border-radius: 19px;
    box-shadow:
        0 24px 52px rgba(30, 103, 200, 0.34),
        0 0 0 12px rgba(30, 103, 200, 0.10);
}

.support-chat__launcher svg {
    width: 30px;
    height: 30px;
}

.support-chat__launcher-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 26px;
    border: 1px solid rgba(30, 103, 200, 0.35);
    animation: supportChatPulse 2.4s ease-out infinite;
}

@keyframes supportChatPulse {
    0% {
        opacity: 0.75;
        transform: scale(0.92);
    }

    100% {
        opacity: 0;
        transform: scale(1.35);
    }
}

/* =========================
   Notice
========================= */

.support-chat__notice {
    position: absolute;
    right: 76px;
    left: auto;
    bottom: 4px;
    width: 265px;
    padding: 16px 42px 16px 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(16, 24, 40, 0.08);
    box-shadow: 0 22px 55px rgba(15, 31, 54, 0.16);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(12px) translateY(8px) scale(0.96);
    transition:
        opacity 0.32s ease,
        visibility 0.32s ease,
        transform 0.32s ease;
}

.support-chat__notice.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0) translateY(0) scale(1);
}

.support-chat__notice strong {
    display: block;
    color: #101828;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 900;
}

.support-chat__notice span {
    display: block;
    margin-top: 5px;
    color: #667085;
    font-size: 12px;
    line-height: 1.35;
    font-weight: 600;
}

.support-chat__notice-close {
    position: absolute;
    right: 11px;
    top: 10px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    background: #f1f4f8;
    color: #667085;
    font-size: 18px;
    line-height: 1;
}

/* =========================
   Window desktop
========================= */

.support-chat__window {
    position: absolute;

    /* На ПК окно открывается сбоку от кнопки */
    right: calc(100% + 16px);
    left: auto;
    bottom: 0;

    width: 390px;
    height: min(
        590px,
        calc(
            100vh
            - var(--support-chat-bottom)
            - var(--support-chat-top-safe)
        )
    );

    min-height: 0;
    border-radius: 30px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(16, 24, 40, 0.08);
    box-shadow: 0 34px 100px rgba(15, 31, 54, 0.24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(18px) scale(0.96);
    transform-origin: right bottom;
    transition:
        opacity 0.32s ease,
        visibility 0.32s ease,
        transform 0.32s ease;
}

.support-chat__window.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0) scale(1);
}

/* =========================
   Header
========================= */

.support-chat__header {
    min-height: 84px;
    height: 84px;
    padding: 18px;
    background:
        radial-gradient(circle at 12% 20%, rgba(98, 164, 255, 0.22), transparent 30%),
        linear-gradient(135deg, #101828 0%, #152238 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.support-chat__header-left {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.support-chat__logo {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.support-chat__logo span {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 7px rgba(52, 211, 153, 0.12);
}

.support-chat__header strong {
    display: block;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 900;
}

.support-chat__header p {
    margin: 4px 0 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    line-height: 1.25;
    font-weight: 600;
}

.support-chat__close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
}

/* =========================
   Start
========================= */

.support-chat__start {
    height: calc(100% - 84px);
    padding: 26px;
    overflow-y: auto;
}

.support-chat__start-icon {
    width: 58px;
    height: 58px;
    border-radius: 20px;
    color: #1e67c8;
    background: rgba(30, 103, 200, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.support-chat__start-icon svg {
    width: 30px;
    height: 30px;
}

.support-chat__start h3 {
    margin: 0;
    color: #101828;
    font-size: 28px;
    line-height: 1;
    letter-spacing: -0.055em;
    font-weight: 900;
}

.support-chat__start p {
    margin: 14px 0 0;
    color: #667085;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 500;
}

.support-chat__form {
    margin-top: 24px;
    display: grid;
    gap: 14px;
}

.support-chat__form label {
    display: grid;
    gap: 8px;
    color: #344054;
    font-size: 12px;
    font-weight: 900;
}

.support-chat__form input {
    width: 100%;
    height: 52px;
    border: 1px solid rgba(16, 24, 40, 0.12);
    border-radius: 17px;
    padding: 0 16px;
    outline: none;
    background: #f7f9fc;
    color: #101828;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
}

.support-chat__form input:focus {
    border-color: rgba(30, 103, 200, 0.45);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(30, 103, 200, 0.10);
}

.support-chat__form button {
    height: 54px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    color: #ffffff;
    background: linear-gradient(135deg, #123b78, #1e67c8);
    font-family: inherit;
    font-size: 14px;
    font-weight: 900;
    box-shadow: 0 18px 36px rgba(30, 103, 200, 0.22);
}

/* =========================
   Dialog
========================= */

.support-chat__dialog {
    height: calc(100% - 84px);
    display: none;
    flex-direction: column;
    background: #f4f6f9;
    min-height: 0;
}

.support-chat__dialog.is-active {
    display: flex;
}

.support-chat__agent {
    margin: 14px;
    padding: 13px;
    border-radius: 20px;
    background: #ffffff;
    border: 1px solid rgba(16, 24, 40, 0.08);
    box-shadow: 0 14px 34px rgba(15, 31, 54, 0.08);
    display: none;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.support-chat__agent.is-visible {
    display: flex;
}

.support-chat__agent-photo {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 16px;
    background: #e8eef7;
    overflow: hidden;
    position: relative;
}

.support-chat__agent-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.support-chat__agent-photo span {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #34d399;
    border: 2px solid #ffffff;
}

.support-chat__agent strong {
    display: block;
    color: #101828;
    font-size: 13px;
    line-height: 1.2;
    font-weight: 900;
}

.support-chat__agent p {
    margin: 4px 0 0;
    color: #667085;
    font-size: 12px;
    line-height: 1.25;
    font-weight: 600;
}

.support-chat__messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 4px 14px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.support-chat__message {
    max-width: 82%;
    padding: 12px 14px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.45;
    font-weight: 600;
    animation: supportMessageIn 0.24s ease both;
}

@keyframes supportMessageIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.support-chat__message--client {
    align-self: flex-end;
    color: #ffffff;
    background: linear-gradient(135deg, #123b78, #1e67c8);
    border-bottom-right-radius: 6px;
}

.support-chat__message--agent {
    align-self: flex-start;
    color: #101828;
    background: #ffffff;
    border: 1px solid rgba(16, 24, 40, 0.08);
    border-bottom-left-radius: 6px;
}

.support-chat__message--system {
    align-self: center;
    max-width: 92%;
    padding: 9px 12px;
    color: #667085;
    background: rgba(16, 24, 40, 0.06);
    font-size: 12px;
    text-align: center;
    border-radius: 999px;
}

.support-chat__message-form {
    flex: 0 0 auto;
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid rgba(16, 24, 40, 0.08);
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.support-chat__message-form textarea {
    flex: 1;
    max-height: 110px;
    min-height: 46px;
    border: 1px solid rgba(16, 24, 40, 0.10);
    border-radius: 17px;
    padding: 13px 14px;
    resize: none;
    outline: none;
    background: #f7f9fc;
    color: #101828;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 600;
}

.support-chat__message-form textarea:focus {
    background: #ffffff;
    border-color: rgba(30, 103, 200, 0.42);
}

.support-chat__message-form button {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border: 0;
    border-radius: 16px;
    cursor: pointer;
    color: #ffffff;
    background: linear-gradient(135deg, #123b78, #1e67c8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.support-chat__message-form button svg {
    width: 21px;
    height: 21px;
}

/* =========================
   New chat button
========================= */

.support-chat__new-chat-btn {
    align-self: center;
    margin: 10px auto 4px;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    background: linear-gradient(135deg, #123b78, #1e67c8);
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    box-shadow: 0 14px 28px rgba(30, 103, 200, 0.22);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.support-chat__new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px rgba(30, 103, 200, 0.28);
}

.support-chat__message-form button:disabled,
.support-chat__message-form textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* =========================
   Mobile
========================= */

@media (max-width: 640px) {
    .support-chat {
        --support-chat-bottom: 86px;

        right: 14px;
        left: auto;
        bottom: var(--support-chat-bottom);
        z-index: 5200;
    }

    body.scroll-top-visible .support-chat {
        --support-chat-bottom: 150px;
        bottom: var(--support-chat-bottom);
    }

    .support-chat__launcher {
        width: 56px;
        height: 56px;
        border-radius: 19px;
    }

    .support-chat__launcher svg {
        width: 27px;
        height: 27px;
    }

    .support-chat__notice {
        right: 0;
        left: auto;
        bottom: 70px;
        width: min(310px, calc(100vw - 28px));
    }

    /*
        На мобилке окно становится почти full-screen.
        Оно больше не зависит от положения кнопки, WhatsApp и scroll-top.
    */
    .support-chat__window {
        position: fixed;
        left: 10px;
        right: 10px;
        top: 10px;
        bottom: 10px;

        width: auto;
        height: auto;
        max-width: none;
        max-height: none;

        border-radius: 26px;
        transform: translateY(18px) scale(0.96);
        transform-origin: center bottom;
        box-shadow: 0 24px 80px rgba(7, 12, 22, 0.34);
    }

    @supports (height: 100dvh) {
        .support-chat__window {
            top: 10px;
            bottom: 10px;
            height: auto;
            max-height: calc(100dvh - 20px);
        }
    }

    .support-chat__window.is-open {
        transform: translateY(0) scale(1);
    }

    .support-chat__header {
        height: 76px;
        min-height: 76px;
        padding: 14px;
    }

    .support-chat__logo {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        border-radius: 15px;
    }

    .support-chat__header strong {
        font-size: 14px;
    }

    .support-chat__header p {
        font-size: 11px;
    }

    .support-chat__close {
        width: 34px;
        height: 34px;
        font-size: 23px;
    }

    .support-chat__start {
        height: calc(100% - 76px);
        padding: 20px;
    }

    .support-chat__start-icon {
        width: 52px;
        height: 52px;
        border-radius: 18px;
        margin-bottom: 16px;
    }

    .support-chat__start h3 {
        font-size: 24px;
        letter-spacing: -0.045em;
    }

    .support-chat__start p {
        font-size: 13px;
        line-height: 1.55;
    }

    .support-chat__form {
        margin-top: 18px;
        gap: 12px;
    }

    .support-chat__form input {
        height: 50px;
        border-radius: 16px;
        font-size: 13px;
    }

    .support-chat__form button {
        height: 52px;
        font-size: 13px;
    }

    .support-chat__dialog {
        height: calc(100% - 76px);
    }

    .support-chat__agent {
        margin: 10px;
        padding: 10px;
        border-radius: 18px;
    }

    .support-chat__agent-photo {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        border-radius: 15px;
    }

    .support-chat__messages {
        padding: 4px 10px 10px;
        gap: 8px;
    }

    .support-chat__message {
        max-width: 88%;
        padding: 11px 13px;
        border-radius: 16px;
        font-size: 13px;
    }

    .support-chat__message-form {
        padding: 10px;
        gap: 8px;
    }

    .support-chat__message-form textarea {
        min-height: 44px;
        max-height: 96px;
        padding: 12px 13px;
        border-radius: 16px;
        font-size: 13px;
    }

    .support-chat__message-form button {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
        border-radius: 15px;
    }
}

@media (max-width: 380px) {
    .support-chat__window {
        left: 8px;
        right: 8px;
        top: 8px;
        bottom: 8px;
        border-radius: 22px;
    }

    .support-chat__header {
        height: 72px;
        min-height: 72px;
    }

    .support-chat__start {
        height: calc(100% - 72px);
        padding: 18px;
    }

    .support-chat__dialog {
        height: calc(100% - 72px);
    }

    .support-chat__message {
        max-width: 92%;
        font-size: 12px;
    }
}