/* 访客端客服挂件 · 白色主题（2026-11-29 重新布局） */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f4f6fa;
    color: #1f2933;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
.kf-wrap {
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-shadow: 0 8px 30px rgba(17, 34, 68, .08);
}

/* 顶部 */
.kf-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #ffffff 0%, #f6f9ff 100%);
    border-bottom: 1px solid #eef1f5;
}
.kf-head .avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: none;
    background: #2563eb; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
}
.kf-head .who { min-width: 0; flex: 1; }
.kf-head .t1 { font-size: 16px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kf-head .t2 { font-size: 12px; color: #8a94a6; margin-top: 3px; display: flex; align-items: center; }
.kf-head .t2 .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #cbd2d9; margin-right: 5px; }
.kf-head .t2.online .dot { background: #2ecc71; box-shadow: 0 0 0 3px #e9f9f0; }

/* 留言提示条 */
.kf-notice {
    padding: 9px 16px;
    font-size: 12px;
    line-height: 1.6;
    color: #8a5a00;
    background: #fff8e6;
    border-bottom: 1px solid #ffe9b8;
}

/* 消息区 */
.kf-body {
    flex: 1; overflow-y: auto; padding: 16px;
    background: #ffffff;
    scroll-behavior: smooth;
}
.kf-msg { display: flex; margin-bottom: 16px; gap: 8px; }
.kf-msg.guest { flex-direction: row-reverse; }
.kf-msg .avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff;
}
.kf-msg.admin .avatar { background: #2563eb; }
.kf-msg.guest .avatar { background: #7b8794; }
.kf-msg .bubble { max-width: 72%; }
.kf-msg .nick { font-size: 11px; color: #9aa5b1; margin-bottom: 4px; }
.kf-msg.guest .nick { text-align: right; }
.kf-msg .balloon {
    padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.58;
    word-break: break-word; white-space: pre-wrap;
}
.kf-msg.admin .balloon { background: #f0f4ff; border-top-left-radius: 4px; }
.kf-msg.guest .balloon { background: #eff3f8; border-top-right-radius: 4px; }
.kf-msg .balloon img { max-width: 220px; border-radius: 10px; display: block; }
.kf-msg .balloon .emoji { font-size: 28px; line-height: 1.2; }
.kf-msg .meta-line { font-size: 10px; color: #b0b7bf; margin-top: 5px; }
.kf-msg.guest .meta-line { text-align: right; }

/* 底部输入 */
.kf-foot { border-top: 1px solid #eef1f5; background: #fff; }
.kf-tool {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px 0;
}
.kf-tool > button {
    border: none; background: #f5f7fa; border-radius: 9px;
    width: 34px; height: 34px; cursor: pointer; font-size: 17px; color: #52606d;
    line-height: 1;
}
.kf-tool > button:hover { background: #eef2f7; }
.kf-tool-gap { flex: 1; }
/* 语言选择：图标放在工具栏最右侧，点击弹出带国旗的浮动语言层 */
.kf-lang-wrap { position: relative; margin-left: auto; }
.kf-lang {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; padding: 0;
    border: 1px solid #e4e7eb; border-radius: 9px;
    background: #fff; color: #52606d; cursor: pointer; outline: none;
}
.kf-lang:hover { border-color: #cfd8e3; background: #fbfcfe; color: #2563eb; }
.kf-lang svg { display: block; }
.kf-lang .flag-mini {
    display: block; width: 22px; height: 15px;
    object-fit: cover; border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(20,40,80,.12);
}
.kf-lang-menu {
    display: none; position: absolute; right: 0; bottom: 44px; width: 296px;
    max-height: 356px; overflow-y: auto; padding: 6px;
    background: #fff; border: 1px solid #e4e7eb; border-radius: 14px;
    box-shadow: 0 14px 40px rgba(20,40,80,.2); z-index: 80;
}
.kf-lang-menu.open { display: block; }
.kf-lang-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.kf-lang-item:hover { background: #f3f7ff; }
.kf-lang-item.active { background: #eef5ff; }
.kf-lang-item .flag-ico { width: 34px; height: 22px; object-fit: cover; border-radius: 4px; flex: none; box-shadow: 0 0 0 1px rgba(20,40,80,.08); }
.kf-lang-item .txt { min-width: 0; display: flex; flex-direction: column; }
.kf-lang-item .nm { font-size: 13px; color: #1f2933; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kf-lang-item.active .nm { color: #1d4fd7; font-weight: 600; }
.kf-lang-item .cd { font-size: 10px; color: #98a1ad; letter-spacing: .08em; margin-top: 1px; }

.kf-input-row { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px 12px; }
.kf-input-row textarea {
    flex: 1; resize: none; border: 1px solid #e4e7eb; border-radius: 10px;
    padding: 10px 12px; font-size: 14px; height: 42px; outline: none; font-family: inherit;
    background: #fbfcfe; line-height: 1.5;
}
.kf-input-row textarea:focus { border-color: #2563eb; background: #fff; }
.kf-send {
    border: none; background: #2563eb; color: #fff; border-radius: 10px;
    height: 42px; padding: 0 18px; font-size: 14px; cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .22);
}
.kf-send:hover { background: #1d4fd7; }
.kf-send:disabled { background: #93b4f5; cursor: not-allowed; box-shadow: none; }

/* 表情面板（浮在工具栏上方） */
.kf-emoji {
    display: none; flex-wrap: wrap; gap: 4px; padding: 10px 12px;
    border-top: 1px solid #f0f2f5;
    background: #fbfcfe;
}
.kf-emoji.open { display: flex; }
.kf-emoji span { font-size: 24px; padding: 4px 6px; cursor: pointer; border-radius: 8px; line-height: 1; }
.kf-emoji span:hover { background: #eef2f7; }

.kf-empty { text-align: center; color: #b0b7bf; margin-top: 60px; font-size: 13px; }
.kf-closed-tip { margin: 12px auto; max-width: 86%; padding: 8px 12px; border-radius: 10px; background: #f4f6f8; color: #7f8b9c; font-size: 11.5px; line-height: 1.6; text-align: center; }
.kf-notice .kf-reconnect { margin-left: 8px; padding: 4px 10px; border: 1px solid #e2b85e; border-radius: 7px; background: #fff; color: #8a5a00; font-size: 11.5px; cursor: pointer; }
.kf-notice .kf-reconnect:hover { background: #fff3d2; }
.kf-tip { text-align: center; font-size: 11px; color: #b0b7bf; padding: 6px; }
/* 选择客服弹框（sid 为空或无效时） */
.kf-picker { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 16px; }
.kf-picker.open { display: flex; }
.kf-picker-mask { position: absolute; inset: 0; background: rgba(17, 28, 48, .42); backdrop-filter: blur(2px); }
.kf-picker-card { position: relative; width: 100%; max-width: 380px; background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgba(15, 30, 60, .24); overflow: hidden; animation: kfPop .18s ease-out; }
@keyframes kfPop { from { transform: translateY(10px) scale(.98); } to { transform: none; } }
.kf-picker-head { padding: 18px 18px 10px; }
.kf-picker-head .t1 { font-size: 16px; font-weight: 600; color: #1f2933; }
.kf-picker-head .t2 { margin-top: 5px; font-size: 12px; color: #8a94a6; line-height: 1.5; }
.kf-picker-list { padding: 4px 14px 8px; max-height: 60vh; overflow-y: auto; }
.kf-agent-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px; border: 1px solid #edf0f5; border-radius: 12px; background: #fbfcfe; margin-bottom: 8px; cursor: pointer; text-align: left; font-family: inherit; }
.kf-agent-item:hover { border-color: #9dbde8; background: #f5f9ff; }
.kf-agent-item .av { width: 38px; height: 38px; border-radius: 50%; flex: none; background: #2563eb; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; overflow: hidden; }
.kf-agent-item .av img { width: 100%; height: 100%; object-fit: cover; }
.kf-agent-item .meta { flex: 1; min-width: 0; }
.kf-agent-item .nm { font-size: 14px; color: #1f2933; font-weight: 600; }
.kf-agent-item .st { font-size: 11px; color: #9aa5b1; margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.kf-agent-item .st .dot { width: 6px; height: 6px; border-radius: 50%; background: #cbd2d9; }
.kf-agent-item .st.online { color: #16a085; }
.kf-agent-item .st.online .dot { background: #2ecc71; }
.kf-agent-item .go { color: #b6c0cc; font-size: 16px; }
.kf-picker-foot { padding: 9px 18px 14px; font-size: 11px; color: #a0a8b3; border-top: 1px solid #f3f5f8; background: #fbfcfe; }

/* 无效客服链接：不再弹选择客服，只显示系统错误 */
.kf-system-error { max-width: 330px; padding: 28px 24px 26px; text-align: center; }
.kf-system-error-icon {
    width: 42px; height: 42px; margin: 0 auto 14px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    background: #fff1ee; border: 1px solid #ffd9d2; color: #dc4a38; font-size: 23px; font-weight: 700;
}
.kf-system-error .t1 { font-size: 16px; font-weight: 600; color: #1f2933; }
.kf-system-error .t2 { margin-top: 7px; font-size: 12px; line-height: 1.7; color: #8a94a6; }

