/* 商卫AI文档清洁工 (Shangwei CleanDoc) - 全局样式 */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
  --bg: #f9fafb;
  --bg-card: #ffffff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  margin: 0;
}

/* ============ 编辑器样式 ============ */
.editor-content {
  min-height: calc(100vh - 280px);
  padding: 48px 64px;
  font-size: 15px;
  line-height: 1.8;
  color: #1f2937;
  outline: none;
  background: #fff;
}

.editor-content > *:first-child { margin-top: 0; }

.editor-content h1 { font-size: 28px; font-weight: 700; margin: 24px 0 16px; line-height: 1.3; }
.editor-content h2 { font-size: 22px; font-weight: 700; margin: 20px 0 12px; line-height: 1.3; }
.editor-content h3 { font-size: 18px; font-weight: 600; margin: 16px 0 8px; }
.editor-content h4 { font-size: 16px; font-weight: 600; margin: 12px 0 8px; }

.editor-content p { margin: 0 0 12px; }
.editor-content ul, .editor-content ol { padding-left: 28px; margin: 0 0 12px; }
.editor-content li { margin-bottom: 4px; }
.editor-content blockquote {
  border-left: 4px solid #d1d5db;
  padding: 4px 16px;
  color: #6b7280;
  margin: 12px 0;
  background: #f9fafb;
}
.editor-content code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 13px;
  color: #db2777;
}
.editor-content pre {
  background: #1e293b;
  color: #f1f5f9;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
}
.editor-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}
.editor-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}
.editor-content table th,
.editor-content table td {
  border: 1px solid #d1d5db;
  padding: 8px 12px;
  text-align: left;
}
.editor-content table th {
  background: #f3f4f6;
  font-weight: 600;
}
.editor-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 24px 0;
}
.editor-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.editor-content a {
  color: #2563eb;
  text-decoration: underline;
}

/* 占位符 */
.editor-content[data-empty="true"]::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
  position: absolute;
}

/* ============ 工具栏 ============ */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  border: none;
  background: transparent;
}
.toolbar-btn:hover {
  background: #f3f4f6;
  color: #111827;
}
.toolbar-btn.active {
  background: #dbeafe;
  color: #2563eb;
}
.toolbar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: #e5e7eb;
  margin: 0 4px;
}

/* ============ 通用按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.btn-primary {
  background: #2563eb;
  color: white;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border-color: #e5e7eb;
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-ghost {
  background: transparent;
  color: #4b5563;
}
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover { background: #dc2626; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 560px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: white;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-left: 4px solid #10b981;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 250px;
  animation: slideIn 0.3s;
}
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }
.toast.info { border-left-color: #3b82f6; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ AI 面板 ============ */
.ai-panel {
  background: white;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}
.ai-feature-card {
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
}
.ai-feature-card:hover {
  border-color: #2563eb;
  background: #f0f7ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37,99,235,0.1);
}
.ai-feature-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ 价格卡 ============ */
.price-card {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  padding: 32px 24px;
  position: relative;
  transition: all 0.2s;
}
.price-card:hover {
  border-color: #2563eb;
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(37,99,235,0.15);
}
.price-card.featured {
  border-color: #2563eb;
  background: linear-gradient(135deg, #f0f7ff 0%, #fff 100%);
}
.price-card.featured::before {
  content: "推荐";
  position: absolute;
  top: -12px;
  right: 24px;
  background: linear-gradient(90deg, #2563eb, #8b5cf6);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* 加载动画 */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 净化高亮提示 */
.clean-hint {
  background: linear-gradient(90deg, #fef3c7, #fffbeb);
  border-left: 3px solid #f59e0b;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: #92400e;
  margin: 8px 0;
}

/* ============ Mermaid / ECharts 图表块 ============ */
.diagram-block {
  margin: 16px 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
  overflow: hidden;
  user-select: none;
}
.diagram-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12px;
}
.diagram-toolbar-error {
  background: #fef2f2;
  border-bottom-color: #fecaca;
}
.diagram-tag {
  color: #4b5563;
  font-weight: 500;
}
.diagram-actions {
  display: flex;
  gap: 6px;
}
.diagram-btn {
  padding: 2px 8px;
  font-size: 11px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
}
.diagram-btn:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.diagram-loading {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}
.diagram-svg {
  padding: 12px;
  text-align: center;
  background: #fff;
  overflow-x: auto;
}
.diagram-svg svg {
  max-width: 100%;
  height: auto;
}
.diagram-canvas {
  background: #fff;
}
.diagram-error-msg {
  padding: 12px;
  color: #b91c1c;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.diagram-error-source {
  margin: 0 12px 12px;
}
.diagram-error-source summary {
  cursor: pointer;
  color: #6b7280;
  font-size: 12px;
  padding: 4px 0;
}
.diagram-error-source pre {
  background: #f9fafb;
  padding: 8px;
  border-radius: 4px;
  overflow: auto;
  max-height: 200px;
  font-size: 12px;
}
/* 普通代码块 */
.code-block {
  background: #1f2937;
  color: #e5e7eb;
  padding: 12px 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  margin: 12px 0;
  position: relative;
}
.code-block[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 10px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
