/* 客服系统样式 */

/* 客服悬浮按钮 */
.customer-service-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(118, 75, 162, 0.4);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.customer-service-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(118, 75, 162, 0.6);
}

.customer-service-btn i {
    color: white;
    font-size: 24px;
}

/* 脉冲动画 */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 20px rgba(118, 75, 162, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(118, 75, 162, 0.6), 0 0 0 10px rgba(118, 75, 162, 0.1);
    }
    100% {
        box-shadow: 0 4px 20px rgba(118, 75, 162, 0.4);
    }
}

/* 客服状态指示器 */
.service-status {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid white;
}

.service-status.online {
    background: #4CAF50;
}

.service-status.offline {
    background: #f44336;
}

/* 客服模态框 */
.customer-service-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 20px;
    box-sizing: border-box;
}

.customer-service-modal.show {
    display: flex;
}

.service-modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: modalSlideUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

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

/* 客服头部 */
.service-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

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

.service-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.service-info p {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.service-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.service-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 工作时间提示 */
.working-hours {
    background: #f8f9fa;
    padding: 14px 20px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.working-hours h4 {
    margin: 0 0 6px 0;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.working-hours p {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.3;
}

.working-hours p:last-child {
    margin-bottom: 0;
    font-weight: 500;
    color: #333;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background: #4CAF50;
}

.status-indicator.offline {
    background: #f44336;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #fafafa;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f0f0f0;
    min-height: 200px;
    max-height: 400px;
}

/* 聊天区域滚动条样式 - Webkit浏览器 */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
    transition: background 0.2s;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.chat-message.user .message-avatar {
    background: #28a745;
}

.message-content {
    background: white;
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 260px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    word-break: break-word;
    display: inline-block;
    white-space: normal;
    text-align: left;
}

.chat-message.user .message-content {
    background: #667eea;
    color: white;
    max-width: 240px;
}

.message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: calc(100% - 42px);
}

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

.message-time {
    font-size: 10px;
    color: #999;
    white-space: nowrap;
    align-self: flex-end;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.chat-message.user .message-time {
    color: #bbb;
}

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

.chat-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    min-height: 20px;
    max-height: 80px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-shadow: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.chat-input:focus {
    border-color: #667eea;
    box-shadow: none;
    outline: none;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #5a67d8;
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 快捷回复 */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-reply-btn {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    .customer-service-btn {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
    
    .customer-service-btn i {
        font-size: 20px;
    }
    
    .customer-service-modal {
        padding: 10px;
    }
    
    .service-modal-content {
        width: 100%;
        max-width: none;
        max-height: 95vh;
        min-height: 400px;
    }
    
    .service-modal-header {
        padding: 14px 16px;
    }
    
    .working-hours {
        padding: 12px 16px;
    }
    
    .chat-area {
        padding: 12px 16px;
        min-height: 180px;
        max-height: 320px;
    }
    
    .chat-input-area {
        padding: 12px 16px;
    }
    
    .message-content {
        max-width: 240px;
    }
    
    .chat-message.user .message-content {
        max-width: 220px;
    }
    
    .message-wrapper {
        max-width: calc(100% - 36px);
    }
}

/* 离线状态样式 */
.service-offline .customer-service-btn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    animation: none;
}

.service-offline .customer-service-btn:hover {
    box-shadow: 0 6px 25px rgba(108, 117, 125, 0.4);
}

/* 加载状态 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    width: 60px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}
