/* ==========================================================================
   MENA.ME — Outcome Configurator Styles
   Node-based workflow builder with dark futuristic aesthetic
   ========================================================================== */

/* ==========================================================================
   1. CONFIGURATOR SHELL
   ========================================================================== */

.configurator {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--surface);
  visibility: hidden;
  opacity: 0;
  transition:
    visibility 0.3s ease,
    opacity 0.3s ease;
}

.configurator.is-active {
  visibility: visible;
  opacity: 1;
}

/* Transition overlay - typing animation */
.configurator-transition {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 10;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.5s ease, opacity 0.5s ease;
}

.configurator-transition.is-active {
  visibility: visible;
  opacity: 1;
}

.transition-text {
  font-family: var(--font-mono);
  font-size: clamp(0.875rem, 2vw, 1.125rem);
  color: var(--accent);
  text-align: left;
  max-width: 600px;
  padding: var(--space-lg);
}

.transition-line {
  display: block;
  opacity: 0;
  transform: translateY(10px);
  animation: type-line 0.4s var(--ease-out-expo) forwards;
}

.transition-line:nth-child(1) { animation-delay: 0.1s; }
.transition-line:nth-child(2) { animation-delay: 0.4s; }
.transition-line:nth-child(3) { animation-delay: 0.7s; }
.transition-line:nth-child(4) { animation-delay: 1.0s; }
.transition-line:nth-child(5) { animation-delay: 1.3s; }

.transition-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.2em;
  background: var(--accent);
  margin-left: 0.2em;
  animation: cursor-blink 0.8s step-end infinite;
}

/* Main app container - hidden during transition */
.configurator-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.4s ease, opacity 0.4s ease;
}

.configurator-app.is-active {
  visibility: visible;
  opacity: 1;
}


/* ==========================================================================
   EPIC TRANSITION - PHASE 1: SHATTER
   ========================================================================== */

@keyframes shatter-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--fall-x), 150vh) rotate(var(--fall-rotate)); opacity: 0; }
}

.shatter-shard {
  position: fixed;
  background: var(--surface);
  clip-path: polygon(var(--clip));
  animation: shatter-fall 0.8s var(--ease-out-expo) forwards;
  animation-delay: var(--delay);
  z-index: 10001;
}


/* ==========================================================================
   EPIC TRANSITION - PHASE 2: VOID + PARTICLES
   ========================================================================== */

.transition-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.transition-rain {
  opacity: 0.6;
  mix-blend-mode: screen;
}


/* ==========================================================================
   EPIC TRANSITION - CORE IGNITION
   ========================================================================== */

.core-ignition {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.core-pulse {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow:
    0 0 60px 30px var(--accent),
    0 0 100px 60px rgba(255, 61, 0, 0.5),
    0 0 140px 90px rgba(255, 61, 0, 0.2);
  opacity: 0;
  transform: scale(0);
  animation: core-ignite 1s var(--ease-out-expo) forwards;
  animation-delay: 1.5s;
}

@keyframes core-ignite {
  0% { opacity: 0; transform: scale(0); }
  50% { opacity: 1; transform: scale(1.5); }
  100% { opacity: 1; transform: scale(1); }
}

.core-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
}

.core-ring--1 {
  width: 100px;
  height: 100px;
  animation: ring-expand 2s var(--ease-out-expo) forwards;
  animation-delay: 1.7s;
}

.core-ring--2 {
  width: 200px;
  height: 200px;
  animation: ring-expand 2s var(--ease-out-expo) forwards;
  animation-delay: 1.9s;
}

.core-ring--3 {
  width: 400px;
  height: 400px;
  animation: ring-expand 2s var(--ease-out-expo) forwards;
  animation-delay: 2.1s;
}

@keyframes ring-expand {
  0% { opacity: 0.8; transform: translate(-50%, -50%) scale(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(3); }
}


/* ==========================================================================
   EPIC TRANSITION - GRID DRAW
   ========================================================================== */

.grid-draw {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.grid-rect {
  animation: grid-reveal 1.5s ease-out forwards;
  animation-delay: 2s;
}

@keyframes grid-reveal {
  0% { opacity: 0; }
  100% { opacity: 1; }
}


/* ==========================================================================
   EPIC TRANSITION - LOADING TERMINAL
   ========================================================================== */

.loading-terminal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 800px);
  max-height: 70vh;
  background: rgba(10, 10, 11, 0.95);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-mono);
  z-index: 10;
  opacity: 0;
  animation: terminal-appear 0.5s ease-out forwards;
  animation-delay: 0.6s;
}

