/* ===== 内置客服系统 - 用户端 ===== */
#ba-kefu-root {
    position: fixed;
    inset: 0;
    z-index: 99999;
    color: #1f2329;
    pointer-events: none;
}
#ba-kefu-root * { box-sizing: border-box; margin: 0; padding: 0; pointer-events: auto; }

/* 悬浮按钮（默认右下角，导航栏“我的”上方；可拖拽） */
.ba-kefu-btn {
    position: fixed;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3370ff, #165dff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(22, 93, 255, .4);
    transition: box-shadow .2s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    z-index: 99999;
}
.ba-kefu-btn:active { box-shadow: 0 3px 10px rgba(22, 93, 255, .5); }
.ba-kefu-btn svg { width: 28px; height: 28px; pointer-events: none; }
.ba-kefu-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #f53f3f;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    padding: 0 5px;
    display: none;
}

/* 聊天面板 */
.ba-kefu-panel {
    display: none;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    width: 360px;
    max-width: calc(100vw - 24px);
    height: 500px;
    max-height: calc(100vh - 90px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
    overflow: hidden;
    flex-direction: column;
    z-index: 99999;
}
.ba-kefu-panel.open { display: flex; }
.ba-kefu-head {
    background: linear-gradient(135deg, #3370ff, #165dff);
    color: #fff;
    padding: 12px 14px;
}
.ba-kefu-head-top { display: flex; align-items: center; justify-content: space-between; }
.ba-kefu-title { font-size: 15px; font-weight: 700; }
.ba-kefu-close { cursor: pointer; font-size: 18px; line-height: 1; opacity: .9; padding: 0 2px; }
.ba-kefu-close:hover { opacity: 1; }
.ba-kefu-user {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
}
.ba-kefu-user span { background: rgba(255, 255, 255, .18); border-radius: 4px; padding: 2px 8px; }
.ba-kefu-user .ba-kefu-uname { font-weight: 600; background: rgba(255, 255, 255, .28); }

/* 消息区 */
.ba-kefu-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ba-kefu-msg { display: flex; flex-direction: column; }
.ba-kefu-msg.mine { align-items: flex-end; }
.ba-kefu-msg.them { align-items: flex-start; }
.ba-kefu-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
}
.ba-kefu-text {
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.ba-kefu-msg.mine .ba-kefu-bubble { background: #3370ff; color: #fff; border-top-right-radius: 2px; }
.ba-kefu-msg.them .ba-kefu-bubble { background: #fff; border: 1px solid #e5e6eb; border-top-left-radius: 2px; }
.ba-kefu-img {
    display: block;
    max-width: 220px;
    max-height: 260px;
    border-radius: 8px;
    cursor: zoom-in;
    background: #eef0f3;
}
.ba-kefu-time { font-size: 11px; color: #a9aeb8; margin-top: 3px; }

/* 输入栏 */
.ba-kefu-inputbar {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
    align-items: flex-end;
}
.ba-kefu-img-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #4e5969;
    background: #f2f3f5;
    transition: background .2s;
}
.ba-kefu-img-btn:hover { background: #e5e6eb; color: #3370ff; }
.ba-kefu-img-btn svg { width: 20px; height: 20px; pointer-events: none; }
#ba-kefu-input {
    flex: 1;
    border: 1px solid #dcdfe6;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
    resize: none;
    font-family: inherit;
    height: 40px;
    white-space: pre-wrap;
    word-break: break-all;
}
#ba-kefu-input:focus { border-color: #3370ff; }
.ba-kefu-send {
    height: 40px;
    padding: 0 18px;
    border: none;
    border-radius: 8px;
    background: #3370ff;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}
.ba-kefu-send:hover { background: #2b5fd9; }
.ba-kefu-send:disabled { opacity: .5; cursor: not-allowed; }

.ba-kefu-tip {
    text-align: center;
    color: #86909c;
    font-size: 13px;
    padding: 30px 20px;
    white-space: pre-wrap;
    word-break: break-all;
}
.ba-kefu-login-hint {
    text-align: center;
    padding: 30px 20px;
    color: #4e5969;
    font-size: 14px;
}
.ba-kefu-login-hint a { color: #3370ff; cursor: pointer; text-decoration: none; }

/* 图片预览 */
.ba-kefu-preview {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.ba-kefu-preview.show { display: flex; }
.ba-kefu-preview img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
