/**
 * Skill Manager Modal — 样式
 *
 * DAG 画布使用 HTML div 节点 + Canvas 连线（节点可交互，连线由 canvas 绘制）
 */

/* ── Modal 遮罩 ──────────────────────────────────────────────────────────── */

.skill-manager-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

/* ── Modal 容器 ──────────────────────────────────────────────────────────── */

.skill-manager-modal {
  width: 90vw;
  height: 88vh;
  background: #13131a;
  border: 1px solid #1e1e2e;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 顶栏 ────────────────────────────────────────────────────────────────── */

.skill-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  border-bottom: 1px solid #1e1e2e;
  flex-shrink: 0;
}

.skill-manager-title {
  font-size: 14px;
  font-weight: 600;
  color: #e0e0e0;
  letter-spacing: 0.02em;
}

.skill-manager-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.skill-manager-close:hover {
  background: rgba(255,255,255,0.06);
  color: #ccc;
}

/* ── 主体：左右分栏 ──────────────────────────────────────────────────────── */

.skill-manager-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* 左侧：Skill 列表 */
.skill-list-panel {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid #1e1e2e;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 列表行：名称 + ⊕ 按钮 */
.skill-list-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.skill-list-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #888;
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  background: transparent;
  text-align: left;
  flex: 1;
  min-width: 0;
}

.skill-list-item:hover {
  background: rgba(255,255,255,0.04);
  color: #ccc;
}

.skill-list-item.active {
  background: rgba(108, 133, 255, 0.12);
  color: #a0aaff;
}

.skill-list-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #444;
  flex-shrink: 0;
  transition: background 0.15s;
}
.skill-list-item.active .skill-list-dot {
  background: #6c85ff;
}

/* ⊕ 快照按钮 */
.skill-snapshot-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: #444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.skill-snapshot-btn:hover {
  background: rgba(108,133,255,0.15);
  color: #6c85ff;
}

/* 右侧：内容区 */
.skill-content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* ── DAG 画布区 ──────────────────────────────────────────────────────────── */

.dag-panel {
  flex: 1;
  position: relative;
  overflow: auto;
  background: #0f0f14;
  border-bottom: 1px solid #1e1e2e;
  min-height: 0;
}

.dag-canvas-container {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

/* Canvas 用于绘制连线（绝对覆盖，pointer-events:none） */
.dag-edges-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
}

/* 节点层 */
.dag-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

/* ── DAG 节点 ────────────────────────────────────────────────────────────── */

.dag-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.dag-node-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #333;
  background: #1e1e2e;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  position: relative;
}

.dag-node:hover .dag-node-dot {
  border-color: #6c85ff;
  background: rgba(108, 133, 255, 0.1);
}

.dag-node.selected .dag-node-dot {
  border-color: #6c85ff;
  background: rgba(108, 133, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(108, 133, 255, 0.2);
}

.dag-node.is-head .dag-node-dot {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
}

.dag-node.is-head.selected .dag-node-dot {
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
}

/* 节点内部小圆 */
.dag-node-inner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  transition: background 0.15s;
}
.dag-node:hover .dag-node-inner,
.dag-node.selected .dag-node-inner {
  background: #6c85ff;
}
.dag-node.is-head .dag-node-inner {
  background: #4ade80;
}

/* hash 标签 */
.dag-node-hash {
  margin-top: 4px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace, monospace;
  color: #555;
  transition: color 0.15s;
}
.dag-node:hover .dag-node-hash,
.dag-node.selected .dag-node-hash {
  color: #8899ff;
}

/* Branch/Tag 标签 */
.dag-node-labels {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  white-space: nowrap;
}

.dag-label {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dag-label-branch {
  background: rgba(108, 133, 255, 0.2);
  color: #8899ff;
  border: 1px solid rgba(108, 133, 255, 0.3);
}

.dag-label-head {
  background: rgba(74, 222, 128, 0.18);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.dag-label-tag {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

/* ── 节点详情区 ──────────────────────────────────────────────────────────── */

.skill-detail-panel {
  height: 200px;
  flex-shrink: 0;
  border-top: 1px solid #1e1e2e;
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  overflow: hidden;
}

.skill-detail-empty {
  color: #444;
  font-size: 13px;
  margin: auto;
}

.skill-detail-info {
  flex: 1;
  min-width: 0;
}

.skill-detail-message {
  font-size: 14px;
  font-weight: 500;
  color: #ddd;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-detail-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.skill-detail-meta span {
  font-size: 12px;
  color: #666;
}

.skill-detail-meta .meta-hash {
  font-family: monospace;
  color: #8899ff;
}

.skill-detail-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.skill-detail-file-chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  color: #888;
  font-family: monospace;
}

.skill-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.skill-action-btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.skill-action-btn:hover { opacity: 0.85; }
.skill-action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.skill-action-btn.primary {
  background: #6c85ff;
  color: #fff;
}

.skill-action-btn.secondary {
  background: rgba(255,255,255,0.06);
  color: #ccc;
  border: 1px solid #2a2a3a;
}

/* ── 空状态 ──────────────────────────────────────────────────────────────── */

.dag-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #444;
  font-size: 13px;
  gap: 8px;
}

/* ══════════════════════════════════════════════════════════════════════════
   Skill 编辑器 Modal
   ══════════════════════════════════════════════════════════════════════════ */

.skill-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 1010;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(3px);
}

