/**
 * AI客服聊天窗口样式
 */

/* 基础样式 */
#ai-cs-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#ai-cs-chat-widget.right {
    right: 20px;
    bottom: 20px;
}

#ai-cs-chat-widget.left {
    left: 20px;
    bottom: 20px;
}

/* 聊天按钮 */
#ai-cs-chat-widget .chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 999999;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
}

#ai-cs-chat-widget .chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

#ai-cs-chat-widget .chat-button .close-icon {
    display: none;
    color: #fff;
    font-size: 24px;
}

#ai-cs-chat-widget.open .chat-button .open-icon {
    display: none;
}

#ai-cs-chat-widget.open .chat-button .close-icon {
    display: block;
}

#ai-cs-chat-widget .chat-button .unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* 聊天窗口 */
#ai-cs-chat-widget .chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

#ai-cs-chat-widget.left .chat-window {
    right: auto;
    left: 0;
}

#ai-cs-chat-widget.open .chat-window {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 头部 */
#ai-cs-chat-widget .chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#ai-cs-chat-widget .header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#ai-cs-chat-widget .header-info .avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

#ai-cs-chat-widget .header-info .title-section h4 {
    margin: 0;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

#ai-cs-chat-widget .header-info .title-section .status {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

#ai-cs-chat-widget .header-info .title-section .status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    margin-right: 5px;
}

#ai-cs-chat-widget .minimize-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

#ai-cs-chat-widget .minimize-btn:hover {
    color: #fff;
}

/* 消息区域 */
#ai-cs-chat-widget .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

#ai-cs-chat-widget .message {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

#ai-cs-chat-widget .message.user {
    flex-direction: row-reverse;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#ai-cs-chat-widget .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

#ai-cs-chat-widget .message.ai .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#ai-cs-chat-widget .message.user .message-avatar {
    background: #e9ecef;
}

#ai-cs-chat-widget .message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

#ai-cs-chat-widget .message.ai .message-content {
    background: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#ai-cs-chat-widget .message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

#ai-cs-chat-widget .message-text {
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
}

#ai-cs-chat-widget .message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 5px;
}

/* 加载动画 */
#ai-cs-chat-widget .message.loading .message-content {
    padding: 16px 20px;
}

#ai-cs-chat-widget .typing-indicator {
    display: flex;
    gap: 4px;
}

#ai-cs-chat-widget .typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

#ai-cs-chat-widget .typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

#ai-cs-chat-widget .typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* 快捷操作 */
#ai-cs-chat-widget .quick-actions {
    padding: 10px 15px;
    background: #fff;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
}

#ai-cs-chat-widget .quick-actions::-webkit-scrollbar {
    display: none;
}

#ai-cs-chat-widget .quick-btn {
    padding: 8px 14px;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    background: #fff;
    color: #667eea;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

#ai-cs-chat-widget .quick-btn:hover {
    background: #f8f9fa;
    border-color: #667eea;
}

/* 输入区域 */
#ai-cs-chat-widget .chat-input {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #e9ecef;
}

#ai-cs-chat-widget .input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px 8px 8px 12px;
}

#ai-cs-chat-widget #ai-cs-input {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    max-height: 100px;
    padding: 6px 0;
    outline: none;
    font-family: inherit;
}

#ai-cs-chat-widget .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#ai-cs-chat-widget .send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#ai-cs-chat-widget .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#ai-cs-chat-widget .input-footer {
    text-align: center;
    margin-top: 8px;
}

#ai-cs-chat-widget .powered-by {
    font-size: 11px;
    color: #adb5bd;
}

/* 转人工提示 */
#ai-cs-chat-widget .handoff-notice {
    padding: 15px;
    background: #fff3cd;
    text-align: center;
    font-size: 13px;
    color: #856404;
}

#ai-cs-chat-widget .handoff-notice p {
    margin: 0;
}

/* 响应式设计 */
@media (max-width: 480px) {
    #ai-cs-chat-widget .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
    }
    
    #ai-cs-chat-widget.right,
    #ai-cs-chat-widget.left {
        right: 10px;
        bottom: 10px;
    }
    
    #ai-cs-chat-widget .chat-button {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
}

/* 滚动条样式 */
#ai-cs-chat-widget .chat-messages::-webkit-scrollbar {
    width: 6px;
}

#ai-cs-chat-widget .chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#ai-cs-chat-widget .chat-messages::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 3px;
}

#ai-cs-chat-widget .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* 主题样式 */
/* 蓝色主题 */
#ai-cs-chat-widget.theme-blue .chat-button,
#ai-cs-chat-widget.theme-blue .chat-header,
#ai-cs-chat-widget.theme-blue .send-btn {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

