/* ===================================================================
   Quilt Live Simulator
   Side-by-side code + runtime + dependency graph
   =================================================================== */

.sim-main {
  padding: 40px 0 80px;
  position: relative;
}

.sim-header {
  text-align: center;
  margin-bottom: 32px;
}

.sim-header h1 {
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
  background: var(--grad-1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sim-header p {
  font-size: 16px;
  color: var(--fg-2);
  max-width: 600px;
  margin: 0 auto;
}

/* Preset selector */
.sim-presets {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.sim-presets-label {
  font-size: 13px;
  color: var(--fg-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.preset-btn {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--fg-2);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s ease;
}
.preset-btn:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.preset-btn.active {
  background: var(--grad-1);
  color: white;
  border-color: transparent;
}

/* Main sim grid: code on left, runtime on right */
.sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .sim-grid { grid-template-columns: 1fr; }
}

/* Sim panes (shared style) */
.sim-pane {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-family: var(--font-mono);
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-2);
  font-weight: 500;
}

.pane-icon {
  color: var(--accent);
  font-size: 14px;
}

.pane-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--fg-3);
}

.btn-mini {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.15s ease;
}
.btn-mini:hover {
  background: var(--accent-2);
}

.pane-body {
  flex: 1;
  overflow: auto;
}

/* Code pane */
.sim-pane-code textarea {
  width: 100%;
  height: 100%;
  min-height: 480px;
  background: transparent;
  color: var(--fg);
  border: none;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

/* Runtime pane */
.runtime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border);
}

.runtime-cell {
  background: var(--bg-2);
  padding: 12px 14px;
  font-size: 12px;
  position: relative;
  transition: all 0.2s ease;
}

.runtime-cell-id {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg-2);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.runtime-cell-kind {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.kind-value   { background: rgba(124, 92, 255, 0.15); color: var(--accent); }
.kind-formula { background: rgba(0, 212, 170, 0.15); color: var(--accent-2); }
.kind-api     { background: rgba(255, 122, 89, 0.15); color: var(--accent-warm); }
.kind-program { background: rgba(255, 199, 0, 0.15); color: #ffc700; }
.kind-sensor  { background: rgba(255, 255, 255, 0.08); color: var(--fg-3); }
.kind-router  { background: rgba(255, 122, 89, 0.1); color: var(--accent-warm); }
.kind-listener { background: rgba(0, 212, 170, 0.1); color: var(--accent-2); }
.kind-io      { background: rgba(255, 255, 255, 0.08); color: var(--fg-3); }

.runtime-cell-value {
  font-family: var(--font-mono);
  color: var(--fg);
  word-break: break-all;
  line-height: 1.4;
  max-height: 80px;
  overflow: auto;
}

.runtime-cell-status {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-ready { background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); }
.status-stale { background: #ffc700; }
.status-error { background: var(--accent-warm); }
.status-computing { background: var(--accent); animation: pulse 1s infinite; }
.status-idle { background: var(--fg-3); }

.runtime-cell.flash {
  animation: cellFlash 0.6s ease;
}

@keyframes cellFlash {
  0% { background: rgba(124, 92, 255, 0.2); }
  100% { background: var(--bg-2); }
}

/* Bottom: graph + actions */
.sim-bottom {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .sim-bottom { grid-template-columns: 1fr; }
}

.sim-pane-graph {
  min-height: 400px;
}

.sim-pane-graph svg {
  width: 100%;
  height: 100%;
  min-height: 380px;
}

.pane-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--fg-3);
}

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

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-value { background: var(--accent); }
.dot-formula { background: var(--accent-2); }
.dot-api { background: var(--accent-warm); }
.dot-program { background: #ffc700; }
.dot-sensor { background: var(--fg-3); }
.dot-router { background: var(--accent-warm); }

/* Graph node + edge styles */
.graph-node {
  cursor: pointer;
  transition: all 0.2s ease;
}
.graph-node:hover { filter: brightness(1.3); }

.graph-node-circle {
  fill: var(--bg-2);
  stroke-width: 2;
  transition: all 0.2s ease;
}

.graph-node-label {
  fill: var(--fg);
  font-family: var(--font-mono);
  font-size: 10px;
  text-anchor: middle;
  pointer-events: none;
}

.graph-node-sublabel {
  fill: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 8px;
  text-anchor: middle;
  pointer-events: none;
}

.graph-edge {
  fill: none;
  stroke: var(--fg-3);
  stroke-width: 1;
  opacity: 0.4;
  transition: all 0.2s ease;
}

.graph-edge.active {
  stroke: var(--accent-2);
  stroke-width: 2;
  opacity: 1;
}

/* Actions pane */
.actions-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.action-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
}

.action-item-desc {
  font-size: 11px;
  color: var(--fg-3);
  font-family: var(--font-mono);
}

.action-item input,
.action-item select {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg);
  width: 100%;
}

.action-item button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}

.empty-state {
  color: var(--fg-3);
  font-size: 12px;
  text-align: center;
  padding: 32px 16px;
  font-style: italic;
}
