/*
 * AI Stack Graph Styles
 * 技术栈动态图谱样式 - 节点浮动、连线脉冲、故障效果
 */

/* ===== 图谱容器 ===== */
.graph-container {
  position: relative;
  width: 100%;
  height: 600px;
  background: rgba(var(--terminal-bg), 0.4);
  border: 1px solid rgba(var(--primary), 0.15);
  border-radius: 16px;
  overflow: hidden;
}

.graph-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ===== 控制面板 ===== */
.graph-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
}

.graph-control-group {
  background: rgba(var(--terminal-bg), 0.52);
  backdrop-filter: blur(18px) saturate(125%);
  border: 1px solid rgba(var(--primary), 0.12);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.22);
}

.graph-control-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(var(--primary), 0.7);
  margin-bottom: 10px;
}

/* ===== 层级过滤器 ===== */
.graph-layer-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.graph-layer-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: rgba(var(--off-white), 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
}

.graph-layer-filter:hover {
  color: rgba(var(--primary), 1);
}

.graph-layer-filter input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(var(--primary), 0.4);
  border-radius: 4px;
  background: rgba(var(--primary), 0.1);
  cursor: pointer;
  position: relative;
}

.graph-layer-filter input[type="checkbox"]:checked {
  background: rgba(var(--primary), 0.3);
  border-color: rgba(var(--primary), 0.8);
}

.graph-layer-filter input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: rgba(var(--primary), 1);
}

.graph-layer-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: auto;
}

/* ===== 搜索框 ===== */
.graph-search-box {
  position: relative;
  width: 200px;
}

.graph-search-input {
  width: 100%;
  background: rgba(var(--terminal-bg), 0.6);
  border: 1px solid rgba(var(--primary), 0.15);
  border-radius: 8px;
  padding: 8px 12px 8px 32px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: rgba(var(--off-white), 0.9);
  outline: none;
  transition: all 0.2s ease;
}

.graph-search-input::placeholder {
  color: rgba(var(--muted-teal), 0.3);
}

.graph-search-input:focus {
  border-color: rgba(var(--primary), 0.4);
  background: rgba(var(--terminal-bg), 0.8);
}

.graph-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Material Symbols Outlined";
  font-size: 16px;
  color: rgba(var(--muted-teal), 0.4);
  pointer-events: none;
}

/* ===== 图例 ===== */
.graph-legend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(var(--terminal-bg), 0.52);
  backdrop-filter: blur(18px) saturate(125%);
  border: 1px solid rgba(var(--primary), 0.12);
  border-radius: 12px;
  padding: 12px;
  z-index: 20;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.22);
}

.graph-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 300px;
}

.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  color: rgba(var(--off-white), 0.7);
}

.graph-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ===== 详情面板 ===== */
.graph-detail-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 280px;
  background: rgba(var(--terminal-bg), 0.62);
  backdrop-filter: blur(22px) saturate(130%);
  border: 1px solid rgba(var(--primary), 0.18);
  border-radius: 12px;
  padding: 16px;
  z-index: 20;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), inset 0 0 40px rgba(var(--primary), 0.03);
}

.graph-detail-panel.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.graph-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(var(--primary), 0.1);
}

.graph-detail-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-center;
  background: rgba(var(--primary), 0.15);
  border: 1px solid rgba(var(--primary), 0.3);
  border-radius: 8px;
  font-family: "Material Symbols Outlined";
  font-size: 18px;
  color: rgba(var(--primary), 1);
}

.graph-detail-title {
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: rgba(var(--off-white), 0.95);
}

.graph-detail-layer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(var(--muted-teal), 0.6);
}

.graph-detail-description {
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(var(--off-white), 0.7);
  margin-bottom: 12px;
}

.graph-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.graph-detail-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  color: rgba(var(--muted-teal), 0.5);
  background: rgba(var(--muted-teal), 0.1);
  padding: 4px 8px;
  border-radius: 6px;
}

.graph-detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(var(--off-white), 0.4);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.graph-detail-close:hover {
  background: rgba(var(--primary), 0.1);
  color: rgba(var(--primary), 1);
}

/* ===== 节点浮动动画 ===== */
@keyframes node-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* ===== 连线脉冲动画 ===== */
@keyframes link-pulse {
  0% {
    offset-distance: 0%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}

/* ===== 故障效果动画 ===== */
@keyframes graph-glitch {
  0%, 100% {
    transform: translate(0, 0);
    filter: hue-rotate(0deg);
  }
  20% {
    transform: translate(-2px, 1px);
    filter: hue-rotate(90deg);
  }
  40% {
    transform: translate(2px, -1px);
    filter: hue-rotate(180deg);
  }
  60% {
    transform: translate(-1px, 2px);
    filter: hue-rotate(270deg);
  }
  80% {
    transform: translate(1px, -2px);
    filter: hue-rotate(360deg);
  }
}

.graph-glitch-effect {
  animation: graph-glitch 0.3s ease-in-out;
}

/* ===== 节点发光效果 ===== */
@keyframes node-glow {
  0%, 100% {
    filter: drop-shadow(0 0 8px rgba(var(--primary), 0.6));
  }
  50% {
    filter: drop-shadow(0 0 16px rgba(var(--primary), 0.9));
  }
}

/* ===== 能量流动画 ===== */
@keyframes energy-flow {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* ===== 统计信息 ===== */
.graph-stats {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  color: rgba(var(--muted-teal), 0.5);
  z-index: 10;
}

.graph-stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.graph-stat-value {
  color: rgba(var(--primary), 0.8);
  font-weight: 600;
}

/* ===== 操作提示 ===== */
.graph-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: rgba(var(--muted-teal), 0.4);
  text-align: center;
  pointer-events: none;
  z-index: 5;
}

.graph-hint.is-hidden {
  display: none;
}

/* ===== 工具栏按钮 ===== */
.graph-toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 20;
}

.graph-toolbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--terminal-bg), 0.52);
  backdrop-filter: blur(18px) saturate(125%);
  border: 1px solid rgba(var(--primary), 0.12);
  border-radius: 10px;
  color: rgba(var(--off-white), 0.6);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: "Material Symbols Outlined";
  font-size: 18px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.22);
}

.graph-toolbar-btn:hover {
  background: rgba(var(--primary), 0.15);
  border-color: rgba(var(--primary), 0.4);
  color: rgba(var(--primary), 1);
}

.graph-toolbar-btn.is-active {
  background: rgba(var(--primary), 0.25);
  border-color: rgba(var(--primary), 0.6);
  color: rgba(var(--primary), 1);
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .graph-container {
    height: 400px;
  }

  .graph-controls {
    top: 8px;
    left: 8px;
  }

  .graph-detail-panel {
    top: auto;
    bottom: 8px;
    right: 8px;
    left: 8px;
    width: auto;
  }

  .graph-legend {
    display: none;
  }

  .graph-toolbar {
    top: 8px;
  }
}

/* ===== 无障碍 - 减少动画 ===== */
@media (prefers-reduced-motion: reduce) {
  .graph-glitch-effect,
  [data-animate-float],
  [data-animate-pulse] {
    animation: none !important;
  }
}
