/**
 * Flow diagram styles
 * @countermeasure/web-components/visualization/flow-diagram
 */

/* ============================================================================
   Container
   ============================================================================ */
.cmm-flow-diagram {
  position: relative;
  overflow: hidden;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
  cursor: grab;
}

.cmm-flow-diagram:active {
  cursor: grabbing;
}

.cmm-flow-diagram__svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================================
   Nodes
   ============================================================================ */
.cmm-flow-diagram__node {
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.cmm-flow-diagram__node:hover {
  opacity: 0.85;
}

.cmm-flow-diagram__node--selected .cmm-flow-diagram__node-shape {
  stroke: hsl(var(--primary));
  stroke-width: 2.5;
}

.cmm-flow-diagram__node-shape {
  fill: hsl(var(--background));
  stroke: hsl(var(--border));
  stroke-width: 1.5;
  transition: stroke var(--transition-fast), fill var(--transition-fast);
}

.cmm-flow-diagram__node:hover .cmm-flow-diagram__node-shape {
  stroke: hsl(var(--primary));
  fill: hsl(var(--accent));
}

.cmm-flow-diagram__node-icon {
  font-size: 0.875rem;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* ============================================================================
   Labels
   ============================================================================ */
.cmm-flow-diagram__label {
  font-size: 0.75rem;
  fill: hsl(var(--foreground));
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  font-weight: 500;
}

.cmm-flow-diagram__edge-label {
  font-size: 0.6875rem;
  fill: hsl(var(--muted-foreground));
  text-anchor: middle;
  dominant-baseline: auto;
  pointer-events: none;
}

/* ============================================================================
   Edges
   ============================================================================ */
.cmm-flow-diagram__edge {
  cursor: pointer;
}

.cmm-flow-diagram__edge-path {
  fill: none;
  stroke: hsl(var(--border));
  stroke-width: 1.5;
  transition: stroke var(--transition-fast);
}

.cmm-flow-diagram__edge:hover .cmm-flow-diagram__edge-path {
  stroke: hsl(var(--primary));
  stroke-width: 2;
}

.cmm-flow-diagram__edge--dashed .cmm-flow-diagram__edge-path {
  stroke-dasharray: 8 4;
}

.cmm-flow-diagram__edge--dotted .cmm-flow-diagram__edge-path {
  stroke-dasharray: 3 3;
}

.cmm-flow-diagram__edge--animated .cmm-flow-diagram__edge-path {
  animation: cmm-flow-dash 0.6s linear infinite;
}

.cmm-flow-diagram__arrowhead {
  fill: hsl(var(--border));
}

.cmm-flow-diagram__edge:hover .cmm-flow-diagram__arrowhead {
  fill: hsl(var(--primary));
}

/* ============================================================================
   Animation keyframes
   ============================================================================ */
@keyframes cmm-flow-dash {
  to {
    stroke-dashoffset: -12;
  }
}

/* ============================================================================
   Zoom controls (optional overlay)
   ============================================================================ */
.cmm-flow-diagram__controls {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cmm-flow-diagram__control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.cmm-flow-diagram__control-btn:hover {
  background: hsl(var(--accent));
}
