/* CampfireValley Visualization Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Metrics Panel Styles */
.metrics-panel {
    width: 280px;
    background: #2d2d2d;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
}

.metrics-header {
    padding: 15px 20px;
    border-bottom: 1px solid #444;
    background: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metrics-header h3 {
    font-size: 16px;
    color: #ff6b35;
    margin: 0;
}

.btn-small {
    background: #555;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-small:hover {
    background: #666;
}

.metrics-content {
    padding: 20px;
    flex: 1;
}

.metric-group {
    margin-bottom: 25px;
}

.metric-group h4 {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metrics-grid {
    display: grid;
    gap: 10px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #3a3a3a;
    border-radius: 6px;
    border-left: 3px solid #ff6b35;
}

.metric-label {
    font-size: 12px;
    color: #aaa;
}

.metric-value {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
}

.metrics-list {
    max-height: 200px;
    overflow-y: auto;
}

.node-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    margin-bottom: 5px;
    background: #3a3a3a;
    border-radius: 4px;
    font-size: 11px;
}

.node-metric .node-name {
    color: #ccc;
    flex: 1;
}

.node-metric .node-status {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
}

.node-status.active {
    background: #4CAF50;
    color: white;
}

.node-status.idle {
    background: #ff9800;
    color: white;
}

.node-status.error {
    background: #f44336;
    color: white;
}

.metrics-panel.collapsed {
    width: 50px;
}

.metrics-panel.collapsed .metrics-content {
    display: none;
}

.metrics-panel.collapsed .metrics-header h3 {
    display: none;
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    background: #2d2d2d;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #444;
    background: #333;
}

.sidebar-header h1 {
    font-size: 18px;
    color: #ff6b35;
    margin-bottom: 5px;
}

.sidebar-header .status {
    font-size: 12px;
    color: #888;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.control-group {
    margin-bottom: 25px;
}

.control-group h3 {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-item {
    margin-bottom: 10px;
}

.control-item label {
    display: block;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 5px;
}

.control-item input[type="range"] {
    width: 100%;
    height: 4px;
    background: #444;
    outline: none;
    border-radius: 2px;
}

.control-item input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #ff6b35;
    border-radius: 50%;
    cursor: pointer;
}

/* Task Section Styles */
.task-section {
    background: #333;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.task-section h3 {
    color: #ff6b35;
    margin-bottom: 15px;
    font-size: 16px;
}

#taskInput {
    width: 100%;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
}

#taskInput:focus {
    outline: none;
    border-color: #ff6b35;
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
}

.start-task-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.start-task-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.start-task-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.stop-task-btn {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stop-task-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #d32f2f, #b71c1c);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.3);
}

.stop-task-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.task-status {
    margin-top: 10px;
    padding: 8px 12px;
    background: #2a2a2a;
    border-radius: 4px;
    border-left: 4px solid #4CAF50;
}

.task-status.processing {
    border-left-color: #ff9800;
    animation: pulse 2s infinite;
}

.task-status.error {
    border-left-color: #f44336;
}

.task-status .status-text {
    font-size: 12px;
    color: #ccc;
}

.task-status.processing .status-text {
    color: #ffa500;
    font-weight: bold;
}

.task-status.completed .status-text {
    color: #28a745;
    font-weight: bold;
}

.task-status.error .status-text {
    color: #dc3545;
    font-weight: bold;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.control-item button {
    background: #ff6b35;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.control-item button:hover {
    background: #e55a2b;
}

.control-item button:disabled {
    background: #666;
    cursor: not-allowed;
}

/* Main Canvas Area */
.main-area {
    flex: 1;
    position: relative;
    background: #1a1a1a;
}

.canvas-container {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    overflow: hidden;
    border-radius: 8px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    cursor: grab;
}

.canvas-container.dragging {
    cursor: grabbing;
}

.main-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    background: transparent;
}

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

.main-canvas.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Canvas UI overlays */
.canvas-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 100;
}

.canvas-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.canvas-controls button {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #444;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.canvas-controls button:hover {
    background: rgba(255, 107, 53, 0.8);
    border-color: #FF6B35;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ccc;
    font-size: 18px;
    z-index: 10;
}

/* Toolbar */
.toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.toolbar button {
    background: rgba(45, 45, 45, 0.9);
    color: white;
    border: 1px solid #555;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.toolbar button:hover {
    background: rgba(255, 107, 53, 0.8);
    border-color: #ff6b35;
}

