/* REVELMONT SUPPORT CHAT V1 */

.support-chat-widget {
    position: fixed;
    right: 20px;
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 4900;
    font-family: var(--rv-font-family, inherit);
}

.support-chat-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 52px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--rv-teal, #0f8199);
    color: #fff;
    box-shadow: 0 12px 36px rgba(15, 23, 42, .28);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.support-chat-launcher:hover {
    transform: translateY(-1px);
}

.support-chat-launcher__icon {
    font-size: 1.2rem;
}

.support-chat-launcher__badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

.support-chat-panel {
    position: absolute;
    right: 0;
    bottom: 66px;
    width: min(390px, calc(100vw - 32px));
    max-height: min(650px, calc(100vh - 120px));
    overflow: hidden;
    border: 1px solid var(--rv-line, #dbe2ea);
    border-radius: 18px;
    background: var(--rv-card, #fff);
    color: var(--rv-text, #1a2435);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.support-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    background: var(--rv-teal, #0f8199);
    color: #fff;
}

.support-chat-header strong,
.support-chat-header span {
    display: block;
}

.support-chat-header strong {
    font-size: 1rem;
}

.support-chat-header span {
    margin-top: 2px;
    opacity: .88;
    font-size: .78rem;
}

.support-chat-close {
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 1.7rem;
    line-height: 1;
}

.support-chat-start,
.support-chat-conversation {
    padding: 16px;
}

.support-chat-intro {
    margin: 0 0 14px;
    color: var(--rv-muted, #5e6878);
    font-size: .9rem;
    line-height: 1.5;
}

.support-chat-start-form label {
    display: block;
    margin-bottom: 11px;
}

.support-chat-start-form label > span:first-child {
    display: block;
    margin-bottom: 5px;
    font-size: .78rem;
    font-weight: 800;
}

.support-chat-start-form input:not([type="checkbox"]),
.support-chat-start-form textarea,
.support-chat-composer textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--rv-line, #dbe2ea);
    border-radius: 10px;
    background: var(--rv-card, #fff);
    color: inherit;
    font: inherit;
    font-size: .9rem;
}

.support-chat-start-form input:not([type="checkbox"]) {
    min-height: 42px;
    padding: 8px 10px;
}

.support-chat-start-form textarea,
.support-chat-composer textarea {
    padding: 10px;
    resize: vertical;
}

.support-chat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.support-chat-privacy {
    display: flex !important;
    align-items: flex-start;
    gap: 8px;
    color: var(--rv-muted, #5e6878);
    font-size: .72rem;
    line-height: 1.4;
}

.support-chat-privacy input {
    flex: none;
    margin-top: 2px;
}

.support-chat-privacy a {
    color: var(--rv-teal, #0f8199);
}

.support-chat-primary,
.support-chat-secondary {
    min-height: 42px;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.support-chat-primary {
    border: 1px solid var(--rv-teal, #0f8199);
    background: var(--rv-teal, #0f8199);
    color: #fff;
}

.support-chat-start-form > .support-chat-primary {
    width: 100%;
}

.support-chat-secondary {
    padding: 8px 14px;
    border: 1px solid var(--rv-line, #dbe2ea);
    background: transparent;
    color: inherit;
}

.support-chat-error {
    margin: 12px 16px 0;
    padding: 9px 11px;
    border-radius: 9px;
    background: rgba(220, 38, 38, .10);
    color: #b91c1c;
    font-size: .8rem;
}

.support-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 9px;
    height: min(360px, calc(100vh - 310px));
    min-height: 220px;
    overflow-y: auto;
    padding: 2px 2px 12px;
}

.support-chat-message {
    max-width: 85%;
    padding: 9px 11px;
    border-radius: 12px;
    font-size: .86rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.support-chat-message--visitor {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: var(--rv-teal, #0f8199);
    color: #fff;
}

.support-chat-message--operator {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background: var(--rv-teal-soft, #e6f5f7);
    color: var(--rv-text, #1a2435);
}

.support-chat-message--system {
    align-self: center;
    max-width: 95%;
    background: transparent;
    color: var(--rv-muted, #687386);
    font-size: .72rem;
    text-align: center;
}

.support-chat-message__time {
    display: block;
    margin-top: 4px;
    opacity: .7;
    font-size: .65rem;
}

.support-chat-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    padding-top: 11px;
    border-top: 1px solid var(--rv-line, #dbe2ea);
}

.support-chat-composer .support-chat-primary {
    padding: 0 14px;
}

.support-chat-closed {
    padding-top: 12px;
    border-top: 1px solid var(--rv-line, #dbe2ea);
    text-align: center;
}

.support-chat-closed p {
    margin: 0 0 9px;
    color: var(--rv-muted, #687386);
    font-size: .8rem;
}

.support-chat-honeypot {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

html[data-theme="dark"] .support-chat-panel {
    --rv-card: #111827;
    --rv-text: #e5edf7;
    --rv-muted: #9aa8ba;
    --rv-line: #334155;
}

html[data-theme="dark"] .support-chat-message--operator {
    background: #19333b;
    color: #e5edf7;
}

@media (max-width: 640px) {
    .support-chat-widget {
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .support-chat-launcher {
        min-height: 48px;
        padding: 0 15px;
    }

    .support-chat-panel {
        position: fixed;
        right: 10px;
        bottom: 72px;
        left: 10px;
        width: auto;
        max-height: calc(100dvh - 90px);
    }

    .support-chat-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .support-chat-messages {
        height: min(310px, calc(100dvh - 330px));
    }
}

/* =========================================================
   SUPPORT_CHAT_V3A_R3_PUBLIC_AVAILABILITY
   ========================================================= */

.support-chat-header__identity {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.support-chat-header__text {
    min-width: 0;
}

.support-chat-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, .7);
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 1rem;
    font-weight: 900;
}

.support-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.support-chat-widget .support-chat-presence {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    color: var(--support-muted) !important;
    font-size: .69rem;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.support-chat-presence::before {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 5px;
    border-radius: 50%;
    background: #cbd5e1;
    content: "";
}

.support-chat-presence[data-status="online"]::before {
    background: #86efac;
}

.support-chat-presence[data-status="office"]::before {
    background: #67e8f9;
}

.support-chat-presence[data-status="busy"]::before {
    background: #fbbf24;
}

.support-chat-presence[data-status="away"]::before {
    background: #fdba74;
}

.support-chat-presence[data-status="offline"]::before {
    background: #cbd5e1;
}

.support-chat-offline {
    padding: 25px 20px;
    text-align: center;
}

.support-chat-offline__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 13px;
    border-radius: 50%;
    background: var(--rv-teal-soft, #e4f4f6);
    color: var(--rv-teal, #0f8199);
    font-size: 1.35rem;
    font-weight: 900;
}

.support-chat-offline > strong {
    display: block;
    margin-bottom: 7px;
    font-size: 1rem;
}

.support-chat-offline p {
    margin: 0 auto 8px;
    max-width: 310px;
    color: var(--rv-muted, #5e6878);
    font-size: .88rem;
    line-height: 1.5;
}

.support-chat-offline__hours {
    display: block;
    margin-bottom: 17px;
    color: var(--rv-muted, #5e6878);
    font-size: .76rem;
    font-weight: 700;
}

.support-chat-email {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
}

html[data-theme="dark"] .support-chat-offline__icon {
    background: rgba(15, 129, 153, .18);
}

@media (max-width: 640px) {
    .support-chat-avatar {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
    }

    .support-chat-header__identity {
        gap: 9px;
    }

    .support-chat-offline {
        padding: 22px 16px;
    }
}

/* SUPPORT_CHAT_V3B_DYNAMIC_DESIGN */

.support-chat-widget {
    --support-font-family: "Segoe UI", Arial, sans-serif;
    --support-font-size: 14px;
    --support-heading-size: 16px;
    --support-radius: 14px;
    --support-header-bg: #0f8199;
    --support-header-text: #fff;
    --support-panel-bg: #fff;
    --support-text: #1a2435;
    --support-muted: #687386;
    --support-border: #dbe2ea;
    --support-visitor-bg: #0f8199;
    --support-visitor-text: #fff;
    --support-operator-bg: #e6f5f7;
    --support-operator-text: #1a2435;
    --support-button-bg: #0f8199;
    --support-button-text: #fff;
    --support-launcher-bg: #0f8199;
    font-family: var(--support-font-family);
}

.support-chat-widget .support-chat-launcher {
    background: var(--support-launcher-bg) !important;
    color: var(--support-button-text) !important;
}

.support-chat-widget .support-chat-panel {
    border-color: var(--support-border) !important;
    border-radius: var(--support-radius) !important;
    background: var(--support-panel-bg) !important;
    color: var(--support-text) !important;
    font-family: var(--support-font-family) !important;
}

.support-chat-widget .support-chat-header {
    background: var(--support-header-bg) !important;
    color: var(--support-header-text) !important;
}

.support-chat-widget .support-chat-header strong {
    color: var(--support-header-text) !important;
    font-size: var(--support-heading-size) !important;
}

.support-chat-widget .support-chat-message {
    border-radius: var(--support-radius) !important;
    font-size: var(--support-font-size) !important;
}

.support-chat-widget .support-chat-message--visitor {
    background: var(--support-visitor-bg) !important;
    color: var(--support-visitor-text) !important;
}

.support-chat-widget .support-chat-message--operator {
    background: var(--support-operator-bg) !important;
    color: var(--support-operator-text) !important;
}

.support-chat-widget .support-chat-primary {
    background: var(--support-button-bg) !important;
    border-color: var(--support-button-bg) !important;
    color: var(--support-button-text) !important;
    border-radius: var(--support-radius) !important;
}

/* ==================================================
   SUPPORT_CHAT_DESIGN_FORM_SYNC_V1
   Public form uses support-chat design variables.
   ================================================== */

.support-chat-widget .support-chat-intro,
.support-chat-widget .support-chat-privacy {
    color: var(--support-muted) !important;
}

.support-chat-widget
.support-chat-start-form label > span:first-child {
    color: var(--support-text) !important;
}

.support-chat-widget
.support-chat-start-form input:not([type="checkbox"]),
.support-chat-widget
.support-chat-start-form textarea,
.support-chat-widget
.support-chat-composer textarea {
    border-color: var(--support-border) !important;
    border-radius: var(--support-radius) !important;
    background: var(--support-panel-bg) !important;
    color: var(--support-text) !important;
}

.support-chat-widget
.support-chat-start-form input:not([type="checkbox"])::placeholder,
.support-chat-widget
.support-chat-start-form textarea::placeholder,
.support-chat-widget
.support-chat-composer textarea::placeholder {
    color: var(--support-muted) !important;
    opacity: 1;
}

.support-chat-widget .support-chat-privacy a {
    color: var(--support-button-bg) !important;
}

.support-chat-widget .support-chat-secondary {
    border-color: var(--support-border) !important;
    border-radius: var(--support-radius) !important;
    color: var(--support-text) !important;
}

.support-chat-widget
.support-chat-start-form input:not([type="checkbox"]):focus,
.support-chat-widget
.support-chat-start-form textarea:focus,
.support-chat-widget
.support-chat-composer textarea:focus {
    border-color: var(--support-button-bg) !important;
    outline: 2px solid color-mix(
        in srgb,
        var(--support-button-bg) 22%,
        transparent
    );
    outline-offset: 1px;
}

/* SUPPORT_CHAT_V3C_B1_UI */

.support-chat-v3c-toolbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.support-chat-v3c-icon-button {
    min-width: 38px;
    min-height: 38px;
    border: 1px solid var(--support-border);
    border-radius: 10px;
    background: var(--support-panel-bg);
    color: var(--support-text);
    cursor: pointer;
}

.support-chat-v3c-file-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--support-muted);
    font-size: 12px;
}

.support-chat-v3c-close {
    margin-left: auto;
    min-height: 38px;
}

.support-chat-v3c-emoji-picker {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--support-border);
    border-radius: 12px;
    background: var(--support-panel-bg);
    box-shadow: 0 12px 28px rgb(15 23 42 / 16%);
}

.support-chat-v3c-emoji-picker[hidden] {
    display: none;
}

.support-chat-v3c-emoji-picker button {
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}

.support-chat-attachment {
    display: flex;
    margin-top: 7px;
    max-width: 230px;
    gap: 6px;
    align-items: center;
    color: inherit;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.support-chat-attachment__image {
    display: block;
    width: 100%;
    max-width: 210px;
    max-height: 160px;
    object-fit: cover;
    border-radius: 10px;
}

@media (max-width: 520px) {
    .support-chat-v3c-close {
        margin-left: 0;
    }
}

/* ==================================================
   SUPPORT_CHAT_AVATAR_RENDER_V1
   Force the operator photo to fill the circular avatar.
   ================================================== */

.support-chat-widget [data-support-chat-avatar] {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
}

.support-chat-widget [data-support-chat-avatar-image] {
    width: 100% !important;
    height: 100% !important;
    min-width: 100%;
    min-height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: inherit;
    object-fit: cover !important;
    object-position: 50% 50% !important;
}

.support-chat-widget [data-support-chat-avatar-fallback] {
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

/* ==========================================================
   SUPPORT_CHAT_PUBLIC_AVATAR_RENDER_V2
   ========================================================== */

.support-chat-widget .support-chat-avatar {
    position: relative !important;

    flex: 0 0 42px !important;

    width: 42px !important;
    height: 42px !important;

    min-width: 42px !important;
    min-height: 42px !important;

    aspect-ratio: 1 / 1 !important;

    overflow: hidden !important;

    border-radius: 50% !important;
}

.support-chat-widget
.support-chat-avatar
> img[data-support-chat-avatar-image] {
    position: absolute !important;

    inset: 0 !important;

    display: block !important;

    width: 100% !important;
    height: 100% !important;

    min-width: 100% !important;
    min-height: 100% !important;

    max-width: none !important;
    max-height: none !important;

    margin: 0 !important;
    padding: 0 !important;

    object-fit: cover !important;
    object-position: center center !important;

    border-radius: inherit !important;
}

/* ==========================================================
   SUPPORT_CHAT_PUBLIC_LAYOUT_V3
   Viewport-safe public chat + reliable hidden states.
   ========================================================== */

/*
 * HTML hidden state must always win over author display rules.
 * This is critical for closed conversations.
 */
.support-chat-widget [hidden] {
    display: none !important;
}


/*
 * Open panel uses the available vertical space.
 */
.support-chat-widget
.support-chat-panel:not([hidden]) {
    display: flex;
    flex-direction: column;
}

.support-chat-widget
.support-chat-header {
    flex: 0 0 auto;
}


/*
 * Conversation body may shrink.
 * Message history scrolls instead of pushing controls
 * below the viewport.
 */
.support-chat-widget
.support-chat-conversation:not([hidden]) {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;

    min-height: 0;

    overflow: hidden;
}

.support-chat-widget
.support-chat-messages {
    flex: 1 1 auto;

    height: auto !important;
    min-height: 0 !important;

    overflow-y: auto;

    overscroll-behavior: contain;
}


/*
 * Controls at the bottom remain visible.
 */
.support-chat-widget
.support-chat-composer:not([hidden]),
.support-chat-widget
.support-chat-closed:not([hidden]) {
    flex: 0 0 auto;
}

.support-chat-widget
.support-chat-composer:not([hidden]) {
    display: grid;
}


/*
 * Start/offline screens can scroll on short screens.
 */
.support-chat-widget
.support-chat-start:not([hidden]),
.support-chat-widget
.support-chat-offline:not([hidden]) {
    min-height: 0;

    overflow-y: auto;
}


/*
 * Mobile / narrow viewport.
 */
@media (max-width: 640px) {
    .support-chat-widget
    .support-chat-panel:not([hidden]) {
        position: fixed;

        top: max(
            8px,
            env(safe-area-inset-top)
        );

        right: 8px;

        bottom: max(
            8px,
            env(safe-area-inset-bottom)
        );

        left: 8px;

        width: auto;
        height: auto;

        max-height: none;
    }

    /*
     * Do not let the launcher cover the send controls
     * while the panel is open.
     */
    .support-chat-widget:has(
        .support-chat-panel:not([hidden])
    )
    .support-chat-launcher {
        display: none;
    }

    .support-chat-widget
    .support-chat-conversation:not([hidden]) {
        padding-top: 12px;
        padding-bottom: 12px;
    }
}


/*
 * Short viewport, including smaller notebook windows.
 */
@media (max-height: 700px) {
    .support-chat-widget
    .support-chat-header {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .support-chat-widget
    .support-chat-conversation:not([hidden]) {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .support-chat-widget
    .support-chat-messages {
        min-height: 0 !important;
    }
}


/* ==========================================================
   SUPPORT_CHAT_UX_V4
   Narrow desktop layout + readability.
   ========================================================== */

@media (min-width: 641px) {
    .support-chat-widget
    .support-chat-panel {
        width: min(
            350px,
            calc(100vw - 32px)
        ) !important;
    }
}

.support-chat-widget
.support-chat-header span {
    opacity: 1 !important;
    font-size: .82rem !important;
    line-height: 1.4 !important;
}

.support-chat-widget
.support-chat-intro {
    color: var(--support-text) !important;
    font-size: .92rem !important;
    font-weight: 500;
    line-height: 1.55 !important;
}

.support-chat-widget
.support-chat-start-form
label > span:first-child {
    color: var(--support-text) !important;
    font-size: .82rem !important;
    font-weight: 800 !important;
    line-height: 1.35;
}

.support-chat-widget
.support-chat-start-form
input:not([type="checkbox"]),
.support-chat-widget
.support-chat-start-form textarea,
.support-chat-widget
.support-chat-composer textarea {
    font-size: .92rem !important;
    line-height: 1.45;
}

.support-chat-widget
.support-chat-privacy {
    color: var(--support-text) !important;
    font-size: .78rem !important;
    line-height: 1.5 !important;
}

.support-chat-widget
.support-chat-v3c-file-name {
    color: var(--support-text) !important;
    font-size: .78rem !important;
}

.support-chat-widget
.support-chat-message {
    line-height: 1.55 !important;
}

.support-chat-widget
.support-chat-offline {
    color: var(--support-text) !important;
}


/* ==========================================================
   SUPPORT_CHAT_V4_ATTACHMENT_BUTTON
   Stronger attachment control.
   ========================================================== */

.support-chat-widget
[data-support-chat-file-button] {
    min-width: 42px !important;
    min-height: 42px !important;

    border: 2px solid
        var(--support-button-bg) !important;

    background: color-mix(
        in srgb,
        var(--support-button-bg) 14%,
        var(--support-panel-bg)
    ) !important;

    color: var(--support-text) !important;

    font-size: 21px !important;
    font-weight: 900 !important;

    box-shadow:
        0 3px 10px
        rgb(15 23 42 / 14%);
}

.support-chat-widget
[data-support-chat-file-button]:hover {
    background: color-mix(
        in srgb,
        var(--support-button-bg) 25%,
        var(--support-panel-bg)
    ) !important;
}

.support-chat-widget
[data-support-chat-emoji-button] {
    font-size: 20px !important;
}
