/* SVG GUI Styles for Node-based Flow Editor */

.svg-connected-items-container {
  width: 100%;
  height: 100%;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.flow-svg {
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20px 20px, #cbd5e1 1.5px, transparent 1.5px),
    linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 40px 40px, 100% 100%;
}

.svg-connectable-item {
  cursor: move;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.svg-connectable-item rect:first-child {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.07)) drop-shadow(0 1px 3px rgba(0, 0, 0, 0.1));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.svg-connectable-item:hover rect:first-child {
  fill: #ffffff;
  stroke: #3b82f6;
  stroke-width: 2;
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1)) drop-shadow(0 4px 6px rgba(59, 130, 246, 0.1));
  transform: translateY(-2px);
}

.connector {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.connector:hover {
  transform: scale(1.3);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.input-connector {
  fill: linear-gradient(135deg, #10b981 0%, #059669 100%);
  stroke: #ffffff;
  stroke-width: 2;
}

.input-connector:hover {
  fill: #059669;
  stroke: #10b981;
  stroke-width: 3;
  filter: drop-shadow(0 4px 8px rgba(16, 185, 129, 0.3));
}

.output-connector {
  fill: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  stroke: #ffffff;
  stroke-width: 2;
}

.output-connector:hover {
  fill: #d97706;
  stroke: #f59e0b;
  stroke-width: 3;
  filter: drop-shadow(0 4px 8px rgba(245, 158, 11, 0.3));
}

.container-input-connector,
.container-output-connector {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.container-input-connector {
  fill: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  stroke: #ffffff;
  stroke-width: 2.5;
}

.container-output-connector {
  fill: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  stroke: #ffffff;
  stroke-width: 2.5;
}

.container-input-connector:hover,
.container-output-connector:hover {
  transform: scale(1.25);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
}

.container-input-connector:hover {
  fill: #4f46e5;
  stroke: #6366f1;
  stroke-width: 3;
  filter: drop-shadow(0 6px 12px rgba(99, 102, 241, 0.3));
}

.container-output-connector:hover {
  fill: #db2777;
  stroke: #ec4899;
  stroke-width: 3;
  filter: drop-shadow(0 6px 12px rgba(236, 72, 153, 0.3));
}

.connections-group path {
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.connections-group path:hover {
  stroke-width: 4;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

/* Prompt editing popup styles */
.prompt-edit-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.popup-content {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding: 32px;
  border-radius: 16px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 10px 20px -6px rgba(0, 0, 0, 0.1);
  width: 500px;
  max-width: 90vw;
  border: 1px solid rgba(255, 255, 255, 0.8);
  /* animation: slideIn 0.3s ease-out; */
  height: calc(100% - 50px);
  display: flex;
  flex-direction: column;
}

@keyframes slideIn {
  from { 
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popup-content h3 {
  /* margin: 0 0 24px 0; */
  color: #1f2937;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.popup-content label {
  display: block;
  margin: 16px 0 8px 0;
  font-weight: 600;
  color: #374151;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0.025em;
}

.popup-content select,
.popup-content textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  box-sizing: border-box;
  transition: all 0.2s ease;
  background: #ffffff;
}

.popup-content select:focus,
.popup-content textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.popup-content select {
  height: 48px;
}

.popup-content textarea {
  height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.popup-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
}

.popup-buttons button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.popup-buttons button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.popup-buttons button:hover::before {
  left: 100%;
}

.popup-buttons button:first-child {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.popup-buttons button:first-child:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(16, 185, 129, 0.4);
}

.popup-buttons button:last-child {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3);
}

.popup-buttons button:last-child:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(239, 68, 68, 0.4);
}

/* Node text styling */
.svg-connectable-item text {
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.025em;
}

/* Make node title and prompt draggable */
.svg-connectable-item .node-title,
.svg-connectable-item .node-prompt {
  pointer-events: auto;
  cursor: move;
}

/* Keep other text elements non-interactive */
.svg-connectable-item .delete-icon,
.svg-connectable-item .tools-icon {
  pointer-events: none;
}

/* Connection animation */
@keyframes connectionPulse {
  0% { 
    stroke-opacity: 0.7; 
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  }
  50% { 
    stroke-opacity: 1; 
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
  }
  100% { 
    stroke-opacity: 0.7; 
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  }
}

.connections-group path.active {
  animation: connectionPulse 2.5s infinite ease-in-out;
  stroke-width: 4;
}

/* Dragging state */
.svg-connectable-item.dragging {
  opacity: 0.95;
  transition: none;
}

.svg-connectable-item.dragging rect:first-child {
  stroke: #3b82f6;
  stroke-width: 3;
  filter: drop-shadow(0 15px 25px rgba(59, 130, 246, 0.4)) drop-shadow(0 5px 10px rgba(59, 130, 246, 0.2));
  transform: rotate(2deg) scale(1.05);
}

/* Result indicator styling enhancements */
.result-indicator {
  cursor: pointer;
}

.result-indicator .result-bg {
  transition: fill 0.2s ease, filter 0.2s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.result-indicator:hover .result-bg {
  fill: #059669 !important;
  filter: drop-shadow(0 4px 8px rgba(16, 185, 129, 0.3));
}

.result-indicator .result-icon {
  font-weight: bold;
}

/* Connection context menu */
.connection-context-menu {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 
    0 20px 25px -5px rgba(0, 0, 0, 0.1), 
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(8px);
}

.connection-context-menu div {
  padding: 12px 16px;
  transition: all 0.2s ease;
  border-radius: 6px;
  margin: 4px;
  font-weight: 500;
}

.connection-context-menu div:hover {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%) !important;
  transform: translateX(2px);
}

/* Enhanced node styling */
.svg-connectable-item rect:first-child {
  fill: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  stroke: #e1e5e9;
  stroke-width: 2;
  rx: 12;
  ry: 12;
}

/* Professional node text styling */
.flow-node .node-title {
  fill: #1f2937;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.025em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.flow-node .node-content {
  fill: #64748b;
  font-size: 8px;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.flow-node .node-info {
  fill: #475569;
  font-size: 7px;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.flow-node .node-details {
  fill: #6b7280;
  font-size: 6px;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Smooth transitions for all SVG elements */
.flow-node {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.connection-path {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.container-connector {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced professional hover effects - no transform to avoid jitter */
.flow-node:not(.dragging):hover .node-background {
  stroke: #3b82f6;
  stroke-width: 2;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15)) drop-shadow(0 2px 6px rgba(59, 130, 246, 0.1));
}

.flow-node .node-background {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Node connector styling improvements - no transform to avoid jitter */
.node-connector {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.1));
}

.node-connector:hover {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2)) brightness(1.1);
}

/* Container connector improvements */
.container-connector {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.container-connector:hover {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

/* Professional grid background */
.flow-svg {
  background: 
    radial-gradient(circle at 40px 40px, #cbd5e1 1.5px, transparent 1.5px),
    linear-gradient(135deg, #f8fafc 0%, #f1f5f9 25%, #e2e8f0 75%, #cbd5e1 100%);
  background-size: 40px 40px, 100% 100%;
}

/* HTML Node Styling */
.html-node {
  position: absolute;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 8px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  cursor: move;
  user-select: none;
  pointer-events: auto;
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
}

.html-node:hover {
  border-color: #3b82f6 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(59, 130, 246, 0.1) !important;
}

.html-node-main {
  border-radius: 4px;
}

.html-node-title {
  font-size: 11px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 2px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.025em;
}

.html-node-content {
  font-size: 8px;
  color: #64748b;
  margin-bottom: 1px;
  text-align: center;
  line-height: 1.1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 16px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.html-node-info {
  font-size: 7px;
  color: #475569;
  margin-bottom: 1px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

.html-node-details {
  font-size: 6px;
  color: #6b7280;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

/* Pulse animation for tool addition feedback */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Task node specific styling */
.html-node.task-node {
  background: linear-gradient(135deg, #fefce8 0%, #fef3c7 50%, #fde68a 100%);
  border-color: #d97706;
}

.html-node.task-node .html-node-title {
  color: #92400e;
}

/* Trigger node specific styling */
.html-node.trigger-node {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #bae6fd 100%);
  border-color: #0ea5e9;
}

.html-node.trigger-node .html-node-title {
  color: #0369a1;
}

/* Ensure HTML nodes are positioned relative to SVG container */
.svg-flow-editor {
  position: relative;
}

.task-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
}

/* HTML Node Interactive Elements */
.html-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  border: 2px solid white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
  z-index: 20;
  transition: all 0.2s ease;
}

.html-delete-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.html-tools-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #10b981;
  color: white;
  border: 2px solid white;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  z-index: 20;
  transition: all 0.2s ease;
}

.html-tools-indicator:hover {
  background: #059669;
  transform: scale(1.1);
}

.html-tools-indicator.visible {
  display: flex;
}

.html-node-title {
  margin-top: 8px;
}