/* 主对话框样式 */
.ai-dialog .ai-assistant-modal {
    max-width: 800px;
    min-height: 600px;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.ai-dialog .chat-container {
    display: flex;
    flex-direction: column;
    height: 70vh;
}

/* 聊天历史记录区 */
.ai-dialog .chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 16px;
}

/* 消息气泡样式 */
.ai-dialog .chat-message {
    margin-bottom: 12px;
    max-width: 80%;
    
    &.user {
        margin-left: auto;
        .message-content {
            background: #0073aa;
            color: white;
        }
    }
    
    &.ai {
        margin-right: auto;
        .message-content {
            background: #fff;
            border: 1px solid #ccd0d4;
        }
    }
}

.ai-dialog .message-content {
    padding: 12px;
    border-radius: 18px;
    position: relative;
    
    .message-actions {
        position: absolute;
        right: -10px;
        top: 50%;
        transform: translateY(-50%);
        opacity: 0;
        transition: opacity 0.2s;
        
        button {
            margin-left: 4px;
        }
    }
    
    &:hover .message-actions {
        opacity: 1;
    }
}

/* 输入区样式 */
.ai-dialog .chat-input {
    display: flex;
    gap: 8px;
    
    .components-text-control__input {
        flex: 1;
        border-radius: 24px;
        padding: 8px 16px;
    }
}

/* 工具栏按钮 */
.ai-assistant-toolbar .ai-dialog-trigger {
    margin-left: 8px;
    padding: 6px 12px;
    background: #0073aa;
    color: white !important;
    border-radius: 3px;
    transition: all 0.2s;
}

.ai-assistant-toolbar .ai-dialog-trigger:hover {
    background: #006387;
}

/* 确保层级 */
.ai-dialog .ai-assistant-modal {
    z-index: 999999 !important;
}

