﻿/* =====================================================================
 * AI智能客服 · 访客窗口样式（widget.css）
 * 约定：类名统一 dzcs- 前缀；不依赖、也不污染站点原有样式；不写 body/html
 * 等全局选择器（移动端全屏适配除外）；主题色经根容器变量 --dzcs-theme 使用。
 * 风格：深色文字 + 浅色背景的简洁现代风。
 * ===================================================================== */

/* -------------------- 根容器：右下角锚点（left 时左下角） -------------------- */
.dzcs-widget {
    position: fixed; right: 24px; bottom: 24px; z-index: 999999;
    --dzcs-theme: #2f6fed;
}
.dzcs-widget--left {
    right: auto; left: 24px;
}

/* -------------------- 悬浮客服按钮 -------------------- */
.dzcs-launcher {
    position: absolute; right: 0; bottom: 0; width: 56px; height: 56px;
    padding: 0; border: 0; border-radius: 50%; background: var(--dzcs-theme);
    color: #fff; cursor: pointer; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(20, 35, 60, .28);
    transition: transform .18s ease, box-shadow .18s ease;
}
.dzcs-widget--left .dzcs-launcher {
    left: 0; right: auto;
}
.dzcs-launcher:hover {
    transform: translateY(-2px); box-shadow: 0 12px 28px rgba(20, 35, 60, .32);
}
.dzcs-launcher:active {
    transform: translateY(0) scale(.96);
}
.dzcs-launcher-icon {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; font-size: 26px; line-height: 1;
}
.dzcs-launcher-icon img {
    width: 100%; height: 100%; object-fit: cover;
}