.toolbar button.active {
    background: #ff6b35;
    border-color: #ff6b35;
}

/* Minimap */
.minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: rgba(45, 45, 45, 0.9);
    border: 1px solid #555;
    border-radius: 6px;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.minimap-header {
    padding: 8px 12px;
    border-bottom: 1px solid #555;
    font-size: 12px;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.minimap-canvas {
    width: 100%;
    height: calc(100% - 32px);
    background: #222;
}

/* Node Styles */
.node {
    position: absolute;
    border-radius: 8px;
    border: 2px solid;
    background: rgba(45, 45, 45, 0.9);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.node:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.3);
}

.node.selected {
    border-color: #ff6b35 !important;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.5);
}

.node.valley {
    border-color: #4CAF50;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2), rgba(45, 45, 45, 0.9));
}

.node.campfire {
    border-color: #ff6b35;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.2), rgba(45, 45, 45, 0.9));
}

.node.camper {
    border-color: #2196F3;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.2), rgba(45, 45, 45, 0.9));
}

.node.torch {
    border-color: #FFC107;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(45, 45, 45, 0.9));
}

.node-header {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.node-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.node-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    flex: 1;
}

.node-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
}

.node-status.active {
    background: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.node-status.inactive {
    background: #f44336;
}

.node-status.pending {
    background: #FFC107;
}

.node-content {
    padding: 12px;
}

.node-metric {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
}

.node-metric-label {
    color: #aaa;
}

.node-metric-value {
    color: #fff;
    font-weight: 500;
}

/* Connection Lines */
.connection {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    stroke-width: 2;
    fill: none;
    transition: all 0.3s ease;
}

.connection.torch-flow {
    stroke: #FFC107;
    stroke-dasharray: 5, 5;
    animation: torch-flow 2s linear infinite;
}

.connection.management {
    stroke: #2196F3;
    stroke-width: 1;
    opacity: 0.6;
}

.connection.data-flow {
    stroke: #4CAF50;
    stroke-width: 1.5;
    opacity: 0.8;
}

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

/* Loading and Status */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #aaa;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top: 3px solid #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: rgba(45, 45, 45, 0.9);
    border-top: 1px solid #555;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 12px;
    color: #aaa;
    backdrop-filter: blur(10px);
}

