/* ═══════════════════════════════════════════
   WORKFLOW EDITOR — Production Styles
   ═══════════════════════════════════════════ */
:root {
  --wf-bg: #09090b;
  --wf-surface: #111318;
  --wf-surface2: #16181f;
  --wf-surface3: #1c1e27;
  --wf-border: rgba(255,255,255,.06);
  --wf-border-h: rgba(255,255,255,.12);
  --wf-text: #f0f0f5;
  --wf-muted: #7c819a;
  --wf-dim: #4e5266;
  --wf-en: 'Inter', sans-serif;
  --wf-font: 'Noto Sans KR', 'Inter', sans-serif;
  --wf-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--wf-font);
  background: var(--wf-bg);
  color: var(--wf-text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App Layout ── */
.wf-app {
  display: flex;
  height: calc(100vh - 56px);
  margin-top: 56px;
  transition: height .4s ease, margin-top .4s ease;
}
.navbar-collapsed .wf-app {
  height: 100vh;
  margin-top: 0;
}

/* ════════════════════════════════
   LEFT SIDEBAR
   ════════════════════════════════ */
.wf-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--wf-surface);
  border-right: 1px solid var(--wf-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 20;
}

.wf-sidebar::-webkit-scrollbar { width: 4px; }
.wf-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

.wf-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--wf-border);
  flex-shrink: 0;
}

.wf-logo {
  font-family: var(--wf-en);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wf-logo i { color: #64ffda; }

.wf-badge {
  font-family: var(--wf-en);
  font-size: .55rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(100,255,218,.1);
  color: #64ffda;
  letter-spacing: 1px;
}

.wf-sidebar-section {
  padding: 16px 16px 8px;
}

.wf-section-label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--wf-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
  padding: 0 4px;
}

.wf-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--wf-muted);
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s var(--wf-ease);
  text-align: left;
  font-family: var(--wf-font);
  text-decoration: none;
}
.wf-nav-item:hover {
  background: rgba(255,255,255,.04);
  color: var(--wf-text);
}
.wf-nav-item.active {
  background: rgba(100,255,218,.06);
  color: #64ffda;
}
.wf-nav-item i {
  width: 16px;
  text-align: center;
  font-size: .82rem;
}

/* ── Node Palette ── */
.wf-node-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.wf-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--wf-border);
  cursor: grab;
  transition: all .2s var(--wf-ease);
  font-size: .75rem;
  color: var(--wf-muted);
  user-select: none;
}
.wf-palette-item:hover {
  background: rgba(255,255,255,.05);
  border-color: var(--wf-border-h);
  color: var(--wf-text);
  transform: translateY(-1px);
}
.wf-palette-item:active {
  cursor: grabbing;
  transform: scale(0.96);
}

