/* ===== Sidebar ===== */
#sidebar {
  width: 160px;
  min-width: 160px;
  background: #1a2035;
  color: #c8cdd8;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  overflow: hidden;
}
#sidebar.collapsed { width: 0; min-width: 0; }

.sidebar-header {
  padding: 18px 16px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #7a8aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #2a3350;
  display: flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-item {
  padding: 10px 8px 10px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin: 2px 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.15s;
  overflow: hidden;
}
.sidebar-item:hover { background: #2a3350; }
.sidebar-item.active {
  background: #2563eb22;
  border-left: 3px solid #2563eb;
  padding-left: 13px;
}

/* 项目名称：单行截断，超长部分显示省略号 */
.sidebar-item .proj-name {
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 日期行：单行截断 */
.sidebar-item .proj-meta {
  font-size: 11px;
  color: #6b7a9a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 状态+删除按钮行：不换行，超出部分隐藏（删除按钮 flex-shrink:0 保证不被压缩） */
.sidebar-item .proj-row { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; overflow: hidden; }

.proj-status {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.proj-status.done    { background: #16a34a22; color: #4ade80; }
.proj-status.pending { background: #6b7a9a22; color: #94a3b8; }
.proj-status.running { background: #2563eb22; color: #60a5fa; animation: pulse 1.2s infinite; }
.proj-status.parsing { background: #f59e0b22; color: #fbbf24; animation: pulse 1.2s infinite; }
.proj-status.error   { background: #ef444422; color: #f87171; }

.proj-delete-btn {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #6b7a9a;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
  margin-left: 2px;
}
.sidebar-item:hover .proj-delete-btn { opacity: 1; }
.proj-delete-btn:hover { background: #dc262633 !important; color: #f87171 !important; }
.proj-delete-btn.disabled { pointer-events: none; opacity: 0 !important; }

.sidebar-new-btn {
  margin: 12px;
  padding: 9px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-new-btn:hover { background: #1d4ed8; }

/* ===== Main Area ===== */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ===== Top Bar ===== */
#topbar {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

#toggle-sidebar {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
}
#toggle-sidebar:hover { background: #f3f4f6; }

.topbar-title { font-size: 15px; font-weight: 600; color: #1a1a1a; flex: 1; }
.topbar-project-badge {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Step Bar ===== */
#stepbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 48px;
  gap: 0;
  flex-shrink: 0;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 100%;
  cursor: default;
  color: #9ca3af;
  font-size: 13px;
  position: relative;
  white-space: nowrap;
}
.step-item.active { color: #2563eb; font-weight: 600; }
.step-item.done   { color: #10b981; }
.step-item.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: #2563eb;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.step-item.active .step-num { background: #2563eb; color: #fff; }
.step-item.done   .step-num { background: #10b981; color: #fff; }
.step-arrow { color: #d1d5db; font-size: 12px; }

/* ===== Content Area ===== */
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== Step Panels ===== */
.step-panel { animation: fadeIn 0.2s ease; }

/* ===== Step 3 Layout: Chapter + Preview ===== */
#step3-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 176px);
}

#chapter-panel {
  width: 260px;
  min-width: 260px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#chapter-panel .panel-header {
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
#chapter-panel .panel-header .select-all {
  font-size: 12px;
  color: #2563eb;
  cursor: pointer;
  font-weight: 400;
}
#chapter-panel .panel-footer {
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#preview-panel {
  flex: 1;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
#preview-panel .panel-header {
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.preview-badge {
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

#preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  font-size: 14px;
  line-height: 1.8;
  color: #1a1a1a;
}

/* ===== Step 4 Layout: Progress（单列时间线，无分栏）===== */
/* step4 使用单列 .timeline-log，不需要额外布局规则 */

/* ===== Step 5 Layout: Result (三栏) ===== */
#result-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 148px);
}

#result-chapter-panel {
  width: 180px;
  min-width: 160px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease;
  flex-shrink: 0;
}
#result-chapter-panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border: none;
}
#result-chapter-panel .panel-header {
  height: 44px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
#result-chapter-panel .chapter-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* 导航模式节点行样式（无复选框） */
.tree-node-row-nav {
  padding-left: 4px !important;
}
/* Step5 章节目录树：统一所有层级字号为 11px，覆盖 components.css 中的层级差异 */
#result-chapter-panel .tree-node-text {
  font-size: 11px !important;
}

/* 原始文档面板（与更新后文档面板对称） */
#result-original-panel {
  flex: 1;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 最小宽度 300px：防止面板被压得过窄导致字号过小 */
  min-width: 300px;
  transition: flex 0.25s ease, width 0.25s ease;
}
#result-original-panel.collapsed {
  flex: 0 0 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  border: none;
  overflow: hidden;
}

#result-doc-panel {
  flex: 1;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 最小宽度 300px：防止面板被压得过窄导致字号过小 */
  min-width: 300px;
}

/* ===== Diff 差异标记样式 ===== */
/* 原始文档中被修改的段落/表格：绿色左边框 + 淡绿背景（旧的/已有的） */
.diff-changed-orig {
  border-left: 3px solid #10b981 !important;
  background-color: #f0fdf4 !important;
  padding-left: 6px !important;
  box-sizing: border-box;
}
/* 更新后文档中对应被修改的段落/表格：橙色左边框 + 淡黄背景（新的/需关注的变化） */
.diff-changed-work {
  border-left: 3px solid #f59e0b !important;
  background-color: #fffbeb !important;
  padding-left: 6px !important;
  box-sizing: border-box;
}

/* ===== 溯源抽屉（底部弹出，替代原右侧溯源面板）===== */

/* 遮罩 */
#trace-drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 299;
}
#trace-drawer-mask.visible { display: block; }

/* 抽屉主体 */
#trace-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  /* 默认隐藏在屏幕底部以下 */
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  /* 默认高度：足以展示完整溯源内容（69vh再增加1/3至85vh） */
  height: 85vh;
  min-height: 400px;
  max-height: 92vh;
}
#trace-drawer.open {
  transform: translateY(0);
}

/* 拖拽手柄 */
#trace-drawer-handle {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ns-resize;
  flex-shrink: 0;
  user-select: none;
}
.drawer-handle-bar {
  width: 40px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  pointer-events: none;
}

/* 标题栏 */
#trace-drawer-header {
  height: 44px;
  padding: 0 18px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: #fafafa;
}
.drawer-header-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}
#trace-drawer-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  background: #f3f4f6;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}
#trace-drawer-close:hover { background: #e5e7eb; }

/* 主体：上下分区 */
#trace-drawer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 上区：指标信息横排（固定高度，不滚动） */
#trace-drawer-info {
  flex-shrink: 0;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  padding: 8px 18px 6px;
  overflow: hidden;
}

/* 下区：原始数据主区域（flex:1，尽可能高）*/
/* 自身不滚动，由内部 .drawer-raw-content 负责滚动，使 .drawer-raw-header 固定在顶部 */
#trace-drawer-raw {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
}