.skill-editor-modal {
  width: 88vw;
  height: 86vh;
  background: #13131a;
  border: 1px solid #1e1e2e;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.skill-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  border-bottom: 1px solid #1e1e2e;
  flex-shrink: 0;
  gap: 12px;
}

.skill-editor-title {
  font-size: 13px;
  font-weight: 600;
  color: #ccc;
  white-space: nowrap;
}

.skill-editor-ref {
  font-size: 11px;
  font-family: monospace;
  color: #555;
  flex: 1;
}

.skill-editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* 文件树 */
.skill-filetree {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid #1e1e2e;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.skill-file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: #777;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
  font-family: monospace;
}
.skill-file-item:hover {
  background: rgba(255,255,255,0.04);
  color: #bbb;
}
.skill-file-item.active {
  background: rgba(108,133,255,0.1);
  color: #a0aaff;
}

.skill-file-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

/* 编辑区 */
.skill-editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.skill-editor-path {
  padding: 8px 16px;
  font-size: 11px;
  font-family: monospace;
  color: #555;
  border-bottom: 1px solid #1a1a24;
  flex-shrink: 0;
  background: #0f0f14;
}

.skill-editor-textarea {
  flex: 1;
  width: 100%;
  background: #0f0f14;
  color: #d0d0d0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.65;
  border: none;
  outline: none;
  resize: none;
  padding: 16px;
  tab-size: 2;
}

.skill-editor-footer {
  border-top: 1px solid #1e1e2e;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: #13131a;
}

.skill-editor-commit-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: #ccc;
  outline: none;
  transition: border-color 0.15s;
}
.skill-editor-commit-input:focus {
  border-color: #6c85ff;
}
.skill-editor-commit-input::placeholder {
  color: #444;
}

.skill-editor-save-btn {
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  background: #6c85ff;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.skill-editor-save-btn:hover { opacity: 0.85; }
.skill-editor-save-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.skill-editor-status {
  font-size: 12px;
  color: #4ade80;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════
   Tool Manager 样式（复制自 Skill Manager）
   ══════════════════════════════════════════════════════════════════════════ */

/* 左侧：Tool 列表 */
.tool-list-panel {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid #1e1e2e;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tool-list-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tool-list-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #888;
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  background: transparent;
  text-align: left;
  flex: 1;
  min-width: 0;
}

.tool-list-item:hover {
  background: rgba(255,255,255,0.04);
  color: #ccc;
}

.tool-list-item.active {
  background: rgba(108, 133, 255, 0.12);
  color: #a0aaff;
}

.tool-list-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #444;
  flex-shrink: 0;
  transition: background 0.15s;
}
.tool-list-item.active .tool-list-dot {
  background: #6c85ff;
}

.tool-snapshot-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: #444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.tool-snapshot-btn:hover {
  background: rgba(108,133,255,0.15);
  color: #6c85ff;
}

/* 右侧：内容区 */
.tool-content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* 版本详情面板 */
.tool-detail-panel {
  flex-shrink: 0;
  padding: 16px;
  border-top: 1px solid #1e1e2e;
  background: #0a0a0f;
  min-height: 140px;
  max-height: 200px;
  overflow-y: auto;
}

.tool-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #444;
  font-size: 13px;
}

.tool-detail-info {
  flex: 1;
  min-width: 0;
}

.tool-detail-message {
  font-size: 14px;
  color: #ccc;
  font-weight: 500;
  margin-bottom: 8px;
}

.tool-detail-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.tool-detail-meta span {
  font-size: 12px;
  color: #666;
}

.tool-detail-meta .meta-hash {
  font-family: monospace;
  color: #8899ff;
}

.tool-detail-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tool-detail-file-chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  color: #888;
  font-family: monospace;
}

.tool-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.tool-action-btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.tool-action-btn:hover { opacity: 0.85; }
.tool-action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.tool-action-btn.primary {
  background: #6c85ff;
  color: #fff;
}

.tool-action-btn.secondary {
  background: rgba(255,255,255,0.06);
  color: #ccc;
  border: 1px solid #2a2a3a;
}
