/* ── Image Generation Flow Editor (Drawflow) ── */

/* Helpers extracted from inline cssText (shared with imagegen-pipeline/-app/-nodes) */
.igen-thumb { width:100%; max-height:240px; object-fit:contain; border-radius:6px; display:block; }
.igen-thumb-220 { width:100%; max-height:220px; object-fit:contain; border-radius:6px; display:block; }
.igen-thumb-label { font-size:10px; color:#888; margin-top:4px; text-align:center; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.igen-thumb-label-3 { font-size:10px; color:#888; margin-top:3px; text-align:center; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.igen-result { max-width:100%; max-height:200px; border-radius:4px; display:block; margin:0 auto; }
.igen-svg-16 { width:16px; height:16px; }
.igen-canvas-fill { width:100%; height:100%; position:absolute; top:0; left:0; }
.igen-port-dot { width:8px; height:8px; border-radius:50%; display:inline-block; margin-right:8px; }

/* Canvas */
.igf-canvas {
  flex: 1;
  min-height: 400px;
  background: #1a1a2e;
  position: relative;
}
.igf-canvas .drawflow {
  width: 100%;
  height: 100%;
}

/* Toolbar */
.igf-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
}
.igf-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Add node dropdown */
.igf-add-wrap {
  position: relative;
}
.igf-add-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.igf-add-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.igf-add-menu button:hover {
  background: rgba(255,255,255,.06);
}

/* ── Drawflow overrides ── */
.drawflow .drawflow-node {
  background: #2a2a3a;
  border: 1px solid #444;
  border-radius: 10px;
  min-width: 220px;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.drawflow .drawflow-node.selected {
  border-color: var(--accent, #3b7dd8);
  box-shadow: 0 0 0 2px var(--accent, #3b7dd8), 0 4px 16px rgba(0,0,0,.4);
}
.drawflow .drawflow-node .drawflow_content_node {
  padding: 0;
}

/* Connection lines */
.drawflow .connection .main-path {
  stroke: #5a6a7a;
  stroke-width: 2px;
}
.drawflow .connection .main-path:hover,
.drawflow .connection.selected .main-path {
  stroke: var(--accent, #3b7dd8);
  stroke-width: 3px;
}

/* Input/output dots */
.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
  width: 14px;
  height: 14px;
  border: 2px solid #666;
  background: #333;
  border-radius: 50%;
}
.drawflow .drawflow-node .input:hover,
.drawflow .drawflow-node .output:hover {
  border-color: var(--accent, #3b7dd8);
  background: var(--accent, #3b7dd8);
}

/* ── Node type styles ── */
.igf-node {
  padding: 12px;
}
.igf-node-title {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

/* Prompt node */
.igf-type-prompt .drawflow_content_node { border-left: 3px solid #4ecdc4; }
.igf-prompt textarea {
  width: 100%;
  min-height: 60px;
  background: #1a1a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 8px;
  font-size: 12px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}
.igf-prompt textarea:focus {
  border-color: #4ecdc4;
  outline: none;
}

/* Image Input node */
.igf-type-imageInput .drawflow_content_node { border-left: 3px solid #45b7d1; }
.igf-upload-zone {
  padding: 20px 12px;
  border: 2px dashed #444;
  border-radius: 6px;
  text-align: center;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.igf-upload-zone:hover,
.igf-upload-zone.igf-dragover {
  border-color: #45b7d1;
  background: rgba(69,183,209,.08);
}
.igf-thumb {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 6px;
  margin-top: 8px;
}

/* Image Gen node — all-in-one Krea-style */
.igf-type-imageGen .drawflow_content_node { border-left: 3px solid #a855f7; }
.igf-type-imageGen { min-width: 260px; }

/* Generated image preview at top of node */
.igf-gen-preview {
  background: #151525;
  border-radius: 6px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 11px;
  overflow: hidden;
  margin-bottom: 8px;
}
.igf-gen-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

/* Built-in prompt textarea */
.igf-gen-prompt {
  width: 100%;
  min-height: 50px;
  background: #1a1a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 8px;
  font-size: 12px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
  margin-bottom: 6px;
}
.igf-gen-prompt:focus { border-color: #a855f7; outline: none; }

/* Field rows */
.igf-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.igf-field span {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  min-width: 40px;
}
.igf-field select {
  flex: 1;
  background: #1a1a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  padding: 4px 6px;
  font-size: 11px;
  font-family: inherit;
  min-width: 0;
}
.igf-field select:focus { border-color: #a855f7; outline: none; }

/* Collapsible settings */
.igf-settings-toggle {
  font-size: 11px;
  color: #888;
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
  border-top: 1px solid rgba(255,255,255,.06);
  margin-top: 4px;
}
.igf-settings-toggle:hover { color: #bbb; }
.igf-settings-body {
  padding-top: 6px;
}

/* Status indicator */
.igf-status {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  min-height: 16px;
  margin-bottom: 6px;
}
.igf-status:empty { display: none; }
.igf-status-running { background: rgba(255,204,0,.15); color: #ffcc00; }
.igf-status-done { background: rgba(0,204,102,.15); color: #00cc66; }
.igf-status-error { background: rgba(255,68,68,.15); color: #ff4444; }

/* Preview node */
.igf-type-preview .drawflow_content_node { border-left: 3px solid #f97316; }
.igf-preview-area {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 12px;
  background: #1a1a2a;
  border-radius: 6px;
  padding: 8px;
  overflow: hidden;
}
.igf-preview-area img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
}

/* Text Combine node */
.igf-type-textCombine .drawflow_content_node { border-left: 3px solid #eab308; }
.igf-text-combine label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #aaa;
}
.igf-text-combine input {
  flex: 1;
  background: #1a1a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
}

/* ── Drawflow background grid ── */
.drawflow {
  background: #1a1a2e;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* ── Delete button on nodes ── */
.drawflow .drawflow-delete {
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  top: -8px;
  right: -8px;
}