@keyframes terminal-appear {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--surface-border);
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-border);
}

.terminal-dot:nth-child(1) { background: #ff5f57; }
.terminal-dot:nth-child(2) { background: #ffbd2e; }
.terminal-dot:nth-child(3) { background: #28c840; }

.terminal-title {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.terminal-body {
  padding: 20px;
  max-height: 50vh;
  overflow-y: auto;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.terminal-body::-webkit-scrollbar {
  width: 6px;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: var(--surface-border);
  border-radius: 3px;
}

/* Terminal line styles */
.terminal-line {
  opacity: 0;
  transform: translateX(-10px);
  animation: line-appear 0.3s ease-out forwards;
  white-space: pre-wrap;
  margin-bottom: 2px;
}

@keyframes line-appear {
  to { opacity: 1; transform: translateX(0); }
}

.terminal-line--status {
  color: var(--text-secondary);
}

.terminal-line--ok {
  color: var(--success);
}

.terminal-line--standby {
  color: var(--warning);
}

.terminal-line--warning {
  color: #ffaa00;
  font-weight: 700;
  margin: 8px 0;
}

.terminal-line--header {
  color: var(--accent);
  font-weight: 600;
  margin-top: 8px;
}

.terminal-line--sub {
  color: var(--text-muted);
  padding-left: 20px;
  font-size: 0.75rem;
}

.terminal-line--final {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.875rem;
  margin-top: 16px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Rotating text effect */
.rotating-text {
  display: inline-block;
  min-width: 200px;
  color: var(--accent);
}

.rotating-text--models {
  animation: text-cycle 0.15s steps(1) infinite;
}

/* Cursor blink - terminal specific */
.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  margin-left: 4px;
  animation: cursor-blink 1s step-end infinite;
}


/* ==========================================================================
   EPIC TRANSITION - SCREEN SHAKE
   ========================================================================== */

@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-2px) rotate(-0.5deg); }
  20% { transform: translateX(2px) rotate(0.5deg); }
  30% { transform: translateX(-2px); }
  40% { transform: translateX(2px); }
  50% { transform: translateX(-1px); }
  60% { transform: translateX(1px); }
}

.shake {
  animation: screen-shake 0.4s ease-out;
}


/* ==========================================================================
   EPIC TRANSITION - GLITCH TEXT
   ========================================================================== */

.glitch-text {
  position: relative;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.8;
}

.glitch-text::before {
  color: #0ff;
  animation: glitch-1 0.3s infinite;
  clip-path: inset(0 0 50% 0);
}

.glitch-text::after {
  color: #f0f;
  animation: glitch-2 0.3s infinite;
  clip-path: inset(50% 0 0 0);
}

@keyframes glitch-1 {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-2px); }
  40% { transform: translateX(2px); }
  60% { transform: translateX(-1px); }
}

@keyframes glitch-2 {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(2px); }
  40% { transform: translateX(-2px); }
  60% { transform: translateX(1px); }
}

/* Scan line effect */
.scan-lines::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1) 0px,
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  animation: scan-move 8s linear infinite;
}

@keyframes scan-move {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}


/* ==========================================================================
   EPIC TRANSITION - INTERFACE MATERIALIZE
   ========================================================================== */

.configurator-app.is-active .node-library {
  animation: slide-in-left 0.5s var(--ease-out-expo) forwards;
  animation-delay: 0.1s;
}

.configurator-app.is-active .canvas-container {
  animation: fade-scale-in 0.5s var(--ease-out-expo) forwards;
  animation-delay: 0.2s;
}

.configurator-app.is-active .estimation-bar {
  animation: slide-in-bottom 0.5s var(--ease-out-expo) forwards;
  animation-delay: 0.3s;
}

@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

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

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


/* ==========================================================================
   2. LAYOUT
   ========================================================================== */

/* Header - 64px fixed top bar */
.configurator-header {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--surface-border);
  z-index: 100;
}

.configurator-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.configurator-logo span {
  color: var(--accent);
}

.configurator-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.configurator-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out-expo);
}

.configurator-close:hover {
  background: var(--surface-elevated);
  border-color: var(--accent);
  color: var(--accent);
}

.configurator-close svg {
  width: 20px;
  height: 20px;
}

