/* Node Styles */
.node {
    background: #1a1a2e;
    border: 2px solid #2d3748;
    border-radius: 12px;
    min-width: 160px;
    max-width: 220px;
    position: absolute;
    cursor: move;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    z-index: 10;
    user-select: none;
}

.node:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.node.selected {
    border-color: #00ff41;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.node.dragging {
    z-index: 1000;
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

/* Node Header with Category and Stage */
.node-header {
    background: linear-gradient(135deg, #2d3748, #374151);
    border-bottom: 1px solid #374151;
    border-radius: 10px 10px 0 0;
    padding: 8px 12px;
    position: relative;
}

.node-title {
    color: #e0e7ff;
    font-weight: bold;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: move;
}

.node-stage {
    position: absolute;
    top: -6px;
    right: 8px;
    background: #00ff41;
    color: #000;
    font-size: 8px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.node-content {
    padding: 12px;
    position: relative;
}

.node-subtitle {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.node-note {
    font-size: 10px;
    color: #00ff41;
    margin-bottom: 6px;
    font-weight: 600;
}

/* Node Play Button */
.node-play-btn {
    background: #00ff41;
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
    margin-top: 8px;
    width: 100%;
    transition: all 0.2s;
}

.node-play-btn:hover {
    background: #00d9ff;
    transform: translateY(-1px);
}

/* Child Port for Hierarchical Nodes */
.child-port {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #00ff41;
    border: 2px solid #1a1a2e;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #000;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 255, 65, 0.3);
}

.child-port:hover {
    background: #00d9ff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.4);
}

.child-port .child-count {
    position: absolute;
    top: -8px;
    left: -8px;
    background: #ff006e;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1a1a2e;
}

/* Hierarchical Node States */
.node.dimmed {
    opacity: 0.3;
    filter: grayscale(50%);
    pointer-events: none;
}

.node.child-level {
    border-color: #00d9ff;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.node.child-level .node-header {
    border-left-color: #00d9ff;
}

/* Enhanced Node Subtitle for Hierarchical Content */
.node-subtitle {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 8px;
    line-height: 1.3;
}

.node-subtitle .hierarchical-content {
    color: #00d9ff;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    background: rgba(0, 217, 255, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    margin-left: 8px;
    border-left: 2px solid #00d9ff;
}

.node-subtitle .child-summary {
    display: block;
    color: #00ff41;
    font-size: 10px;
    margin-top: 4px;
    font-weight: 500;
}

/* Navigation Breadcrumb */
.navigation-breadcrumb {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: #e0e7ff;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.navigation-breadcrumb .breadcrumb-item {
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

.navigation-breadcrumb .breadcrumb-item:hover {
    color: #00ff41;
}

.navigation-breadcrumb .breadcrumb-separator {
    color: #374151;
    margin: 0 6px;
}

.navigation-breadcrumb .current-level {
    color: #00ff41;
    font-weight: 600;
}

/* Double-click hint */
.node .double-click-hint {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: #666;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.node:hover .double-click-hint {
    opacity: 1;
}

/* Node Category Color Coding - Based on Execution Stages */
.node-category-source .node-header {
    border-left: 4px solid #00d9ff;
    background: linear-gradient(135deg, #1e3a8a, #3730a3);
}

.node-category-structural .node-header {
    border-left: 4px solid #ff006e;
    background: linear-gradient(135deg, #7c2d12, #9a3412);
}

.node-category-rhythmic .node-header {
    border-left: 4px solid #fbbf24;
    background: linear-gradient(135deg, #92400e, #b45309);
}

.node-category-effect .node-header,
.node-category-spectral .node-header {
    border-left: 4px solid #9400d3;
    background: linear-gradient(135deg, #581c87, #7c3aed);
}

.node-category-space .node-header {
    border-left: 4px solid #8b5cf6;
    background: linear-gradient(135deg, #3730a3, #6366f1);
}

.node-category-wrapper .node-header {
    border-left: 4px solid #00ff41;
    background: linear-gradient(135deg, #14532d, #15803d);
}

.node-category-control .node-header,
.node-category-modulation .node-header {
    border-left: 4px solid #ffa500;
    background: linear-gradient(135deg, #92400e, #d97706);
}

.node-category-pitch .node-header {
    border-left: 4px solid #ec4899;
    background: linear-gradient(135deg, #9f1239, #e11d48);
}

/* Legacy node type color coding for backward compatibility */
.node-DrumSymbol .node-header,
.node-Instrument .node-header,
.node-instrument .node-header {
    border-left: 4px solid #00d9ff;
    background: linear-gradient(135deg, #1e3a8a, #3730a3);
}

.node-Repeater .node-header,
.node-multiplier .node-header {
    border-left: 4px solid #ff006e;
    background: linear-gradient(135deg, #7c2d12, #9a3412);
}

.node-Group .node-header,
.node-group .node-header {
    border-left: 4px solid #8b5cf6;
    background: linear-gradient(135deg, #3730a3, #6366f1);
}

.node-Chance .node-header {
    border-left: 4px solid #00ff41;
    background: linear-gradient(135deg, #14532d, #15803d);
}

.node-Effect .node-header {
    border-left: 4px solid #9400d3;
    background: linear-gradient(135deg, #581c87, #7c3aed);
}

.node-Generator .node-header,
.node-Transform .node-header {
    border-left: 4px solid #ffa500;
    background: linear-gradient(135deg, #92400e, #d97706);
}

.node-Output .node-header,
.node-note .node-header {
    border-left: 4px solid #9400d3;
    background: linear-gradient(135deg, #581c87, #7c3aed);
}

.node-rest .node-header {
    border-left: 4px solid #666;
    background: linear-gradient(135deg, #374151, #4b5563);
}

.node-stack .node-header {
    border-left: 4px solid #00ff41;
    background: linear-gradient(135deg, #14532d, #15803d);
}

.node-parallel .node-header {
    border-left: 4px solid #ffa500;
    background: linear-gradient(135deg, #92400e, #d97706);
}

/* Canvas Content for Node Editor */
#node-canvas {
    flex: 1;
    background: var(--bg-darkest);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    min-height: 400px;
    margin-bottom: 12px;
}

/* Canvas Search Toolbar */
.canvas-search-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 1000;
    display: none;
}

.canvas-search-toolbar.active {
    display: block;
}

.search-container {
    display: flex;
    gap: 8px;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 8px;
    backdrop-filter: blur(10px);
}

.node-search-input {
    flex: 1;
    background: #1a1a2e;
    border: 1px solid #4b5563;
    border-radius: 4px;
    padding: 8px 12px;
    color: #e0e7ff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.node-search-input:focus {
    border-color: #00ff41;
}

.node-search-input::placeholder {
    color: #6b7280;
}

.search-btn {
    background: #00ff41;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    color: #0f0f1b;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.search-btn:hover {
    background: #00cc33;
    transform: translateY(-1px);
}

.search-results {
    margin-top: 8px;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid #2d3748;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    backdrop-filter: blur(10px);
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #2d3748;
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(0, 255, 65, 0.1);
}

.search-result-item.selected {
    background: rgba(0, 255, 65, 0.15);
    border-left: 2px solid #00ff41;
}

.search-result-item .result-name {
    font-weight: 600;
    color: #00ff41;
    margin-bottom: 2px;
}

.search-result-item .result-category {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
}

/* Canvas Context Menu */
.canvas-context-menu {
    position: fixed;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 8px 0;
    min-width: 180px;
    z-index: 10000;
    display: none;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-size: 13px;
}

.canvas-context-menu.visible {
    display: block;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    color: #e0e7ff;
    font-size: 13px;
}

.context-menu-item:hover {
    background: rgba(0, 255, 65, 0.1);
}

.context-menu-item i {
    width: 16px;
    color: #00ff41;
    font-size: 12px;
}

.context-menu-divider {
    height: 1px;
    background: #2d3748;
    margin: 8px 0;
}

.canvas-content {
    width: 100%;
    height: 100%;
    position: relative;
    background-image:
        linear-gradient(var(--bg-darkest) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-darkest) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Canvas Toolbar */
.canvas-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(26, 26, 46, 0.9);
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.toolbar-btn {
    background: #374151;
    border: 1px solid #4b5563;
    color: #e0e7ff;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #4b5563;
    border-color: #00ff41;
}

.toolbar-btn.active {
    background: #00ff41;
    color: #000;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(26, 26, 46, 0.9);
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 100;
}

.zoom-btn {
    background: #374151;
    border: 1px solid #4b5563;
    color: #e0e7ff;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: #4b5563;
    border-color: #00ff41;
}

.zoom-level {
    color: #94a3b8;
    font-size: 11px;
    text-align: center;
    padding: 5px;
}

/* Error Message */
.error-message {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #ff006e;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(255, 0, 110, 0.4);
    max-width: 300px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Node Properties Panel - Essential Styles */
#node-properties {
    color: #e0e7ff;
}

.node-info {
    background: #0f0f1b;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #374151;
}

.node-info h3 {
    color: #00d9ff;
    margin: 0 0 8px 0;
    font-size: 16px;
}

.node-id {
    color: #94a3b8;
    font-size: 12px;
    margin: 0;
}

.property-section {
    background: #0f0f1b;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #374151;
    overflow: hidden;
}

.property-section h4 {
    background: #1a1a2e;
    color: #00ff41;
    margin: 0;
    padding: 12px 15px;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid #374151;
}

.property-controls {
    padding: 15px;
}

.property-control {
    margin-bottom: 15px;
}

.property-control:last-child {
    margin-bottom: 0;
}

.property-control label {
    display: block;
    color: #94a3b8;
    font-size: 12px;
    margin-bottom: 8px;
    font-weight: 500;
}

/* Side Panel Styles */
#side-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 380px;
    height: 100vh;
    background: #1a1a2e;
    border-left: 1px solid #2d3748;
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding: 20px;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
}

#side-panel.closed {
    right: -400px;
}

.side-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #374151;
}

.side-panel-header h3 {
    color: #00ff41;
    margin: 0;
    font-size: 16px;
}

.side-panel-close {
    background: none;
    border: none;
    color: #e0e7ff;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.side-panel-close:hover {
    background: #374151;
    color: #00ff41;
}

#node-properties .property-group {
    margin-bottom: 20px;
}

#node-properties label {
    display: block;
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 500;
}

#node-properties select,
#node-properties input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    background: #0f0f1b;
    border: 1px solid #374151;
    color: #e0e7ff;
    border-radius: 6px;
    font-size: 13px;
}

#node-properties select:focus,
#node-properties input[type="text"]:focus {
    border-color: #00ff41;
    outline: none;
}

#node-properties input[type="range"] {
    width: 100%;
    margin: 8px 0;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #374151;
    outline: none;
}

#node-properties input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00ff41;
    cursor: pointer;
}

#node-properties input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00ff41;
    cursor: pointer;
    border: none;
}

#node-properties .value {
    display: inline-block;
    color: #00d9ff;
    font-size: 12px;
    font-weight: bold;
    min-width: 40px;
    text-align: right;
}

#node-properties .btn {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    font-size: 12px;
}

/* Effects Section Styles */
.effects-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #374151;
}

.effects-section h4 {
    color: #00d9ff;
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: bold;
}

.effects-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.effect-item {
    background: #0f0f1b;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #374151;
}

.effect-item label {
    display: flex;
    align-items: center;
    color: #e0e7ff;
    font-size: 13px;
    margin-bottom: 10px;
    cursor: pointer;
}

.effect-item input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.1);
    accent-color: #00ff41;
}

.effect-item input[type="checkbox"]:checked + label {
    color: #00ff41;
}

.effect-item input[type="range"] {
    margin: 10px 0 5px 0;
}

.effect-value {
    display: block;
    color: #00d9ff;
    font-size: 11px;
    text-align: right;
    font-weight: bold;
}

.effect-item input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.effect-item input[type="range"]:disabled::-webkit-slider-thumb {
    background: #666;
    cursor: not-allowed;
}

.effect-item input[type="range"]:disabled::-moz-range-thumb {
    background: #666;
    cursor: not-allowed;
}

#apply-effects {
    background: #00ff41;
    color: #000;
}

#apply-effects:hover {
    background: #00d9ff;
}

#clear-effects {
    background: #374151;
    color: #e0e7ff;
}

#clear-effects:hover {
    background: #4b5563;
}

/* Canvas Controls - Pan and Zoom */
.canvas-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

.control-group {
    background: rgba(26, 26, 46, 0.9);
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
}

.control-btn {
    background: #374151;
    border: 1px solid #4b5563;
    color: #e0e7ff;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.control-btn:hover {
    background: #4b5563;
    border-color: #00ff41;
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn.active {
    background: #00ff41;
    color: #000;
    border-color: #00ff41;
}

.back-btn {
    background: #ff006e;
    color: white;
    border-color: #ff006e;
}

.back-btn:hover {
    background: #ff4081;
    border-color: #ff4081;
    transform: translateY(-1px);
}

.back-btn:disabled {
    background: #374151;
    color: #666;
    border-color: #374151;
    cursor: not-allowed;
    transform: none;
}

.pan-btn.active {
    background: #00d9ff;
    color: #000;
}

.zoom-level {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    padding: 0 8px;
    min-width: 45px;
    text-align: center;
    border-left: 1px solid #4b5563;
    margin-left: 4px;
    padding-left: 8px;
}

/* Canvas Transformation Styles */
.canvas-content {
    width: 100%;
    height: 100%;
    position: relative;
    background-image:
        linear-gradient(var(--bg-darkest) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-darkest) 1px, transparent 1px);
    background-size: 20px 20px;
    transition: transform 0.2s ease;
    cursor: default;
}

.canvas-content.pan-tool-active {
    cursor: grab;
}

.canvas-content.pan-tool-active:active {
    cursor: grabbing;
}

.canvas-content.zoomed {
    transform-origin: 0 0;
}

/* Canvas Panning Cursor States */
.canvas-panning {
    cursor: grab;
}

.canvas-panning:active {
    cursor: grabbing;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .canvas-controls {
        top: 5px;
        right: 5px;
    }
    
    .control-group {
        padding: 4px;
        gap: 4px;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .zoom-level {
        font-size: 11px;
        padding: 0 6px;
        min-width: 40px;
    }
}