/* Graph container */
.graph-container {
  position: relative;
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--topbar-height) - 48px);
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.graph-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
}

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

/* Graph toolbar */
.graph-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.graph-toolbar .btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.graph-toolbar .btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.graph-toolbar .btn.active {
  background: var(--accent-primary);
  color: #fff;
}

/* Graph controls panel */
.graph-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.graph-controls .graph-ctrl-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.graph-controls .graph-ctrl-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Node info popup */
.node-popup {
  position: absolute;
  min-width: 260px;
  max-width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  animation: nodePopupIn 0.2s ease;
}

@keyframes nodePopupIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.node-popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
}

.node-popup-header .node-type-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.node-popup-header h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.node-popup-header .node-type-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.node-popup-body {
  padding: 14px;
}

.node-popup-body .node-detail {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: var(--text-sm);
}

.node-detail-label {
  color: var(--text-muted);
}

.node-detail-value {
  color: var(--text-primary);
  font-weight: 500;
}

.node-popup-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

/* Link style legend */
.link-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 10px 14px;
  z-index: 10;
}

.link-legend-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.link-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.link-legend-line {
  width: 24px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}

.link-legend-line.dashed {
  background: none;
  border-top: 2px dashed;
}

/* Minimap */
.graph-minimap {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 160px;
  height: 120px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 10;
}

.graph-minimap canvas {
  width: 100%;
  height: 100%;
}

.minimap-viewport {
  position: absolute;
  border: 1.5px solid var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
  border-radius: 2px;
  pointer-events: none;
}

@media (max-width: 768px) {
  .graph-container {
    height: calc(100vh - var(--topbar-height) - 32px);
  }
  .graph-minimap { display: none; }
  .link-legend { display: none; }
}