/* Main content area */
.configurator-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Node library sidebar - 240px */
.node-library {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--surface-border);
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 64px - 80px); /* header + footer */
}

.node-library-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--surface-border);
}

.node-library-title {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.node-library-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

/* Canvas container */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0; /* Important for flex children */
  background: var(--surface);
}

/* Estimation bar - 80px fixed bottom */
.estimation-bar {
  height: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--surface-elevated);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -4px 20px rgba(255, 61, 0, 0.1);
  gap: 24px;
}


/* ==========================================================================
   3. NODE LIBRARY
   ========================================================================== */

.node-category {
  margin-bottom: var(--space-xs);
}

.node-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-xs);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.node-category-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.node-category-title {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.node-category-count {
  font-size: 0.5625rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.node-category-toggle {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.node-category.is-collapsed .node-category-toggle {
  transform: rotate(-90deg);
}

.node-category-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: var(--space-xs);
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.3s var(--ease-out-expo);
}

.node-category.is-collapsed .node-category-content {
  max-height: 0;
}

/* Node template - draggable card */
.node-template {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  cursor: grab;
  transition: all 0.2s var(--ease-out-expo);
}

.node-template:hover {
  border-color: var(--text-muted);
  transform: translateX(4px);
}

.node-template:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.node-template-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.node-template-label {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Node type color coding */

/* Outcomes - Orange/Accent */
.node-category--outcomes .node-category-title::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
}

.node-template--outcome .node-template-icon {
  background: rgba(255, 61, 0, 0.15);
  color: var(--accent);
}

.node-template--outcome:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(255, 61, 0, 0.1);
}

/* Systems - Blue */
.node-category--systems .node-category-title::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 2px;
}

.node-template--system .node-template-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.node-template--system:hover {
  border-color: #3b82f6;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

/* Agents - Green */
.node-category--agents .node-category-title::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 2px;
}

.node-template--agent .node-template-icon {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.node-template--agent:hover {
  border-color: #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.1);
}

/* Constraints - Yellow */
.node-category--constraints .node-category-title::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #eab308;
  border-radius: 2px;
}

.node-template--constraint .node-template-icon {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

.node-template--constraint:hover {
  border-color: #eab308;
  box-shadow: 0 0 20px rgba(234, 179, 8, 0.1);
}


/* ==========================================================================
   4. CANVAS
   ========================================================================== */

/* Grid dot background */
.canvas-viewport {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle, var(--surface-border) 1px, transparent 1px);
  background-size: 24px 24px;
  transform-origin: 0 0;
  cursor: grab;
}

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

.canvas-viewport.is-panning {
  cursor: grabbing;
}

/* Connections layer - SVG for bezier curves */
.connections-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.connections-layer svg {
  width: 100%;
  height: 100%;
}

/* Nodes layer - DOM nodes */
.nodes-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 2;
}

/* Empty state */
.canvas-empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  border: 2px dashed var(--surface-border);
  border-radius: 12px;
  text-align: center;
  max-width: 400px;
  transition: opacity 0.3s ease;
}

