/* ============================================================
   editor.css — 画布、节点、端口、连线与节点库面板
   ============================================================ */

/* ---------- 画布视口 ---------- */
#canvas-viewport {
  flex: 1; position: relative; overflow: hidden;
  background-color: #eef1f5;
  background-image: radial-gradient(circle, #ccd4e0 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: default;
  touch-action: none;
}
#canvas-viewport.panning { cursor: grabbing; }
#canvas-viewport.linking { cursor: crosshair; }

#canvas-world {
  position: absolute; left: 0; top: 0;
  width: 6000px; height: 4000px;
  transform-origin: 0 0;
}

/* ---------- 连线层 ---------- */
#link-layer {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
}
#link-layer path { fill: none; }
.link-hit { stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.link-line { stroke: #93a1b5; stroke-width: 2; pointer-events: none; transition: stroke .12s; }
.link-group:hover .link-line { stroke: var(--accent); }
.link-group.selected .link-line { stroke: var(--accent); stroke-width: 2.6; filter: drop-shadow(0 0 3px rgba(31, 111, 235, .4)); }
.link-temp { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 5; opacity: .9; }

/* ---------- 节点卡片 ---------- */
.node {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  user-select: none;
  transition: box-shadow .12s, border-color .12s;
}
.node:hover { border-color: #c4cedb; box-shadow: 0 2px 8px rgba(16, 24, 40, .1); }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.node.dragging { opacity: .92; z-index: 10; }

.node-header {
  height: 30px; flex: none;
  display: flex; align-items: center; gap: 7px;
  padding: 0 10px 0 8px;
  border-bottom: 1px solid var(--border2);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--panel2);
  cursor: grab;
}
.node-header:active { cursor: grabbing; }
.node-icon {
  width: 20px; height: 20px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; color: #fff;
}
.node-icon svg { width: 13px; height: 13px; }
.node-title { flex: 1; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-status { width: 7px; height: 7px; border-radius: 50%; background: #c3ccd9; flex: none; }
.node-status.st-active { background: var(--green); }
.node-status.st-connected { background: var(--accent); }
.node-status.st-recording { background: var(--amber); }
.node-status.st-error { background: var(--red); }

.node-body { flex: 1; min-height: 0; overflow: hidden; padding: 8px 10px; font-size: 12px; color: var(--text2); position: relative; }
.node-summary { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; line-height: 1.45; }
.node-summary .k { color: var(--text3); }
.node-summary .v { color: var(--text); font-family: var(--mono); font-size: 11px; }

/* 分类色（左边框 + 图标底） */
.node.cat-source { border-left: 3px solid var(--cat-source); }
.node.cat-source .node-icon { background: var(--cat-source); }
.node.cat-process { border-left: 3px solid var(--cat-process); }
.node.cat-process .node-icon { background: var(--cat-process); }
.node.cat-output { border-left: 3px solid var(--cat-output); }
.node.cat-output .node-icon { background: var(--cat-output); }

/* ---------- 端口 ---------- */
.node-ports { position: absolute; left: 0; right: 0; top: 30px; bottom: 0; pointer-events: none; }
.port {
  position: absolute; width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff; border: 2px solid #93a1b5;
  pointer-events: auto; cursor: crosshair;
  transition: transform .1s, border-color .1s;
}
.port:hover { transform: scale(1.35); border-color: var(--accent); }
.port.port-in { margin-left: -7px; }
.port.port-out { margin-right: -7px; }
.cat-source .port.port-out { border-color: var(--cat-source); }
.cat-process .port.port-out { border-color: var(--cat-process); }
.cat-output .port.port-out { border-color: var(--cat-output); }
.port.port-in { border-color: var(--accent); }

/* ---------- 画布工具条 ---------- */
#canvas-toolbar {
  position: absolute; right: 12px; bottom: 220px; z-index: 15;
  display: flex; align-items: center; gap: 4px;
  padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow);
}
#canvas-toolbar .btn-icon { width: 26px; height: 26px; font-size: 14px; }
.zoom-label { font-size: 11.5px; color: var(--text2); min-width: 40px; text-align: center; font-family: var(--mono); }

/* ---------- 拖拽幽灵 ---------- */
.drag-ghost {
  position: fixed; z-index: 999; pointer-events: none;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 6px;
  box-shadow: var(--shadow-lg); color: var(--text);
  transform: translate(-50%, -50%);
}
.drag-ghost svg { width: 13px; height: 13px; }

/* ---------- 节点库 ---------- */
.palette-search { padding: 8px 10px; border-bottom: 1px solid var(--border2); }
.palette-search input {
  width: 100%; height: 26px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel2);
  font-size: 12px;
}
.palette-search input:focus { outline: none; border-color: var(--accent); background: #fff; }
#palette-list { flex: 1; overflow-y: auto; padding: 8px; }
.palette-cat {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1px; color: var(--text3);
  margin: 10px 4px 5px; text-transform: uppercase;
}
.palette-cat:first-child { margin-top: 2px; }
.palette-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; margin-bottom: 4px;
  border: 1px solid transparent; border-radius: 7px;
  cursor: grab; touch-action: none;
  transition: background .1s, border-color .1s;
}
.palette-item:hover { background: var(--panel2); border-color: var(--border); }
.palette-item:active { cursor: grabbing; }
.palette-item .pi-icon {
  width: 24px; height: 24px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; color: #fff;
}
.palette-item .pi-icon svg { width: 14px; height: 14px; }
.palette-item.cat-source .pi-icon { background: var(--cat-source); }
.palette-item.cat-process .pi-icon { background: var(--cat-process); }
.palette-item.cat-output .pi-icon { background: var(--cat-output); }
.pi-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.pi-text b { font-size: 12.5px; font-weight: 600; }
.pi-text small { font-size: 10.5px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-tip {
  flex: none; padding: 8px 10px;
  font-size: 10.5px; color: var(--text3);
  border-top: 1px solid var(--border2); background: var(--panel2);
}
