/* ========================================
   客服系统 - 全新侧边栏模板
   右滑式设计 + 现代聊天界面
   ======================================== */

.customer-service-widget {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* 遮罩层 */
.cs-modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.4) !important;
    z-index: 9999 !important;
    display: none !important;
    transition: opacity 0.3s !important;
}

.cs-modal-overlay.active {
    display: block !important;
}

/* 聊天窗口 - 右侧滑入式侧边栏 */
.cs-chat-window {
    position: fixed !important;
    top: 0 !important;
    right: -400px !important;
    width: 400px !important;
    height: 100vh !important;
    background: #f8f9fa !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15) !important;
    z-index: 10000 !important;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.cs-chat-window.active {
    right: 0 !important;
}

/* 头部 - 品牌区 */
.cs-chat-header {
    background: linear-gradient(135deg, #1e90ff 0%, #00bfff 100%) !important;
    color: #ffffff !important;
    padding: 24px 20px !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.cs-header-info {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    flex: 1 !important;
}

/* 客服头像 - 发光效果 */
.cs-avatar {
    width: 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 24px !important;
    flex-shrink: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.cs-header-text {
    flex: 1 !important;
}

.cs-header-text h3 {
    font-size: 17px !important;
    font-weight: 700 !important;
    margin: 0 0 4px 0 !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.cs-service-time {
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

.cs-service-time::before {
    content: '●' !important;
    color: #4ade80 !important;
    font-size: 10px !important;
    animation: statusBlink 2s ease-in-out infinite !important;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* 关闭按钮 - 透明圆形 */
.cs-close-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #ffffff !important;
    font-size: 20px !important;
    cursor: pointer !important;
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    transition: all 0.2s !important;
    flex-shrink: 0 !important;
}

.cs-close-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.1) !important;
}

/* 欢迎卡片 */
.cs-welcome-card {
    background: #ffffff !important;
    margin: 16px !important;
    padding: 16px !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
    text-align: center !important;
    flex-shrink: 0 !important;
}

.cs-welcome-card p {
    margin: 0 !important;
    font-size: 13px !important;
    color: #6b7280 !important;
    line-height: 1.6 !important;
}

/* 快捷问题 - 紧凑一排 */
.cs-quick-questions {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
    padding: 0 12px 16px 12px !important;
    flex-shrink: 0 !important;
}

.cs-quick-question-btn {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 14px !important;
    padding: 6px 8px !important;
    font-size: 11px !important;
    color: #374151 !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.cs-quick-question-btn:hover {
    background: #1e90ff !important;
    color: #ffffff !important;
    border-color: #1e90ff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(30, 144, 255, 0.3) !important;
}

/* 消息区域 - 聊天流 */
.cs-chat-messages {
    flex: 1 !important;
    padding: 16px !important;
    overflow-y: auto !important;
    background: transparent !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
}

/* 美化滚动条 */
.cs-chat-messages::-webkit-scrollbar {
    width: 6px !important;
}

.cs-chat-messages::-webkit-scrollbar-track {
    background: transparent !important;
}

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

.cs-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8 !important;
}

/* 消息容器 */
.cs-message {
    display: flex !important;
    gap: 10px !important;
    align-items: flex-start !important;
}

.cs-message.user {
    flex-direction: row-reverse !important;
}

.cs-message.service {
    flex-direction: row !important;
}

/* 消息头像 - 小图标 */
.cs-message-avatar {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    background: #1e90ff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 6px rgba(30, 144, 255, 0.3) !important;
}

.cs-message.user .cs-message-avatar {
    background: #10b981 !important;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3) !important;
}

.cs-message-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    max-width: 75% !important;
}

/* 消息气泡 - 对话式 */
.cs-message-bubble {
    padding: 12px 16px !important;
    border-radius: 16px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    word-wrap: break-word !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08) !important;
}

.cs-message.service .cs-message-bubble {
    background: #ffffff !important;
    color: #1f2937 !important;
    border-bottom-left-radius: 4px !important;
}

.cs-message.user .cs-message-bubble {
    background: #1e90ff !important;
    color: #ffffff !important;
    border-bottom-right-radius: 4px !important;
}

.cs-message-time {
    font-size: 11px !important;
    color: #9ca3af !important;
    padding: 0 4px !important;
    display: block !important;
}

.cs-message.user .cs-message-time {
    text-align: right !important;
}

/* 系统消息 - 时间线 */
.cs-system-message {
    text-align: center !important;
    color: #9ca3af !important;
    font-size: 11px !important;
    padding: 8px 0 !important;
    position: relative !important;
}

.cs-system-message::before,
.cs-system-message::after {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    width: 30% !important;
    height: 1px !important;
    background: #e5e7eb !important;
}

.cs-system-message::before {
    left: 0 !important;
}

.cs-system-message::after {
    right: 0 !important;
}

/* 输入区域 - 现代化设计 */
.cs-chat-input-area {
    padding: 16px !important;
    background: #ffffff !important;
    border-top: 1px solid #e5e7eb !important;
    flex-shrink: 0 !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05) !important;
}

.cs-input-wrapper {
    display: flex !important;
    gap: 10px !important;
    align-items: flex-end !important;
    background: #f3f4f6 !important;
    border-radius: 12px !important;
    padding: 8px 10px !important;
}

.cs-input-box {
    flex: 1 !important;
}

/* 输入框 - 无边框 */
.cs-input-textarea {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    padding: 4px 8px !important;
    font-size: 14px !important;
    resize: none !important;
    font-family: inherit !important;
    outline: none !important;
    min-height: 24px !important;
    max-height: 100px !important;
    line-height: 1.5 !important;
    box-sizing: border-box !important;
    color: #1f2937 !important;
}

.cs-input-textarea::placeholder {
    color: #9ca3af !important;
}

/* 发送按钮 - 圆形图标 */
.cs-send-btn {
    background: #1e90ff !important;
    border: none !important;
    color: #ffffff !important;
    padding: 0 !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    font-size: 16px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(30, 144, 255, 0.3) !important;
}

.cs-send-btn::before {
    content: '➤' !important;
    font-size: 14px !important;
}

.cs-send-btn:hover:not(:disabled) {
    background: #0080ff !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(30, 144, 255, 0.4) !important;
}

.cs-send-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: #94a3b8 !important;
    box-shadow: none !important;
}

/* 空状态 */
.cs-empty-state {
    text-align: center !important;
    padding: 40px 20px !important;
    color: #9ca3af !important;
    font-size: 13px !important;
}

/* 未读徽章 - 红点提示 */
.unread-badge {
    position: absolute !important;
    top: -2px !important;
    right: -2px !important;
    background: #ef4444 !important;
    color: #ffffff !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.6), 0 0 0 2px rgba(30, 41, 59, 1) !important;
    animation: badgePulse 2s ease-in-out infinite !important;
    z-index: 10 !important;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.6), 0 0 0 2px rgba(30, 41, 59, 1);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.8), 0 0 0 2px rgba(30, 41, 59, 1);
    }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .cs-chat-window {
        width: 100vw !important;
        right: -100vw !important;
    }
    
    .cs-chat-window.active {
        right: 0 !important;
    }
}

/* 平板适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    .cs-chat-window {
        width: 360px !important;
        right: -360px !important;
    }
}
