/* ============================================
   Canvas Enhanced Styles
   基于 TapNow/新片场画布的精细化设计
   ============================================ */

/* --- Canvas 容器增强 --- */
.canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #0e0e0e;
  /* 添加微妙的渐变 */
  background: radial-gradient(ellipse at center, #12121a 0%, #0a0a0f 100%);
}

/* --- 网格背景优化（点状） --- */
.canvas-grid {
  position: absolute;
  inset: 0;
  /* 改为点状网格 */
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
  /* 添加渐变遮罩，边缘淡化 */
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 100%);
}

/* --- 画布视口增强 --- */
.canvas-viewport {
  position: absolute;
  inset: 0;
  cursor: grab;
  /* 平滑过渡 */
  transition: none;
  will-change: transform;
}

.canvas-viewport:active {
  cursor: grabbing;
}

.canvas-viewport.cv-space-pan {
  cursor: grabbing !important;
}

/* --- 画布世界容器 --- */
.canvas-world {
  position: absolute;
  transform-origin: 0 0;
  transition: none;
  /* 性能优化 */
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

/* ============================================
   节点样式增强
   ============================================ */

/* --- 基础节点样式 --- */
.canvas-node {
  position: absolute;
  width: 240px;
  /* 更深的卡片背景 */
  background: linear-gradient(135deg, #1a1a21 0%, #15151a 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  cursor: move;
  user-select: none;
  /* 增强阴影效果 */
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    0 1px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition:
    border-color 200ms ease,
    box-shadow 200ms ease,
    transform 150ms ease;
  /* 3D 效果 */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* --- 悬停效果 --- */
.canvas-node:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(-1px) translateZ(0);
}

/* --- 选中状态 --- */
.canvas-node.selected {
  border-color: rgba(96, 165, 250, 0.6);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.3),
    0 8px 24px rgba(96, 165, 250, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(96, 165, 250, 0.1);
}

/* --- 生成中状态 --- */
/* 这里原本在 .canvas-node 本体上跑 node-pulse（0→4px 的扩散方环）。
   节点本体是直角（border-radius:0，圆角在内部卡片上），所以那一圈环画出来
   就是一个和卡片圆角对不上的直角矩形——也就是用户截图里那条"直角边框"。
   现在改成只由 .shotlab-node-card 的渐变外发光呼吸表达，本体不再画环。 */
.canvas-node.generating {
  border-color: transparent;
  animation: none;
}

@keyframes node-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(96, 165, 250, 0.4),
      0 4px 16px rgba(0, 0, 0, 0.4);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(96, 165, 250, 0.1),
      0 8px 24px rgba(96, 165, 250, 0.2);
  }
}

/* --- 错误状态 --- */
.canvas-node.error {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow:
    0 0 0 1px rgba(239, 68, 68, 0.2),
    0 4px 16px rgba(239, 68, 68, 0.15);
}

/* --- 节点头部 --- */
.canvas-node-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  /* 微妙的渐变 */
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.02) 0%,
    transparent 100%);
  border-radius: 14px 14px 0 0;
}

.canvas-node-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  /* 图标背景渐变 */
  background: linear-gradient(135deg,
    rgba(96, 165, 250, 0.15),
    rgba(147, 51, 234, 0.15));
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.canvas-node-model {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: -0.01em;
}

.canvas-node-status {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

/* --- 节点预览区 --- */
.canvas-node-preview {
  aspect-ratio: 16/9;
  background: #0a0a0f;
  margin: 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  /* 内阴影 */
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.canvas-node-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 图片加载动画 */
  animation: img-fade-in 300ms ease;
}

@keyframes img-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- 节点底部 --- */
.canvas-node-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(0deg,
    rgba(0, 0, 0, 0.15) 0%,
    transparent 100%);
}

.canvas-node-cost {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 4px;
}

.canvas-node-run {
  padding: 6px 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
  color: #000000;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.canvas-node-run:hover {
  background: #ffffff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.canvas-node-run:active {
  transform: translateY(0);
}

/* ============================================
   连线样式增强
   ============================================ */

.canvas-connections {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* 必须与 css/style.css 里的同名规则保持一致：0 = 画在节点层之下。
     这里是后加载的同权重覆盖，改一边不改这边等于没改。 */
  z-index: 0;
}

/* 连线路径 */
.canvas-connection-path {
  fill: none;
  stroke: rgba(96, 165, 250, 0.3);
  stroke-width: 2;
  transition: stroke 200ms ease;
}

.canvas-connection-path:hover {
  stroke: rgba(96, 165, 250, 0.6);
  stroke-width: 3;
}

