/* 思维导图卡片样式 - 豆包简洁风格 */
.mindmap-card {
    background: transparent;  /* 透明背景，更简洁 */
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 20px 0;
    box-shadow: none;
}

/* 包含思维导图的消息需要更宽 */
.ai-message:has(.mindmap-card) {
    max-width: 95% !important;
}

.mindmap-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 12px;
    text-align: center;  /* 居中显示 */
}

.mindmap-description {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 16px;
    text-align: center;  /* 居中显示 */
}

.mindmap-explanation {
    font-size: 15px;
    color: #475569;
    line-height: 1.7;
    padding: 16px 24px;
    background: #f8fafc;  /* 更浅的背景色 */
    border-left: 4px solid #3b82f6;  /* 蓝色边框 */
    border-radius: 8px;
    margin-bottom: 24px;
}

.mindmap-container {
    background: #ffffff;  /* 纯白色背景 */
    border-radius: 12px;
    padding: 40px;  /* 增加内边距，让图表更舒展 */
    margin-bottom: 20px;
    overflow: hidden;
    min-height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    border: 1px solid #e5e7eb;  /* 浅灰色边框 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);  /* 轻微阴影 */
}

.mindmap-container:active {
    cursor: grabbing;
}

.mindmap-container:fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    padding: 40px;
}

/* Mermaid SVG样式 */
.mindmap-container svg {
    width: 100%;
    height: auto;
    min-height: 450px;
    display: block;
    max-width: 100%;
    background: #ffffff !important;  /* 强制白色背景 */
}

/* 强制覆盖 Mermaid 生成的深色背景 */
.mindmap-container svg rect[fill="#2c3e50"],
.mindmap-container svg rect[fill="#34495e"],
.mindmap-container svg rect[fill="#1a1a1a"],
.mindmap-container svg rect[fill*="#2"],
.mindmap-container svg rect[fill*="#3"][fill*="4"] {
    fill: #ffffff !important;
}

/* 强制覆盖 Mermaid mindmap 的背景 */
.mindmap-container svg g.mindmap-node rect {
    fill: #ffffff !important;
}

/* SVG包装器 - 弹性铺满 */
.mindmap-svg-wrapper {
    width: 100% !important;
    min-height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

/* 操作按钮 - 豆包风格 */
.mindmap-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;  /* 居中显示 */
    margin-top: 16px;
}

.mindmap-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #4b5563;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.mindmap-action-btn:hover {
    background: #f9fafb;
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.mindmap-action-btn:active {
    transform: translateY(0);
}

.mindmap-action-btn svg {
    width: 18px;
    height: 18px;
}

/* 错误状态 */
.mindmap-error {
    text-align: center;
    padding: 40px 20px;
    color: #ef4444;
}

.mindmap-error .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.mindmap-error .error-message {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.mindmap-error .error-detail {
    font-size: 14px;
    color: #6b7280;
}

/* 加载状态 */
.mindmap-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #3b82f6;
}

.mindmap-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.mindmap-loading-text {
    font-size: 16px;
    color: #3b82f6;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 响应式 */
@media (max-width: 768px) {
    .mindmap-card {
        padding: 0;
        margin: 16px 0;
    }
    
    .mindmap-container {
        padding: 24px;
        min-height: 350px;
    }
    
    .mindmap-explanation {
        padding: 12px 16px;
        margin-bottom: 16px;
    }
    
    .mindmap-actions {
        gap: 8px;
    }
    
    .mindmap-action-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .mindmap-action-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* 深色主题 */
.dark-theme .mindmap-card {
    background: transparent;
}

.dark-theme .mindmap-container {
    background: #1f2937;
    border-color: #374151;
}

.dark-theme .mindmap-title {
    color: #f3f4f6;
}

.dark-theme .mindmap-description {
    color: #9ca3af;
}

.dark-theme .mindmap-explanation {
    background: #1f2937;
    border-left-color: #3b82f6;
    color: #d1d5db;
}

.dark-theme .mindmap-action-btn {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.dark-theme .mindmap-action-btn:hover {
    background: #4b5563;
    border-color: #3b82f6;
    color: #3b82f6;
}

.dark-theme .mindmap-error .error-detail {
    color: #9ca3af;
}

/* 降级视图样式（当Mermaid无法渲染时） */
.mindmap-fallback {
    background: #f8fafc;
    border-radius: 12px;
    padding: 24px;
    border: 2px dashed #cbd5e1;
}

.fallback-header {
    text-align: center;
    margin-bottom: 20px;
}

.fallback-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.fallback-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.fallback-subtitle {
    font-size: 14px;
    color: #64748b;
    line-height: 1.6;
}

.fallback-code {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    max-height: 400px;
    overflow-y: auto;
}

.fallback-code pre {
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #334155;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.fallback-code code {
    background: none;
    padding: 0;
    border: none;
}

.fallback-error {
    font-size: 12px;
    color: #ef4444;
    background: #fef2f2;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 12px;
    border-left: 3px solid #ef4444;
}

.fallback-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.fallback-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.fallback-copy-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.fallback-copy-btn:active {
    transform: translateY(0);
}

.fallback-copy-btn svg {
    width: 16px;
    height: 16px;
}

/* 加载中样式 */
.mindmap-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    font-size: 16px;
    color: #64748b;
    background: #f8fafc;
    border-radius: 8px;
}

.mindmap-loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 12px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
