/**
 * Markdown渲染器样式
 * 为AI回复气泡中的Markdown内容提供专业的样式支持
 */

/* ===== 主容器样式 ===== */
.markdown-container {
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 16px 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
}

.markdown-container.basic {
    border-left: 4px solid #ffa500;
}

/* ===== 工具栏样式 ===== */
.markdown-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    min-height: 48px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 内容类型标签 */
.content-type-badge {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.content-type-badge.technical {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.content-type-badge.tutorial {
    background: #f3e5f5;
    color: #7b1fa2;
    border: 1px solid #ce93d8;
}

.content-type-badge.explanation {
    background: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.content-type-badge.reference {
    background: #fff3e0;
    color: #ef6c00;
    border: 1px solid #ffcc02;
}

.content-type-badge.standard {
    background: #f5f5f5;
    color: #424242;
    border: 1px solid #bdbdbd;
}

/* 复杂度标签 */
.complexity-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
}

.complexity-badge.level-1 {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.complexity-badge.level-2 {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

.complexity-badge.level-3 {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.complexity-badge.level-4,
.complexity-badge.level-5 {
    background: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

/* 工具栏按钮 */
.markdown-toolbar button {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 4px;
}

.markdown-toolbar button:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.markdown-toolbar button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.markdown-toolbar button.copied {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

/* ===== 内容区域样式 ===== */
.markdown-content {
    padding: 24px;
    max-width: none;
    overflow-x: auto;
}

/* 标题样式 */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 24px 0 16px 0;
    font-weight: 600;
    line-height: 1.25;
    color: #24292e;
}

.markdown-content h1 {
    font-size: 2em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 8px;
}

.markdown-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 6px;
}

.markdown-content h3 {
    font-size: 1.25em;
}

.markdown-content h4 {
    font-size: 1em;
}

.markdown-content h5 {
    font-size: 0.875em;
}

.markdown-content h6 {
    font-size: 0.85em;
    color: #6a737d;
}

/* 段落样式 */
.markdown-content p {
    margin: 16px 0;
    color: #24292e;
}

/* 列表样式 */
.markdown-content ul,
.markdown-content ol {
    margin: 16px 0;
    padding-left: 32px;
}

.markdown-content li {
    margin: 4px 0;
}

.markdown-content li > p {
    margin: 8px 0;
}

/* 代码样式 */
.markdown-content code {
    background: #f6f8fa;
    border-radius: 3px;
    font-size: 85%;
    margin: 0;
    padding: 0.2em 0.4em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    color: #e83e8c;
}

.markdown-content pre {
    background: #f6f8fa;
    border-radius: 6px;
    font-size: 85%;
    line-height: 1.45;
    overflow: auto;
    padding: 16px;
    margin: 16px 0;
    position: relative;
}

.markdown-content pre code {
    background: transparent;
    border: 0;
    display: inline;
    line-height: inherit;
    margin: 0;
    max-width: auto;
    overflow: visible;
    padding: 0;
    word-wrap: normal;
    color: #24292e;
}

/* 代码块复制按钮 */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ffffff;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.markdown-content pre:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: #f6f8fa;
}

/* 表格样式 */
.markdown-content table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    margin: 16px 0;
    overflow: auto;
    display: block;
    white-space: nowrap;
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid #d0d7de;
    padding: 6px 13px;
    text-align: left;
}

.markdown-content table th {
    background: #f6f8fa;
    font-weight: 600;
}

.markdown-content table tr:nth-child(2n) {
    background: #f6f8fa;
}

/* 引用块样式 */
.markdown-content blockquote {
    border-left: 4px solid #d0d7de;
    color: #656d76;
    margin: 16px 0;
    padding: 0 16px;
}

.markdown-content blockquote > :first-child {
    margin-top: 0;
}

.markdown-content blockquote > :last-child {
    margin-bottom: 0;
}

/* 链接样式 */
.markdown-content a {
    color: #0969da;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* 分隔线样式 */
.markdown-content hr {
    background: #d0d7de;
    border: 0;
    height: 1px;
    margin: 24px 0;
}

/* 图片样式 */
.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 8px 0;
}

/* ===== 数学公式样式 ===== */
.markdown-content .katex {
    font-size: 1.1em;
}

.markdown-content .katex-display {
    margin: 16px 0;
    text-align: center;
}

/* ===== Mermaid图表样式 ===== */
.markdown-content .mermaid {
    text-align: center;
    margin: 16px 0;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 16px;
}

/* ===== 统计信息样式 ===== */
.markdown-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    font-size: 12px;
    color: #6c757d;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.stat-item i {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* ===== 全屏模式样式 ===== */
.markdown-container:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.markdown-container:fullscreen .markdown-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .markdown-toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .toolbar-left,
    .toolbar-right {
        justify-content: center;
    }
    
    .markdown-content {
        padding: 16px;
    }
    
    .markdown-stats {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .markdown-content {
        padding: 12px;
    }
    
    .markdown-content h1 {
        font-size: 1.5em;
    }
    
    .markdown-content h2 {
        font-size: 1.25em;
    }
    
    .markdown-content table {
        font-size: 14px;
    }
}

/* ===== 打印样式 ===== */
@media print {
    .markdown-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .markdown-toolbar,
    .markdown-stats {
        display: none;
    }
    
    .markdown-content {
        padding: 0;
    }
    
    .markdown-content a {
        color: #000;
        text-decoration: underline;
    }
}

/* ===== 深色主题支持 ===== */
@media (prefers-color-scheme: dark) {
    .markdown-container {
        background: #0d1117;
        border-color: #30363d;
        color: #c9d1d9;
    }
    
    .markdown-toolbar {
        background: linear-gradient(135deg, #161b22 0%, #21262d 100%);
        border-bottom-color: #30363d;
    }
    
    .markdown-content h1,
    .markdown-content h2,
    .markdown-content h3,
    .markdown-content h4,
    .markdown-content h5,
    .markdown-content h6 {
        color: #f0f6fc;
    }
    
    .markdown-content p {
        color: #c9d1d9;
    }
    
    .markdown-content code {
        background: #161b22;
        color: #f85149;
    }
    
    .markdown-content pre {
        background: #161b22;
    }
    
    .markdown-content pre code {
        color: #c9d1d9;
    }
    
    .markdown-content table th {
        background: #161b22;
    }
    
    .markdown-content table tr:nth-child(2n) {
        background: #0d1117;
    }
    
    .markdown-content blockquote {
        border-left-color: #30363d;
        color: #8b949e;
    }
    
    .markdown-content a {
        color: #58a6ff;
    }
    
    .markdown-stats {
        background: #161b22;
        border-top-color: #30363d;
        color: #8b949e;
    }
}