/* ============================================================
   三骑机械 83777.cn · 在线客服挂件
   品牌色: 深蓝 #0b1a2b / 红 #d42e2e / 金 #f5b342
   ============================================================ */

/* 未读红点 (挂在 float-bar 在线按钮上) */
.cw-badge {
    position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
    padding: 0 5px; border-radius: 18px; background: #d42e2e; color: #fff;
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
    border: 2px solid #fff; box-sizing: content-box;
}
.float-bar .fb-online { position: relative; }

/* 聊天面板 */
.chat-widget { position: fixed; right: 20px; bottom: 96px; z-index: 9999; }
.chat-panel {
    width: 348px; max-width: calc(100vw - 40px);
    height: 480px; max-height: calc(100vh - 140px);
    background: #fff; border-radius: 16px; overflow: hidden;
    box-shadow: 0 18px 50px rgba(11,26,43,.28);
    display: flex; flex-direction: column;
    border: 1px solid rgba(11,26,43,.08);
    animation: cwPop .22s ease;
}
@keyframes cwPop {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-panel.hide { display: none; }

/* 头部 */
.cw-head {
    background: linear-gradient(135deg, #0b1a2b 0%, #1f3853 100%);
    color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
.cw-head .cw-ava {
    width: 38px; height: 38px; border-radius: 50%; background: #f5b342; color: #0b1a2b;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px;
    flex-shrink: 0;
}
.cw-head .cw-tit { flex: 1; min-width: 0; }
.cw-head .cw-tit b { display: block; font-size: 15px; }
.cw-head .cw-tit span { font-size: 11.5px; color: rgba(255,255,255,.7); display: flex; align-items: center; gap: 5px; }
.cw-head .cw-tit span::before { content:''; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.cw-close {
    background: rgba(255,255,255,.12); border: none; color: #fff; width: 28px; height: 28px;
    border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1; flex-shrink: 0;
}
.cw-close:hover { background: rgba(255,255,255,.24); }

/* 消息区 */
.cw-body { flex: 1; overflow-y: auto; padding: 14px; background: #f1f5f9; }
.cw-body::-webkit-scrollbar { width: 6px; }
.cw-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }

.cw-row { display: flex; margin-bottom: 12px; align-items: flex-end; gap: 8px; }
.cw-row.me { justify-content: flex-end; }
.cw-row .cw-ava2 {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.cw-row.them .cw-ava2 { background: #0b1a2b; color: #f5b342; }
.cw-row.me .cw-ava2 { background: #d42e2e; color: #fff; }
.cw-bubble {
    max-width: 78%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.55;
    word-break: break-word; white-space: pre-wrap;
}
.cw-row.them .cw-bubble { background: #fff; color: #0f1e2e; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.cw-row.me .cw-bubble { background: #d42e2e; color: #fff; border-bottom-right-radius: 4px; }
.cw-row .cw-time { font-size: 10.5px; color: #8aa3bb; margin-bottom: 2px; flex-shrink: 0; }

/* 系统提示 */
.cw-sys { text-align: center; color: #8aa3bb; font-size: 12px; margin: 8px 0; }

/* 底部 */
.cw-foot { border-top: 1px solid #e2e8f0; padding: 10px 12px; background: #fff; flex-shrink: 0; display: flex; gap: 8px; align-items: flex-end; }
.cw-foot textarea {
    flex: 1; border: 1px solid #e2e8f0; border-radius: 10px; padding: 9px 12px; font-size: 13.5px;
    resize: none; outline: none; height: 40px; min-height: 40px; max-height: 90px; font-family: inherit; line-height: 1.4;
}
.cw-foot textarea:focus { border-color: #d42e2e; box-shadow: 0 0 0 3px rgba(212,46,46,.1); }
.cw-send {
    background: #d42e2e; color: #fff; border: none; border-radius: 10px; padding: 0 16px; height: 40px;
    font-weight: 700; font-size: 13.5px; cursor: pointer; flex-shrink: 0; transition: .15s;
}
.cw-send:hover { background: #b82222; }
.cw-send:disabled { opacity: .55; cursor: not-allowed; }

/* 欢迎/表单 状态 */
.cw-welcome { padding: 6px 2px 4px; }
.cw-welcome .cw-tip { font-size: 13px; color: #5a6b7c; margin-bottom: 12px; }
.cw-form { display: flex; flex-direction: column; gap: 9px; }
.cw-form input {
    border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; outline: none;
    font-family: inherit;
}
.cw-form input:focus { border-color: #d42e2e; box-shadow: 0 0 0 3px rgba(212,46,46,.1); }
.cw-form .cw-start {
    background: #d42e2e; color: #fff; border: none; border-radius: 10px; padding: 11px; font-weight: 700;
    font-size: 14px; cursor: pointer;
}
.cw-form .cw-start:hover { background: #b82222; }
.cw-skip { text-align: center; margin-top: 6px; }
.cw-skip a { color: #1d4ed8; font-size: 12.5px; cursor: pointer; }

/* 关闭提示 + 重新咨询 */
.cw-restart {
    display: block; width: 100%; margin-top: 4px; padding: 9px; background: #0b1a2b; color: #f5b342;
    border: none; border-radius: 10px; font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.cw-restart:hover { background: #1f3853; }

/* 移动端 */
@media (max-width: 480px) {
    .chat-widget { right: 14px; bottom: 90px; left: 14px; }
    .chat-panel { width: auto; height: 70vh; max-width: none; }
}
