/* ========================================
   Markdown 渲染器样式文件
   用途：定义 Markdown 内容渲染容器的布局和样式
   ======================================== */

/* ========================================
   主容器样式
   ======================================== */

.markdown-renderer {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: #ffffff;
  
  /* 隐藏滚动条但保留滚动功能 */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.markdown-renderer::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* ========================================
   内容容器
   ======================================== */

.markdown-container {
  width: 100%;
  margin: 0;
  padding: 45px;
  min-height: 100vh;
}

/* ========================================
   文件头部样式
   ======================================== */

.file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid #d0d7de;
}

.file-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  color: #24292f;
  font-family: 'LXGWWenKaiMono', ui-monospace, var(--font-family-base);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 16px;
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  background: #f6f8fa;
  color: #57606a;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(31, 35, 40, 0.04);
  white-space: nowrap;
  font-family: 'LXGWWenKaiMono', ui-monospace, var(--font-family-base);
}

.action-button:hover {
  background: #ffffff;
  border-color: #d0d7de;
  color: #24292f;
  box-shadow: 0 2px 6px rgba(31, 35, 40, 0.08);
  transform: translateY(-1px);
}

.action-button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(31, 35, 40, 0.06);
}

.copy-button.success {
  background: #2da44e;
  border-color: #2da44e;
  color: #ffffff;
}

/* ========================================
   GitHub Markdown Body 样式增强
   ======================================== */

.markdown-body {
  box-sizing: border-box;
  min-width: 200px;
  font-family: 'LXGWWenKaiMono', ui-monospace, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji" !important;
  font-size: 20.8px;  /* 16px * 1.3 = 20.8px */
  line-height: 1.6;
  word-wrap: break-word;
  background-color: transparent;
}

/* 覆盖 github-markdown-css 的字体设置 */
.markdown-body,
.markdown-body p,
.markdown-body li,
.markdown-body td,
.markdown-body th,
.markdown-body div,
.markdown-body span {
  font-family: 'LXGWWenKaiMono', ui-monospace, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif !important;
}

/* 代码字体保持等宽 */
.markdown-body code,
.markdown-body pre,
.markdown-body tt {
  font-family: 'LXGWWenKaiMono', ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace !important;
}

/* ========================================
   DeepSeek 风格代码块样式
   ======================================== */

.code-block-wrapper {
  margin: 16px 0;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  overflow: hidden;
  background: #f6f8fa;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid #d0d7de;
}

.code-language {
  font-size: 12px;
  font-weight: 600;
  color: #57606a;
  text-transform: lowercase;
  font-family: 'LXGWWenKaiMono', ui-monospace, monospace;
}

.code-actions {
  display: flex;
  gap: 6px;
}

.code-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #57606a;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'LXGWWenKaiMono', ui-monospace, var(--font-family-base);
  white-space: nowrap;
}

.code-action-btn:hover {
  background: #ffffff;
  border-color: #d0d7de;
  color: #24292f;
}

.code-action-btn:active {
  background: #f6f8fa;
  transform: scale(0.98);
}

/* 代码块内的 pre 标签样式覆盖 */
.code-block-wrapper pre {
  margin: 0 !important;
  padding: 16px !important;
  background: #ffffff !important;
  border: none !important;
  border-radius: 0 !important;
  overflow-x: auto;
}

.code-block-wrapper pre code {
  background: transparent !important;
  padding: 0 !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
}

/* ========================================
   原有图片和表格样式
   ======================================== */
.markdown-body img {
  transition: transform 0.3s ease;
  max-width: 100%;
}

.markdown-body img.zoomed {
  transform: scale(1.5);
  cursor: zoom-out;
  position: relative;
  z-index: 10;
}

/* 表格优化 */
.markdown-body table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow: auto;
}

/* ========================================
   加载状态样式
   ======================================== */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #57606a;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f0f0f0;
  border-top: 4px solid #0969da;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-state p {
  margin: 0;
  font-size: 14px;
}

/* ========================================
   错误状态样式
   ======================================== */

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #cf222e;
  text-align: center;
  padding: 24px;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-state h2 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 600;
  color: #24292f;
}

.error-state p {
  margin: 0;
  font-size: 14px;
  color: #57606a;
  max-width: 500px;
}

/* ========================================
   空状态样式
   ======================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #57606a;
  text-align: center;
  padding: 24px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.6;
}

.empty-state h2 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 600;
  color: #24292f;
}

.empty-state p {
  margin: 0;
  font-size: 16px;
  color: #57606a;
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 768px) {
  .markdown-container {
    padding: 20px 16px;
  }
  
  .markdown-body {
    font-size: 14px;
  }

  .file-header {
    margin-bottom: 24px;
    padding-bottom: 12px;
  }

  .file-title {
    font-size: 20px;
  }

  .action-button {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }

  /* 移动端代码块样式调整 */
  .code-block-header {
    padding: 6px 10px;
  }

  .code-language {
    font-size: 11px;
  }

  .code-action-btn {
    padding: 3px 6px;
    font-size: 11px;
  }

  .code-block-wrapper pre {
    padding: 12px !important;
  }

  .code-block-wrapper pre code {
    font-size: 13px !important;
  }
  
  /* 移动端图片不支持放大 */
  .markdown-body img {
    cursor: default;
  }
  
  .markdown-body img.zoomed {
    transform: none;
  }
}

@media (max-width: 480px) {
  .markdown-container {
    padding: 16px 12px;
  }

  .file-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .file-title {
    padding-right: 0;
    white-space: normal;
    word-break: break-word;
  }

  .file-actions {
    align-self: flex-end;
  }
}

/* ========================================
   数学公式样式优化
   ======================================== */

.markdown-body .katex {
  font-size: 1.1em;
}

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

/* ========================================
   代码块滚动条样式
   ======================================== */

.markdown-body pre {
  overflow-x: auto;
}

.markdown-body pre::-webkit-scrollbar {
  height: 8px;
}

.markdown-body pre::-webkit-scrollbar-track {
  background: #f6f8fa;
  border-radius: 4px;
}

.markdown-body pre::-webkit-scrollbar-thumb {
  background: #d0d7de;
  border-radius: 4px;
}

.markdown-body pre::-webkit-scrollbar-thumb:hover {
  background: #afb8c1;
}

/* ========================================
   文件元数据样式
   ======================================== */

.file-metadata {
  margin-top: 60px;
  padding-top: 32px;
}

.metadata-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, #d0d7de 20%, #d0d7de 80%, transparent);
  margin-bottom: 24px;
}

.metadata-content {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  padding: 20px 24px;
  background: #f6f8fa;
  border-radius: 6px;
  border: 1px solid #d0d7de;
}

.metadata-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.metadata-label {
  color: #57606a;
  font-weight: 500;
}

.metadata-value {
  color: #24292f;
  font-weight: 600;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .file-metadata {
    margin-top: 40px;
    padding-top: 24px;
  }
  
  .metadata-content {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }
  
  .metadata-item {
    font-size: 13px;
  }
}

