/* ═══════════════════════════════════════════════════════════════
   Speaksy Agent Flow Studio — visual call-flow builder
   Dograh-inspired topology · Speaksy green brand · production UI
   ═══════════════════════════════════════════════════════════════ */

.sfs-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
  min-height: min(72vh, 820px);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(52, 211, 153, 0.14);
  background: #0b0f0e;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

@media (max-width: 980px) {
  .sfs-shell { grid-template-columns: 1fr; min-height: auto; }
  .sfs-rail { border-left: 0; border-top: 1px solid rgba(255,255,255,.08); }
}

.sfs-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 560px;
}

.sfs-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(16, 32, 26, 0.95), rgba(11, 15, 14, 0.98));
}

.sfs-toolbar .sfs-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .02em;
  color: #e8f5ef;
  margin-right: 6px;
}

.sfs-toolbar .sfs-sub {
  color: #7a9588;
  font-size: 12px;
  margin-right: auto;
}

.sfs-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.sfs-badge.draft {
  background: rgba(210, 153, 34, 0.12);
  color: #e3b341;
  border-color: rgba(210, 153, 34, 0.28);
}

.sfs-toolbar .btn { margin: 0; }

.sfs-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 480px;
  background-color: #0b0f0e;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(52, 211, 153, 0.09) 1px, transparent 0);
  background-size: 22px 22px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}

.sfs-canvas-wrap.is-panning { cursor: grabbing; }
.sfs-canvas-wrap.is-connecting { cursor: crosshair; }

.sfs-world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.sfs-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.sfs-edges path.sfs-edge {
  fill: none;
  stroke: rgba(52, 211, 153, 0.55);
  stroke-width: 2;
  stroke-dasharray: 6 5;
  pointer-events: stroke;
}

.sfs-edges path.sfs-edge:hover,
.sfs-edges path.sfs-edge.selected {
  stroke: #34d399;
  stroke-width: 2.5;
  stroke-dasharray: none;
}

.sfs-edges path.sfs-edge-temp {
  fill: none;
  stroke: rgba(94, 234, 180, 0.7);
  stroke-width: 2;
  stroke-dasharray: 4 4;
}

.sfs-edge-label {
  fill: #0b0f0e;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}

.sfs-edge-label-bg {
  fill: #34d399;
  rx: 4;
}

.sfs-node {
  position: absolute;
  width: 260px;
  border-radius: 12px;
  background: linear-gradient(165deg, #141c19 0%, #101614 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  cursor: grab;
  transition: box-shadow .15s, border-color .15s, transform .12s;
  z-index: 2;
}

.sfs-node:hover {
  border-color: rgba(52, 211, 153, 0.35);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}

.sfs-node.selected {
  border-color: #34d399;
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.45), 0 16px 40px rgba(0, 0, 0, 0.55);
}

.sfs-node.is-dragging { cursor: grabbing; z-index: 5; }

.sfs-node-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}

.sfs-node-type {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
}

.sfs-node[data-type="start"] .sfs-node-type {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
}
.sfs-node[data-type="global"] .sfs-node-type {
  background: rgba(96, 165, 250, 0.16);
  color: #60a5fa;
}
.sfs-node[data-type="agent"] .sfs-node-type {
  background: rgba(167, 139, 250, 0.16);
  color: #a78bfa;
}
.sfs-node[data-type="end"] .sfs-node-type {
  background: rgba(248, 113, 113, 0.16);
  color: #f87171;
}

.sfs-node-title {
  flex: 1;
  font-size: 13px;
  font-weight: 650;
  color: #eef7f2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sfs-node-body {
  padding: 10px 12px 14px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #8fa89b;
  max-height: 88px;
  overflow: hidden;
}

.sfs-node-body strong {
  display: block;
  color: #b7cfc3;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 700;
}

.sfs-port {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0b0f0e;
  border: 2px solid #34d399;
  z-index: 3;
  cursor: crosshair;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
}

