/* ========== 在线客服聊天挂件（PC门户） ========== */

/* 右侧悬浮工具栏「在线客服」入口：保持原有视觉，仅增加可点击手势 */
#kefuEntry {
    cursor: pointer;
    outline: none;
}

#kefuEntry:focus-visible {
    box-shadow: 0 0 0 2px #d9000b inset;
}

/* ---------- 面板主体 ---------- */
.kefu-panel {
    position: fixed;
    right: 142px;
    bottom: 60px;
    width: 360px;
    height: 520px;
    max-height: calc(100vh - 140px);
    display: none;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
    overflow: hidden;
    /* 介于 .right-box(9999999) 与 UI.toast(9999999999) 之间 */
    z-index: 99999999;
    font-size: 13px;
    color: #333;
}

.kefu-panel.kefu-panel-show {
    display: flex;
}

/* ---------- 标题栏 ---------- */
.kefu-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 46px;
    padding: 0 10px 0 14px;
    background: #d9000b;
    color: #fff;
    flex-shrink: 0;
}

.kefu-title {
    font-size: 15px;
    font-weight: bold;
    white-space: nowrap;
}

.kefu-status-tag {
    font-size: 12px;
    line-height: 18px;
    padding: 0 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .22);
    color: #fff;
    white-space: nowrap;
}

.kefu-status-queue {
    background: #fff3e0;
    color: #e08a00;
}

.kefu-status-serving {
    background: #eaf7ee;
    color: #2e7d32;
}

.kefu-status-closed {
    background: #f2f2f2;
    color: #999;
}

.kefu-status-error {
    background: #fdecec;
    color: #d9000b;
}

.kefu-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kefu-header-btn {
    border: none;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
}

.kefu-header-btn:hover {
    background: rgba(255, 255, 255, .34);
}

.kefu-icon-btn {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 17px;
    line-height: 1;
    width: 24px;
    height: 24px;
    border-radius: 3px;
    cursor: pointer;
}

.kefu-icon-btn:hover {
    background: rgba(255, 255, 255, .25);
}

/* ---------- 顶部提示条（排队/服务中/断线） ---------- */
.kefu-banner {
    display: none;
    padding: 9px 12px;
    font-size: 12px;
    line-height: 1.6;
    border-bottom: 1px solid transparent;
    flex-shrink: 0;
}

.kefu-banner-info {
    background: #eef4ff;
    color: #3d6fb5;
    border-bottom-color: #dbe7fb;
}

.kefu-banner-queue {
    background: #fff8e6;
    color: #b76e00;
    border-bottom-color: #ffe4b3;
}

.kefu-banner-serving {
    background: #eaf7ee;
    color: #2e7d32;
    border-bottom-color: #d4ecd9;
}

.kefu-banner-closed {
    background: #f5f5f5;
    color: #888;
    border-bottom-color: #ececec;
}

.kefu-banner-error {
    background: #fdecec;
    color: #d9000b;
    border-bottom-color: #f8d7d7;
}

.kefu-banner-clickable {
    cursor: pointer;
    text-decoration: underline;
}

/* ---------- 消息列表 ---------- */
.kefu-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 10px;
    background: #f5f5f5;
}

.kefu-empty {
    text-align: center;
    color: #aaa;
    font-size: 13px;
    padding: 40px 10px;
}

.kefu-msg {
    margin-bottom: 14px;
}

.kefu-msg-right {
    text-align: right;
}

.kefu-msg-left {
    text-align: left;
}

.kefu-msg-name {
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
    text-align: left;
}

.kefu-bubble {
    display: inline-block;
    max-width: 250px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
    text-align: left;
    vertical-align: top;
}

.kefu-msg-left .kefu-bubble {
    background: #fff;
    border: 1px solid #ebebeb;
    color: #333;
}

.kefu-msg-right .kefu-bubble {
    background: #d9000b;
    color: #fff;
}