#ai-cs-chat-widget.theme-blue .quick-btn {
    color: #2196F3;
}

/* 绿色主题 */
#ai-cs-chat-widget.theme-green .chat-button,
#ai-cs-chat-widget.theme-green .chat-header,
#ai-cs-chat-widget.theme-green .send-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
}

#ai-cs-chat-widget.theme-green .quick-btn {
    color: #4CAF50;
}

/* 深色主题 */
#ai-cs-chat-widget.theme-dark .chat-button,
#ai-cs-chat-widget.theme-dark .chat-header,
#ai-cs-chat-widget.theme-dark .send-btn {
    background: linear-gradient(135deg, #424242 0%, #212121 100%);
}

#ai-cs-chat-widget.theme-dark .quick-btn {
    color: #424242;
}

/* 错误消息样式 */
#ai-cs-chat-widget .message.error .message-content {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* 系统消息样式 */
#ai-cs-chat-widget .message.system .message-content {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
    font-size: 13px;
    text-align: center;
    max-width: 100%;
}

#ai-cs-chat-widget .message.system {
    justify-content: center;
}

/* 头部操作按钮 */
#ai-cs-chat-widget .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 声音开关按钮 */
#ai-cs-chat-widget .sound-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

#ai-cs-chat-widget .sound-toggle:hover {
    background: rgba(255,255,255,0.3);
    border-color: #fff;
}

#ai-cs-chat-widget .sound-toggle.muted {
    opacity: 0.6;
}

#ai-cs-chat-widget .sound-toggle.muted .sound-icon {
    opacity: 0.5;
}
/* ... existing CSS ... */

/* 产品卡片样式 */
#ai-cs-chat-widget .product-message .message-content {
    max-width: 90%;
}

#ai-cs-chat-widget .ai-product-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

#ai-cs-chat-widget .ai-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none !important;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#ai-cs-chat-widget .ai-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border-color: #667eea;
}

#ai-cs-chat-widget .ai-product-image {
    width: 100%;
    height: 120px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#ai-cs-chat-widget .ai-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

#ai-cs-chat-widget .ai-product-card:hover .ai-product-image img {
    transform: scale(1.05);
}

#ai-cs-chat-widget .ai-product-info {
    padding: 12px;
}

#ai-cs-chat-widget .ai-product-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
}

#ai-cs-chat-widget .ai-product-price {
    font-size: 16px;
    font-weight: 700;
    color: #e53935;
    margin-bottom: 6px;
}

#ai-cs-chat-widget .ai-product-price del {
    font-size: 12px;
    color: #999;
    font-weight: 400;
    margin-left: 6px;
}

#ai-cs-chat-widget .ai-product-price ins {
    text-decoration: none;
}

#ai-cs-chat-widget .ai-product-stock {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

#ai-cs-chat-widget .ai-product-stock.in-stock {
    color: #4caf50;
    background: #e8f5e9;
}

#ai-cs-chat-widget .ai-product-stock.out-of-stock {
    color: #f44336;
    background: #ffebee;
}

/* 单列卡片布局（小屏幕） */
@media (max-width: 400px) {
    #ai-cs-chat-widget .ai-product-cards {
        grid-template-columns: 1fr;
    }
}

/* 添加占位图样式 */
#ai-cs-chat-widget .ai-product-image:empty::before {
    content: '📦';
    font-size: 40px;
    opacity: 0.3;
}

/* ==================== 订单卡片样式 ==================== */

#ai-cs-chat-widget .order-message .message-content {
    max-width: 90%;
}

#ai-cs-chat-widget .ai-order-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

#ai-cs-chat-widget .ai-order-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none !important;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: block;
}

#ai-cs-chat-widget .ai-order-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    border-color: #667eea;
}

/* 订单头部 */
#ai-cs-chat-widget .ai-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

#ai-cs-chat-widget .ai-order-number {
    font-size: 12px;
    color: #666;
    font-family: monospace;
}

#ai-cs-chat-widget .ai-order-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

/* 订单主体 */
#ai-cs-chat-widget .ai-order-body {
    display: flex;
    gap: 12px;
    padding: 12px;
}

#ai-cs-chat-widget .ai-order-image {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0f0f0;
}

#ai-cs-chat-widget .ai-order-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#ai-cs-chat-widget .ai-order-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

#ai-cs-chat-widget .ai-order-product {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#ai-cs-chat-widget .ai-order-total {
    font-size: 16px;
    font-weight: 700;
    color: #e53935;
    margin-bottom: 4px;
}

