/* ========== 代码块复制按钮 ========== */
.code-copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.markdown-body pre:hover .code-copy-btn {
  opacity: 1;
  pointer-events: auto;
}

.code-copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text-body);
  border-color: var(--border-default);
}

.code-copy-btn:active {
  transform: scale(0.95);
}

.code-copy-btn.copied {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.code-copy-btn svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.code-copy-btn .copy-text {
  font-size: 12px;
  line-height: 1;
}

/* ========== Mermaid 图表样式 ========== */
.markdown-body .mermaid {
  text-align: center;
  margin: 20px 0;
  padding: 16px;
  overflow-x: auto;
}

.markdown-body .mermaid svg {
  max-width: 100%;
  height: auto;
}

/* 暗黑模式下 Mermaid 使用纯白背景 */
[data-theme="dark"] .markdown-body .mermaid {
  background: #ffffff;
  border-radius: 8px;
}

/* ========== PDF 图片式显示 ========== */
.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.pdf-page-img {
  max-width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  cursor: zoom-in;
  transition: box-shadow 0.2s;
}

.pdf-page-img:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.pdf-loading,
.pdf-error {
  padding: 48px;
  text-align: center;
  color: var(--text-placeholder);
  font-size: 14px;
}

.pdf-error {
  color: #e53935;
}

/* ========== 图片查看器 ========== */
.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease-out;
}

.image-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  color: #fff;
}

.image-viewer-info {
  font-size: 14px;
  opacity: 0.8;
}

.image-viewer-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.image-viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px 24px;
  overflow: auto;
}

.image-viewer-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ========== 图片模态框 ========== */
.image-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease-out;
}

.image-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  color: #fff;
  flex-shrink: 0;
}

.image-modal-title {
  font-size: 14px;
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 16px;
}

.image-modal-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.image-modal-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px 24px;
  overflow: auto;
}

.image-modal-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ========== 返回顶部按钮 ========== */
.back-to-top-btn {
  display: none;
  position: fixed;
  bottom: 80px;
  right: calc(var(--toc-width) + 24px);
  width: 44px;
  height: 44px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  cursor: pointer;
  z-index: 98;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.back-to-top-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(51, 112, 255, 0.3);
}

.back-to-top-btn:active {
  transform: translateY(0);
}

.back-to-top-btn svg {
  width: 20px;
  height: 20px;
}
