/* 新增：确保按钮不会被body/html裁剪 */
html, body {
    overflow: visible !important;
    position: static !important; /* 取消body的relative定位，避免fixed按钮以body为基准 */
}

/* 基础样式重置 - 匹配 JS 的 ID 命名 */
#svc-button, #svc-chatbox {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 客服按钮 - 仅强化层级，视觉不变 */
#svc-button {
    position: fixed;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #c03;
    color: white;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 9999999 !important;
    transition: all 0.3s ease;
    pointer-events: auto !important;
}

/* 电脑端（>=768px）- 固定对话框高度+位置 */
@media (min-width: 768px) {
    #svc-button {
        bottom: 30px;
        top: 90%;
    }
    #svc-chatbox {
        bottom: 100px;
        top: auto;
        right: 20px;
        width: 380px !important;
        height: 580px !important; /* PC端固定高度 */
    }
}

/* 移动端（<768px）- 固定对话框高度+适配 */
@media (max-width: 767px) {
    #svc-button {
        top: 50% !important;
        transform: translateY(-50%);
        bottom: auto;
    }
    #svc-chatbox {
        top: 50%;
        transform: translateY(-50%);
        right: 10px;
        width: 90% !important;
        max-width: 380px;
        bottom: auto;
        height: 80vh !important; /* 移动端固定高度（视口80%） */
    }
}

/* 客服窗口核心样式 - 固定高度+Flex布局（关键修复） */
#svc-chatbox {
    position: fixed !important;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    z-index: 99998 !important;
    overflow: hidden !important;
    display: none !important;
    pointer-events: auto !important;
    /* 关键：Flex列布局，让内部区域自适应高度 */
    display: flex !important;
    flex-direction: column !important;
    /* 强制隐藏（覆盖上面的display:flex） */
    display: none !important;
}

/* 强制显示类 - 匹配 JS 的 svc-open 类 */
#svc-chatbox.svc-open {
    display: flex !important; /* 改为flex显示，匹配内部布局 */
}

/* 对话框头部 - 固定高度区域 */
#svc-header {
    background: #c03;
    padding: 15px;
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    border-radius: 12px 12px 0 0;
    position: relative;
    flex-shrink: 0; /* 禁止头部压缩 */
}

#svc-close {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
}

#svc-close:hover {
    color: #f0f0f0;
}

/* 欢迎语 - 固定高度区域 */
#svc-welcome {
    padding: 15px;
    background: #f9f9f9;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0; /* 禁止压缩 */
}

/* 快捷按钮区 - 固定高度区域 */
#svc-quick-options {
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #eee;
    text-align: center;
    flex-shrink: 0; /* 禁止压缩 */
}

.svc-quick-btn {
    margin: 5px;
    padding: 6px 12px;
    background: #f0f0f0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.svc-quick-btn:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

/* 消息容器 - 自适应剩余高度+滚动（核心修复） */
#svc-messages {
    flex: 1 !important; /* 占满剩余高度（关键） */
    overflow-y: auto !important; /* 内容超出显示垂直滚动条 */
    padding: 15px;
    background-color: #fcfcfc;
    display: flex;
    flex-direction: column;
    gap: 12px; /* 消息间隔 */
    /* 移除max-height，由flex:1控制高度 */
    max-height: none !important;
}

/* 用户消息气泡（右侧） */
.svc-msg-user {
    text-align: right;
    margin-left: auto; /* 强制右对齐 */
    align-self: flex-end;
}

.svc-msg-user span {
    display: inline-block;
    background: #007bff;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    max-width: 80%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
}

/* 用户消息气泡尖角 */
.svc-msg-user span::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 12px;
    border: 6px solid transparent;
    border-left-color: #007bff;
}

/* 客服消息气泡（左侧） */
.svc-msg-bot {
    text-align: left;
    margin-right: auto; /* 强制左对齐 */
    align-self: flex-start;
}

.svc-msg-bot span {
    display: inline-block;
    background: #e9ecef;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    max-width: 80%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
}

/* 客服消息气泡尖角 */
.svc-msg-bot span::after {
    content: '';
    position: absolute;
    left: -10px;
    top: 12px;
    border: 6px solid transparent;
    border-right-color: #e9ecef;
}

/* 移除时间戳显示 */
.svc-msg-user span > span,
.svc-msg-bot span > span {
    display: none !important;
}

/* 输入框区域 - 两端对齐+增宽输入框（核心修复） */
#svc-footer {
    padding: 8px 15px !important; /* 优化左右内边距，增加输入框宽度 */
    border-top: 1px solid #eee;
    background: #fff;
    /* 关键：Flex布局+两端对齐 */
    display: flex !important;
    align-items: center !important;
    gap: 10px !important; /* 输入框与按钮间距 */
    flex-shrink: 0; /* 禁止输入区压缩 */
}

/* 输入框 - 增宽+占满剩余宽度（关键） */
#svc-input {
    flex: 1 !important; /* 占满所有剩余宽度（增宽核心） */
    padding: 12px 18px !important; /* 优化内边距，提升输入体验 */
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    transition: border 0.2s;
    /* 移除多余margin，确保宽度最大化 */
    margin: 0 !important;
    outline: none !important;
}

#svc-input:focus {
    border-color: #007bff; /* 聚焦高亮 */
}

/* 发送按钮 - 固定宽度+靠右（关键） */
#svc-send {
    padding: 12px 22px !important; /* 优化按钮尺寸 */
    background: #007bff;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0 !important; /* 禁止按钮压缩 */
    width: auto !important; /* 固定按钮宽度，不被拉伸 */
}

#svc-send:hover {
    background: #e22e50;
}

/* 免责声明 - 固定高度区域 */
#svc-disclaimer {
    padding: 10px 15px;
    font-size: 12px;
    color: #666;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    flex-shrink: 0; /* 禁止压缩 */
}

#svc-disclaimer a {
    color: #c03;
    text-decoration: none;
}

#svc-disclaimer a:hover {
    text-decoration: underline;
}

/* 滚动条美化 - 确保滚动条正常显示 */
#svc-messages::-webkit-scrollbar {
    width: 6px !important; /* 滚动条宽度 */
    height: 6px !important;
}

#svc-messages::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 3px !important;
}

#svc-messages::-webkit-scrollbar-thumb {
    background: #ccc !important;
    border-radius: 3px !important;
}

#svc-messages::-webkit-scrollbar-thumb:hover {
    background: #999 !important;
}