/**
 * 智能客服页面优化样式
 * 包含：聊天界面、会话列表、知识库、响应式布局
 */

/* ===========================
   聊天布局
   =========================== */
.chat-layout {
    display: flex;
    height: calc(100vh - 150px);
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 会话列表侧栏 */
.chat-sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-sidebar-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #32325d;
}

.chat-sessions-list {
    flex: 1;
    overflow-y: auto;
}

.chat-session-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.chat-session-item:hover {
    background: #f8f9fa;
}

.chat-session-item.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1), transparent);
    border-left: 3px solid #667eea;
}

.session-avatar {
    position: relative;
    margin-right: 12px;
}

.session-avatar img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-dot.online {
    background: #48bb78;
}

.status-dot.offline {
    background: #cbd5e0;
}

.status-dot.busy {
    background: #ed8936;
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-name {
    font-weight: 600;
    color: #32325d;
    margin-bottom: 4px;
}

.session-preview {
    font-size: 13px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.session-time {
    font-size: 12px;
    color: #adb5bd;
}

.unread-badge {
    background: #f56565;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* 主聊天区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.chat-user-name {
    font-weight: 600;
    color: #32325d;
    margin-bottom: 2px;
}

.chat-user-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6c757d;
}

.chat-actions {
    display: flex;
    gap: 10px;
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chat-message {
    display: flex;
    margin-bottom: 20px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 10px;
    flex-shrink: 0;
}

.chat-message.agent .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.chat-message.user .message-avatar {
    background: #e9ecef;
    color: #6c757d;
}

.message-item-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.text-end .message-item-block {
    align-items: flex-end;
}

.message-content {
    max-width: 70%;
    border-radius: 18px;
    text-align: left;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
}

.chat-message.agent .message-bubble {
    background: white;
    color: #32325d;
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.user .message-time {
    text-align: right;
}

.auto-reply-tag {
    display: inline-block;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 600;
}

.message-failed {
    color: #f56565;
    font-size: 12px;
    margin-top: 4px;
}

/* 输入区域 */
.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.chat-quick-replies {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.quick-reply-btn {
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 13px;
    color: #6c757d;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-reply-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 5px;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}

.chat-attach-btn,
.chat-emoji-btn,
.chat-send-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-attach-btn:hover,
.chat-emoji-btn:hover {
    background: #e9ecef;
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

/* 用户信息侧栏 */
.chat-info-sidebar {
    width: 280px;
    background: white;
    border-left: 1px solid #e9ecef;
    padding: 20px;
    overflow-y: auto;
}

.user-info-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.user-info-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #32325d;
}

.user-info-content {
    margin-bottom: 30px;
}

.user-info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.user-info-item label {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
}

.user-info-item span {
    font-size: 13px;
    color: #32325d;
    text-align: right;
}

.user-info-history {
    margin-top: 20px;
}

.user-info-history h6 {
    font-size: 14px;
    font-weight: 600;
    color: #32325d;
    margin-bottom: 15px;
}

/* 空状态 */
.empty-sessions,
.chat-empty {
    padding: 40px 20px;
    text-align: center;
    color: #adb5bd;
    font-size: 14px;
}

.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.empty-chat i {
    font-size: 64px;
    color: #dee2e6;
    margin-bottom: 20px;
}

.empty-chat h5 {
    color: #6c757d;
    margin-bottom: 10px;
}

.empty-chat p {
    color: #adb5bd;
}

/* ===========================
   知识库样式
   =========================== */
.knowledge-base {
    background: white;
    border-radius: 12px;
    padding: 25px;
}

.knowledge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.knowledge-header h4 {
    margin: 0;
    color: #32325d;
}

.knowledge-search {
    margin-bottom: 20px;
}

.knowledge-search input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
}

.knowledge-search input:focus {
    border-color: #667eea;
    outline: none;
}

.knowledge-categories {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.category-btn {
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 20px;
    font-size: 14px;
    color: #6c757d;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.category-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.category-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
}

.knowledge-list {
    max-height: 600px;
    overflow-y: auto;
}

.knowledge-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.knowledge-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.knowledge-question {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 600;
    color: #32325d;
    margin-bottom: 10px;
}

.knowledge-question i {
    color: #667eea;
    margin-top: 2px;
}

.knowledge-answer {
    color: #6c757d;
    line-height: 1.6;
    margin-bottom: 15px;
}

.knowledge-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.knowledge-category {
    display: inline-block;
    padding: 4px 10px;
    background: white;
    border-radius: 12px;
    font-size: 12px;
    color: #667eea;
    font-weight: 500;
}

.knowledge-usage {
    font-size: 12px;
    color: #adb5bd;
}

.knowledge-actions {
    display: flex;
    gap: 5px;
}

.knowledge-actions button {
    width: 30px;
    height: 30px;
    border: none;
    background: white;
    border-radius: 50%;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
}

.knowledge-actions button:hover {
    background: #667eea;
    color: white;
}

.empty-knowledge {
    padding: 60px 20px;
    text-align: center;
    color: #adb5bd;
}

/* ===========================
   统计卡片样式
   =========================== */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.stat-icon.active {
    background: linear-gradient(135deg, #48bb78, #38a169);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #32325d;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: #6c757d;
}

/* ===========================
   响应式布局
   =========================== */
@media (max-width: 1400px) {
    .chat-info-sidebar {
        display: none;
    }
}

@media (max-width: 1200px) {
    .chat-sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
        height: auto;
    }
    
    .chat-sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .chat-main {
        height: 500px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .knowledge-categories {
        flex-wrap: wrap;
    }
}

@media (max-width: 576px) {
    .chat-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .chat-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .quick-reply-btn {
        font-size: 12px;
        padding: 4px 10px;
    }
    
    .knowledge-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .knowledge-header button {
        width: 100%;
    }
}