.wf-palette-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  flex-shrink: 0;
}
.wf-palette-icon.trigger  { background: rgba(251,191,36,.1);  color: #fbbf24; }
.wf-palette-icon.condition { background: rgba(96,165,250,.1);  color: #60a5fa; }
.wf-palette-icon.action   { background: rgba(74,222,128,.1);  color: #4ade80; }
.wf-palette-icon.delay    { background: rgba(168,85,247,.1);  color: #a855f7; }
.wf-palette-icon.email    { background: rgba(251,113,133,.1); color: #fb7185; }
.wf-palette-icon.slack    { background: rgba(74,222,128,.1);  color: #4ade80; }
.wf-palette-icon.webhook  { background: rgba(96,165,250,.1);  color: #60a5fa; }
.wf-palette-icon.database { background: rgba(245,158,11,.1);  color: #f59e0b; }

/* ── Saved Workflows ── */
.wf-saved-section { flex: 1; min-height: 0; }

.wf-saved-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wf-saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: .82rem;
  color: var(--wf-muted);
  cursor: pointer;
  transition: all .2s var(--wf-ease);
}
.wf-saved-item:hover {
  background: rgba(255,255,255,.03);
  color: var(--wf-text);
}
.wf-saved-item.active {
  background: rgba(100,255,218,.06);
  color: var(--wf-text);
  font-weight: 600;
}

.wf-saved-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.wf-saved-item-main span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wf-saved-count {
  font-size: .65rem;
  color: var(--wf-dim);
  flex-shrink: 0;
  margin-left: auto;
}

.wf-saved-delete {
  background: none;
  border: none;
  color: var(--wf-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: .7rem;
  opacity: 0;
  transition: all .15s;
}
.wf-saved-item:hover .wf-saved-delete { opacity: 1; }
.wf-saved-delete:hover { color: #fb7185; background: rgba(251,113,133,.1); }

.wf-empty-saved {
  font-size: .78rem;
  color: var(--wf-dim);
  padding: 12px 8px;
  text-align: center;
}

.wf-sidebar-bottom {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--wf-border);
  flex-shrink: 0;
}

/* ════════════════════════════════
   MAIN AREA
   ════════════════════════════════ */
.wf-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Toolbar ── */
.wf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--wf-surface);
  border-bottom: 1px solid var(--wf-border);
  flex-shrink: 0;
  z-index: 15;
}

.wf-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wf-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wf-tb-sep {
  width: 1px;
  height: 20px;
  background: var(--wf-border);
  margin: 0 4px;
}

.wf-flow-name {
  background: transparent;
  border: 1px solid transparent;
  color: var(--wf-text);
  font-size: .95rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--wf-font);
  transition: all .2s var(--wf-ease);
  width: 200px;
}
.wf-flow-name:hover { border-color: rgba(255,255,255,.06); }
.wf-flow-name:focus { outline: none; border-color: rgba(100,255,218,.3); background: rgba(100,255,218,.03); }

.wf-status {
  font-size: .7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--wf-dim);
}
.wf-status.active { color: #4ade80; }
.wf-status i { font-size: .4rem; }

.wf-tb-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--wf-border);
  background: transparent;
  color: var(--wf-muted);
  font-size: .78rem;
  cursor: pointer;
  transition: all .2s var(--wf-ease);
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--wf-en);
  white-space: nowrap;
}
.wf-tb-btn:hover {
  background: rgba(255,255,255,.04);
  color: var(--wf-text);
  border-color: var(--wf-border-h);
}
.wf-tb-btn:active { transform: scale(0.96); }
.wf-tb-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.wf-tb-btn.primary {
  background: rgba(74,222,128,.1);
  color: #4ade80;
  border-color: rgba(74,222,128,.15);
}
.wf-tb-btn.primary:hover { background: rgba(74,222,128,.18); }

.wf-tb-btn.save {
  background: rgba(96,165,250,.1);
  color: #60a5fa;
  border-color: rgba(96,165,250,.15);
}
.wf-tb-btn.save:hover { background: rgba(96,165,250,.18); }

/* ── Canvas Wrap ── */
.wf-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--wf-bg);
  cursor: default;
}
.wf-canvas-wrap.panning,
.wf-canvas-wrap.pan-ready { cursor: grab; }
.wf-canvas-wrap.panning { cursor: grabbing; }

.wf-canvas {
  position: absolute;
  width: 4000px;
  height: 3000px;
  transform-origin: 0 0;
  will-change: transform;
}

.wf-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

/* Zoom indicator */
.wf-zoom-indicator {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: var(--wf-surface2);
  border: 1px solid var(--wf-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: var(--wf-en);
  font-size: .72rem;
  font-weight: 600;
  color: var(--wf-dim);
  pointer-events: none;
  z-index: 10;
}

/* Minimap (placeholder) */
.wf-minimap {
  display: none; /* future use */
}

/* ════════════════════════════════
   NODES
   ════════════════════════════════ */
.wf-node {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--wf-surface2);
  border: 1px solid var(--wf-border);
  border-radius: 12px;
  cursor: move;
  transition: box-shadow .25s var(--wf-ease), border-color .25s var(--wf-ease), transform .15s var(--wf-ease);
  min-width: 180px;
  z-index: 2;
  user-select: none;
}

