/**
 * 原型外壳：左目录 + 中系统面板 + 右标注栏（三栏）
 * 标杆：进行中/v2.2.52 客户档案/v2.2.52 客户档案.html
 * 规范：../UI设计规范.md §6.5
 */

.proto-shell {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  padding: 16px;
  gap: 16px;
}
body.shell-bg {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  height: 100%;
  background: #dfe6ee;
}
.app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: transparent;
}

/* 左目录 + 中预览 + 右标注：外壳同时有 .app 与 .proto-shell 时必须横向三栏 */
.app.proto-shell,
.proto-shell.app {
  flex-direction: row;
  align-items: stretch;
}
.app.proto-shell > .catalog,
.proto-shell.app > .catalog {
  align-self: stretch;
  height: 100%;
  max-height: 100%;
}

/* ===== 原型目录侧栏（可拖拽 + 可折叠） ===== */
.catalog {
  width: var(--catalog-w);
  min-width: 160px;
  max-width: 480px;
  flex-shrink: 0;
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border-radius: var(--radius-md);
  transition: width 0.22s ease, min-width 0.22s ease;
}
.catalog.no-anim { transition: none; }
.catalog.collapsed {
  width: 44px !important;
  min-width: 44px;
  max-width: 44px;
}
.catalog.collapsed .catalog-body { display: none; }
.catalog.collapsed .catalog-title { display: none; }
.catalog.collapsed .catalog-head {
  padding: 14px 0 8px;
  justify-content: center;
}
.catalog-resizer {
  width: 5px;
  cursor: col-resize;
  background: #eee;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
}
.catalog-resizer.hidden { width: 0; pointer-events: none; }
.catalog-resizer:hover,
.catalog-resizer.dragging { background: var(--primary); }
.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}
.catalog-title { font-weight: 700; font-size: var(--fs-lg); }
.catalog-tools { display: flex; gap: 8px; color: var(--text-3); }
.icon-btn {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 2px 4px;
  font-size: var(--fs-lg);
  line-height: 1;
}
.icon-btn:hover { color: var(--primary); }
.catalog-search {
  margin: 0 12px 8px;
  height: 32px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #bbb;
}
.catalog-search input {
  border: 0;
  outline: none;
  flex: 1;
  margin-left: 6px;
  background: transparent;
  font-size: var(--fs-base);
}
.catalog-all {
  display: flex;
  justify-content: space-between;
  padding: 6px 16px 8px;
  color: #333;
  font-size: var(--fs-sm);
}
.muted { color: #b0b0b0; }
.catalog-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.catalog-search .search-ico { margin-right: 6px; color: #bbb; }
.catalog-nav {
  overflow: auto;
  flex: 1;
  padding-bottom: 16px;
}
/* 折叠分组：子容器 */
.cat-children { display: none; }
.cat-children.open { display: block; }
.cat-item.folder-row .arrow { transition: transform 0.15s; }
.cat-item.folder-row.open .arrow { transform: rotate(90deg); }
/* 嵌套分组头缩进 */
.cat-group .cat-children .cat-item.folder-row.child { padding-left: 40px; }
.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  color: #333;
  user-select: none;
}
.cat-item:hover { background: #fafafa; }
.cat-item.active {
  background: var(--primary-sel);
  color: var(--primary);
}
.cat-item .doc,
.cat-item .folder {
  color: var(--text-ph);
  font-size: var(--fs-md);
  width: 16px;
  text-align: center;
}
.cat-item.active .doc { color: var(--primary); }
.cat-item .arrow {
  display: inline-flex;
  width: 14px;
  justify-content: center;
  color: #bbb;
  font-size: 10px;
}
.cat-item .cnt { margin-left: auto; color: #bbb; font-size: var(--fs-sm); }
.cat-item.child { padding-left: 42px; }
.cat-item.grand { padding-left: 64px; }
.cat-group .cat-item.folder-row { padding-left: 16px; }

/* 兼容旧版 class 名（逐步迁移至 .cat-item） */
.catalog-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  font-size: var(--fs-lg);
  font-weight: 600;
}
.catalog-tree {
  overflow: auto;
  flex: 1;
  padding: 6px 0 12px;
  font-size: var(--fs-base);
  line-height: 1.4;
}
.tree-group-hd {
  display: flex; align-items: center; gap: 4px;
  padding: 7px 10px 7px 14px; cursor: pointer;
  color: var(--text); font-weight: 500; user-select: none;
}
.tree-group-hd:hover { background: #f5f8fc; }
.tree-group-hd .arrow {
  width: 14px; height: 14px; flex-shrink: 0;
  color: var(--text-3); transition: transform 0.15s;
}
.tree-group-hd.open .arrow { transform: rotate(90deg); }
.tree-children { display: none; padding-left: 8px; }
.tree-children.open { display: block; }
.tree-page {
  display: block; width: 100%; text-align: left;
  padding: 7px 14px 7px 32px;
  font-size: var(--fs-base); color: var(--text-2);
  cursor: pointer; line-height: 1.45;
}
.tree-page:hover { background: #f0f6ff; color: var(--primary); }
.tree-page.active {
  background: #e8f1ff; color: var(--primary); font-weight: 500;
}

/* ===== 中栏 + 右栏：横向滚动舞台 ===== */
.work-scroller {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  background: transparent;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.work-scroller::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.work-content {
  flex: 0 0 var(--work-stage-w);
  width: var(--work-stage-w);
  min-width: var(--work-stage-w);
  max-width: var(--work-stage-w);
  display: flex;
  min-height: 0;
  background: var(--card);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}
.anno-rail-resizer {
  width: 5px;
  flex-shrink: 0;
  align-self: stretch;
  cursor: col-resize;
  background: #eee;
  position: relative;
  z-index: 3;
  border-radius: 2px;
}
.anno-rail-resizer:hover,
.anno-rail-resizer.dragging {
  background: var(--primary);
}
/* 系统页内滑出层：仅覆盖 work-content，与右侧标注区解耦 */
.sys-overlays {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}
.sys-overlays > .mask.show,
.sys-overlays > .drawer.open,
.sys-overlays > [class*="mask"].show,
.sys-overlays > [class*="drawer"].open,
.sys-overlays > [class*="drawer"].show {
  pointer-events: auto;
}

/* ===== 预览舞台（work-content 内 CRM 主区） ===== */
.stage {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* ===== 预览区 ===== */
.preview {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; min-width: 0;
  overflow: auto; padding: 8px 16px 32px;
}
.preview-label {
  align-self: flex-start;
  font-size: var(--fs-md); color: var(--text-2);
  margin-bottom: 14px; padding-left: 4px;
}
.preview-label strong { color: var(--text); font-weight: 600; }

/* ===== 改动说明侧栏 ===== */
.note-drop {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; margin-left: 2px;
  border: none; background: transparent; cursor: pointer;
  vertical-align: middle; flex-shrink: 0; position: relative;
}
.note-drop::before {
  content: ""; width: 18px; height: 18px;
  background: linear-gradient(135deg, #69c0ff, var(--primary));
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(24, 144, 255, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}
.note-drop:hover::before {
  transform: rotate(-45deg) scale(1.15);
}
.note-drop.active::before {
  background: linear-gradient(135deg, #ff7875, var(--danger));
}
.note-panel {
  position: fixed; top: 0; right: 0; height: 100vh;
  width: var(--note-w); min-width: 320px; max-width: 720px;
  z-index: 3500; transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.note-panel.open { transform: translateX(0); pointer-events: auto; }
.note-panel.collapsed { transform: translateX(calc(100% - 40px)); pointer-events: auto; }
.note-panel-resizer {
  position: absolute; left: 0; top: 0; width: 6px; height: 100%;
  cursor: col-resize; z-index: 2;
}
.note-panel-resizer:hover,
.note-panel-resizer.dragging { background: rgba(24, 144, 255, 0.25); }
.note-panel-inner {
  margin-left: 6px; height: 100%; background: var(--card);
  border-left: 1px solid var(--border-2);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  display: flex; flex-direction: column;
}
.note-panel-hd {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.note-panel-title {
  flex: 1; font-weight: 600; font-size: var(--fs-xl);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.note-panel-bd {
  flex: 1; overflow-y: auto; padding: 16px 18px;
  font-size: var(--fs-base); line-height: 1.65; color: var(--text-2);
}
.note-panel-bd h4 {
  font-size: var(--fs-base); color: var(--text-3);
  margin: 14px 0 6px; font-weight: 500;
}
.note-panel-bd h4:first-child { margin-top: 0; }
.note-panel-bd ul { padding-left: 18px; margin: 6px 0; }
.note-panel-bd li { margin: 4px 0; }
.note-panel-ft {
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: var(--fs-sm); color: var(--text-3); flex-shrink: 0;
}
body.note-open .preview { padding-right: calc(var(--note-w) + 24px); }

/* ===== 嵌入模式（iframe / ?embed=1） ===== */
html.embed-mode .catalog,
html.embed-mode .catalog-resizer,
html.embed-mode .note-panel,
html.embed-mode .note-resizer,
html.embed-mode .anno-rail-resizer,
html.embed-mode .anno-rail,
html.embed-mode .anno-hint,
html.embed-mode .insight-panel {
  display: none !important;
}
html.embed-mode .proto-shell { padding: 0; gap: 0; }
html.embed-mode body.shell-bg { background: var(--card); }
html.embed-mode .work-content {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: none;
  border-radius: 0;
}
html.embed-mode .stage {
  width: 100%;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
html.embed-mode .crm { width: 100%; min-width: 1180px; }
html.embed-mode .app { height: 100vh; border-radius: 0; background: var(--card); }
html.embed-mode .work-scroller { gap: 0; }