/* AI 对话框核心样式 */
 .ai-dialog {
    width: 450px;
    height: 600px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    transition: 
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
 .ai-dialog.hidden{display:none;}
/* 最小化状态 */
.ai-dialog.minimized {
    height: 50px !important;
    opacity: 0.9;
}

/* 最大化状态 */
.ai-dialog.maximized {
    width: 95% !important;
    height: 90vh !important;
    top: 50% !important;
    left: 50% !important;
    margin: 0 !important;
    transform: translate(-50%, -50%) !important;
}

.ai-dialog .dialog-header {
    padding: 14px 16px;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    cursor: move;
}

.ai-dialog .dialog-header h3 {
    margin: 0;
    font-size: 16px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-dialog .controls {
    display: flex;
    gap: 6px;
}

.ai-dialog .control-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-dialog .control-btn:hover {
    background: #f1f3f5;
    color: #495057;
}

/* 聊天区域 */
.ai-dialog .chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #fff;
}

/* 消息气泡 */
.ai-dialog .message {
    margin: 8px 0;
    padding: 12px 16px;
    max-width: 85%;
    border-radius: 12px;
    position: relative;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-dialog .message.user {
    margin-left: auto;
    background: #007bff;
    color: white;
    border-radius: 12px 12px 0 12px;
}

.ai-dialog .message.ai {
    background: #f1f3f5;
    border-radius: 12px 12px 12px 0;
}

/* 输入区域 */
.ai-dialog .input-area {
    padding: 12px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.ai-dialog .input-wrapper {
    display: flex;
    gap: 8px;
    position: relative;
}

.ai-dialog textarea {
    flex: 1;
    min-height: 80px;
    padding: 12px 16px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
}

.ai-dialog .send-button,.stop-button{
    width: 40px;
    height: 40px;
    border: none;
    background: #007bff;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ai-dialog .send-button:hover,.stop-button:hover {
    background: #0056b3;
}

/* 工具提示 */
.ai-dialog .ai-tooltip {
    position: fixed;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000000;
}

.ai-dialog .ai-tooltip.visible {
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .ai-dialog {
        width: 95vw !important;
        height: 80vh !important;
    }
    
    .ai-dialog.maximized {
        height: 95vh !important;
    }
}
/* 新增部分 */
/* 悬浮按钮 */
.ai-dialog-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: all 0.3s ease;
}

/* 对话框激活时隐藏按钮 */
 .ai-dialog:not(.hidden) + .ai-dialog-trigger {
    display: none !important;
}

/* 消息操作按钮 */
.ai-dialog  .message .actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ai-dialog  .message:hover .actions {
    opacity: 1;
}

.ai-dialog  .action-btn {
    padding: 6px 12px;
    background: rgba(0,0,0,0.05);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ai-dialog  .action-btn:hover {
    background: rgba(0,0,0,0.1);
}
/* 触发按钮 */
.ai-dialog  .ai-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* 对话框 */
.ai-dialog .ai-dialog {
    z-index: 9999;
    /* 其他原有样式保持不变 */
}

/* 消息操作按钮优化 */
.ai-dialog .actions {
    gap: 8px;
    margin-top: 10px;
}

.ai-dialog .action-btn {
    padding: 6px 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.ai-dialog .action-btn:hover {
    background: rgba(0,0,0,0.1);
}

/* Toast提示优化 */
.ai-dialog .toast {
    padding: 12px 24px;
    border-radius: 28px;
}

.ai-dialog .toast.error {
    background: #ff4444;
}

.ai-dialog .ai-dialog {
    width: 450px;
    height: 600px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Trigger Button */
.ai-dialog .ai-dialog-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: all 0.3s ease;
    font-size: 12px;
}

/* Message Styling */
.ai-dialog .message {
    margin: 12px;
    padding: 16px;
    border-radius: 12px;
    animation: messageAppear 0.3s ease;
}

.ai-dialog .message.user {
    background: #007bff;
    color: white;
    margin-left: auto;
}

.ai-dialog .message.ai {
    margin-right: auto;
    display: flex;
    align-items: flex-start;
    padding: 0;
    background: transparent;
}

.ai-dialog .message.ai .ai-content {
    background: #f3f4f6;
    padding: 12px 16px;
    border-radius: 12px 12px 12px 0;
    flex: 1;
    word-break: break-word;
}

.ai-dialog .customer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    margin-top: 4px;
    flex-shrink: 0;
    object-fit: cover;
}

/* Action Buttons */
.ai-dialog .actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ai-dialog .message:hover .actions {
    opacity: 1;
}

.ai-dialog .action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Toast Notifications */
.ai-dialog .ai-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10000;
}

.ai-dialog .ai-toast.show {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-dialog {
        width: 95vw !important;
        height: 80vh !important;
    }
}

/* 加载动画 */
.ai-dialog .loading-dots {
    display: inline-block;
    margin-left: 10px;
}

.ai-dialog .typing-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 0;
}

.ai-dialog .typing-indicator .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #b0b8c1;
    border-radius: 50%;
    animation: dot-bounce 1.4s infinite ease-in-out both;
}

.ai-dialog .typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.ai-dialog .typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }
.ai-dialog .typing-indicator .dot:nth-child(3) { animation-delay: 0s; }

.ai-dialog .typing-indicator .typing-text {
    margin-left: 8px;
    font-size: 12px;
    color: #9ca3af;
    animation: typing-fade 1.8s ease-in-out infinite;
}

@keyframes dot-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes typing-fade {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.ai-dialog .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 4px;
    background: #ddd;
    border-radius: 50%;
    animation: dot-pulse 1.4s infinite ease-in-out;
}

.ai-dialog .dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dialog .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
    0%, 40%, 100% { transform: scale(0.6); }
    20% { transform: scale(1); }
}

/* 知识库引用文章卡片 */
.ai-dialog .kb-sources-card {
    margin: 8px 12px 16px 0;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f0f9ff 0%, #f8fafc 100%);
    border: 1px solid #dbeafe;
    border-radius: 10px;
    animation: sourceSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-dialog .kb-sources-card__title {
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

.ai-dialog .kb-sources-card__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ai-dialog .kb-sources-card__item {
    margin-bottom: 6px;
    line-height: 1.4;
}

.ai-dialog .kb-sources-card__item:last-child {
    margin-bottom: 0;
}

.ai-dialog .kb-sources-card__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #2563eb;
    text-decoration: none;
    padding: 4px 10px;
    background: rgba(37, 99, 235, 0.06);
    border-radius: 6px;
    transition: all 0.2s ease;
    word-break: break-all;
}

.ai-dialog .kb-sources-card__link::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'%3E%3C/path%3E%3Cpolyline points='15 3 21 3 21 9'%3E%3C/polyline%3E%3Cline x1='10' y1='14' x2='21' y2='3'%3E%3C/line%3E%3C/svg%3E") center/contain no-repeat;
    flex-shrink: 0;
}

