/* Flow Editor Styles */

/* Flow Tabs */
#flow-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  overflow-x: auto;
}

.flow-tabs-list {
  display: flex;
  gap: 0.25rem;
}

.flow-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: all 0.15s;
  position: relative;
  bottom: -1px;
}

.flow-tab:hover {
  background: var(--gray-50);
  color: var(--gray-800);
}

.flow-tab.active {
  background: white;
  border-bottom-color: white;
  color: var(--primary);
}

.flow-tab-name {
  cursor: pointer;
}

.flow-tab-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  opacity: 0;
  transition: all 0.2s ease;
  margin-left: 0.25rem;
}

.flow-tab:hover .flow-tab-delete {
  opacity: 1;
}

.flow-tab-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.flow-tab-delete:active {
  background: var(--error);
  color: white;
}

.flow-tab-add {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px dashed var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--gray-500);
  transition: all 0.15s;
}

.flow-tab-add:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.flow-tab-rename-input {
  width: 120px;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--primary);
  border-radius: 3px;
  font-size: 0.875rem;
  font-weight: 500;
  outline: none;
}

.flow-editor-container {
  display: flex;
  height: 600px;
  border: 1px solid var(--gray-200);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  background: #f8fafc;
}

.flow-editor-sidebar {
  width: 200px;
  background: white;
  border-right: 1px solid var(--gray-200);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.flow-editor-sidebar h4 {
  margin: 0;
  font-size: 0.875rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flow-node-draggable {
  padding: 0.75rem 1rem;
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  cursor: grab;
  text-align: center;
  font-weight: 500;
  transition: all 0.2s;
  user-select: none;
}

.flow-node-draggable:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.flow-node-draggable.ivr {
  border-color: #8b5cf6;
  background: #f5f3ff;
  color: #6d28d9;
}

.flow-node-draggable.ivr:hover {
  background: #ede9fe;
}

.flow-node-draggable.department {
  border-color: #0ea5e9;
  background: #f0f9ff;
  color: #0284c7;
}

.flow-node-draggable.department:hover {
  background: #e0f2fe;
}

.flow-node-draggable.user {
  border-color: #10b981;
  background: #ecfdf5;
  color: #059669;
}

.flow-node-draggable.user:hover {
  background: #d1fae5;
}

.flow-editor-canvas {
  flex: 1;
  position: relative;
}

#drawflow {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle, var(--gray-200) 0.75px, transparent 0.75px);
  background-size: 24px 24px;
}

[data-theme="dark"] #drawflow {
  background:
    radial-gradient(circle, var(--gray-700) 0.75px, transparent 0.75px);
  background-size: 24px 24px;
}

/* Drawflow node styling */
.drawflow .drawflow-node {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  min-width: 280px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.drawflow .drawflow-node:hover:not(.is-dragging) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.drawflow .drawflow-node.is-dragging {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0.9;
  transition: none;
  will-change: transform;
}

/* IVR node - wider horizontal layout */
.drawflow .drawflow-node.ivr-node {
  min-width: 420px;
}

/* User node - compact */
.drawflow .drawflow-node.user-node {
  min-width: 200px;
}

.drawflow .drawflow-node.selected {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.4);
  background: #faf5ff;
}

.drawflow .drawflow-node .drawflow_content_node {
  padding: 0;
}

/* Node header */
.flow-node-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: grab;
}

.flow-node-header:active {
  cursor: grabbing;
}

/* Grip dots indicator on header */
.flow-node-header::before {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  flex-shrink: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.45) 1px, transparent 1px);
  background-size: 4px 4px;
  margin-right: -0.125rem;
}

.flow-node-header .node-type {
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header .node-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-node-header .node-title-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  outline: none;
}

