/* ===== 智能客服悬浮窗（双模式：桌面常驻 / 移动端点按钮展开） ===== */
/* 强制覆盖：CSS 规范的 [hidden] 默认 display:none 会被下方 #chat-widget-panel 的 display:flex 覆盖 */
/* 这里用 !important 强制 [hidden] 优先，确保 JS 设的 hidden=true 能生效 */
[hidden] { display: none !important; }

:root {
    --cw-primary: #E55B00;
    --cw-primary-dark: #B84500;
    --cw-primary-light: #FF8C42;
    --cw-accent: #D4A574;
    --cw-bg: #F5F0E8;
    --cw-bot-bubble: #ffffff;
    --cw-user-bubble: #E55B00;
    --cw-text: #2C2C2C;
    --cw-text-muted: #6c757d;
    --cw-border: #e1d8c8;
    --cw-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

/* 聊天面板（常驻显示在右下角，不需要按钮触发） */
#chat-widget-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 360px;
    height: 500px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--cw-shadow);
    z-index: 9991;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--cw-text);
    border: 1px solid var(--cw-border);
}

/* 头部 */
.cw-header {
    background: linear-gradient(135deg, var(--cw-primary) 0%, var(--cw-primary-dark) 100%);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.cw-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}
.cw-header-title .icon {
    width: 28px; height: 28px;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
}
.cw-header-hint {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 1px;
}

/* 消息区 */
.cw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: var(--cw-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cw-messages::-webkit-scrollbar { width: 6px; }
.cw-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 3px; }

.cw-msg {
    max-width: 78%;
    padding: 9px 12px;
    border-radius: 12px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.cw-msg.bot {
    background: var(--cw-bot-bubble);
    align-self: flex-start;
    border: 1px solid var(--cw-border);
    border-top-left-radius: 4px;
}
.cw-msg.user {
    background: var(--cw-user-bubble);
    color: #fff;
    align-self: flex-end;
    border-top-right-radius: 4px;
}
.cw-msg-meta {
    font-size: 11px;
    color: var(--cw-text-muted);
    margin-top: 2px;
    padding: 0 4px;
}
.cw-msg-meta.user { text-align: right; }

.cw-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--cw-border);
    border-top-left-radius: 4px;
    border-radius: 12px;
    padding: 10px 14px;
    display: none;
    color: var(--cw-text-muted);
    font-size: 13px;
}
.cw-typing.show { display: block; }
.cw-typing span {
    display: inline-block;
    width: 6px; height: 6px;
    background: var(--cw-text-muted);
    border-radius: 50%;
    margin: 0 1px;
    animation: cw-bounce 1.2s infinite;
}
.cw-typing span:nth-child(2) { animation-delay: 0.15s; }
.cw-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cw-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* 输入区 */
.cw-input {
    border-top: 1px solid var(--cw-border);
    padding: 8px;
    display: flex;
    gap: 6px;
    background: #fff;
    flex-shrink: 0;
}
.cw-input input {
    flex: 1;
    border: 1px solid var(--cw-border);
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.cw-input input:focus { border-color: var(--cw-primary); }
.cw-input button {
    background: var(--cw-primary);
    color: #fff;
    border: none;
    border-radius: 18px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.cw-input button:hover { background: var(--cw-primary-dark); }
.cw-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 快捷问题 */
.cw-suggest {
    padding: 8px 12px;
    background: #fff;
    border-top: 1px dashed var(--cw-border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}
.cw-suggest-chip {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: 12px;
    color: var(--cw-primary);
    cursor: pointer;
    transition: background 0.15s;
}
.cw-suggest-chip:hover { background: #ebe0d0; }

/* 浮动按钮（移动端才显示） */
#chat-widget-button {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cw-primary) 0%, var(--cw-primary-dark) 100%);
    color: #fff;
    border: none;
    box-shadow: 0 6px 20px rgba(229, 91, 0, 0.45);
    cursor: pointer;
    z-index: 9991;
    font-size: 28px;
    display: none;           /* 桌面端默认隐藏 */
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    padding: 0;
    line-height: 1;
}
#chat-widget-button:hover { transform: scale(1.08); }
#chat-widget-button:active { transform: scale(0.95); box-shadow: 0 3px 10px rgba(229, 91, 0, 0.5); }

/* 按钮内 SVG 图标（headset）的 3D 立体效果 */
.cw-icon {
    width: 32px;
    height: 32px;
    fill: #fff;
    /* 多层 drop-shadow 模拟卡通 3D 立体：底部主阴影 + 顶部高光 + 中间柔光 */
    filter:
        drop-shadow(0 1px 0 rgba(0, 0, 0, 0.25))         /* 底深色描边 */
        drop-shadow(0 2px 3px rgba(0, 0, 0, 0.30))       /* 投影 */
        drop-shadow(0 0 6px rgba(255, 255, 255, 0.35));  /* 顶部高光 */
    transition: filter 0.15s, transform 0.15s;
}
#chat-widget-button:hover .cw-icon {
    filter:
        drop-shadow(0 1px 0 rgba(0, 0, 0, 0.25))
        drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35))
        drop-shadow(0 0 10px rgba(255, 255, 255, 0.50));
}

/* 关闭按钮 */
.cw-close {
    background: rgba(255,255,255,0.18);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.cw-close:hover { background: rgba(255,255,255,0.32); }

/* 移动端响应 — 双模式（移动端默认只显示按钮，点开才出弹窗） */
@media (max-width: 480px) {
    /* 移动端：显示按钮 */
    #chat-widget-button { display: flex; }

    /* 移动端：弹窗样式 */
    #chat-widget-panel {
        right: 12px;
        left: auto;                  /* 不左右贴满屏幕 */
        width: 300px;                /* 固定宽度 */
        max-width: calc(100vw - 24px); /* 极窄屏不超出 */
        bottom: 12px;
        height: 55vh;                /* 占屏幕 55% */
        max-height: 420px;
        min-height: 320px;
        border-radius: 10px;
    }
    .cw-header { padding: 10px 12px; }
    .cw-header-title { font-size: 14px; }
    .cw-messages { padding: 10px; }
    .cw-msg { font-size: 13px; padding: 7px 10px; }
    .cw-suggest { padding: 6px 10px; gap: 4px; }
    .cw-suggest-chip { font-size: 11px; padding: 3px 8px; }
    .cw-input { padding: 6px; }
    .cw-input input { font-size: 13px; padding: 7px 12px; }
    .cw-input button { font-size: 13px; padding: 7px 12px; }
}