/* ==========================================================================
   华巽云国际站 · 在线客服浮动窗口
   布局参考：深色顶栏（头像 + 标题 + 在线状态 + 翻译/关闭）
             消息区（左灰白 / 右蓝气泡 + 蓝色快捷胶囊）
             底部输入框 + 橙色圆形发送按钮
   ========================================================================== */
.cw {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 90;
    font-family: inherit;
}

/* ---------------- 启动按钮 ---------------- */
.cw__launcher {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 50px;
    padding: 0 20px 0 16px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #2f6bff 0%, #1e4fd8 100%);
    color: #fff;
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(31, 79, 216, .38), 0 2px 6px rgba(10, 37, 64, .16);
    transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.cw__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(31, 79, 216, .46), 0 3px 8px rgba(10, 37, 64, .18);
}
.cw__launcher svg { flex: 0 0 auto; }
.cw__launcher .cw__badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 2.5px #fff;
}
.cw__launcher-wrap { position: relative; display: inline-flex; }

/* ---------------- 面板 ---------------- */
.cw__panel {
    position: absolute;
    right: 0;
    bottom: 64px;
    width: 372px;
    max-width: calc(100vw - 32px);
    height: 552px;
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(10, 37, 64, .26), 0 4px 14px rgba(10, 37, 64, .12);
    border: 1px solid rgba(10, 37, 64, .06);
}
.cw.open .cw__panel {
    display: flex;
    animation: cwIn .26s var(--ease);
}
@keyframes cwIn {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* ---------------- 顶栏 ---------------- */
.cw__head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 14px;
    background: linear-gradient(135deg, #1b2c4d 0%, #16233d 100%);
    color: #fff;
    flex: 0 0 auto;
}
.cw__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
}
.cw__avatar svg { display: block; }
.cw__head-main { min-width: 0; flex: 1 1 auto; }
.cw__head-main b {
    display: block;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .01em;
    line-height: 1.25;
}
.cw__head-main span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, .72);
}
.cw__head-main span::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .22);
}
.cw__head-acts { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.cw__icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .86);
    cursor: pointer;
    transition: background .18s var(--ease), color .18s var(--ease);
}
.cw__icon-btn:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.cw__icon-btn.is-on { background: #f26722; color: #fff; }
.cw__icon-btn--close { font-size: 19px; line-height: 1; }

/* 转人工条 */
.cw__human {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 14px;
    background: #fff7ed;
    border-bottom: 1px solid #fed7aa;
    font-size: 12.5px;
    color: #9a3412;
    flex: 0 0 auto;
}
.cw__human a {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: #f26722;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: filter .18s var(--ease);
}
.cw__human a:hover { filter: brightness(1.08); }

/* ---------------- 消息区 ---------------- */
.cw__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px 12px;
    background: #f6f8fc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.cw__row { display: flex; flex-direction: column; max-width: 100%; }
.cw__row--user { align-items: flex-end; }

.cw__bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.62;
    word-break: break-word;
    white-space: pre-wrap;
}
.cw__row--agent .cw__bubble {
    background: #fff;
    color: var(--ink, #0f2540);
    border: 1px solid #e6eaf2;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(10, 37, 64, .05);
}
.cw__row--user .cw__bubble {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .24);
}
.cw__time {
    margin-top: 4px;
    font-size: 10.5px;
    color: #94a3b8;
    padding: 0 3px;
}

/* 命中「常见问题」的自动回复：先小字列出匹配到的问题，再给出答案 */
.cw__faqq {
    max-width: 82%;
    margin-bottom: 4px;
    padding: 0 3px;
    font-size: 11.5px;
    line-height: 1.5;
    color: #64748b;
}
.cw__faqq::before {
    content: "Q：";
    color: #2563eb;
    font-weight: 600;
}
.cw__row--agent .cw__bubble--faq {
    background: #f8fafc;
    border-color: #cfe0ff;
    border-left: 3px solid #2563eb;
}

