* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow-x: hidden;
}

/* 确保根元素和所有父元素都不限制宽度 */
html,
body,
#root {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100%;
    box-sizing: border-box;
}

/* 聊天页面容器 */
#root {
    max-width: 800px !important;
    width: 100% !important;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

/* 聊天页面 */
.chat-page {
    width: 100% !important;
    max-width: 800px !important;
    height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 聊天容器 */
.chat-container {
    width: 100% !important;
    max-width: 800px !important;
    min-width: 300px;
    height: 100%;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    flex: 1;
}

/* 确保card类不影响宽度 */
.chat-container.card {
    width: 100% !important;
    max-width: 800px !important;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 聊天头部 */
.chat-header {
    padding: 16px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    background-color: #fafafa;
    width: 100%;
    box-sizing: border-box;
}

.chat-header-left {
    display: flex;
    align-items: center;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #1890ff;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 12px;
}

.avatar i {
    font-size: 18px;
}

.chat-header-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.status-text {
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot.online {
    background-color: #52c41a;
}

.status-dot.offline {
    background-color: #999;
}

/* 客服项目基础样式 */
.agent-item {
    padding: 10px;
    margin: 5px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.agent-item.enabled {
    opacity: 1;
}

.agent-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 在线客服样式 */
.agent-item.online {
    background-color: #f6ffed !important;
    border-color: #b7eb8f !important;
    box-shadow: 0 2px 8px rgba(82, 196, 26, 0.2) !important;
}

.agent-item.online:hover {
    background-color: #d9f7be !important;
    border-color: #95de64 !important;
}

/* 离线客服样式 */
.agent-item.offline {
    background-color: #f5f5f5 !important;
    border-color: #d9d9d9 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.agent-item.offline:hover {
    background-color: #e8e8e8 !important;
    border-color: #bfbfbf !important;
}

/* 聊天消息区域 */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.message-system {
    align-self: center;
    background-color: #f0f0f0;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 12px;
    color: #666;
}

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.message-row.visitor {
    flex-direction: row-reverse;
}

.message-content {
    max-width: 70%;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.message-bubble.visitor {
    background-color: #1890ff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-bubble.agent {
    background-color: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: block;
}

.avatar.sm {
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.visitor-avatar {
    background-color: #e5e5e5;
    color: #666;
}

/* 聊天输入区域 */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e5e5;
    background-color: #fafafa;
    width: 100%;
    box-sizing: border-box;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 8px;
    width: 100%;
    box-sizing: border-box;
}

.chat-rich-editor {
    flex: 1;
    min-height: 32px;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    font-size: 14px;
    line-height: 1.4;
}

.chat-rich-editor[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background-color: transparent;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.toolbar-btn:hover {
    background-color: #f0f0f0;
}

.send-btn {
    width: 32px;
    height: 32px;
    border: none;
    background-color: #1890ff;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.send-btn:hover {
    background-color: #40a9ff;
}

.send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 800px) {
    #root,
    .chat-page,
    .chat-container {
        max-width: 100% !important;
        width: 100% !important;
    }
}