.wf-node:hover {
  border-color: var(--wf-border-h);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.wf-node.selected {
  z-index: 5 !important;
  box-shadow: 0 0 0 2px rgba(100,255,218,.3), 0 12px 32px rgba(0,0,0,.5);
  border-color: rgba(100,255,218,.2);
}

/* Type border accents */
.wf-node.trigger   { border-left: 3px solid #fbbf24; }
.wf-node.condition  { border-left: 3px solid #60a5fa; }
.wf-node.action     { border-left: 3px solid #4ade80; }
.wf-node.delay      { border-left: 3px solid #a855f7; }
.wf-node.email      { border-left: 3px solid #fb7185; }
.wf-node.slack      { border-left: 3px solid #4ade80; }
.wf-node.webhook    { border-left: 3px solid #60a5fa; }
.wf-node.database   { border-left: 3px solid #f59e0b; }

/* Simulation glow */
.wf-node.simulating {
  animation: nodeGlow .8s ease-in-out;
}
@keyframes nodeGlow {
  0%   { box-shadow: 0 0 0 0 rgba(100,255,218,0); }
  30%  { box-shadow: 0 0 20px 4px rgba(100,255,218,.25), 0 0 40px 8px rgba(100,255,218,.1); }
  100% { box-shadow: 0 0 0 0 rgba(100,255,218,0); }
}

/* Node icon */
.wf-node-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}
.wf-node-icon.trigger  { background: rgba(251,191,36,.1);  color: #fbbf24; }
.wf-node-icon.condition { background: rgba(96,165,250,.1);  color: #60a5fa; }
.wf-node-icon.action   { background: rgba(74,222,128,.1);  color: #4ade80; }
.wf-node-icon.delay    { background: rgba(168,85,247,.1);  color: #a855f7; }
.wf-node-icon.email    { background: rgba(251,113,133,.1); color: #fb7185; }
.wf-node-icon.slack    { background: rgba(74,222,128,.1);  color: #4ade80; }
.wf-node-icon.webhook  { background: rgba(96,165,250,.1);  color: #60a5fa; }
.wf-node-icon.database { background: rgba(245,158,11,.1);  color: #f59e0b; }

.wf-node-body { min-width: 0; flex: 1; }
.wf-node-title {
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wf-node-sub {
  font-size: .72rem;
  color: var(--wf-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status dot */
.wf-node-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wf-dim);
  flex-shrink: 0;
  transition: all .3s var(--wf-ease);
}
.wf-node-status.on {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74,222,128,.5);
}

/* ── Ports ── */
.wf-port {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--wf-dim);
  border: 2px solid var(--wf-surface2);
  cursor: crosshair;
  transition: all .2s var(--wf-ease);
  z-index: 4;
}
.wf-port:hover {
  background: #64ffda;
  transform: translateX(-50%) scale(1.4);
  box-shadow: 0 0 8px rgba(100,255,218,.4);
}
.wf-port.in {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
}
.wf-port.out {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
}

/* ════════════════════════════════
   SVG CONNECTIONS
   ════════════════════════════════ */
.wf-connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.wf-conn {
  fill: none;
  stroke: rgba(255,255,255,.12);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  animation: connDash 1.5s linear infinite;
  transition: stroke .2s, stroke-width .2s;
  pointer-events: none;
}
.wf-conn.conn-active {
  stroke: #64ffda;
  stroke-width: 2.5;
  filter: url(#connGlow);
  stroke-dasharray: 8 4;
  animation: connDash 0.6s linear infinite;
}

.wf-conn-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
  cursor: pointer;
}
.wf-conn.conn-hover {
  stroke: rgba(251,113,133,.6);
  stroke-width: 3;
}

.wf-conn-temp {
  fill: none;
  stroke: rgba(100,255,218,.4);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  animation: connDash 0.8s linear infinite;
  pointer-events: none;
}

@keyframes connDash {
  to { stroke-dashoffset: -20; }
}

/* ════════════════════════════════
   RIGHT SETTINGS PANEL
   ════════════════════════════════ */
.wf-settings {
  width: 300px;
  flex-shrink: 0;
  background: rgba(17,19,24,.92);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-left: 1px solid var(--wf-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  margin-right: -300px;
  transition: transform .35s var(--wf-ease), margin-right .35s var(--wf-ease);
  z-index: 18;
  overflow: hidden;
}
.wf-settings.open {
  transform: translateX(0);
  margin-right: 0;
}

.wf-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--wf-border);
  flex-shrink: 0;
}

.wf-settings-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  font-weight: 700;
}

.wf-settings-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
}

.wf-settings-close {
  background: none;
  border: none;
  color: var(--wf-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: .9rem;
  transition: all .15s;
}
.wf-settings-close:hover {
  color: var(--wf-text);
  background: rgba(255,255,255,.05);
}

.wf-settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.wf-settings-body::-webkit-scrollbar { width: 4px; }
.wf-settings-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.06); border-radius: 2px; }

.wf-settings-divider {
  height: 1px;
  background: var(--wf-border);
  margin: 16px 0;
}

.wf-field {
  margin-bottom: 14px;
}
.wf-field label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--wf-muted);
  margin-bottom: 6px;
  letter-spacing: .3px;
}

.wf-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--wf-border);
  background: rgba(255,255,255,.03);
  color: var(--wf-text);
  font-size: .82rem;
  font-family: var(--wf-font);
  transition: all .2s var(--wf-ease);
  outline: none;
}
.wf-input:hover { border-color: var(--wf-border-h); }
.wf-input:focus {
  border-color: rgba(100,255,218,.3);
  background: rgba(100,255,218,.03);
  box-shadow: 0 0 0 3px rgba(100,255,218,.06);
}

select.wf-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%237c819a' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 30px;
}
select.wf-input option {
  background: var(--wf-surface2);
  color: var(--wf-text);
}

textarea.wf-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.wf-muted-text {
  font-size: .8rem;
  color: var(--wf-dim);
  padding: 8px 0;
}

.wf-settings-footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--wf-border);
  flex-shrink: 0;
}

.wf-btn-save {
  flex: 1;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: rgba(74,222,128,.12);
  color: #4ade80;
  font-size: .82rem;
  font-weight: 600;
  font-family: var(--wf-font);
  cursor: pointer;
  transition: all .2s var(--wf-ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.wf-btn-save:hover { background: rgba(74,222,128,.2); }
.wf-btn-save:active { transform: scale(0.97); }

.wf-btn-delete {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: rgba(251,113,133,.08);
  color: #fb7185;
  font-size: .82rem;
  font-weight: 600;
  font-family: var(--wf-font);
  cursor: pointer;
  transition: all .2s var(--wf-ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.wf-btn-delete:hover { background: rgba(251,113,133,.15); }
.wf-btn-delete:active { transform: scale(0.97); }

/* ════════════════════════════════
   TOAST NOTIFICATION
   ════════════════════════════════ */
.wf-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--wf-surface2);
  border: 1px solid var(--wf-border-h);
  border-radius: 10px;
  padding: 10px 24px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--wf-text);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: all .35s var(--wf-ease);
  z-index: 999;
  backdrop-filter: blur(12px);
}
.wf-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ════════════════════════════════
   RESPONSIVE
   ════════════════════════════════ */
@media (max-width: 900px) {
  .wf-sidebar { width: 220px; }
  .wf-settings { width: 260px; margin-right: -260px; }
  .wf-node-palette { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .wf-sidebar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .3s var(--wf-ease);
  }
  .wf-sidebar.open { transform: translateX(0); }
  .wf-toolbar-left { flex: 1; min-width: 0; }
  .wf-flow-name { width: 120px; }
}