.canvas-empty-state.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 1.5rem;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.empty-state-desc {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Canvas controls */
.canvas-controls {
  position: absolute;
  bottom: var(--space-md);
  left: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.canvas-control-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.canvas-control-btn:hover {
  background: var(--surface);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.canvas-control-btn svg {
  width: 18px;
  height: 18px;
}

/* Minimap */
.canvas-minimap {
  position: absolute;
  bottom: var(--space-md);
  right: var(--space-md);
  width: 160px;
  height: 100px;
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  overflow: hidden;
  z-index: 10;
}

.minimap-content {
  position: relative;
  width: 100%;
  height: 100%;
}

.minimap-viewport {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(255, 61, 0, 0.1);
  pointer-events: none;
}


/* ==========================================================================
   5. ESTIMATION BAR
   ========================================================================== */

.estimation-metrics {
  display: flex;
  align-items: center;
  gap: 40px;
  flex: 1;
}

.estimation-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.estimation-metric__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.estimation-metric__value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.estimation-metric__value--highlight {
  color: var(--accent);
}

/* Legacy metric classes for compatibility */
.metric-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.metric-value--accent {
  color: var(--accent);
}

.metric-value--success {
  color: #22c55e;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Commit button */
.commit-btn {
  padding: 16px 40px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.commit-btn:hover:not(:disabled) {
  background: #ff5722;
  transform: translateY(-1px);
}

.commit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ==========================================================================
   6. TRANSITION ANIMATIONS
   ========================================================================== */

@keyframes type-line {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes glitch-out {
  0% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
  20% {
    clip-path: inset(20% 0 60% 0);
    transform: translate(-5px, 5px);
  }
  40% {
    clip-path: inset(40% 0 40% 0);
    transform: translate(5px, -5px);
  }
  60% {
    clip-path: inset(60% 0 20% 0);
    transform: translate(-3px, 3px);
  }
  80% {
    clip-path: inset(80% 0 0 0);
    transform: translate(3px, -3px);
  }
  100% {
    clip-path: inset(100% 0 0 0);
    transform: translate(0);
    opacity: 0;
  }
}

@keyframes fade-grid {
  from {
    opacity: 0;
    background-size: 48px 48px;
  }
  to {
    opacity: 1;
    background-size: 24px 24px;
  }
}

@keyframes node-appear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes connection-draw {
  from {
    stroke-dashoffset: 1000;
  }
  to {
    stroke-dashoffset: 0;
  }
}


/* ==========================================================================
   7. NODE STYLES (Placed Graph Nodes)
   ========================================================================== */

.graph-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated);
  border: 2px solid var(--surface-border);
  cursor: move;
  user-select: none;
  transition:
    box-shadow 0.2s var(--ease-out-expo),
    border-color 0.2s ease;
  animation: node-appear 0.3s var(--ease-out-expo);
}

.graph-node:hover {
  border-color: var(--text-muted);
}

/* Node content */
.graph-node-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.graph-node-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-primary);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-node-sublabel {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  color: var(--text-muted);
  text-align: center;
}

/* Connection ports */
.graph-node-port {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border: 2px solid var(--surface-border);
  border-radius: 50%;
  cursor: crosshair;
  transition: all 0.15s ease;
  z-index: 10;
}

.graph-node-port--input {
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
}

.graph-node-port--output {
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
}

.graph-node-port:hover,
.graph-node-port.is-connecting {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-50%) scale(1.3);
  box-shadow: 0 0 15px var(--accent);
}

/* Outcome nodes - Hexagonal, orange */
.graph-node--outcome {
  width: 100px;
  height: 100px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--surface);
  border: none;
  padding: var(--space-sm);
}

.graph-node--outcome::before {
  content: '';
  position: absolute;
  inset: -2px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: linear-gradient(135deg, var(--accent) 0%, rgba(255, 61, 0, 0.3) 100%);
  z-index: -1;
}

.graph-node--outcome:hover {
  box-shadow: 0 0 40px rgba(255, 61, 0, 0.3);
}

.graph-node--outcome .graph-node-icon {
  color: var(--accent);
}

/* System nodes - Rounded rectangle, blue */
.graph-node--system {
  width: 140px;
  min-height: 70px;
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  border-color: rgba(59, 130, 246, 0.3);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, var(--surface-elevated) 100%);
}

.graph-node--system:hover {
  border-color: #3b82f6;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}

.graph-node--system .graph-node-icon {
  color: #3b82f6;
}

/* Agent nodes - Circle, green */
.graph-node--agent {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border-color: rgba(34, 197, 94, 0.3);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, var(--surface-elevated) 100%);
}

.graph-node--agent:hover {
  border-color: #22c55e;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.2);
}

.graph-node--agent .graph-node-icon {
  color: #22c55e;
}

/* Constraint nodes - Diamond, yellow */
.graph-node--constraint {
  width: 70px;
  height: 70px;
  transform: rotate(45deg);
  border-color: rgba(234, 179, 8, 0.3);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.08) 0%, var(--surface-elevated) 100%);
}

.graph-node--constraint > * {
  transform: rotate(-45deg);
}

.graph-node--constraint:hover {
  border-color: #eab308;
  box-shadow: 0 0 30px rgba(234, 179, 8, 0.2);
}

.graph-node--constraint .graph-node-icon {
  color: #eab308;
}

/* Selected state */
.graph-node.is-selected {
  z-index: 100;
}

.graph-node.is-selected::after {
  content: '';
  position: absolute;
  inset: -6px;
  border: 2px solid var(--accent);
  border-radius: inherit;
  pointer-events: none;
  animation: selection-pulse 1.5s ease-in-out infinite;
}

