/* ACS Contact Chat - 联系客服对话框 */
.acs-chat {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 24px;
    visibility: hidden;
    opacity: 0;
    transition: opacity .22s ease, visibility .22s ease;
    pointer-events: none;
}

.acs-chat.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.acs-chat__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .28);
    opacity: 0;
    transition: opacity .22s ease;
}

.acs-chat.is-open .acs-chat__backdrop {
    opacity: 1;
}

.acs-chat__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: 100%;
    height: 540px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
    overflow: hidden;
    transform: translateY(18px) scale(.98);
    opacity: 0;
    transition: transform .26s cubic-bezier(.16, 1, .3, 1), opacity .22s ease;
}

.acs-chat.is-open .acs-chat__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* 头部 */
.acs-chat__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1f6feb, #3b82f6);
    color: #fff;
}

.acs-chat__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    line-height: 1;
    flex: 0 0 auto;
}

.acs-chat__id {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.acs-chat__id strong {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.acs-chat__status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, .86);
}

.acs-chat__status i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, .22);
}

.acs-chat__close-btn {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .18s ease;
    padding: 0;
}

.acs-chat__close-btn:hover {
    background: rgba(255, 255, 255, .3);
}

/* 消息区 */
.acs-chat__body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 8px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
}

.acs-chat__body::-webkit-scrollbar {
    width: 6px;
}

.acs-chat__body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .5);
    border-radius: 3px;
}

.acs-chat__msg {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 100%;
    animation: acs-chat-in .24s ease both;
}

@keyframes acs-chat-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.acs-chat__msg--user {
    flex-direction: row-reverse;
}

.acs-chat__ava {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e8effc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex: 0 0 auto;
}

.acs-chat__bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 4px 14px 14px 14px;
    background: #fff;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    word-break: break-word;
}

.acs-chat__msg--user .acs-chat__bubble {
    background: #1f6feb;
    color: #fff;
    border-radius: 14px 4px 14px 14px;
    box-shadow: none;
}

.acs-chat__bubble p {
    margin: 0;
    white-space: pre-line;
}

.acs-chat__bubble p + p {
    margin-top: 6px;
}

.acs-chat__url {
    display: block;
    margin-top: 8px;
    color: #1f6feb;
    font-size: 13px;
    text-decoration: underline;
    word-break: break-all;
}

.acs-chat__cta {
    display: block;
    margin-top: 10px;
    padding: 9px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1f6feb, #3b82f6);
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none !important;
    transition: filter .18s ease, transform .18s ease;
}

.acs-chat__cta:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

/* 输入中动画 */
.acs-chat__typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 2px;
}

.acs-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: acs-chat-dot 1.2s infinite ease-in-out;
}

.acs-chat__typing span:nth-child(2) { animation-delay: .16s; }
.acs-chat__typing span:nth-child(3) { animation-delay: .32s; }

@keyframes acs-chat-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* 输入区 */
.acs-chat__form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 12px;
    background: #fff;
    border-top: 1px solid #eef2f7;
}

.acs-chat__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 42px;
    padding: 0 14px;
    border: 1px solid #dbe3ee;
    border-radius: 21px;
    background: #f8fafc;
    color: #1f2937;
    font-size: 14px;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.acs-chat__input:focus {
    background: #fff;
    border-color: #1f6feb;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, .12);
}

.acs-chat__send {
    flex: 0 0 auto;
    height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 21px;
    background: #1f6feb;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s ease;
}

.acs-chat__send:hover {
    background: #185fd0;
}

.acs-chat__send:disabled {
    background: #c7d5ea;
    cursor: default;
}

@media (max-width: 640px) {
    .acs-chat {
        padding: 0;
        align-items: flex-end;
    }

    .acs-chat__panel {
        width: 100%;
        max-width: 100%;
        height: 78vh;
        max-height: 78vh;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
    }

    .acs-chat.is-open .acs-chat__panel {
        transform: translateY(0);
    }

    body.acs-chat-open {
        overflow: hidden;
    }

    .acs-chat__bubble {
        font-size: 14.5px;
    }
}
