/* Custom Node Editor Styles */

#workflow-editor-container {
    background-color: #0B0F19;
    position: relative;
    overflow: hidden;
    user-select: none;
    cursor: grab;
    width: 100%;
    height: 100%;
}

.workflow-controls-top {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
    display: flex;
    gap: 10px;
}

.workflow-info-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(31, 41, 55, 0.9);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #374151;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.workflow-name-display {
    color: #F3F4F6;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.workflow-unsaved-indicator {
    color: #fbbf24;
    font-size: 1.2rem;
    line-height: 0.5;
    display: none;
}

.workflow-unsaved-indicator.visible {
    display: inline-block;
}

.workflow-select {
    background: #111827;
    border: 1px solid #4B5563;
    color: #D1D5DB;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 150px;
}

.workflow-select:hover {
    border-color: #981c13;
}

.workflow-select:focus {
    border-color: #FF6B4A;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

#workflow-editor-container:active {
    cursor: grabbing;
}

/* Internal Canvas Layer (Transformed) */
#editor-canvas {
    transform-origin: 0 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Background Pattern */
.editor-background {
    position: absolute;
    top: -5000px;
    left: -5000px;
    width: 10000px;
    height: 10000px;
    pointer-events: none;
    background-image: radial-gradient(#1F2937 1.5px, transparent 1.5px);
    background-size: 30px 30px;
    z-index: 0;
}

/* SVG Layer for Connections */
#connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

.connection-line {
    fill: none;
    stroke: #981c13;
    stroke-width: 3px;
    stroke-linecap: round;
    pointer-events: visibleStroke;
    transition: stroke 0.2s;
}

.connection-line:hover {
    stroke: #A855F7;
    cursor: pointer;
}

/* Dragging Connection Line */
.drag-line {
    stroke: #D2F800;
    /* Lime for active dragging */
    stroke-dasharray: 5, 5;
}

/* Node Container */
.node {
    position: absolute;
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid #374151;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    min-width: 280px;
    color: #F3F4F6;
    font-family: 'Inter', sans-serif;
    z-index: 2;
    display: flex;
    flex-direction: column;
}

.node.selected {
    border: 2px solid #D2F800;
    /* Visible Selection Highlight */
    box-shadow: 0 0 0 4px rgba(210, 248, 0, 0.2);
    z-index: 10;
}

.node.bypassed {
    opacity: 0.5;
    filter: grayscale(100%);
    pointer-events: none;
    /* Only if we want them unclickable, but user might want to un-bypass */
}

.node.bypassed .node-header,
.node.bypassed .node-content {
    pointer-events: auto;
    /* Allow header interactions to move/select/un-bypass */
}

/* Node Header */
.node-header {
    background: #2D3748;
    padding: 10px 15px;
    border-bottom: 1px solid #4A5568;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.node-title {
    color: #E2E8F0;
    pointer-events: none;
}

/* Node Content */
.node-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    /* For socket positioning */
}

/* Inputs in Node */
.node-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.node-label {
    font-size: 0.75rem;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.node-control {
    background: #374151;
    border: 1px solid #4B5563;
    color: #F3F4F6;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s;
}

.node-control:focus {
    outline: none;
    border-color: #981c13;
    background: #4B5563;
}

textarea.node-control {
    resize: vertical;
    min-height: 80px;
}

/* Sockets (Ports) */
.socket {
    width: 16px;
    height: 16px;
    background: #4B5563;
    border: 2px solid #1F2937;
    border-radius: 50%;
    position: absolute;
    /* top is set inline by JS renderer */
    cursor: crosshair;
    transition: transform 0.2s, background 0.2s;
    z-index: 10;
}

.socket:hover {
    transform: scale(1.3);
    background: #D2F800;
    /* Highlight on hover */
    border-color: #fff;
}

.socket.input {
    left: -10px;
    /* Stick out left */
    background: #981c13;
    /* Input color */
}

.socket.output {
    right: -10px;
    /* Stick out right */
    background: #FF6B4A;
    /* Output color */
}

/* Custom Context Menu */
.context-menu {
    position: fixed;
    /* Fixed to viewport */
    background: #1F2937;
    border: 1px solid #374151;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    padding: 6px;
    min-width: 180px;
    z-index: 1000;
    display: none;
}

.context-menu.active {
    display: block;
}

.menu-item {
    padding: 8px 12px;
    color: #E2E8F0;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.menu-item:hover {
    background: #981c13;
    color: white;
}

.menu-group-label {
    padding: 8px 12px;
    font-size: 0.75rem;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

/* Submenu Support */
.menu-item.has-submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.menu-item.has-submenu::after {
    content: "â–¶";
    font-size: 8px;
    margin-left: 8px;
    opacity: 0.5;
}

.submenu {
    position: absolute;
    left: 100%;
    top: -1px;
    background: #1F2937;
    border: 1px solid #374151;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    padding: 6px;
    min-width: 150px;
    display: none;
    z-index: 1001;
}

.menu-item.has-submenu:hover > .submenu {
    display: block;
}