.flow-node-header .node-title-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.flow-node-header .node-title-input:focus {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.flow-node-header.ivr {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.ivr .node-type {
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header.department {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.department .node-type {
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header.user {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.user .node-type {
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header.voicemail {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.voicemail .node-type {
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header.dialbyname {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.dialbyname .node-type {
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header.contactcenter {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.contactcenter .node-type {
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header.playmessage {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.playmessage .node-type {
  background: rgba(255, 255, 255, 0.2);
}

.flow-node-header.externalrouting {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  color: white;
  border-radius: 6px 6px 0 0;
}

.flow-node-header.externalrouting .node-type {
  background: rgba(255, 255, 255, 0.2);
}

/* Node body */
.flow-node-body {
  padding: 1rem;
}

.flow-node-field {
  margin-bottom: 0.75rem;
}

.flow-node-field:last-child {
  margin-bottom: 0;
}

.flow-node-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--gray-500);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.flow-node-field input,
.flow-node-field select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.875rem;
}

.flow-node-field input:focus,
.flow-node-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* IVR node layout */
.drawflow .drawflow-node.ivr-node {
  min-width: 300px;
  max-width: 320px;
}

/* Row layout for fields */
.flow-node-row {
  display: flex;
  gap: 0.5rem;
}

.flow-node-field.flex-1 {
  flex: 1;
  min-width: 0;
}

/* Greeting textarea */
.flow-node-body textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  resize: vertical;
  min-height: 50px;
}

.flow-node-body textarea:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

/* Key press section */
.keypress-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
}

.keypress-header {
  margin-bottom: 0.5rem;
}

.keypress-header label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
}

.keypress-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.keypress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
}

.keypress-num {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #8b5cf6;
  color: white;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.keypress-input {
  flex: 1;
  height: 24px;
  padding: 0 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.75rem;
  min-width: 0;
}

.keypress-input:focus {
  outline: none;
  border-color: #8b5cf6;
}

.keypress-input::placeholder {
  color: var(--gray-400);
  font-style: italic;
  font-size: 0.7rem;
}

/* Audio file upload display */
.audio-file-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--dark);
}

.audio-file-display span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.btn-remove-file {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0 0 8px;
  flex-shrink: 0;
}

.btn-remove-file:hover {
  color: var(--danger);
}

/* Department node specifics */
.members-list {
  max-height: 100px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 0.5rem;
  background: var(--gray-50);
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.8rem;
}

.member-item input[type="checkbox"] {
  width: auto;
}

/* Sequential ordered member list */
.member-order-list {
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 0.375rem;
  background: var(--gray-50);
}

.member-order-list .form-hint {
  display: block;
  padding: 0.25rem;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.member-order-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.375rem;
  border-radius: 4px;
  transition: background 0.1s;
}

.member-order-item:hover {
  background: var(--gray-100);
}

.member-order-badge {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #8b5cf6;
  color: white;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.member-order-name {
  flex: 1;
  font-size: 0.8rem;
  color: var(--gray-700);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-order-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.member-order-actions button {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s;
}

.member-order-actions button:hover:not(:disabled) {
  background: var(--gray-200);
  color: var(--gray-700);
}

.member-order-actions button:disabled {
  opacity: 0.3;
  cursor: default;
}

.member-order-actions .member-order-remove:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.member-add-row {
  margin-top: 0.375rem;
}

.member-add-row select {
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--gray-600);
  background: white;
}

.member-add-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* Connection lines */
.drawflow .connection .main-path {
  stroke: var(--primary);
  stroke-width: 2.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-width 0.15s ease;
}

.drawflow .connection .main-path:hover {
  stroke: var(--primary-dark);
  stroke-width: 3.5px;
}

/* Input/Output points */
.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
  width: 14px;
  height: 14px;
  background: white;
  border: 3px solid var(--primary);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}

.drawflow .drawflow-node .input:hover,
.drawflow .drawflow-node .output:hover {
  background: var(--primary);
  transform: scale(1.2);
}

/* IVR outputs - aligned with key press rows */
.drawflow .drawflow-node.ivr-node .outputs {
  position: absolute;
  right: -10px;
  top: 410px;  /* Position to align with first keypress row */
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.drawflow .drawflow-node.ivr-node .output {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  width: 20px !important;
  height: 20px !important;
  background: #8b5cf6 !important;
  border: 2px solid #8b5cf6 !important;
  border-radius: 50% !important;
  transition: all 0.15s;
  cursor: crosshair;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.drawflow .drawflow-node.ivr-node .output::after {
  color: white;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* Numbers for each output (column-reverse means 1 is at bottom, 0 at top) */
.drawflow .drawflow-node.ivr-node .output:nth-child(1)::after { content: "1"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(2)::after { content: "2"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(3)::after { content: "3"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(4)::after { content: "4"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(5)::after { content: "5"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(6)::after { content: "6"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(7)::after { content: "7"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(8)::after { content: "8"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(9)::after { content: "9"; }
.drawflow .drawflow-node.ivr-node .output:nth-child(10)::after { content: "0"; }

.drawflow .drawflow-node.ivr-node .output:hover {
  transform: scale(1.2);
  background: #7c3aed !important;
  border-color: #7c3aed !important;
}

/* Endpoint nodes - single input centered */
.drawflow .drawflow-node.department-node .inputs,
.drawflow .drawflow-node.user-node .inputs,
.drawflow .drawflow-node.voicemail-node .inputs,
.drawflow .drawflow-node.dialbyname-node .inputs,
.drawflow .drawflow-node.contactcenter-node .inputs,
.drawflow .drawflow-node.playmessage-node .inputs,
.drawflow .drawflow-node.externalrouting-node .inputs {
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
}

/* IVR input on left side */
.drawflow .drawflow-node.ivr-node .inputs {
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
}

/* Delete node button */
.flow-node-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.drawflow .drawflow-node:hover .flow-node-delete {
  opacity: 1;
}

/* Toolbar */
.flow-editor-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: white;
  border-bottom: 1px solid var(--gray-200);
}

.flow-editor-toolbar .btn {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

/* Zoom controls */
.flow-zoom-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-surface, white);
  color: var(--gray-700);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 0.25rem;
}

.flow-zoom-controls button {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: 4px;
  font-size: 1rem;
}

/* Snap toggle in zoom controls */
.flow-zoom-controls .snap-toggle {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.flow-zoom-controls .snap-toggle.active {
  background: var(--primary-light, rgba(79, 70, 229, 0.1));
  color: var(--primary);
}

.flow-zoom-controls button:hover {
  background: var(--gray-100);
}

.zoom-level {
  font-size: 0.8rem;
  min-width: 40px;
  text-align: center;
}

/* Node actions menu */
.node-actions {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.5rem;
  display: none;
  z-index: 100;
}

.node-actions.visible {
  display: block;
}

.node-actions button {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.node-actions button:hover {
  background: var(--gray-100);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .flow-editor-container {
    flex-direction: column;
    height: 500px;
  }

  .flow-editor-sidebar {
    width: 100%;
    flex-direction: row;
    padding: 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }

  .flow-editor-sidebar h4 {
    display: none;
  }

  .flow-node-draggable {
    flex: 1;
    padding: 0.5rem;
  }
}

/* Flow Name Modal */
.flow-name-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.flow-name-modal {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.flow-name-modal h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  color: var(--gray-800);
}

.flow-name-modal p {
  margin: 0 0 1rem 0;
  color: var(--gray-600);
  font-size: 0.9rem;
}

.flow-name-modal input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.flow-name-modal input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.flow-name-modal-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.flow-name-modal-buttons .btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* === Flow Cards Grid (Wizard Step 4) === */
.flow-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
}

.flow-card {
  background: var(--bg-surface);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1rem;
  transition: box-shadow 0.2s, border-color 0.2s;
  cursor: default;
}

.flow-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.flow-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.flow-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--dark);
}

.flow-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
}

.flow-card-actions {
  display: flex;
  gap: 0.5rem;
}

/* Status badges */
.badge-draft {
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.badge-published {
  background: var(--success-bg);
  color: var(--success-text);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
}

/* === Standalone Flow Editor === */
.flow-editor-standalone {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.flow-editor-standalone .flow-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--gray-200);
  min-height: 48px;
  flex-shrink: 0;
}

.flow-name-editable {
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  outline: none;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-name-editable:hover,
.flow-name-editable:focus {
  border-color: var(--gray-300);
  background: var(--gray-50);
}

.flow-editor-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.flow-editor-toolbar-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.save-status {
  font-size: 0.8rem;
  padding: 4px 8px;
}

.save-status-saved {
  color: var(--gray-400);
}

.save-status-saving {
  color: var(--primary);
}

.save-status-failed {
  color: var(--error);
}

.flow-editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.flow-editor-standalone .flow-editor-sidebar {
  width: 180px;
  flex-shrink: 0;
  padding: 1rem;
  border-right: 1px solid var(--gray-200);
  background: var(--bg-surface);
  overflow-y: auto;
}

.flow-editor-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* === Standalone Sidebar Widgets === */
.flow-sidebar-section {
  margin-bottom: 1rem;
}

.flow-sidebar-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
}

.flow-sidebar-nodes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flow-node-widget {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: grab;
  font-size: 0.85rem;
  transition: all 0.15s;
  background: var(--bg-surface);
}

.flow-node-widget > span:not(.widget-info) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-node-widget:hover {
  border-color: var(--primary);
  background: var(--gray-50);
}

.flow-node-widget:active {
  cursor: grabbing;
}

.flow-node-widget-icon {
  width: 32px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.flow-node-widget-icon.ivr {
  background: var(--primary, #5c6bc0);
}

.flow-node-widget-icon.department {
  background: var(--success, #66bb6a);
}

.flow-node-widget-icon.user {
  background: var(--warning, #ffa726);
}

.flow-node-widget-icon.voicemail {
  background: #f59e0b;
}

.flow-node-widget-icon.dialbyname {
  background: #6366f1;
}

.flow-node-widget-icon.contactcenter {
  background: #ec4899;
}

.flow-node-widget-icon.playmessage {
  background: #f97316;
}

.flow-node-widget-icon.externalrouting {
  background: #64748b;
}

/* Widget info tooltip */
.widget-info {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  font-style: italic;
  color: var(--gray-400);
  cursor: help;
  flex-shrink: 0;
  margin-left: auto;
  position: relative;
  /* Don't interfere with drag */
  -webkit-user-drag: none;
}

.widget-info:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Tooltip popup — positioned by JS, appended to <body> */
.widget-info-tooltip {
  position: fixed;
  background: var(--gray-900, #111827);
  color: white;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  max-width: 220px;
  width: max-content;
  white-space: normal;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.12s;
}

.widget-info-tooltip.visible {
  opacity: 1;
}

[data-theme="dark"] .widget-info-tooltip {
  background: #e5e7eb;
  color: #1a1d2e;
}

/* === Version History Panel === */
.flow-version-panel {
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease;
  border-left: 1px solid var(--gray-200);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.flow-version-panel.open {
  width: 300px;
  overflow-y: auto;
  padding: 1rem;
}

.flow-version-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flow-version-panel h3 {
  font-size: 1rem;
  margin: 0 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.version-item {
  padding: 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.version-item:hover {
  border-color: var(--gray-300);
  background: var(--gray-50);
}

.version-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.version-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: 4px;
}

.version-item-meta {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-bottom: 0.5rem;
}

/* === Dark mode overrides === */
[data-theme="dark"] .flow-card {
  background: var(--bg-surface);
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-card:hover {
  border-color: var(--primary);
}

[data-theme="dark"] .badge-draft {
  background: var(--gray-100);
  color: var(--gray-600);
}

[data-theme="dark"] .badge-published {
  background: var(--success-bg);
  color: var(--success-text);
}

[data-theme="dark"] .flow-editor-standalone .flow-editor-toolbar {
  background: var(--bg-surface);
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-editor-standalone .flow-name-editable:hover {
  border-color: var(--gray-300);
  background: var(--gray-100);
}

[data-theme="dark"] .flow-editor-standalone .flow-editor-sidebar {
  background: var(--bg-surface);
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-version-panel {
  background: var(--bg-surface);
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-version-panel h3 {
  border-color: var(--gray-200);
}

[data-theme="dark"] .version-item {
  border-color: var(--gray-200);
}

[data-theme="dark"] .version-item:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

[data-theme="dark"] .version-label {
  background: var(--gray-100);
  color: var(--gray-500);
}

[data-theme="dark"] .flow-node-widget {
  background: var(--bg-surface);
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-node-widget:hover {
  border-color: var(--primary);
  background: var(--gray-50);
}

[data-theme="dark"] .widget-info {
  border-color: #9ca3af;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .widget-info:hover {
  border-color: #9B7DFF;
  color: #9B7DFF;
  background: rgba(155, 125, 255, 0.1);
}


[data-theme="dark"] .flow-name-editable:hover,
[data-theme="dark"] .flow-name-editable:focus {
  border-color: var(--gray-300);
  background: var(--gray-100);
}

[data-theme="dark"] .flow-version-panel-header {
  border-color: var(--gray-200);
}

/* Dark mode for drawflow nodes */
[data-theme="dark"] .drawflow .drawflow-node {
  background: var(--bg-surface);
  border-color: var(--gray-200);
  color: var(--gray-700);
}

[data-theme="dark"] .drawflow .drawflow-node.selected {
  border-color: #8b5cf6;
  background: #1e1333;
}

[data-theme="dark"] .flow-node-header {
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-node-field input,
[data-theme="dark"] .flow-node-field select,
[data-theme="dark"] .flow-node-body textarea,
[data-theme="dark"] .keypress-input {
  background: var(--gray-50);
  border-color: var(--gray-200);
  color: var(--gray-700);
}

[data-theme="dark"] .members-list {
  background: var(--gray-50);
  border-color: var(--gray-200);
}

[data-theme="dark"] .member-item {
  color: var(--gray-700);
}

[data-theme="dark"] .member-order-list {
  background: var(--gray-50);
  border-color: var(--gray-200);
}

[data-theme="dark"] .member-order-name {
  color: var(--gray-700);
}

[data-theme="dark"] .member-order-item:hover {
  background: var(--gray-100);
}

[data-theme="dark"] .member-add-row select {
  background: var(--gray-50);
  border-color: var(--gray-200);
  color: var(--gray-700);
}

[data-theme="dark"] .drawflow .drawflow-node:hover:not(.is-dragging) {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .drawflow .drawflow-node.is-dragging {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .drawflow .drawflow-node.selected {
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.5);
}

[data-theme="dark"] .flow-zoom-controls {
  background: var(--bg-surface, #1e293b);
}

[data-theme="dark"] .flow-zoom-controls .snap-toggle.active {
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
}

[data-theme="dark"] .flow-editor-container {
  background: var(--bg-light);
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-editor-sidebar {
  background: var(--bg-surface);
  border-color: var(--gray-200);
}

[data-theme="dark"] .flow-node-draggable.ivr {
  border-color: #7c3aed;
  background: #1e1333;
  color: #a78bfa;
}

[data-theme="dark"] .flow-node-draggable.ivr:hover {
  background: #2d1b4e;
}

[data-theme="dark"] .flow-node-draggable.department {
  border-color: #0284c7;
  background: #0c1a2e;
  color: #38bdf8;
}

[data-theme="dark"] .flow-node-draggable.department:hover {
  background: #0f2440;
}

[data-theme="dark"] .flow-node-draggable.user {
  border-color: #059669;
  background: #0c1f1a;
  color: #34d399;
}

[data-theme="dark"] .flow-node-draggable.user:hover {
  background: #0f2e24;
}

/* Example Flow Modal */
.example-flow-modal-content {
  max-width: 95vw;
  width: 95vw;
  max-height: 92vh;
}

.example-flow-modal-content .modal-body {
  overflow: hidden;
  height: 75vh;
}

/* Hide delete buttons in example view */
#example-drawflow .flow-node-delete,
#example-drawflow .drawflow-delete {
  display: none;
}

/* Disable all inputs/selects in example view */
#example-drawflow input,
#example-drawflow select,
#example-drawflow textarea {
  pointer-events: none;
  opacity: 0.8;
}