.status-item {
    margin-right: 20px;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-indicator.connected {
    background: #4CAF50;
}

.status-indicator.disconnected {
    background: #f44336;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    .minimap {
        width: 150px;
        height: 100px;
    }
    
    .toolbar {
        top: 10px;
        right: 10px;
    }
    
    .toolbar button {
        padding: 8px;
        font-size: 12px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #2d2d2d;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* LiteGraph Container Styles */
.litegraph-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    overflow: hidden;
}

.litegraph-header {
    background: #2a2a2a;
    padding: 10px 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
}

.litegraph-header h2 {
    color: #fff;
    margin: 0;
    font-size: 1.5em;
    font-weight: bold;
}

.litegraph-controls {
    display: flex;
    gap: 10px;
}

.litegraph-controls .btn {
    padding: 8px 16px;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.litegraph-controls .btn:hover {
    background: #444;
    border-color: #666;
}

.litegraph-canvas {
    flex: 1;
    width: 100%;
    background: #1a1a1a;
    border: none;
    outline: none;
}

/* LiteGraph Overrides */
.litegraph {
    background: #1a1a1a !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

.litegraph .lgraphnode {
    background: #2a2a2a !important;
    border: 1px solid #444 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
    min-width: 160px !important;
}

.litegraph .lgraphnode.selected {
    border-color: #4a9eff !important;
    box-shadow: 0 0 15px rgba(74, 158, 255, 0.6) !important;
}

.litegraph .lgraphnode .title {
    background: #333 !important;
    color: #fff !important;
    font-weight: bold !important;
    padding: 6px 12px !important;
    border-radius: 8px 8px 0 0 !important;
    font-size: 13px !important;
    text-align: center !important;
}

.litegraph .lgraphnode .content {
    padding: 8px 12px !important;
    color: #ccc !important;
    font-size: 12px !important;
}

.litegraph .connection {
    stroke: #4a9eff !important;
    stroke-width: 3px !important;
    opacity: 0.8 !important;
}

.litegraph .connection.highlighted {
    stroke: #ffaa00 !important;
    stroke-width: 4px !important;
    opacity: 1 !important;
}

/* Custom node type colors */
.litegraph .lgraphnode[data-type="campfire/valley"] .title {
    background: linear-gradient(135deg, #2d5a2d, #4a8f4a) !important;
}

.litegraph .lgraphnode[data-type="campfire/dock"] .title {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6) !important;
}

.litegraph .lgraphnode[data-type="campfire/dockmaster_campfire"] .title {
    background: linear-gradient(135deg, #7c2d12, #ea580c) !important;
}

.litegraph .lgraphnode[data-type="campfire/sanitizer_campfire"] .title {
    background: linear-gradient(135deg, #7f1d1d, #ef4444) !important;
}

.litegraph .lgraphnode[data-type="campfire/justice_campfire"] .title {
    background: linear-gradient(135deg, #581c87, #8b5cf6) !important;
}

.litegraph .lgraphnode[data-type="campfire/campfire"] .title {
    background: linear-gradient(135deg, #8b4513, #cd853f) !important;
}

.litegraph .lgraphnode[data-type="campfire/loader_camper"] .title,
.litegraph .lgraphnode[data-type="campfire/router_camper"] .title,
.litegraph .lgraphnode[data-type="campfire/packer_camper"] .title {
    background: linear-gradient(135deg, #064e3b, #10b981) !important;
}

.litegraph .lgraphnode[data-type="campfire/scanner_camper"] .title,
.litegraph .lgraphnode[data-type="campfire/filter_camper"] .title,
.litegraph .lgraphnode[data-type="campfire/quarantine_camper"] .title {
    background: linear-gradient(135deg, #7f1d1d, #f87171) !important;
}

.litegraph .lgraphnode[data-type="campfire/detector_camper"] .title,
.litegraph .lgraphnode[data-type="campfire/enforcer_camper"] .title,
.litegraph .lgraphnode[data-type="campfire/governor_camper"] .title {
    background: linear-gradient(135deg, #4c1d95, #a78bfa) !important;
}

.litegraph .lgraphnode[data-type="campfire/camper"] .title {
    background: linear-gradient(135deg, #4682b4, #87ceeb) !important;
}

.litegraph .lgraphnode[data-type="campfire/task_input"] .title {
    background: linear-gradient(135deg, #6a5acd, #9370db) !important;
}

.litegraph .lgraphnode[data-type="campfire/view_mode"] .title {
    background: linear-gradient(135deg, #20b2aa, #48d1cc) !important;
}

.litegraph .lgraphnode[data-type="campfire/filter"] .title {
    background: linear-gradient(135deg, #ff8c00, #ffa500) !important;
}

.litegraph .lgraphnode[data-type="campfire/zoom_control"] .title {
    background: linear-gradient(135deg, #32cd32, #90ee90) !important;
}

.litegraph .lgraphnode[data-type="campfire/display_options"] .title {
    background: linear-gradient(135deg, #da70d6, #dda0dd) !important;
}

.litegraph .lgraphnode[data-type="campfire/node_details"] .title {
    background: linear-gradient(135deg, #ffd700, #ffff00) !important;
    color: #333 !important;
}

.litegraph .lgraphnode[data-type="campfire/status_legend"] .title {
    background: linear-gradient(135deg, #dc143c, #ff6347) !important;
}

.litegraph .lgraphnode[data-type="campfire/websocket_data"] .title {
    background: linear-gradient(135deg, #ff6347, #ff7f50) !important;
}

/* Node input/output slots */
.litegraph .slot {
    background: #555 !important;
    border: 1px solid #777 !important;
}

.litegraph .slot.input {
    background: #4a9eff !important;
}

.litegraph .slot.output {
    background: #ff6b6b !important;
}

/* Context menu styling */
.litegraph .litecontextmenu {
    background: #2a2a2a !important;
    border: 1px solid #555 !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}

.litegraph .litecontextmenu .item {
    color: #ccc !important;
    padding: 8px 16px !important;
}

.litegraph .litecontextmenu .item:hover {
    background: #444 !important;
    color: #fff !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .litegraph-header {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        min-height: auto;
    }
    
    .litegraph-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .litegraph-controls .btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .litegraph .lgraphnode {
        min-width: 140px !important;
    }
    
    .litegraph .lgraphnode .title {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }
    
    .litegraph .lgraphnode .content {
        font-size: 10px !important;
        padding: 6px 8px !important;
    }
}