@keyframes selection-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Dragging state */
.graph-node.is-dragging {
  z-index: 1000;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 0 2px var(--accent);
  cursor: grabbing;
}


/* ==========================================================================
   8. CONNECTION STYLES
   ========================================================================== */

.connection-path {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.2s ease;
  pointer-events: stroke;
}

.connection-path:hover {
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(0 0 8px var(--accent-muted));
}

/* Animated flow */
.connection-path--animated {
  stroke-dasharray: 8 4;
  animation: connection-flow 1s linear infinite;
}

@keyframes connection-flow {
  from { stroke-dashoffset: 12; }
  to { stroke-dashoffset: 0; }
}

/* Connection type colors */
.connection-path--data {
  stroke: #3b82f6;
}

.connection-path--data:hover {
  stroke: #60a5fa;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.connection-path--trigger {
  stroke: var(--accent);
}

.connection-path--trigger:hover {
  filter: drop-shadow(0 0 8px var(--accent-muted));
}

.connection-path--success {
  stroke: #22c55e;
}

.connection-path--success:hover {
  stroke: #4ade80;
  filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.5));
}

/* Temporary connection while dragging */
.connection-temp {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  opacity: 0.7;
  pointer-events: none;
}

/* Connection delete button (appears on hover) */
.connection-delete {
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.connection-path:hover + .connection-delete,
.connection-delete:hover {
  opacity: 1;
  border-color: var(--error);
  color: var(--error);
}


/* ==========================================================================
   9. RESPONSIVE
   ========================================================================== */

@media (max-width: 1024px) {
  .node-library {
    width: 200px;
    min-width: 200px;
  }

  .estimation-metrics {
    gap: var(--space-md);
  }

  .metric-value {
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  /* Header adjustments */
  .configurator-header {
    height: 56px;
    padding: 0 var(--space-md);
  }

  .configurator-title {
    display: none;
  }

  /* Node library becomes bottom sheet */
  .configurator-main {
    flex-direction: column;
  }

  .node-library {
    position: fixed;
    bottom: 72px; /* Above estimation bar */
    left: 0;
    right: 0;
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: 50vh;
    border-right: none;
    border-top: 1px solid var(--surface-border);
    transform: translateY(100%);
    transition: transform 0.3s var(--ease-out-expo);
    z-index: 200;
  }

  .node-library.is-open {
    transform: translateY(0);
  }

  .node-library-scroll {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    padding: var(--space-md);
  }

  .node-category {
    margin-bottom: 0;
  }

  .node-category-header {
    display: none;
  }

  .node-category-content {
    max-height: none !important;
    padding-left: 0;
  }

  /* Toggle button for node library */
  .node-library-toggle {
    position: fixed;
    bottom: 88px;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-xs) var(--space-md);
    background: var(--surface-elevated);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    z-index: 150;
    transition: all 0.2s ease;
  }

  .node-library-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  /* Canvas fills remaining space */
  .canvas-container {
    flex: 1;
  }

  /* Estimation bar */
  .estimation-bar {
    padding: 0 var(--space-md);
    gap: var(--space-sm);
  }

  .estimation-metrics {
    flex: 1;
    gap: var(--space-sm);
  }

  .estimation-metric {
    flex: 1;
  }

  .metric-value {
    font-size: 1.25rem;
  }

  .metric-label {
    font-size: 0.5625rem;
  }

  .commit-btn {
    height: 44px;
    padding: 0 var(--space-lg);
    font-size: 0.75rem;
  }

  /* Larger touch targets for nodes */
  .graph-node-port {
    width: 20px;
    height: 20px;
  }

  .graph-node-port--input {
    left: -10px;
  }

  .graph-node-port--output {
    right: -10px;
  }

  /* Canvas controls */
  .canvas-controls {
    bottom: var(--space-sm);
    left: var(--space-sm);
  }

  .canvas-control-btn {
    width: 44px;
    height: 44px;
  }

  /* Hide minimap on mobile */
  .canvas-minimap {
    display: none;
  }
}

@media (max-width: 480px) {
  .estimation-metrics {
    flex-wrap: wrap;
  }

  .estimation-metric {
    min-width: 60px;
  }

  .metric-value {
    font-size: 1.125rem;
  }

  .commit-btn {
    width: 100%;
    margin-top: var(--space-xs);
  }

  .estimation-bar {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-sm) var(--space-md);
  }
}


/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.configurator-hidden {
  display: none !important;
}

