/* Workflow Canvas Specific Styles */
.workflow-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

.canvas-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    z-index: 10;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.toolbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.toolbar-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 var(--spacing-sm);
}

.workflow-canvas {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    cursor: default;
}

.workflow-canvas.drag-over {
    outline: 2px dashed var(--primary);
    outline-offset: -4px;
    background: rgba(79, 70, 229, 0.03);
}

.canvas-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(100, 116, 139, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 116, 139, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -1px -1px;
    transform-origin: 0 0;
}

.nodes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

.connections-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Node Styles */
.workflow-node {
    position: absolute;
    min-width: 200px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    cursor: move;
    user-select: none;
    transition: all var(--transition-fast);
    z-index: 10;
}

.workflow-node:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.workflow-node.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2), var(--shadow-lg);
}

.workflow-node.dragging {
    opacity: 0.8;
    cursor: grabbing;
    transition: none !important;
}

.workflow-node.executing {
    animation: pulse 2s infinite;
}

.workflow-node.success {
    border-color: var(--success);
}

.workflow-node.error {
    border-color: var(--danger);
}

.workflow-node.pending {
    border-color: var(--warning);
}

.node-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: rgba(0, 0, 0, 0.2);
}

.node-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.node-icon.trigger { background: linear-gradient(135deg, #EF4444, #F87171); }
.node-icon.action { background: linear-gradient(135deg, #10B981, #34D399); }
.node-icon.ai { background: linear-gradient(135deg, #8B5CF6, #A78BFA); }
.node-icon.data { background: linear-gradient(135deg, #F59E0B, #FBBF24); }
.node-icon.integration { background: linear-gradient(135deg, #3B82F6, #60A5FA); }
.node-icon.output { background: linear-gradient(135deg, #6366F1, #818CF8); }

.node-title {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.node-status.idle { background: var(--text-muted); }
.node-status.running { background: var(--primary); animation: blink 1s infinite; }
.node-status.success { background: var(--success); }
.node-status.error { background: var(--danger); }
.node-status.pending { background: var(--warning); }

.node-body {
    padding: 16px;
}

.node-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 12px;
}

.node-ports {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
}

.input-ports,
.output-ports {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.port {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: crosshair;
    transition: all var(--transition-fast);
    user-select: none;
}

.port:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.port.connected {
    background: rgba(79, 70, 229, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.port-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
}

.input-port {
    flex-direction: row;
}

.output-port {
    flex-direction: row-reverse;
}

.node-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.node-actions {
    display: flex;
    gap: 4px;
}

.node-action-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.node-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.node-config {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

/* SVG Connections Layer */
.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    transform-origin: 0 0;
}

.connections-svg path {
    pointer-events: stroke;
}

/* Connection Styles */
.connection {
    pointer-events: none;
}

.connection-line,
.connection-path {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 2;
    pointer-events: stroke;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.connection-line:hover,
.connection-path:hover {
    stroke: var(--primary);
    stroke-width: 3;
}

.connection-line.selected,
.connection-path.selected {
    stroke: var(--primary);
    stroke-width: 3;
    filter: drop-shadow(0 0 4px rgba(79, 70, 229, 0.5));
}

.connection-line.in-progress {
    stroke: var(--primary-light);
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    pointer-events: none;
}

.connection-line.success,
.connection-path.success {
    stroke: var(--success);
}

.connection-line.error,
.connection-path.error {
    stroke: var(--danger);
}

.connection-line.running,
.connection-path.running {
    stroke: var(--primary);
    animation: flow 2s linear infinite;
}

.connection-label {
    font-size: 0.75rem;
    fill: var(--text-secondary);
    pointer-events: none;
    user-select: none;
}

/* Selection Box */
.selection-box {
    position: absolute;
    border: 2px dashed var(--primary);
    background: rgba(79, 70, 229, 0.1);
    pointer-events: none;
    z-index: 100;
    display: none;
}

.selection-box.active {
    display: block;
}

/* Mini Map */
.mini-map {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 180px;
    height: 120px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    z-index: 20;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.mini-map::before {
    content: 'MINIMAP';
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(148, 163, 184, 0.5);
    pointer-events: none;
    z-index: 2;
}

.mini-map-viewport {
    position: absolute;
    border: 1.5px solid var(--primary);
    background: rgba(79, 70, 229, 0.08);
    pointer-events: none;
    border-radius: 1px;
    z-index: 1;
}

/* Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes flow {
    0% {
        stroke-dasharray: 5, 5;
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dasharray: 5, 5;
        stroke-dashoffset: 10;
    }
}

/* Port Hover Effects */
.port.highlight {
    background: rgba(79, 70, 229, 0.2);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.1);
}

.port.active {
    background: rgba(79, 70, 229, 0.3);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
}

/* Connection Preview */
.connection-preview-path {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    pointer-events: none;
}

/* Node Resize Handles */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 11;
}

.workflow-node:hover .resize-handle {
    opacity: 1;
}

.resize-handle.nw {
    top: -4px;
    left: -4px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -4px;
    right: -4px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -4px;
    left: -4px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -4px;
    right: -4px;
    cursor: se-resize;
}

.resize-handle.n {
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle.s {
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle.w {
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

.resize-handle.e {
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

/* Node Configuration Form */
.config-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.config-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.config-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
}

.config-section-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.config-field {
    margin-bottom: var(--spacing-md);
}

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

.config-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.config-field input,
.config-field select,
.config-field textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.config-field input:focus,
.config-field select:focus,
.config-field textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.config-field textarea {
    resize: vertical;
    min-height: 80px;
}

.config-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

/* Execution Badges */
.execution-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    z-index: 12;
}

.execution-badge.success {
    background: var(--success);
    color: white;
}

.execution-badge.error {
    background: var(--danger);
    color: white;
}

.execution-badge.running {
    background: var(--primary);
    color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 20;
    background: rgba(30, 41, 59, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 6px;
    box-shadow: var(--shadow-lg);
    cursor: default;
}

.zoom-controls .drag-handle {
    width: 100%;
    height: 10px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    transition: opacity 0.15s;
}

.zoom-controls .drag-handle:hover {
    opacity: 0.7;
}

.zoom-controls .drag-handle::before {
    content: '';
    width: 20px;
    height: 3px;
    border-top: 2px dotted var(--text-secondary);
    border-bottom: 2px dotted var(--text-secondary);
}

.zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.zoom-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

/* Connection Points */
.connection-point {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    z-index: 9;
    pointer-events: all;
    cursor: crosshair;
    transition: all var(--transition-fast);
}

.connection-point:hover {
    border-color: var(--primary);
    transform: scale(1.2);
}

.connection-point.connected {
    background: var(--primary);
    border-color: var(--primary);
}

.connection-point.input {
    left: -8px;
}

.connection-point.output {
    right: -8px;
}

/* Node Templates */
.node-template {
    position: absolute;
    opacity: 0.7;
    pointer-events: none;
    z-index: 5;
}

/* Workflow Controls */
.workflow-controls {
    position: absolute;
    top: 60px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

.workflow-control-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.workflow-control-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

.workflow-control-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}