/* -------------------- 聊天面板 -------------------- */
.dzcs-panel {
    position: absolute; right: 0; bottom: 76px; width: 360px; height: 560px;
    max-height: calc(100vh - 120px); display: flex; flex-direction: column;
    overflow: hidden; background: #fff; color: #243040; border-radius: 16px;
    box-shadow: 0 18px 48px rgba(20, 35, 60, .22);
    opacity: 0; visibility: hidden; transform: translateY(14px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.dzcs-widget--left .dzcs-panel {
    right: auto; left: 0; transform-origin: bottom left;
}
.dzcs-widget.dzcs-open .dzcs-panel {
    opacity: 1; visibility: visible; transform: none;
}

/* -------------------- 面板头部 -------------------- */
.dzcs-header {
    flex: 0 0 auto; display: flex; align-items: center;
    justify-content: space-between; gap: 8px; padding: 12px 14px;
    background: var(--dzcs-theme); color: #fff;
}
.dzcs-head-left {
    display: flex; align-items: center; gap: 10px; min-width: 0;
}
.dzcs-avatar {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
    overflow: hidden; background: rgba(255, 255, 255, .22);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.dzcs-avatar img {
    width: 100%; height: 100%; object-fit: cover;
}
.dzcs-head-info {
    min-width: 0;
}
.dzcs-head-title {
    font-size: 15px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dzcs-head-status {
    display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .92;
}
.dzcs-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: #8fe0a2;
}
.dzcs-dot--off {
    background: #ffd166;
}
.dzcs-dot--human {
    background: #8fd0ff;
}
.dzcs-head-actions {
    flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
}
.dzcs-act {
    height: 26px; padding: 0 9px; border: 0; border-radius: 8px;
    background: rgba(255, 255, 255, .16); color: #fff; font-size: 12px;
    line-height: 26px; cursor: pointer;
}
.dzcs-act:hover {
    background: rgba(255, 255, 255, .3);
}
.dzcs-act[disabled] {
    opacity: .45; cursor: not-allowed;
}
.dzcs-act-min, .dzcs-act-close {
    width: 26px; padding: 0; font-size: 15px;
}

/* -------------------- 消息滚动区 -------------------- */
.dzcs-body {
    flex: 1 1 auto; overflow-y: auto; padding: 12px 12px 6px;
    background: #f5f7fb; -webkit-overflow-scrolling: touch;
}
.dzcs-messages {
    display: flex; flex-direction: column; gap: 10px;
}
.dzcs-row {
    display: flex;
}
.dzcs-row--visitor {
    justify-content: flex-end;
}
.dzcs-row--ai, .dzcs-row--agent {
    justify-content: flex-start;
}
.dzcs-row--system {
    justify-content: center;
}
.dzcs-col {
    display: flex; flex-direction: column; max-width: 80%;
}
.dzcs-bubble {
    padding: 9px 12px; border-radius: 12px; background: #fff; color: #243040;
    box-shadow: 0 1px 3px rgba(20, 35, 60, .08);
    white-space: pre-wrap; word-break: break-word;
}
.dzcs-row--visitor .dzcs-bubble {
    background: var(--dzcs-theme); color: #fff; border-bottom-right-radius: 4px;
}
.dzcs-row--ai .dzcs-bubble, .dzcs-row--agent .dzcs-bubble {
    border-bottom-left-radius: 4px;
}
.dzcs-bubble img {
    display: block; max-width: 220px; border-radius: 8px;
}
.dzcs-sys {
    max-width: 86%; padding: 5px 10px; border-radius: 10px; background: #eef1f6;
    color: #8a94a6; font-size: 12px; text-align: center;
}
.dzcs-sender {
    display: flex; align-items: center; gap: 5px; margin-bottom: 3px;
    font-size: 11px; color: #8a94a6;
}
.dzcs-tag {
    padding: 0 5px; border-radius: 5px; background: #e6efff;
    color: var(--dzcs-theme); font-size: 10px; line-height: 16px;
}
.dzcs-meta {
    margin-top: 4px; font-size: 11px; color: #9aa4b5;
}
.dzcs-ref {
    margin-top: 4px; font-size: 11px; color: #8a94a6;
}
.dzcs-status {
    margin-top: 3px; font-size: 11px; text-align: right; color: #9aa4b5;
}
.dzcs-row--visitor .dzcs-status {
    color: rgba(255, 255, 255, .85);
}

/* -------------------- 快捷问题栏 -------------------- */
.dzcs-quick {
    flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 12px; background: #fff; border-top: 1px solid #eef1f6;
}
.dzcs-quick:empty {
    display: none;
}
.dzcs-chip {
    max-width: 100%; padding: 4px 10px; border: 1px solid #e2e8f2;
    border-radius: 14px; background: #f7f9fd; color: #3a4a60; font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.dzcs-chip:hover {
    border-color: var(--dzcs-theme); color: var(--dzcs-theme);
}

/* -------------------- 输入联想下拉 -------------------- */
.dzcs-suggest {
    position: absolute; left: 12px; right: 12px; bottom: 62px; z-index: 6;
    display: none; background: #fff; border: 1px solid #e6ebf3;
    border-radius: 10px; overflow: hidden;
    box-shadow: 0 -8px 20px rgba(20, 35, 60, .12);
}
.dzcs-suggest.dzcs-show {
    display: block;
}
.dzcs-suggest-item {
    padding: 8px 12px; color: #3a4a60; font-size: 13px; cursor: pointer;
    border-bottom: 1px solid #f2f5fa;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dzcs-suggest-item:last-child {
    border-bottom: 0;
}
.dzcs-suggest-item:hover {
    background: #f5f8fe; color: var(--dzcs-theme);
}

/* -------------------- 表情面板（8 列栅格） -------------------- */
.dzcs-emoji {
    position: absolute; left: 12px; right: 12px; bottom: 62px; z-index: 7;
    display: none; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 8px;
    background: #fff; border: 1px solid #e6ebf3; border-radius: 10px;
    box-shadow: 0 -8px 20px rgba(20, 35, 60, .12);
}
.dzcs-emoji.dzcs-show {
    display: grid;
}
.dzcs-emoji span {
    padding: 3px 0; border-radius: 6px; font-size: 20px; line-height: 1;
    text-align: center; cursor: pointer;
}
.dzcs-emoji span:hover {
    background: #f2f6fd;
}

/* -------------------- 底部输入区 -------------------- */
.dzcs-footer {
    flex: 0 0 auto; display: flex; align-items: flex-end; gap: 6px;
    padding: 8px 10px; background: #fff; border-top: 1px solid #eef1f6;
}
.dzcs-tool {
    flex: 0 0 auto; width: 34px; height: 34px; padding: 0; border: 0;
    border-radius: 9px; background: #f2f5fa; color: #5a6b82;
    font-size: 17px; line-height: 1; cursor: pointer;
}
.dzcs-tool:hover {
    background: #e8eef8;
}
.dzcs-input {
    flex: 1 1 auto; min-height: 34px; max-height: 88px; padding: 8px 10px;
    border: 1px solid #e2e8f2; border-radius: 10px; background: #fbfcfe;
    color: #243040; font: 14px/1.5 inherit; resize: none; outline: none;
}
.dzcs-input:focus {
    border-color: var(--dzcs-theme); background: #fff;
}
.dzcs-send {
    width: auto; height: 34px; padding: 0 14px; background: var(--dzcs-theme);
    color: #fff; font-size: 13px;
}
.dzcs-send:hover {
    background: var(--dzcs-theme); opacity: .9;
}

/* -------------------- 线索收集 -------------------- */
.dzcs-lead-bar {
    display: none; flex: 0 0 auto; padding: 0 10px 8px; background: #fff;
}
.dzcs-lead-bar.dzcs-show {
    display: block;
}
.dzcs-lead-btn {
    width: 100%; padding: 8px; border: 1px dashed var(--dzcs-theme);
    border-radius: 10px; background: #f7faff; color: var(--dzcs-theme);
    font-size: 13px; cursor: pointer;
}
.dzcs-lead-btn:hover {
    background: #eef4ff;
}
.dzcs-lead-mask {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 9;
    display: none; align-items: center; justify-content: center;
    padding: 16px; background: rgba(15, 28, 48, .45);
}
.dzcs-lead-mask.dzcs-show {
    display: flex;
}
.dzcs-lead-form {
    width: 100%; display: flex; flex-direction: column; gap: 10px; padding: 16px;
    background: #fff; border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 28, 48, .3);
}
.dzcs-lead-title {
    margin: 0; font-size: 15px; color: #243040;
}
.dzcs-lead-input {
    padding: 9px 10px; border: 1px solid #e2e8f2; border-radius: 9px;
    background: #fbfcfe; color: #243040; font: 14px/1.5 inherit;
    resize: none; outline: none;
}
.dzcs-lead-input:focus {
    border-color: var(--dzcs-theme); background: #fff;
}
.dzcs-lead-demand {
    min-height: 64px;
}
.dzcs-lead-err {
    color: #e5484d; font-size: 12px;
}
.dzcs-lead-err:empty {
    display: none;
}
.dzcs-lead-ops {
    display: flex; justify-content: flex-end; gap: 8px;
}
.dzcs-ghost {
    padding: 8px 16px; border: 1px solid #dfe5ef; border-radius: 9px;
    background: #fff; color: #5a6b82; font-size: 13px; cursor: pointer;
}
.dzcs-primary {
    padding: 8px 18px; border: 0; border-radius: 9px; background: var(--dzcs-theme);
    color: #fff; font-size: 13px; cursor: pointer;
}
.dzcs-primary[disabled] {
    opacity: .6; cursor: not-allowed;
}

/* -------------------- 轻提示（排队 / 提交成功等） -------------------- */
.dzcs-toast {
    position: absolute; left: 50%; bottom: 82px; z-index: 20; max-width: 80%;
    padding: 8px 14px; border-radius: 20px; background: rgba(30, 42, 60, .92);
    color: #fff; font-size: 13px; text-align: center; opacity: 0;
    pointer-events: none; transform: translate(-50%, 10px);
    transition: opacity .2s ease, transform .2s ease;
}
.dzcs-toast.dzcs-show {
    opacity: 1; transform: translate(-50%, 0);
}

/* -------------------- 移动端全屏适配（宽度 <= 640px） -------------------- */
@media (max-width: 640px) {
    .dzcs-widget {
        right: 16px; bottom: 16px;
    }
    .dzcs-widget--left {
        left: 16px;
    }
    .dzcs-launcher {
        width: 50px; height: 50px;
    }
    /* 面板铺满全屏，去掉圆角与出场位移 */
    .dzcs-panel, .dzcs-widget--left .dzcs-panel {
        position: fixed; top: 0; right: 0; bottom: 0; left: 0;
        width: auto; height: auto; max-height: none;
        border-radius: 0; transform: none;
    }
    .dzcs-col {
        max-width: 84%;
    }
    .dzcs-suggest, .dzcs-emoji {
        bottom: 68px;
    }
}