.configurator-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ==========================================================================
   DRAG & DROP STATES
   ========================================================================== */

/* Dragging from sidebar */
.node-template.is-dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

/* Ghost/clone while dragging */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 10010;
  opacity: 0.9;
  transform: translate(-50%, -50%) scale(1.05);
  transition: transform 0.1s ease;
}

/* Drop zone active state */
.nodes-layer.drag-over {
  background: rgba(255, 61, 0, 0.05);
}

.nodes-layer.drag-over::after {
  content: '';
  position: absolute;
  inset: 20px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  opacity: 0.5;
  animation: pulse-border 1s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* Invalid drop indicator */
.nodes-layer.drag-invalid {
  background: rgba(255, 51, 51, 0.05);
}


/* ==========================================================================
   PLACED NODES (on canvas) - Enhanced
   ========================================================================== */

.graph-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 14px 18px;
  min-width: 100px;
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  cursor: grab;
  user-select: none;
  transition: all 0.2s ease;
  z-index: 1;
}

.graph-node:hover {
  border-color: var(--text-muted);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.graph-node:active,
.graph-node.is-dragging {
  cursor: grabbing;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.graph-node.is-selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent),
    0 8px 24px rgba(255, 61, 0, 0.2);
  z-index: 10;
}

/* Node type label - positioned above node */
.graph-node__type {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* Node icon */
.graph-node__icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: 8px;
  background: var(--surface);
}

/* Node label */
.graph-node__label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  text-align: center;
  max-width: 100px;
  word-wrap: break-word;
}

/* Connection ports */
.graph-node__port {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  opacity: 0;
  transition: all 0.15s ease;
  z-index: 5;
}

.graph-node:hover .graph-node__port,
.graph-node.is-selected .graph-node__port {
  opacity: 1;
}

.graph-node__port:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.3);
  box-shadow: 0 0 12px var(--accent);
}

.graph-node__port--top { top: -6px; left: 50%; transform: translateX(-50%); }
.graph-node__port--right { right: -6px; top: 50%; transform: translateY(-50%); }
.graph-node__port--bottom { bottom: -6px; left: 50%; transform: translateX(-50%); }
.graph-node__port--left { left: -6px; top: 50%; transform: translateY(-50%); }

.graph-node__port--top:hover { transform: translateX(-50%) scale(1.3); }
.graph-node__port--right:hover { transform: translateY(-50%) scale(1.3); }
.graph-node__port--bottom:hover { transform: translateX(-50%) scale(1.3); }
.graph-node__port--left:hover { transform: translateY(-50%) scale(1.3); }


/* ==========================================================================
   NODE TYPE VARIANTS
   ========================================================================== */

/* Outcome - Orange/Primary */
.graph-node--outcome {
  border-color: rgba(255, 61, 0, 0.3);
}

.graph-node--outcome .graph-node__icon {
  background: rgba(255, 61, 0, 0.15);
  color: var(--accent);
}

.graph-node--outcome.is-selected {
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 30px rgba(255, 61, 0, 0.3);
}

/* System - Blue */
.graph-node--system {
  border-color: rgba(59, 130, 246, 0.3);
}

.graph-node--system .graph-node__icon {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.graph-node--system.is-selected {
  border-color: #3b82f6;
  box-shadow:
    0 0 0 2px #3b82f6,
    0 0 30px rgba(59, 130, 246, 0.3);
}

/* Agent - Green */
.graph-node--agent {
  border-color: rgba(0, 255, 136, 0.3);
}

.graph-node--agent .graph-node__icon {
  background: rgba(0, 255, 136, 0.15);
  color: #00ff88;
}

.graph-node--agent.is-selected {
  border-color: #00ff88;
  box-shadow:
    0 0 0 2px #00ff88,
    0 0 30px rgba(0, 255, 136, 0.3);
}

/* Constraint - Yellow */
.graph-node--constraint {
  border-color: rgba(255, 170, 0, 0.3);
}

.graph-node--constraint .graph-node__icon {
  background: rgba(255, 170, 0, 0.15);
  color: #ffaa00;
}

.graph-node--constraint.is-selected {
  border-color: #ffaa00;
  box-shadow:
    0 0 0 2px #ffaa00,
    0 0 30px rgba(255, 170, 0, 0.3);
}


/* ==========================================================================
   NODE SPAWN ANIMATION
   ========================================================================== */

@keyframes node-spawn {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.graph-node.is-new {
  animation: node-spawn 0.3s var(--ease-out-back) forwards;
}


/* ==========================================================================
   EMPTY STATE UPDATE
   ========================================================================== */

.canvas-empty-state {
  transition: opacity 0.3s ease;
}

.nodes-layer:not(:empty) .canvas-empty-state {
  opacity: 0;
  pointer-events: none;
}

/* When nodes exist, hide empty state */
.nodes-layer.has-nodes .canvas-empty-state {
  display: none;
}


/* ==========================================================================
   RIGHT PANEL - TEMPLATES & IMPACT
   ========================================================================== */

.impact-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 16px;
  max-height: calc(100vh - 64px - 56px);
}

.templates-section {
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin: 0 0 4px 0;
}

.panel-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0 0 16px 0;
}