.sfs-port.in { left: -7px; top: 50%; transform: translateY(-50%); }
.sfs-port.out { right: -7px; top: 50%; transform: translateY(-50%); }

.sfs-port:hover {
  background: #34d399;
  transform: translateY(-50%) scale(1.15);
}

.sfs-fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 6;
}

.sfs-fab button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: linear-gradient(145deg, #1a3328, #12241c);
  color: #34d399;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}

.sfs-fab button:hover { filter: brightness(1.1); }

.sfs-zoom {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  gap: 6px;
  z-index: 6;
}

.sfs-zoom button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(16, 24, 21, 0.92);
  color: #c5d9ce;
  cursor: pointer;
  font-size: 14px;
}

/* Right rail — test & inspector */
.sfs-rail {
  display: flex;
  flex-direction: column;
  background: #0e1412;
  border-left: 1px solid rgba(255,255,255,.06);
  min-height: 560px;
}

.sfs-rail-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sfs-rail-tabs button {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #7a9588;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  font-family: inherit;
}

.sfs-rail-tabs button.on {
  color: #34d399;
  border-bottom-color: #34d399;
}

.sfs-rail-body {
  flex: 1;
  padding: 16px;
  overflow: auto;
}

.sfs-rail-body h4 {
  font-size: 14px;
  font-weight: 700;
  color: #e8f5ef;
  margin: 0 0 6px;
}

.sfs-rail-body .muted {
  color: #7a9588;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.sfs-field {
  display: block;
  margin-bottom: 12px;
}

.sfs-field > span {
  display: block;
  font-size: 11px;
  font-weight: 650;
  color: #7a9588;
  margin-bottom: 5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sfs-field input,
.sfs-field select,
.sfs-field textarea {
  width: 100%;
  background: #0a100e;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: #e8f5ef;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.sfs-field input:focus,
.sfs-field textarea:focus {
  border-color: rgba(52, 211, 153, 0.5);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
}

.sfs-field textarea { min-height: 120px; resize: vertical; line-height: 1.45; }

.sfs-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.sfs-chat-log {
  flex: 1;
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
  background: #0a100e;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
  padding: 10px;
}

.sfs-chat-bubble {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 92%;
}

.sfs-chat-bubble.user {
  background: rgba(52, 211, 153, 0.14);
  color: #d1fae5;
  margin-left: auto;
}

.sfs-chat-bubble.agent {
  background: rgba(255,255,255,.05);
  color: #d5e5dc;
}

.sfs-chat-input-row {
  display: flex;
  gap: 8px;
}

.sfs-chat-input-row input { flex: 1; }

.sfs-empty-inspector {
  text-align: center;
  padding: 40px 16px;
  color: #7a9588;
}

.sfs-empty-inspector .ico {
  font-size: 28px;
  margin-bottom: 10px;
  opacity: .7;
}

.sfs-run-btn {
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: #04241a;
  background: linear-gradient(145deg, #34d399, #10b981 45%, #059669);
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.28);
}

.sfs-run-btn:hover { filter: brightness(1.05); }
.sfs-run-btn:disabled { opacity: .45; cursor: default; }

.sfs-danger {
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  margin-top: 8px;
}

html[data-theme="light"] .sfs-shell {
  background: #f4f7f5;
  border-color: rgba(4, 120, 87, 0.15);
}
html[data-theme="light"] .sfs-canvas-wrap {
  background-color: #eef3f0;
  background-image: radial-gradient(circle at 1px 1px, rgba(4, 120, 87, 0.1) 1px, transparent 0);
}
html[data-theme="light"] .sfs-node {
  background: #fff;
  border-color: rgba(18, 28, 24, 0.1);
}
html[data-theme="light"] .sfs-node-title { color: #17211d; }
html[data-theme="light"] .sfs-node-body { color: #5d6b66; }
html[data-theme="light"] .sfs-rail { background: #fafcfb; }
html[data-theme="light"] .sfs-field input,
html[data-theme="light"] .sfs-field textarea {
  background: #fff;
  color: #17211d;
  border-color: rgba(18,28,24,.12);
}
