/* Markdown 渲染器样式 */
.markdown-renderer {
  line-height: 1.6;
  color: #262626;
  font-size: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.markdown-renderer.own-message {
  color: rgba(255, 255, 255, 0.95);
}

/* 段落样式 */
.markdown-paragraph {
  margin: 0 0 8px 0;
  line-height: 1.6;
}

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

/* 标题样式 */
.markdown-h1,
.markdown-h2,
.markdown-h3,
.markdown-h4,
.markdown-h5,
.markdown-h6 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  line-height: 1.4;
}

.markdown-h1:first-child,
.markdown-h2:first-child,
.markdown-h3:first-child,
.markdown-h4:first-child,
.markdown-h5:first-child,
.markdown-h6:first-child {
  margin-top: 0;
}

.markdown-h1 {
  font-size: 18px;
  border-bottom: 2px solid #e8e8e8;
  padding-bottom: 4px;
}

.markdown-h2 {
  font-size: 16px;
  border-bottom: 1px solid #e8e8e8;
  padding-bottom: 2px;
}

.markdown-h3 {
  font-size: 15px;
}

.markdown-h4 {
  font-size: 14px;
}

.markdown-h5 {
  font-size: 13px;
}

.markdown-h6 {
  font-size: 12px;
  color: #8c8c8c;
}

/* 自己消息的标题样式 */
.own-message .markdown-h1 {
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.own-message .markdown-h2 {
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.own-message .markdown-h6 {
  color: rgba(255, 255, 255, 0.7);
}

/* 引用样式 */
.markdown-blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 4px solid #1890ff;
  background: #f6f8fa;
  border-radius: 0 6px 6px 0;
}

.own-message .markdown-blockquote {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: rgba(255, 255, 255, 0.5);
}

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

.markdown-li {
  margin: 4px 0;
  line-height: 1.6;
}

.markdown-ul .markdown-li {
  list-style-type: disc;
}

.markdown-ol .markdown-li {
  list-style-type: decimal;
}

/* 代码样式 */
.markdown-inline-code {
  background: #f5f5f5;
  color: #e83e8c;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
}

.own-message .markdown-inline-code {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

.markdown-code-block {
  margin: 8px 0;
  background: #f6f8fa;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e1e4e8;
}

.code-language {
  background: #e1e4e8;
  color: #586069;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  border-bottom: 1px solid #d1d5da;
}

.markdown-pre {
  margin: 0;
  padding: 12px;
  background: #f6f8fa;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.4;
}

.markdown-code-block .markdown-pre {
  background: transparent;
  border: none;
}

.own-message .markdown-code-block {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.own-message .code-language {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.own-message .markdown-pre {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

/* 表格样式 */
.markdown-table-wrapper {
  overflow-x: auto;
  margin: 8px 0;
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  overflow: hidden;
}

.markdown-th,
.markdown-td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e8e8e8;
  border-right: 1px solid #e8e8e8;
}

.markdown-th {
  background: #f6f8fa;
  font-weight: 600;
  color: #24292e;
}

.markdown-th:last-child,
.markdown-td:last-child {
  border-right: none;
}

.markdown-tbody .markdown-tr:last-child .markdown-td {
  border-bottom: none;
}

.own-message .markdown-table {
  border-color: rgba(255, 255, 255, 0.3);
}

.own-message .markdown-th {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.own-message .markdown-th,
.own-message .markdown-td {
  border-color: rgba(255, 255, 255, 0.2);
}

/* 链接样式 */
.markdown-link {
  color: #1890ff;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.markdown-link:hover {
  color: #40a9ff;
  border-bottom-color: #40a9ff;
  text-decoration: none;
}

.own-message .markdown-link {
  color: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.own-message .markdown-link:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
}

/* 文本样式 */
.markdown-strong {
  font-weight: 600;
}

.markdown-em {
  font-style: italic;
}

.markdown-del {
  text-decoration: line-through;
  color: #8c8c8c;
}

.own-message .markdown-del {
  color: rgba(255, 255, 255, 0.7);
}

/* 分隔线样式 */
.markdown-hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid #e8e8e8;
}

.own-message .markdown-hr {
  border-top-color: rgba(255, 255, 255, 0.3);
}

/* 复选框样式 */
.markdown-checkbox {
  margin-right: 6px;
  cursor: default;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .markdown-renderer {
    font-size: 13px;
  }
  
  .markdown-h1 {
    font-size: 16px;
  }
  
  .markdown-h2 {
    font-size: 15px;
  }
  
  .markdown-h3 {
    font-size: 14px;
  }
  
  .markdown-h4 {
    font-size: 13px;
  }
  
  .markdown-h5 {
    font-size: 12px;
  }
  
  .markdown-h6 {
    font-size: 11px;
  }
  
  .markdown-inline-code {
    font-size: 12px;
  }
  
  .markdown-pre {
    font-size: 12px;
    padding: 8px;
  }
  
  .markdown-th,
  .markdown-td {
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .markdown-blockquote {
    padding: 6px 10px;
  }
  
  .markdown-ul,
  .markdown-ol {
    padding-left: 16px;
  }
}

/* 语法高亮样式 (使用 highlight.js 的默认主题) */
.markdown-renderer .hljs {
  background: #f6f8fa;
  color: #24292e;
}

.own-message .markdown-renderer .hljs {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

/* 动画效果 */
.markdown-renderer {
  animation: markdownFadeIn 0.3s ease-out;
}

@keyframes markdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 代码块复制按钮样式 */
.markdown-code-block {
  position: relative;
}

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

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d1d5da;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.code-copy-btn:hover {
  background: #ffffff;
  border-color: #1890ff;
  color: #1890ff;
}