/* 在线客服聊天组件样式 */
.chat-widget {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 2147483647 !important; /* 最大z-index值 */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    transform: none !important; /* 防止被父元素transform影响 */
    will-change: auto !important;
    contain: layout !important;
}

/* 聊天按钮 */
.chat-btn {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: #3b82f6;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.chat-btn:hover {
    transform: translateY(-2px);
    background: #2563eb;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.chat-btn i {
    font-size: 28px;
    color: white;
}

.chat-btn .unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53e3e;
    color: white;
    font-size: 12px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* 聊天窗口 */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chat-window.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

/* 聊天头部 */
.chat-header {
    background: #3b82f6;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.human-service-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    border: none;
    outline: none;
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.human-service-btn:hover {
    background: rgba(255,255,255,0.3);
}

.human-service-btn i {
    font-size: 18px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-avatar i {
    font-size: 20px;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    opacity: 0.8;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-close:hover {
    opacity: 1;
}


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

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.message-item {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

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

.message-item.visitor {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-item.visitor .message-avatar {
    background: #3b82f6;
    color: white;
}

.message-content {
    max-width: 70%;
    margin: 0 10px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.message-item.visitor .message-bubble {
    background: #3b82f6;
    color: white;
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    text-align: right;
}

.message-item.visitor .message-time {
    text-align: left;
}

/* 系统消息 */
.system-message {
    text-align: center;
    margin: 16px 0;
}

.system-message span {
    background: #e2e8f0;
    color: #64748b;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
}

/* 输入区域 */
.chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #667eea;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #3b82f6;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    background: #2563eb;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 连接状态 */
.connection-status {
    padding: 8px;
    text-align: center;
    font-size: 12px;
}

.connection-status.connecting {
    background: #fef3c7;
    color: #92400e;
}

.connection-status.connected {
    background: #d1fae5;
    color: #065f46;
}

.connection-status.disconnected {
    background: #fee2e2;
    color: #991b1b;
}

/* 响应式 */
@media (max-width: 480px) {
    .chat-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
    }
    
    .chat-btn {
        bottom: 10px;
        right: 10px;
    }
}
