/* Node Editor Styles */
.node-editor {
    height: 100%;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 20px 20px, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 40px 40px;
}

.add-node-btn-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

/* Node Styles */
.node {
    position: absolute;
    background: linear-gradient(145deg, #404040, #303030);
    border: 1px solid #555;
    border-radius: 8px;
    min-width: 180px;
    min-height: 80px;
    cursor: move;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    user-select: none;
    z-index: 2;
}

.source-node {
    background: linear-gradient(145deg, #7c5770, #5c4155);
    border-color: #9c6c8c;
}

.processing-node {
    background: linear-gradient(145deg, #88683aff, #7c5a2bff);
    border-color: #a57f4aff;
}

.visualisation-node {
    background: linear-gradient(145deg, #577c73, #415c57);
    border-color: #6c9c8e;
}

.node-header {
    background: #555;
    padding: 8px 12px;
    border-radius: 7px 7px 0 0;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.source-node .node-header { background: #9c6c8c; }
.processing-node .node-header { background: #a57f4aff; }
.visualisation-node .node-header { background: #6c9c8e; }

.node-tag {
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.node-body {
    padding: 15px;
    position: relative;
}

.node-body p {
    font-size: 14px;
    margin: 5px 0;
}

.node-body .port-name {
    font-size: 12px;
    color: #aaa;
}

/* Port Styles */
.port {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    top: 0;
    bottom: 0;
    margin: auto 0;
    cursor: crosshair;
    border: 2px solid #666;
    transition: all 0.2s ease;
    z-index: 3;
}

.input-port {
    left: -6px;
    background: #4a90e2;
}

.output-port {
    right: -6px;
    background: #7ed321;
}

.port:hover {
    transform: scale(1.3);
    border-color: #fff;
}

.port.connecting {
    border-color: #ff6b6b;
    box-shadow: 0 0 10px #ff6b6b;
}

/* Connection Styles */
.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-hitbox {
    fill: none;
    stroke: transparent;
    stroke-width: 16;
    cursor: pointer;
    pointer-events: all;
}

.connection-path {
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-dasharray: 8 4;
    animation: flow 0.4s linear infinite;
    pointer-events: none;
    transition: stroke-width 0.2s ease, stroke 0.2s ease, filter 0.2s ease;
}

.connection-hitbox:hover + .connection-path {
    stroke-width: 3;
    stroke: #ff6b6b;
    filter: drop-shadow(0 0 5px #ff6b6b);
}

@keyframes flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -12; }
}

.temp-connection {
    fill: none;
    stroke: #ff6b6b;
    stroke-width: 2;
    stroke-dasharray: 4 2;
    opacity: 0.7;
}

/* Widget Grid Styles */
.widget-grid {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(15, 1fr);
    gap: 2px;
    height: 100%;
    padding: 10px;
    position: relative;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: calc(100% / 20) calc(100% / 15);
}

.widget-grid:hover .grid-overlay { opacity: 1; }

/* Widget Styles */
.widget {
    background: linear-gradient(145deg, #577c73, #415c57);
    border: 2px solid #6c9c8e;
    border-radius: 8px;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: calc(var(--grid-size) * 2);
    min-width: calc(var(--grid-size) * 2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.widget-header {
    background: #6c9c8e;
    padding: 8px 12px;
    border-radius: 6px 6px 0 0;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
}

.widget-header:active { cursor: grabbing; }

.widget-content {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: #6c9c8e;
    cursor: se-resize;
    border-radius: 0 0 6px 0;
}

.resize-handle::after {
    content: '⋰';
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    color: white;
}

.widget-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: color 0.2s ease;
}

.widget-close:hover { color: #ff6b6b; }

/* Mobile Responsive Styles for Components */
@media (max-width: 768px) {
    .widget-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        padding: 5px;
    }
    
    .widget {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        min-height: auto;
    }

    .widget-content { font-size: 12px; }
    .widget-content div { font-size: 18px !important; }
    .widget-content div > div { font-size: 14px !important; }
}