/* 图片/视频/订单卡片自带背景，气泡不再铺底色 */
.kefu-bubble-plain {
    background: transparent !important;
    border: none !important;
    padding: 0;
}

.kefu-time {
    font-size: 11px;
    color: #bbb;
    margin-top: 4px;
}

/* ---------- 媒体消息 ---------- */
.kefu-media-img {
    display: block;
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    cursor: pointer;
    background: #fafafa;
}

.kefu-media-video {
    display: block;
    width: 200px;
    max-width: 100%;
    border-radius: 6px;
    background: #000;
}

.kefu-media-fallback {
    display: inline-block;
    padding: 8px 10px;
    background: #f0f0f0;
    color: #999;
    font-size: 12px;
    border-radius: 6px;
}

/* ---------- 订单卡片 ---------- */
.kefu-order-card {
    width: 230px;
    max-width: 100%;
    background: #fff;
    border: 1px solid #ebebeb;
    border-radius: 8px;
    overflow: hidden;
}

.kefu-order-card-img {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
    background: #fafafa;
}

.kefu-order-card-body {
    padding: 8px 10px;
}

.kefu-order-card-title {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    max-height: 40px;
    overflow: hidden;
}

.kefu-order-card-no {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.kefu-order-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 12px;
}

.kefu-order-card-amount {
    color: #d9000b;
    font-weight: bold;
}

.kefu-order-card-status {
    color: #999;
}

/* ---------- 输入区 ---------- */
.kefu-input {
    border-top: 1px solid #ececec;
    padding: 8px 10px 10px;
    background: #fff;
    flex-shrink: 0;
}

.kefu-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 7px;
}

.kefu-tool-btn {
    font-size: 12px;
    padding: 3px 10px;
    border: 1px solid #e0e0e0;
    background: #fafafa;
    color: #666;
    border-radius: 3px;
    cursor: pointer;
}

.kefu-tool-btn:hover:not(:disabled) {
    border-color: #d9000b;
    color: #d9000b;
    background: #fff;
}

.kefu-tool-btn:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.kefu-textarea {
    display: block;
    width: 100%;
    height: 64px;
    resize: none;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    line-height: 1.5;
    font-family: "Microsoft Yahei", sans-serif;
    color: #333;
    outline: none;
}

.kefu-textarea:focus {
    border-color: #d9000b;
}

.kefu-textarea:disabled {
    background: #f7f7f7;
    cursor: not-allowed;
}

.kefu-send-row {
    display: flex;
    align-items: center;
    margin-top: 7px;
}

.kefu-tip {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: #999;
    padding-right: 8px;
}

.kefu-send-btn {
    background: #d9000b;
    color: #fff;
    border: none;
    padding: 6px 20px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

.kefu-send-btn:hover:not(:disabled) {
    background: #b80009;
}

.kefu-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ---------- 订单选择层 ---------- */
.kefu-order-mask {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, .45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000000;
}

.kefu-order-mask.kefu-order-mask-show {
    display: flex;
}

.kefu-order-box {
    width: 420px;
    max-width: 92vw;
    max-height: 70vh;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

.kefu-order-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: #d9000b;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

.kefu-order-header .kefu-icon-btn {
    margin-left: auto;
}

.kefu-order-list {
    overflow-y: auto;
    padding: 4px 0;
}

.kefu-order-item {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #f2f2f2;
    cursor: pointer;
}

.kefu-order-item:hover {
    background: #fafafa;
}

.kefu-order-item-img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    background: #f5f5f5;
    flex-shrink: 0;
}

.kefu-order-item-body {
    flex: 1;
    min-width: 0;
}

.kefu-order-item-title {
    font-size: 13px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kefu-order-item-no {
    font-size: 12px;
    color: #999;
    margin-top: 3px;
}

.kefu-order-item-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    margin-top: 3px;
}

.kefu-order-amount {
    color: #d9000b;
}

.kefu-order-status {
    color: #999;
}

.kefu-order-empty {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 28px 10px;
}