#ai-cs-chat-widget .ai-order-date {
    font-size: 12px;
    color: #999;
}

/* 空订单状态 */
#ai-cs-chat-widget .ai-order-empty {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}

#ai-cs-chat-widget .ai-order-empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}


/* ==================== 快捷按钮优化 ==================== */

/* 登录用户按钮样式 - 订单按钮高亮 */
#ai-cs-chat-widget .quick-btn[data-i18n="quick_orders"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

#ai-cs-chat-widget .quick-btn[data-i18n="quick_orders"]:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b4190 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 热门产品按钮 - 橙色主题 */
#ai-cs-chat-widget .quick-btn[data-i18n="quick_products"] {
    background: #fff5f0;
    color: #fa8c16;
    border-color: #ffd8bf;
}

#ai-cs-chat-widget .quick-btn[data-i18n="quick_products"]:hover {
    background: #fa8c16;
    color: #fff;
    border-color: #fa8c16;
}

/* 价格咨询按钮 - 绿色主题 */
#ai-cs-chat-widget .quick-btn[data-i18n="quick_price"] {
    background: #f6ffed;
    color: #52c41a;
    border-color: #b7eb8f;
}

#ai-cs-chat-widget .quick-btn[data-i18n="quick_price"]:hover {
    background: #52c41a;
    color: #fff;
    border-color: #52c41a;
}

/* 人工客服按钮 - 红色主题 */
#ai-cs-chat-widget .quick-btn[data-i18n="quick_human"] {
    background: #fff1f0;
    color: #f5222d;
    border-color: #ffa39e;
}

#ai-cs-chat-widget .quick-btn[data-i18n="quick_human"]:hover {
    background: #f5222d;
    color: #fff;
    border-color: #f5222d;
}

/* 联系我们按钮 */
#ai-cs-chat-widget .quick-btn[data-i18n="quick_contact"] {
    background: #e6fffb;
    color: #13c2c2;
    border-color: #87e8de;
}

#ai-cs-chat-widget .quick-btn[data-i18n="quick_contact"]:hover {
    background: #13c2c2;
    color: #fff;
    border-color: #13c2c2;
}

/* 售后服务按钮 */
#ai-cs-chat-widget .quick-btn[data-i18n="quick_service"] {
    background: #f0f5ff;
    color: #2f54eb;
    border-color: #adc6ff;
}

#ai-cs-chat-widget .quick-btn[data-i18n="quick_service"]:hover {
    background: #2f54eb;
    color: #fff;
    border-color: #2f54eb;
}

/* ==================== 图片消息样式 ==================== */

/* 图片上传按钮 */
#ai-cs-chat-widget .upload-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
    visibility: visible !important;
    opacity: 1 !important;
}

#ai-cs-chat-widget .upload-btn:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b4190 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#ai-cs-chat-widget .upload-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* 图片预览区域 */
#ai-cs-chat-widget .image-preview-container {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

#ai-cs-chat-widget .image-preview-wrapper {
    position: relative;
    display: inline-block;
}

#ai-cs-chat-widget .image-preview-wrapper img {
    max-width: 120px;
    max-height: 90px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

#ai-cs-chat-widget .remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ff4d4f;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-cs-chat-widget .remove-image-btn:hover {
    background: #ff7875;
}

/* 聊天消息中的图片 */
#ai-cs-chat-widget .message-text .chat-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

#ai-cs-chat-widget .message-text .chat-image:hover {
    transform: scale(1.02);
}

#ai-cs-chat-widget .message-text .image-link {
    display: inline-block;
    text-decoration: none;
}

/* 输入区域调整 - 适配图片上传按钮 */
#ai-cs-chat-widget .input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 12px;
}

#ai-cs-chat-widget .input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

#ai-cs-chat-widget .upload-hint {
    font-size: 11px;
    color: #999;
}

/* 输入框调整 */
#ai-cs-chat-widget #ai-cs-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    max-height: 100px;
    padding: 8px 0;
}

/* 临时系统消息（自动消失） */
#ai-cs-chat-widget .message.system.temp-system-msg {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    animation: fadeIn 0.3s ease;
}

#ai-cs-chat-widget .message.system.temp-system-msg .message-content {
    background: transparent;
    border: none;
    color: #d48806;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 错误消息样式 */
#ai-cs-chat-widget .message.error {
    justify-content: center;
}

#ai-cs-chat-widget .message.error .message-content {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
    max-width: 90%;
}

#ai-cs-chat-widget .message.error .message-avatar {
    display: none;
}