.panel-divider {
  height: 1px;
  background: var(--surface-border);
  margin: 8px 0;
}


/* ==========================================================================
   TEMPLATE CARDS
   ========================================================================== */

.template-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: #00ff88;
  background: rgba(0, 255, 136, 0.05);
  transform: translateX(4px);
}

.template-card:active {
  transform: translateX(2px) scale(0.99);
}

.template-icon {
  font-size: 1rem;
  color: #00ff88;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
  font-family: var(--font-mono);
}

.template-name {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.template-desc {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.3;
}


/* ==========================================================================
   IMPACT SUMMARY
   ========================================================================== */

.impact-section {
  flex: 1;
}

.impact-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.impact-empty-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

.impact-empty p {
  font-size: 0.8125rem;
  margin: 0;
}

.impact-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.impact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.impact-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.impact-value {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.impact-divider {
  height: 1px;
  background: var(--surface-border);
  margin: 8px 0;
}

.impact-row--highlight {
  flex-wrap: wrap;
}

.impact-row--highlight .impact-label {
  width: 100%;
  margin-bottom: 8px;
}

/* Completeness bar */
.completeness-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-border);
  border-radius: 4px;
  overflow: hidden;
}

.completeness-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff6b35);
  border-radius: 4px;
  transition: width 0.4s var(--ease-out-expo);
}

/* Warnings */
.impact-warnings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.impact-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 170, 0, 0.1);
  border: 1px solid rgba(255, 170, 0, 0.3);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--warning);
}

.impact-warning--error {
  background: rgba(255, 51, 51, 0.1);
  border-color: rgba(255, 51, 51, 0.3);
  color: var(--error);
}

.impact-warning--success {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.3);
  color: var(--success);
}

.impact-warning-icon {
  flex-shrink: 0;
}


/* ==========================================================================
   RESPONSIVE - MOBILE
   ========================================================================== */

@media (max-width: 1024px) {
  .impact-panel {
    display: none; /* Hide on tablet, show in bottom sheet */
  }
}

/* Update main layout for 3-column */
.configurator-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}


/* ==========================================================================
   NEON CONNECTIONS
   ========================================================================== */

.connections-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* Connection line base */
.connection-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px currentColor);
  transition: stroke 0.3s ease;
}

/* Animated dash flow */
.connection-line--animated {
  stroke-dasharray: 8 6;
  animation: connection-flow 1s linear infinite;
}

@keyframes connection-flow {
  from { stroke-dashoffset: 14; }
  to { stroke-dashoffset: 0; }
}

/* Connection states by completeness */
.connection-line--error {
  stroke: #ff3333;
  filter: drop-shadow(0 0 6px #ff3333);
}

.connection-line--warning {
  stroke: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent));
}

.connection-line--success {
  stroke: #00ff88;
  filter: drop-shadow(0 0 6px #00ff88);
}

/* Connection glow pulse */
.connection-line--pulse {
  animation: connection-flow 1s linear infinite, connection-glow 2s ease-in-out infinite;
}

@keyframes connection-glow {
  0%, 100% { filter: drop-shadow(0 0 4px currentColor); }
  50% { filter: drop-shadow(0 0 12px currentColor) drop-shadow(0 0 20px currentColor); }
}

/* Node connection indicators */
.graph-node.is-connected::before {
  content: '';
  position: absolute;
  inset: -3px;
  border: 1px solid currentColor;
  border-radius: 14px;
  opacity: 0.3;
}

.graph-node.is-connected--success { color: #00ff88; }
.graph-node.is-connected--warning { color: var(--accent); }
.graph-node.is-connected--error { color: #ff3333; }
