/* Flow Editor Styles */

/* Container */
.flow-editor-container {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

/* ReactFlow wrapper */
.reactflow-wrapper {
    flex: 1;
    height: 100%;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
}

/* Hide ReactFlow attribution */
.react-flow__attribution {
    display: none;
}

/* Node Palette Sidebar */
.node-palette {
    width: 200px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    max-height: 100%;
    overflow-y: auto;
}

/* Custom Node Styling */
.custom-node {
    padding: 12px 16px;
    border-radius: 6px;
    background: white;
    min-width: 150px;
    transition: all 0.2s ease;
}

.custom-node.selected {
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* Simplified port nodes when zoomed out */
.react-flow__node.simplified-port {
    transition: all 0.3s ease;
}

.react-flow__node.simplified-port .react-flow__handle {
    opacity: 0.5;
}

/* Group Node Styling */
.group-node {
    padding: 0;
    border-radius: 8px;
    background: rgba(100, 181, 246, 0.05);
    transition: all 0.2s ease;
}

.group-node.expanded {
    background: rgba(100, 181, 246, 0.1);
}

/* Hide ReactFlow's default outer group border */
.react-flow__node-group {
    border: none !important;
    background: transparent !important;
}

/* NodeResizer styling (our custom inner handles) */
.react-flow__resize-control.handle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1976D2;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.react-flow__resize-control.handle:hover {
    background: #1565C0;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.react-flow__resize-control.line {
    border-color: #1976D2;
    border-width: 2px;
}

.react-flow__resize-control.line:hover {
    border-width: 3px;
    border-color: #1565C0;
}

.group-header {
    padding: 12px 16px;
    background: rgba(100, 181, 246, 0.15);
    border-bottom: 2px solid rgba(100, 181, 246, 0.3);
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expand-button {
    background: rgba(100, 181, 246, 0.2);
    border: 1px solid rgba(100, 181, 246, 0.4);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    color: #1976D2;
    transition: all 0.2s ease;
}

.expand-button:hover {
    background: rgba(100, 181, 246, 0.4);
    transform: scale(1.1);
}

/* Subflow Port Indicators */
.subflow-port {
    cursor: pointer;
    transition: all 0.2s ease;
}

.subflow-port:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
}

.subflow-port.input-port:hover {
    background: #66BB6A !important;
}

.subflow-port.output-port:hover {
    background: #EF5350 !important;
}

/* Port connection hint on hover */
.group-node:hover .subflow-port::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

/* Subflow port nodes inside the group */
.react-flow__node[data-id*="-input"],
.react-flow__node[data-id*="-output"] {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

/* Handle styling for better visibility */
.react-flow__handle {
    width: 12px;
    height: 12px;
    border: 2px solid white;
    background: #555;
    transition: all 0.2s ease;
}

.react-flow__handle:hover {
    width: 16px;
    height: 16px;
    background: #1976D2;
}

/* Group node handles should be more visible */
.react-flow__node-group .react-flow__handle {
    width: 14px;
    height: 14px;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.react-flow__node-group .react-flow__handle-left {
    background: #4CAF50;
}

.react-flow__node-group .react-flow__handle-right {
    background: #F44336;
}

.react-flow__node-group .react-flow__handle:hover {
    width: 18px;
    height: 18px;
}

/* Edge styling */
.react-flow__edge-path {
    stroke-width: 2;
    transition: stroke-width 0.2s ease;
}

.react-flow__edge.selected .react-flow__edge-path {
    stroke-width: 3;
}

/* Minimap styling */
.react-flow__minimap {
    background: white;
    border: 1px solid #dee2e6;
}

.react-flow__controls {
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.react-flow__controls button {
    background: white;
    border-bottom: 1px solid #dee2e6;
}

.react-flow__controls button:hover {
    background: #f8f9fa;
}
/* Spinning animation for save indicator */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Preferred Route Panel and Button */
.preferred-route-panel {
    display: flex;
    gap: 8px;
}

.preferred-route-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #495057;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.preferred-route-btn:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: #1976D2;
    color: #1976D2;
}

.preferred-route-btn.active {
    background: #E3F2FD;
    border-color: #1976D2;
    color: #1976D2;
}

.preferred-route-btn.active:hover {
    background: #BBDEFB;
}

.preferred-route-btn.disabled,
.preferred-route-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8f9fa;
}

.preferred-route-btn svg {
    flex-shrink: 0;
}

/* Preferred Edge Styling */
.react-flow__edge-path.preferred {
    stroke: #888888;
    stroke-width: 2;
}

.react-flow__edge-path.default {
    stroke: #D7D7D7;
    stroke-width: 2;
}

.react-flow__edge.selected .react-flow__edge-path.preferred {
    stroke-width: 3;
}

.react-flow__edge.selected .react-flow__edge-path.default {
    stroke-width: 3;
}

/* Edge hover effect */
.preferred-edge:hover .react-flow__edge-path {
    stroke-width: 3;
}