.ai-dialog .kb-sources-card__link:hover {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
    text-decoration: none;
}

@keyframes sourceSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 产品卡片容器 */
.ai-dialog .kb-product-cards {
    margin: 8px 12px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 单个产品卡片 */
.ai-dialog .kb-product-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    animation: productCardSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.ai-dialog .kb-product-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
}

.ai-dialog .kb-product-card__link {
    display: flex;
    align-items: stretch;
    text-decoration: none;
    color: inherit;
    padding: 10px;
    gap: 12px;
}

.ai-dialog .kb-product-card__thumbnail {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-dialog .kb-product-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-dialog .kb-product-card__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.ai-dialog .kb-product-card__title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-dialog .kb-product-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-dialog .kb-product-card__price {
    font-size: 14px;
    font-weight: 700;
    color: #dc2626;
    line-height: 1;
}

.ai-dialog .kb-product-card__stock {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    line-height: 1.4;
    white-space: nowrap;
}

.ai-dialog .kb-product-card__stock.stock-in {
    background: #dcfce7;
    color: #166534;
}

.ai-dialog .kb-product-card__stock.stock-out {
    background: #fee2e2;
    color: #991b1b;
}

.ai-dialog .kb-product-card__summary {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@keyframes productCardSlideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
  
  /* 使用统计 */
  .ai-dialog .usage-stats {
      padding: 8px;
      background: #f5f5f5;
      border-top: 1px solid #ddd;
      font-size: 12px;
      color: #666;
  }

  .ai-dialog .ai-assistant-dialog {
    position: fixed;
    right: 30px;
    bottom: 30px;
    width: 400px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 99999;
}

/* 添加在ai-dialog.css中 */
.ai-dialog .chat-time-marker {
    text-align: center;
    margin: 15px 0;
    padding: 5px;
    color: #888;
    font-size: 0.8em;
    border-top: 1px dashed #ddd;
    border-bottom: 1px dashed #ddd;
}
.ai-dialog .message-tools{margin:5px 0;}
.ai-dialog .message-tools button{ padding:5px 10px;margin:2px; cursor:pointer;border:none;background: #007bff;color: white;border-radius:8px;cursor: pointer;transition:background 0.2s ease;font-size:12px;}
.ai-dialog .message-tools button:hover{background-color: #2c3e50;}

/* 流式加载效果 */
.ai-dialog .message.loading .content {
    background: #f5f5f5;
    position: relative;
}

.ai-dialog .status-indicator {
    padding: 8px 0;
    display: none;
}

.ai-dialog .message.loading .status-indicator {
    display: block;
}

.ai-dialog .dot-flashing {
    position: relative;
    width: 6px;
    height: 6px;
    border-radius: 3px;
    background-color: #999;
    animation: dotFlashing 1s infinite linear;
}

@keyframes dotFlashing {
    0% { background-color: #999; }
    50%, 100% { background-color: #e0e0e0; }
}

.ai-dialog .message.ai.loading .content::after {
    content: '▋';
    animation: blink 1s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

/* 思考消息样式 */
.ai-dialog .message.thought {
    background: #f8f9fa;
    border-left: 4px solid #4a90e2;
    margin: 10px 0;
    padding: 12px;
    border-radius: 4px;
}

.ai-dialog .message.thought .content {
    color: #666;
    font-size: 0.9em;
    white-space: pre-wrap;
}

.ai-dialog .thinking-header {
    font-weight: 600;
    color: #4a90e2;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 状态指示器调整 */
.ai-dialog .message.thought .status-indicator {
    display: none;
}