/* 343/U：前台聊天窗口。桌面右下角，手机端全屏。 */
.support-chat {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 50;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}

.support-chat *,
.support-chat *::before,
.support-chat *::after {
    box-sizing: border-box;
}

.support-chat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    color: #fff;
    background: #2563eb;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    cursor: pointer;
}

.support-chat-toggle:hover {
    background: #1d4ed8;
}

.support-chat-toggle:focus-visible,
.support-chat-close:focus-visible,
.support-chat-send:focus-visible,
.support-chat-input:focus-visible,
.support-chat-email-input:focus-visible,
.support-chat-email-save:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.support-chat-toggle svg {
    width: 26px;
    height: 26px;
}

.support-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 88px;
    display: flex;
    flex-direction: column;
    width: min(360px, calc(100vw - 40px));
    height: min(560px, calc(100vh - 120px));
    overflow: hidden;
    color: #1f2937;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
}

.support-chat-panel[hidden] {
    display: none;
}

.support-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    color: #fff;
    background: #2563eb;
}

.support-chat-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.support-chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.support-chat-close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.support-chat-close svg {
    width: 18px;
    height: 18px;
}

.support-chat-messages {
    flex: 1;
    margin: 0;
    padding: 16px;
    overflow-y: auto;
    list-style: none;
}

.support-chat-messages[hidden] {
    display: none;
}

.support-chat-message {
    display: flex;
    margin: 0 0 10px;
}

.support-chat-message:last-child {
    margin-bottom: 0;
}

.support-chat-message--own {
    justify-content: flex-end;
}

.support-chat-message--other {
    justify-content: flex-start;
}

.support-chat-bubble {
    max-width: 80%;
    margin: 0;
    padding: 9px 12px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    border-radius: 12px;
}

.support-chat-message--own .support-chat-bubble {
    color: #fff;
    background: #2563eb;
    border-bottom-right-radius: 4px;
}

.support-chat-message--other .support-chat-bubble {
    color: #1f2937;
    background: #f1f5f9;
    border-bottom-left-radius: 4px;
}

.support-chat-empty {
    flex: 1;
    margin: 0;
    padding: 24px 20px;
    color: #64748b;
    text-align: center;
}

.support-chat-ai-off {
    margin: 0;
    padding: 8px 16px;
    color: #92400e;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    font-size: 13px;
}

.support-chat-status {
    margin: 0;
    padding: 8px 16px;
    color: #475569;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
}

.support-chat-status[hidden] {
    display: none;
}

.support-chat-status.is-error {
    color: #b91c1c;
    background: #fef2f2;
    border-top-color: #fecaca;
}

.support-chat-email {
    display: flex;
    gap: 8px;
    padding: 10px 12px 0;
}

.support-chat-email-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    color: inherit;
    font: inherit;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.support-chat-email-save {
    height: 36px;
    padding: 0 12px;
    color: #fff;
    font: inherit;
    background: #2563eb;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.support-chat-email-save:hover {
    background: #1d4ed8;
}

.support-chat-email-save:disabled {
    cursor: default;
    opacity: 0.6;
}

.support-chat-email[hidden],
.support-chat-email-note[hidden] {
    display: none;
}

.support-chat-email-note {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 12px 0;
    font-size: 13px;
    color: #64748b;
}

.support-chat-email-change {
    padding: 0;
    color: #2563eb;
    font: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

.support-chat-email-change:hover {
    text-decoration: underline;
}

.support-chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
}

.support-chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 9px 10px;
    color: inherit;
    font: inherit;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    resize: none;
}

.support-chat-send {
    min-width: 64px;
    height: 40px;
    padding: 0 14px;
    color: #fff;
    font: inherit;
    background: #2563eb;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.support-chat-send:hover {
    background: #1d4ed8;
}

.support-chat-send:disabled {
    cursor: default;
    opacity: 0.6;
}

@media (max-width: 640px) {
    .support-chat-panel {
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
    }

    .support-chat-toggle {
        right: 16px;
        bottom: 16px;
    }

    .support-chat-header {
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }

    .support-chat-messages {
        padding: 14px;
    }

    .support-chat-form {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
}
