/* === Document View === */

/* ==================== 主内容区 ==================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--neutral-50);
}



.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--neutral-400);
}

.welcome h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--neutral-600);
  margin-bottom: 8px;
}

/* 文档视图 */
.doc-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--neutral-200);
  background: #fff;
}

.doc-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-600);
}

.doc-title .draft-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: #fef3c7;
  color: #d97706;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.doc-actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.btn-primary {
  background: var(--neutral-900);
  color: #fff;
}

.btn-primary:hover {
  background: var(--neutral-700);
}

.btn-secondary {
  background: #fff;
  color: var(--neutral-600);
  border: 1px solid var(--neutral-200);
}

.btn-secondary:hover {
  background: var(--neutral-100);
  border-color: var(--neutral-300);
}

.btn svg {
  width: 14px;
  height: 14px;
}

.doc-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* TOC 目录 */
.toc:empty {
  display: none;
}

.toc {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  background: var(--neutral-50);
  border-left: 1px solid var(--neutral-200);
  order: 1;
  overflow: auto;
  padding: 16px;
  flex-shrink: 0;
}

.toc-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--neutral-500);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc-item {
  display: block;
  padding: 5px 0;
  color: var(--neutral-500);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s;
  line-height: 1.4;
}

.toc-item:hover {
  color: var(--neutral-900);
}

.toc-item.active {
  color: var(--primary-600);
  font-weight: 500;
}

.toc-item.level-2 { padding-left: 12px; }
.toc-item.level-3 { padding-left: 24px; font-size: 12px; }
.toc-item.level-4 { padding-left: 36px; font-size: 12px; }

/* Markdown 渲染区 */
.markdown-body {
  flex: 1;
  padding: 32px 40px;
  overflow: auto;

  background: #fff;
  line-height: 1.5;
  color: #374151;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin-top: 32px;
  margin-bottom: 16px;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}

.markdown-body h1:first-child, .markdown-body h2:first-child {
  margin-top: 0;
}

.markdown-body h1 { font-size: 2em; }
.markdown-body h2 { font-size: 1.5em; padding-bottom: 8px; border-bottom: 1px solid var(--neutral-200); }
.markdown-body h3 { font-size: 1.25em; }

.markdown-body p { margin-bottom: 16px; }

.markdown-body code {
  background: #f3f4f6;
  padding: 0 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
  font-size: 0.9em;
  color: #be185d;
}

.markdown-body pre {
  background: #2b2b2b;
  padding: 16px 20px;
  border-radius: 8px;
  overflow-x: auto;
  position: relative;
  margin: 16px 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  color: #a9b7c6;
  font-size: 13px;
}

.markdown-body img {
  max-width: none;
  border-radius: 8px;
  margin: 16px 0;
}

.markdown-body a {
  color: #2563eb;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary-500);
  padding: 12px 20px;
  margin: 16px 0;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 0 8px 8px 0;
}

.markdown-body table {
  border-collapse: separate;
  border-spacing: 0;
  width: auto;
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  border: 1px solid var(--neutral-200);
}

.markdown-body th, .markdown-body td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--neutral-200);
  border-right: 1px solid var(--neutral-200);
}

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

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

.markdown-body th {
  background: var(--neutral-200);
  font-weight: 600;
  font-size: 13px;
  color: var(--neutral-600);
}

.markdown-body tbody tr:nth-child(odd) td {
  background: #fff;
}

.markdown-body tbody tr:nth-child(even) td {
  background: var(--neutral-50);
}
.markdown-body ul, .markdown-body ol {
  margin: 16px 0;
  padding-left: 24px;
}

.markdown-body li {
  margin: 6px 0;
}

/* 编辑模式 */
.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--neutral-200);
  overflow: hidden;
}

.preview-pane {
  flex: 1;
  overflow: auto;
}

/* CodeMirror 编辑器样式 */
.CodeMirror {
  flex: 1;
  height: 100% !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.75;
}

.CodeMirror-gutters {
  background: var(--neutral-50);
  border-right: 1px solid var(--neutral-200);
}

.CodeMirror-linenumber {
  color: var(--neutral-400);
  padding: 0 8px;
}

.CodeMirror-lines {
  padding: 16px 0;
}

.CodeMirror pre.CodeMirror-line {
  padding: 0 20px;
}

/* 右键菜单 */
.context-menu {
  position: fixed;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 1000;
}

.context-menu.hidden {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--neutral-300);
  transition: background 0.1s;
}

.menu-item:hover {
  background: var(--neutral-700);
  color: #fff;
}

.menu-item svg {
  width: 15px;
  height: 15px;
  color: var(--neutral-500);
}

.menu-item.danger {
  color: #f87171;
}

.menu-item.danger svg {
  color: #f87171;
}

.menu-separator {
  height: 1px;
  background: var(--neutral-700);
  margin: 4px 0;
}

/* 文件预览 */
.file-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-container, .office-preview {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: var(--neutral-50);
}

.pdf-container canvas {
  display: block;
  margin: 0 auto 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  border-radius: 4px;
}

.excel-table {
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

.excel-table th, .excel-table td {
  border: 1px solid var(--neutral-200);
  padding: 4px 8px;
  text-align: left;
}

.excel-table th {
  background: var(--neutral-50);
  font-weight: 600;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
  border-radius: 3px;
}

.sidebar ::-webkit-scrollbar-thumb {
  background: var(--neutral-700);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-400);
}

.sidebar ::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-600);
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--neutral-400);
  padding: 40px;
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  color: var(--neutral-300);
}

.empty-state p {
  font-size: 14px;
}

/* 导出按钮 */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; }
