/* /css/markdown.css */
/*
   懒猫学术 - Markdown 渲染优化
   用于聊天气泡、分析详情等区域的 Markdown 内容样式
*/

.md-content {
    font-size: 14px;
    line-height: 1.75;
    color: inherit;
    word-break: break-word;
}

/* --- 标题 --- */
.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
    margin: 20px 0 10px;
    font-weight: 700;
    color: var(--text-primary, #1a1d23);
    line-height: 1.4;
}
.md-content h1 { font-size: 20px; }
.md-content h2 { font-size: 17px; }
.md-content h3 { font-size: 15px; }
.md-content h4 { font-size: 14px; }
.md-content h1:first-child,
.md-content h2:first-child,
.md-content h3:first-child {
    margin-top: 0;
}

/* --- 段落 --- */
.md-content p {
    margin: 0 0 12px;
}
.md-content p:last-child {
    margin-bottom: 0;
}

/* --- 列表 --- */
.md-content ul,
.md-content ol {
    margin: 8px 0 12px;
    padding-left: 22px;
}
.md-content ul {
    list-style: none;
    padding-left: 0;
}
.md-content ul > li {
    position: relative;
    padding-left: 16px;
    margin-bottom: 6px;
}
.md-content ul > li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 9px;
    width: 5px;
    height: 5px;
    background: var(--brand-primary, #2D5AF0);
}
.md-content ol {
    list-style: none;
    padding-left: 0;
    counter-reset: md-ol-counter;
}
.md-content ol > li {
    position: relative;
    padding-left: 22px;
    margin-bottom: 6px;
    counter-increment: md-ol-counter;
}
.md-content ol > li::before {
    content: counter(md-ol-counter) '.';
    position: absolute;
    left: 0;
    top: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-primary, #2D5AF0);
}
.md-content li > ul,
.md-content li > ol {
    margin: 4px 0;
}
.md-content li:last-child {
    margin-bottom: 0;
}

/* --- 引用块 --- */
.md-content blockquote {
    margin: 12px 0;
    padding: 12px 16px;
    border-left: 3px solid var(--brand-primary, #2D5AF0);
    background: rgba(45, 90, 240, 0.04);
    color: var(--text-secondary, #8b8fa3);
    font-size: 13px;
}
.md-content blockquote p {
    margin-bottom: 4px;
}
.md-content blockquote p:last-child {
    margin-bottom: 0;
}

/* --- 行内代码 --- */
.md-content code {
    font-family: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
    font-size: 12.5px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--brand-primary, #2D5AF0);
}

/* --- 代码块 --- */
.md-content pre {
    margin: 12px 0;
    padding: 14px 16px;
    background: #f5f7fa;
    border: 1px solid var(--border-color, #e4e7ed);
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.6;
}
.md-content pre code {
    display: block;
    padding: 0;
    background: none;
    color: inherit;
    font-size: inherit;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- 表格 --- */
.md-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}
.md-content table th,
.md-content table td {
    border: 1px solid var(--border-color, #e4e7ed);
    padding: 8px 12px;
    text-align: left;
}
.md-content table th {
    background: #f8f9fb;
    font-weight: 600;
    color: var(--text-secondary, #8b8fa3);
    font-size: 12px;
}
.md-content table tr:nth-child(even) {
    background: #fafbfc;
}

/* --- 分割线 --- */
.md-content hr {
    border: none;
    border-top: 1px solid var(--border-color, #e4e7ed);
    margin: 16px 0;
}

/* --- 链接 --- */
.md-content a {
    color: var(--brand-primary, #2D5AF0);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}
.md-content a:hover {
    border-bottom-color: currentColor;
}

/* --- 强调 --- */
.md-content strong {
    font-weight: 700;
    color: var(--text-primary, #1a1d23);
}
.md-content em {
    font-style: italic;
}

/* --- 图片 --- */
.md-content img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-color, #e4e7ed);
}

/* --- 任务列表 --- */
.md-content input[type="checkbox"] {
    margin-right: 6px;
    accent-color: var(--brand-primary, #2D5AF0);
}

/* ===== 用户气泡内的 Markdown 覆盖 ===== */
.chat-bubble.user .md-content code {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
}
.chat-bubble.user .md-content pre {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}
.chat-bubble.user .md-content pre code {
    background: none;
    color: rgba(255, 255, 255, 0.9);
}
.chat-bubble.user .md-content a {
    color: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.5);
}
.chat-bubble.user .md-content a:hover {
    border-bottom-color: rgba(255, 255, 255, 0.9);
}
.chat-bubble.user .md-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
}
.chat-bubble.user .md-content ul > li::before {
    background: rgba(255, 255, 255, 0.6);
}
.chat-bubble.user .md-content ol > li::before {
    color: rgba(255, 255, 255, 0.8);
}
.chat-bubble.user .md-content strong {
    color: #ffffff;
}
.chat-bubble.user .md-content table th,
.chat-bubble.user .md-content table td {
    border-color: rgba(255, 255, 255, 0.15);
}
.chat-bubble.user .md-content table th {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}
.chat-bubble.user .md-content hr {
    border-top-color: rgba(255, 255, 255, 0.2);
}
