/* Markdown 渲染样式 - 参考 Discord/Telegram 风格 */

.markdown-content {
  font-size: 1rem; /* 增大基础字体 */
  line-height: 1.8; /* 增加行高，提高可读性 */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* 段落 */
.md-paragraph {
  margin: 0.6em 0;
  line-height: 1.8;
  font-size: 1rem;
}

.md-paragraph:first-child {
  margin-top: 0;
}

.md-paragraph:last-child {
  margin-bottom: 0;
}

/* 标题 */
.md-heading {
  margin: 1.2em 0 0.6em;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-primary);
  font-family: var(--font-ui); /* Markdown 标题使用微软雅黑 UI */
}

.md-h1 {
  font-size: 1.6rem;
  border-bottom: 2px solid var(--color-border-light);
  padding-bottom: 0.3em;
}

.md-h2 {
  font-size: 1.4rem;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: 0.3em;
}

.md-h3 {
  font-size: 1.25rem;
}

.md-h4 {
  font-size: 1.1rem;
}

/* 行内代码 */
.inline-code {
  background-color: rgba(0, 0, 0, 0.06);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.85em;
  color: #e83e8c;
}

.message.user .inline-code {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* 代码块 */
.code-block-wrapper {
  margin: 0.8em 0;
  border-radius: 8px;
  overflow: hidden;
  background-color: #282c34;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 1em;
  background-color: #21252b;
  border-bottom: 1px solid #181a1f;
}

.code-language {
  font-size: 0.75rem;
  color: #abb2bf;
  font-weight: 500;
  text-transform: lowercase;
}

.copy-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.3em 0.6em;
  background-color: transparent;
  border: 1px solid #3e4451;
  border-radius: 4px;
  color: #abb2bf;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-button:hover {
  background-color: #3e4451;
  color: #fff;
}

/* 引用块 */
.md-blockquote {
  margin: 0.8em 0;
  padding: 0.6em 1.2em;
  border-left: 4px solid var(--color-accent);
  background-color: rgba(0, 0, 0, 0.03);
  color: var(--color-text-secondary);
  border-radius: 0 4px 4px 0;
  font-size: 0.95rem;
  line-height: 1.7;
}

.message.user .md-blockquote {
  background-color: rgba(255, 255, 255, 0.1);
  border-left-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.9);
}

/* 列表 */
.md-list {
  margin: 0.6em 0;
  padding-left: 1.8em;
}

.md-list-item {
  margin: 0.4em 0;
  line-height: 1.7;
  font-size: 1rem;
}

.md-list-ordered {
  list-style-type: decimal;
}

/* 链接 */
.md-link {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.md-link:hover {
  border-bottom-color: var(--color-accent);
}

.message.user .md-link {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.message.user .md-link:hover {
  border-bottom-color: #fff;
}

/* 图片 */
.md-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5em 0;
}

/* 分隔线 */
.md-divider {
  margin: 1.5em 0;
  border: none;
  border-top: 1px solid var(--color-border-light);
}

.message.user .md-divider {
  border-top-color: rgba(255, 255, 255, 0.2);
}

/* 表格 */
.md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 0.9rem;
}

.md-table-head {
  background-color: rgba(0, 0, 0, 0.05);
}

.message.user .md-table-head {
  background-color: rgba(255, 255, 255, 0.1);
}

.md-table-row {
  border-bottom: 1px solid var(--color-border-light);
}

.md-table-cell {
  padding: 0.6em 0.8em;
  text-align: left;
}

.md-table-header {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* KaTeX 数学公式优化 */
.katex {
  font-size: 1.05em;
}

.katex-display {
  margin: 0.8em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* 响应式优化 */
@media (max-width: 768px) {
  .markdown-content {
    font-size: 0.9rem;
  }
  
  .md-h1 {
    font-size: 1.3rem;
  }
  
  .md-h2 {
    font-size: 1.2rem;
  }
  
  .md-h3 {
    font-size: 1.1rem;
  }
}