/* 下区顶部 header 区（文件名），固定不滚动 */
#trace-drawer-raw > .drawer-raw-header {
  flex-shrink: 0;
  padding: 10px 18px 8px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

/* 下区可滚动内容区（表格 / PDF / Word / 公式） */
.drawer-raw-content {
  flex: 1;
  overflow: auto;
  padding: 12px 18px 14px;
}

.panel-toolbar {
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.panel-toolbar .title { font-size: 14px; font-weight: 600; white-space: nowrap; }

/* ===== Step 5 结果状态栏 ===== */
.result-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  margin-bottom: 12px;
}
.result-status-icon { font-size: 20px; }
.result-status-title { font-size: 14px; font-weight: 600; color: #1a1a1a; }
.result-status-time { font-size: 12px; color: #6b7280; }

/* ===== 章节目录徽章 ===== */
.chapter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: auto;
  flex-shrink: 0;
  min-width: 28px;
  line-height: 1.4;
}
.tree-node-has-updates > .tree-node-row-nav {
  background: #fefce8;
  border-radius: 4px;
}
.tree-node-has-updates > .tree-node-row-nav > .tree-node-text {
  font-weight: 600;
  color: #1e293b;
}

/* ===== 文档预览结果汇总栏 ===== */
.doc-result-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.doc-result-info { display: flex; align-items: center; gap: 16px; flex: 1; }
.doc-result-time { font-size: 12px; color: #64748b; }
.doc-result-total { font-size: 13px; color: #1e293b; }
.doc-result-total strong { color: #2563eb; font-size: 15px; }
.doc-result-actions { display: flex; gap: 8px; }
.btn-download-result {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-download-result:hover { background: #1d4ed8; }

/* ===== Step 5 步骤栏布局控件（仅 Step5 显示）===== */
.step5-layout-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}
/* 竖线分隔符 */
.step5-layout-divider {
  width: 1px;
  height: 20px;
  background: #e5e7eb;
  margin: 0 6px;
}
/* 布局切换图标按钮 */
.layout-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.layout-btn:hover { background: #f3f4f6; color: #374151; }
/* 激活状态（面板当前可见） */
.layout-btn.active { color: #2563eb; background: #eff6ff; }

/* ===== Step 5 文档缩放 wrapper ===== */
/* 套在 docx-preview 渲染结果外层，用于 transform: scale() 缩放 */
.doc-scale-wrapper {
  transform-origin: top left;
  will-change: transform;
  /* 宽度由 JS 动态设置（= 文档原始宽度），高度由 JS 动态设置（= 文档原始高度 × ratio） */
}
