/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* ========== 左侧会话列表 ========== */
.sidebar {
    width: 320px;
    background: #fff;
    border-right: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-header h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #999;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff9800;
}

.status-dot.connected {
    background: #4caf50;
}

.status-dot.disconnected {
    background: #f44336;
}

.search-box {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: #1890ff;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #f5f7fa;
}

.conversation-item.active {
    background: #e6f7ff;
    border-left: 3px solid #1890ff;
}

.conversation-item .conv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.conversation-item .conv-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
}

.conversation-item .conv-time {
    font-size: 12px;
    color: #999;
}

.conversation-item .conv-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .unread-badge {
    display: inline-block;
    background: #f44336;
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* ========== 右侧聊天区域 ========== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
}

.chat-header {
    padding: 14px 24px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-size: 16px;
    font-weight: 500;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

/* ========== 消息区域 ========== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

.empty-chat .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.message {
    display: flex;
    margin-bottom: 16px;
    max-width: 70%;
}

.message.customer {
    justify-content: flex-start;
}

.message.agent {
    justify-content: flex-end;
    margin-left: auto;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.customer .message-bubble {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-top-left-radius: 2px;
}

.message.agent .message-bubble {
    background: #1890ff;
    color: #fff;
    border-top-right-radius: 2px;
}

.message-time {
    font-size: 11px;
    color: #bbb;
    margin-top: 4px;
    text-align: center;
}

/* ========== AI 建议面板 ========== */
.ai-suggestion-panel {
    background: #fff;
    border-top: 1px solid #e8e8e8;
    padding: 16px 24px;
}

.ai-suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ai-badge {
    font-size: 14px;
    font-weight: 500;
    color: #722ed1;
}

.ai-actions {
    display: flex;
    gap: 8px;
}

.ai-suggestion-content {
    background: #f9f0ff;
    border: 1px solid #d3adf7;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    min-height: 40px;
    white-space: pre-wrap;
}

.ai-suggestion-meta {
    margin-top: 8px;
    font-size: 12px;
    color: #999;
}

.ai-suggestion-meta .knowledge-ref {
    display: inline-block;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 6px;
    margin-top: 4px;
}

.ai-edit-area {
    margin-top: 10px;
}

.ai-edit-area textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.ai-edit-area textarea:focus {
    border-color: #1890ff;
}

.edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ========== 输入区域 ========== */
.input-area {
    background: #fff;
    border-top: 1px solid #e8e8e8;
    padding: 12px 24px;
}

.input-area textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
}

.input-area textarea:focus {
    border-color: #1890ff;
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.char-count {
    font-size: 12px;
    color: #999;
}

/* ========== 按钮样式 ========== */
.btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #1890ff;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #40a9ff;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover:not(:disabled) {
    background: #e0e0e0;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

/* ========== 模态框 ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: 480px;
    max-width: 90%;
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.modal-content p {
    margin-bottom: 12px;
    color: #666;
    font-size: 14px;
}

.modal-content textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: #52c41a;
}

.toast.error {
    background: #f44336;
}

.toast.info {
    background: #1890ff;
}

/* ========== 滚动条样式 ========== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #bfbfbf;
}
