/* ============ 在线客服：前台 widget + 后台坐席控制台 共享样式 ============ */
/* 自包含配色，不依赖前端主题框架（source 的 Tailwind / default 的 data-theme 均可） */

.chat-fab, .chat-admin-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #22d3ee, #7c3aed);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(124, 58, 237, .35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9990;
    transition: transform .15s ease;
}
.chat-fab:hover, .chat-admin-fab:hover { transform: scale(1.08); }

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    font-weight: 700;
    box-shadow: 0 0 0 2px #fff;
}

/* 前台对话面板 */
.chat-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    color: #1f2733;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9991;
    font-size: 14px;
}
.chat-panel[hidden] { display: none; }

.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #22d3ee, #7c3aed);
    color: #fff;
}
.chat-head .chat-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.chat-head .chat-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.chat-head .chat-dot.off { background: #fbbf24; }
.chat-head .chat-close { border: 0; background: rgba(255,255,255,.22); color: #fff; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; transition: background .15s ease; }
.chat-head .chat-close:hover { background: rgba(255,255,255,.42); }

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    background: #fff;
    border: 1px solid #e9edf2;
}
.chat-msg.me { align-self: flex-end; background: #2563eb; color: #fff; border-color: #2563eb; }
.chat-msg.sys { align-self: center; background: #eef2f7; color: #64748b; font-size: 12px; max-width: 90%; text-align: center; }
.chat-time { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.chat-msg.me .chat-time { color: #dbeafe; }

.chat-foot {
    position: relative;
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e9edf2;
    background: #fff;
    align-items: flex-end;
}
.chat-foot textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d8dee6;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    line-height: 1.5;
    height: 44px;
    max-height: 140px;
    overflow-y: auto;
    outline: none;
}
.chat-foot textarea:focus { border-color: #22d3ee; box-shadow: 0 0 0 2px rgba(34,211,238,.15); }
.chat-send {
    border: 0;
    background: #2563eb;
    color: #fff;
    border-radius: 10px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 600;
    height: 44px;
}
.chat-send:disabled { opacity: .5; cursor: not-allowed; }

/* 输入框左侧：表情 / 图片 图标按钮（前后台共用） */
.chat-ic {
    flex: 0 0 auto;
    width: 40px;
    height: 44px;
    border: 1px solid #d8dee6;
    background: #f8fafc;
    color: #64748b;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chat-ic:hover { background: #eef2f7; color: #2563eb; border-color: #cbd5e1; }
.chat-ic:active { transform: translateY(1px); }

/* 表情选择弹层（前后台共用） */
.chat-emoji-pop {
    position: absolute;
    left: 10px;
    bottom: calc(100% - 4px);
    width: 280px;
    max-height: 220px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .22);
    z-index: 9993;
}
.chat-emoji-pop[hidden] { display: none; }
.chat-emoji-pop button {
    border: 0;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    padding: 4px 0;
    border-radius: 8px;
    cursor: pointer;
}
.chat-emoji-pop button:hover { background: #eef2f7; }

/* 图片气泡（前后台共用基础样式） */
.chat-img {
    max-width: 180px;
    max-height: 180px;
    border-radius: 10px;
    display: block;
    cursor: pointer;
    object-fit: cover;
}
.chat-msg .bubble.chat-img { padding: 3px; }

/* 前台消息气泡：头像 + 昵称 + 气泡 + 时间（结构与后台坐席台一致，仅作用于前台 widget，不影响后台） */
.chat-body .chat-msg {
    display: flex;
    gap: 8px;
    max-width: 100%;
    align-items: flex-end;
    align-self: flex-start;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}
.chat-body .chat-msg.me { flex-direction: row-reverse; align-self: flex-end; background: transparent; color: inherit; }
.chat-body .chat-msg.sys { align-self: center; max-width: 90%; background: transparent; }
.chat-body .chat-msg .m-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex: 0 0 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}
.chat-body .chat-msg .m-col { display: flex; flex-direction: column; width: fit-content; max-width: 76%; min-width: 0; }
.chat-body .chat-msg.me .m-col { align-items: flex-end; }
.chat-body .chat-msg .m-who { font-size: 11px; color: #94a3b8; margin: 0 2px 3px; }
.chat-body .chat-msg .bubble {
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    background: #fff;
    border: 1px solid #e9edf2;
    font-size: 14px;
}
.chat-body .chat-msg.me .bubble { background: #2563eb; color: #fff; border-color: #2563eb; }
.chat-body .chat-msg.sys .bubble { background: #eef2f7; color: #64748b; font-size: 12px; border: none; text-align: center; }
.chat-body .chat-msg .chat-time { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.chat-body .chat-msg.me .chat-time { color: #cbd5e1; }
.chat-body .chat-msg .chat-img { padding: 3px; line-height: 0; border-radius: 12px; }

/* 游客昵称浮层 */
.chat-name-prompt {
    position: absolute;
    inset: 0;
    background: rgba(248, 250, 252, .98);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 18px;
}
.chat-name-prompt[hidden] { display: none; }
.chat-name-prompt input {
    border: 1px solid #d8dee6;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    outline: none;
}
.chat-name-prompt input:focus { border-color: #22d3ee; box-shadow: 0 0 0 2px rgba(34,211,238,.15); }
.chat-name-prompt button {
    border: 0;
    background: #2563eb;
    color: #fff;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    font-weight: 600;
}
.chat-name-close { position: absolute; top: 12px; right: 12px; border: 0; background: #e2e8f0; color: #475569; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.chat-name-close:hover { background: #cbd5e1; }

/* ============ 后台坐席控制台 ============ */
.chat-admin-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: min(960px, 94vw);
    height: min(720px, 88vh);
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    background: #fff;
    color: #1f2733;
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9991;
    font-size: 14px;
}
.chat-admin-panel[hidden] { display: none; }
.chat-admin-panel.dragging { box-shadow: 0 30px 80px rgba(15, 23, 42, .5); }
.chat-admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #0f172a;
    color: #fff;
    cursor: move;
    touch-action: none;
}
.chat-admin-head .chat-title { font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 15px; }
.chat-admin-head .chat-title .ctag { font-size: 11px; color: #cbd5e1; font-weight: 400; margin-left: 2px; }
.chat-admin-body { flex: 1; display: flex; min-height: 0; }

/* 左侧会话列表 */
.chat-admin-list {
    width: 300px;
    flex: 0 0 300px;
    border-right: 1px solid #e9edf2;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-height: 0;
}
.chat-admin-search { position: relative; padding: 12px; border-bottom: 1px solid #e9edf2; }
.chat-admin-search .bi-search { position: absolute; left: 24px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 13px; pointer-events: none; }
.chat-admin-search input {
    width: 100%; box-sizing: border-box; border: 1px solid #d8dee6; border-radius: 10px;
    padding: 9px 10px 9px 32px; font: inherit; font-size: 13px; outline: none; background: #f8fafc;
}
.chat-admin-search input:focus { border-color: #22d3ee; box-shadow: 0 0 0 2px rgba(34,211,238,.15); background: #fff; }
.chat-admin-scroll { flex: 1; overflow-y: auto; min-height: 0; }

.chat-admin-list .conv {
    display: flex; gap: 10px; padding: 12px; cursor: pointer; position: relative;
    border-bottom: 1px solid #f1f5f9; align-items: flex-start;
}
.chat-admin-list .conv:hover { background: #f8fafc; }
.chat-admin-list .conv.active { background: #e0f2fe; }
.chat-admin-list .conv.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #2563eb; }
.chat-admin-list .conv .avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px;
    display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 15px;
}
.chat-admin-list .conv .main { flex: 1; min-width: 0; }
.chat-admin-list .conv .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-admin-list .conv .cname { font-weight: 600; font-size: 14px; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-admin-list .conv .ctime { font-size: 11px; color: #94a3b8; flex: 0 0 auto; }
.chat-admin-list .conv .cpreview { font-size: 12px; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.chat-admin-list .conv .meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.chat-admin-list .conv .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; flex: 0 0 7px; }
.chat-admin-list .conv .dot.closed { background: #cbd5e1; }
.chat-admin-list .conv .cstatus { font-size: 11px; color: #64748b; }
.chat-admin-list .conv .cunread {
    margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
    min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 9px; padding: 0 5px;
}
.chat-admin-empty { padding: 30px 12px; text-align: center; color: #94a3b8; font-size: 13px; }
.chat-admin-scroll .chat-admin-empty { padding: 50px 12px; }

/* 右侧线程 */
.chat-admin-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-admin-thread-head { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid #e9edf2; background: #fff; }
.chat-admin-thread-head[hidden] { display: none; }
.chat-admin-thread-head .th-avatar { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 15px; }
.chat-admin-thread-head .th-name { font-weight: 600; color: #0f172a; font-size: 14px; }
.chat-admin-thread-head .th-status { font-size: 11px; color: #64748b; margin-top: 2px; }
.chat-admin-thread-head .th-status .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; margin-right: 4px; vertical-align: middle; }
.chat-admin-thread-head .th-status .dot.closed { background: #cbd5e1; }

.chat-admin-msgs { flex: 1; overflow-y: auto; padding: 16px; background: #f1f5f9; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.chat-date-sep { align-self: center; font-size: 11px; color: #94a3b8; background: #e2e8f0; padding: 2px 12px; border-radius: 10px; margin: 2px 0; }

/* 消息气泡（仅作用于后台线程，不影响前台 widget） */
.chat-admin-msgs .chat-msg {
    display: flex; gap: 8px; max-width: 100%; align-items: flex-end;
    padding: 0; background: transparent; border: none; border-radius: 0;
}
.chat-admin-msgs .chat-msg.me { flex-direction: row-reverse; align-self: flex-end; }
.chat-admin-msgs .chat-msg.sys { align-self: center; max-width: 90%; }
.chat-admin-msgs .chat-msg .m-avatar { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 13px; }
.chat-admin-msgs .chat-msg .m-col { display: flex; flex-direction: column; max-width: 76%; min-width: 0; }
.chat-admin-msgs .chat-msg.me .m-col { align-items: flex-end; }
.chat-admin-msgs .chat-msg .m-who { font-size: 11px; color: #94a3b8; margin: 0 2px 3px; }
.chat-admin-msgs .chat-msg .bubble { padding: 9px 13px; border-radius: 14px; line-height: 1.55; word-break: break-word; white-space: pre-wrap; background: #fff; border: 1px solid #e9edf2; font-size: 14px; }
.chat-admin-msgs .chat-msg.me .bubble { background: #2563eb; color: #fff; border-color: #2563eb; }
.chat-admin-msgs .chat-msg.sys .bubble { background: #eef2f7; color: #64748b; font-size: 12px; border: none; text-align: center; }
.chat-admin-msgs .chat-time { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.chat-admin-msgs .chat-msg.me .chat-time { color: #cbd5e1; }
.chat-admin-msgs .chat-msg .bubble.chat-img { padding: 3px; line-height: 0; }

.chat-admin-foot { position: relative; display: flex; gap: 8px; padding: 12px; border-top: 1px solid #e9edf2; align-items: flex-end; }
.chat-admin-foot textarea {
    flex: 1; resize: none; border: 1px solid #d8dee6; border-radius: 10px; padding: 10px 12px;
    font: inherit; line-height: 1.5; height: 44px; max-height: 140px; overflow-y: auto; outline: none;
}
.chat-admin-foot textarea:focus { border-color: #22d3ee; box-shadow: 0 0 0 2px rgba(34,211,238,.15); }
.chat-admin-foot .chat-send { padding: 0 20px; height: 44px; }
.chat-admin-foot .chat-close-conv {
    border: 1px solid #fca5a5; background: #fef2f2; color: #dc2626; border-radius: 10px;
    padding: 0 14px; height: 44px; cursor: pointer; font-size: 13px;
}
.chat-admin-foot .chat-send:disabled, .chat-admin-foot .chat-close-conv:disabled { opacity: .5; cursor: not-allowed; }

/* ============ 多渠道联系面板（悬浮按钮展开；仅在线客服弹出聊天窗口） ============ */
/* 自包含配色，不依赖前端主题框架（source / default 主题均可复用） */
.contact-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 300px;
    max-width: calc(100vw - 32px);
    background: #fff;
    color: #1f2733;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
    z-index: 9992;
    overflow: hidden;
    font-size: 14px;
    /* 弹出动效（与 source.css 原有 contact-panel 一致） */
    opacity: 0;
    transform: translateY(14px) scale(.96);
    visibility: hidden;
    pointer-events: none;
    transform-origin: bottom right;
    transition: opacity .28s ease, transform .28s cubic-bezier(.22,1,.36,1), visibility 0s linear .28s;
}
.contact-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    pointer-events: auto;
    transition: opacity .28s ease, transform .28s cubic-bezier(.22,1,.36,1), visibility 0s;
}
.contact-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #22d3ee, #7c3aed);
    color: #fff;
}
.contact-panel-title { font-weight: 600; }
.contact-panel-close {
    border: 0;
    background: rgba(255, 255, 255, .22);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
}
.contact-panel-close:hover { background: rgba(255, 255, 255, .42); }

.contact-panel-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.contact-channel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    color: #1f2733;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid #eef2f7;
    font: inherit;
    text-align: left;
    width: 100%;
    transition: background .15s ease, transform .15s ease, border-color .15s ease;
}
.contact-channel:hover { background: #eef2f7; border-color: #d8dee6; transform: translateY(-1px); }
.contact-channel i:first-child { font-size: 20px; color: #7c3aed; flex: 0 0 auto; }
.contact-channel--primary {
    background: linear-gradient(135deg, #22d3ee, #7c3aed);
    color: #fff;
    border: 0;
}
.contact-channel--primary i:first-child { color: #fff; }
.contact-channel--primary:hover { background: linear-gradient(135deg, #22d3ee, #7c3aed); filter: brightness(1.05); transform: translateY(-1px); }
.contact-channel-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.contact-channel-name { font-weight: 600; }
/* 副标题：外链/账号类渠道在名称下方显示实际值（微信号、邮箱、URL 等） */
.contact-channel-sub {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
    font-weight: 400;
    word-break: break-all;
    line-height: 1.4;
}
.contact-channel-go { font-size: 14px; color: #94a3b8; flex: 0 0 auto; }
.contact-channel--primary .contact-channel-go { color: rgba(255, 255, 255, .85); }

/* 「点击复制」型渠道：鼠标悬停呈可点击态 */
.contact-channel[data-copy] { cursor: pointer; }
[wb-copy-target] { cursor: pointer; }

/* 尊重「减少动态效果」系统偏好 */
@media (prefers-reduced-motion: reduce) {
    .contact-panel { transition: opacity .01s linear, visibility 0s; transform: none; }
    .contact-panel.is-open { transform: none; }
    .contact-channel, .contact-channel:hover { transition: none; transform: none; }
}