/* 快捷胶囊 */
.cw__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 2px 0 4px;
}
.cw__quick button {
    padding: 7px 13px;
    border: 0;
    border-radius: 999px;
    background: #2f6bff;
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .16s var(--ease), filter .16s var(--ease);
}
.cw__quick button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.cw__quick--ghost button {
    background: #fff;
    color: #2f6bff;
    border: 1px solid #c7d7fe;
}
.cw__quick--ghost button:hover { background: #eef4ff; }

/* 翻译状态提示 */
.cw__sysnote {
    align-self: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: #e8eefc;
    color: #3b5bdb;
    font-size: 11.5px;
}

/* ---------------- 底部输入 ---------------- */
.cw__foot {
    flex: 0 0 auto;
    padding: 11px 12px 8px;
    background: #fff;
    border-top: 1px solid #eef1f6;
}
.cw__form { display: flex; align-items: flex-end; gap: 9px; }
.cw__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 42px;
    padding: 0 15px;
    border: 1px solid #dfe5ef;
    border-radius: 999px;
    background: #f7f9fd;
    font-size: 14px;
    color: var(--ink, #0f2540);
    outline: none;
    transition: border-color .18s var(--ease), background .18s var(--ease);
}
.cw__input::placeholder { color: #9aa7bd; }
.cw__input:focus { border-color: #2f6bff; background: #fff; }
.cw__send {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff8a3d 0%, #f26722 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(242, 103, 34, .38);
    transition: transform .18s var(--ease), filter .18s var(--ease);
}
.cw__send:hover { transform: translateY(-1px) scale(1.04); filter: brightness(1.06); }
.cw__send:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.cw__tip {
    margin-top: 7px;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
}

/* 输入中动画 */
.cw__typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.cw__typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #b6c2d6;
    animation: cwBlink 1.2s infinite;
}
.cw__typing i:nth-child(2) { animation-delay: .2s; }
.cw__typing i:nth-child(3) { animation-delay: .4s; }
@keyframes cwBlink {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------------- 快捷联系（WhatsApp / 微信） ---------------- */
.cw__dock {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    justify-content: flex-end;
}
.cw__rail {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cw__rail-btn {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(10, 37, 64, .22), 0 2px 6px rgba(10, 37, 64, .14);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.cw__rail-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(10, 37, 64, .3); }
.cw__rail-btn--wa { background: linear-gradient(135deg, #25d366 0%, #1ebe5a 100%); }
.cw__rail-btn--wc { background: linear-gradient(135deg, #2dd34f 0%, #09b83e 100%); }

/* 微信二维码弹层 */
.cw__qr {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cw__qr[hidden] { display: none; }
.cw__qr-mask { position: absolute; inset: 0; background: rgba(10, 25, 45, .5); }
.cw__qr-card {
    position: relative;
    z-index: 1;
    width: 264px;
    padding: 22px 22px 18px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(10, 37, 64, .3);
    text-align: center;
    animation: cwIn .24s var(--ease);
}
.cw__qr-card img { width: 200px; height: 200px; object-fit: contain; border-radius: 8px; background: #f6f8fc; }
.cw__qr-card p { margin: 12px 0 0; font-size: 13px; color: #5b6b80; }
.cw__qr-x {
    position: absolute; top: 8px; right: 10px;
    width: 30px; height: 30px; border: 0; border-radius: 50%;
    background: #f1f4f9; color: #5b6b80; font-size: 18px; line-height: 1; cursor: pointer;
}
.cw__qr-x:hover { background: #e6ebf2; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 640px) {
    .cw { right: 12px; bottom: 12px; }
    .cw__panel {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: none;
        height: 78vh;
        max-height: none;
        border-radius: 18px 18px 0 0;
    }
    .cw.open .cw__panel { animation: cwUp .28s var(--ease); }
    @keyframes cwUp {
        from { transform: translateY(100%); }
        to   { transform: none; }
    }
    .cw__launcher { height: 46px; padding: 0 16px 0 13px; font-size: 13.5px; }
    .cw__rail-btn { width: 42px; height: 42px; }
    .cw__dock { gap: 10px; }
    .cw__qr-card { width: 240px; }
    .cw__qr-card img { width: 184px; height: 184px; }
}

/* ---------------- 附件 ---------------- */
.cw__attach {
    width: 38px;
    height: 42px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7a90;
    cursor: pointer;
    border-radius: 999px;
    transition: background .18s var(--ease), color .18s var(--ease);
}
.cw__attach:hover { background: #eef4ff; color: #2f6bff; }
.cw__bubble-img {
    display: block;
    max-width: 200px;
    max-height: 170px;
    border-radius: 10px;
    margin-top: 2px;
    cursor: pointer;
}
.cw__bubble-file {
    display: inline-block;
    margin-top: 2px;
    padding: 7px 11px;
    border-radius: 8px;
    background: rgba(0,0,0,.06);
    color: inherit;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
.cw__row--agent .cw__bubble-file { background: rgba(37,99,235,.12); color: #1e4fd8; }
.cw__row--user  .cw__bubble-file { background: rgba(255,255,255,.22); color: #fff; }

/* 未读客服消息红点（面板关闭时） */
.cw__launcher .cw__unread {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e5484d;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