/* 连线动画（生成中） */
.canvas-connection-path.generating {
  stroke: rgba(96, 165, 250, 0.5);
  stroke-dasharray: 8 4;
  animation: dash-flow 1s linear infinite;
}

@keyframes dash-flow {
  to {
    stroke-dashoffset: -12;
  }
}

/* 连线箭头 */
.canvas-connection-arrow {
  fill: rgba(96, 165, 250, 0.4);
}

/* ============================================
   工具栏增强
   ============================================ */

/* --- 左侧工具栏 --- */
.canvas-left-toolbar {
  position: absolute;
  left: 16px;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  /* 玻璃态背景 */
  background: rgba(26, 26, 33, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.toolbar-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms ease;
}

.toolbar-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.toolbar-btn.primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.toolbar-btn.primary:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

.toolbar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 0;
}

/* --- 底部控制栏 --- */
.canvas-bottombar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 30;
  /* 玻璃态背景 */
  background: rgba(26, 26, 33, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.bottombar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.65);
  background: transparent;
  cursor: pointer;
  transition: all 150ms ease;
}

.bottombar-btn:hover {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.08);
}

.bottombar-zoom-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  min-width: 50px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.bottombar-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
}

/* ============================================
   参数面板增强
   ============================================ */

.param-panel {
  position: absolute;
  right: -320px;
  top: 0;
  bottom: 0;
  width: 320px;
  /* 玻璃态背景 */
  background: rgba(26, 26, 33, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  padding: 20px;
  z-index: 40;
  transition: right 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.param-panel.open {
  right: 0;
}

.param-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
}

.param-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: all 150ms ease;
}

.param-close:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.08);
}

/* ============================================
   右侧滑出面板
   ============================================ */

.canvas-right-panel {
  position: absolute;
  right: -400px;
  top: 0;
  bottom: 0;
  width: 400px;
  background: rgba(15, 15, 16, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
  z-index: 35;
  transition: right 400ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.canvas-right-panel.open {
  right: 0;
}

/* 面板调整器 */
.panel-resizer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: ew-resize;
  background: transparent;
  transition: background 150ms ease;
}

.panel-resizer:hover {
  background: rgba(96, 165, 250, 0.3);
}

.panel-content {
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

/* ============================================
   空画布引导
   ============================================ */

.canvas-empty-guide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  animation: guide-fade-in 400ms ease;
}

@keyframes guide-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty-guide-content {
  text-align: center;
  pointer-events: auto;
}

/* 提示胶囊 / chip 行 / 次要入口的样式统一在 css/style.css 的「空状态」一节定义。
   这里曾有一整套旧版定义（胶囊 inline-flex + padding 12px 20px + margin-bottom 24px；
   chip 行 gap 10px + margin-bottom 20px；次要入口 gap 16px；ghost 按钮 13px …），
   因为本文件在 style.css 之后加载、选择器权重又相同，会把新样式整块覆盖成旧样式，
   表现为「改了 CSS 没反应」——已删除，不要在本文档里重新引入。
   这里只保留 style.css 里没有的部分：引导层定位、淡入动画、内容区可点。
   注意：.empty-guide-content 的 pointer-events:auto 是故意的（chip 要能点），
   代价是它会截住落在引导层上的滚轮，所以画布的滚轮处理器必须同时挂到
   #canvas-empty-guide 上（见 js/app.js 的 wheelHosts）。 */

/* ============================================
   性能优化
   ============================================ */

/* GPU 加速 */
.canvas-node,
.canvas-viewport,
.canvas-world,
.toolbar-btn,
.bottombar-btn {
  will-change: transform;
  transform: translateZ(0);
}

/* 滚动优化 */
.param-panel,
.panel-content {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.param-panel::-webkit-scrollbar,
.panel-content::-webkit-scrollbar {
  width: 6px;
}

.param-panel::-webkit-scrollbar-track,
.panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.param-panel::-webkit-scrollbar-thumb,
.panel-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.param-panel::-webkit-scrollbar-thumb:hover,
.panel-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 768px) {
  .canvas-left-toolbar {
    left: 8px;
    top: 8px;
    padding: 6px;
  }

  .toolbar-btn {
    width: 36px;
    height: 36px;
  }

  .canvas-bottombar {
    bottom: 12px;
    padding: 8px 12px;
  }

  .param-panel {
    width: 100%;
    right: -100%;
  }

  .canvas-right-panel {
    width: 100%;
    right: -100%;
  }
}

/* ============================================
   暗色模式微调
   ============================================ */

@media (prefers-color-scheme: dark) {
  .canvas-container {
    background: #0a0a0f;
  }

  .canvas-node {
    box-shadow:
      0 4px 20px rgba(0, 0, 0, 0.6),
      0 1px 4px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.02);
  }
}
