/* CSS for CNC Animator V2 with Debug View */

.cnc-simulator-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1e1e1e;
    color: #d4d4d4;
    overflow: visible;
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    max-width: 100%;
}

/* Viewer (Canvas) */
.cnc-simulator-viewer {
    flex: 1;
    position: relative;
    background: #121212;
    /* Darker background for contrast */
    overflow: hidden;
    border-bottom: 1px solid #333;
}

.cnc-simulator-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

/* Controls */
.cnc-simulator-controls {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    background: #252526;
    border-bottom: 1px solid #333;
    gap: 10px;
    flex-shrink: 0;
}

.cnc-btn {
    background: #0e639c;
    border: none;
    color: white;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.cnc-btn:hover {
    background: #1177bb;
}

.cnc-btn:active {
    transform: translateY(1px);
}

.cnc-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #ccc;
}

.cnc-slider {
    -webkit-appearance: none;
    appearance: none;
    background: #444;
    height: 4px;
    border-radius: 2px;
    width: 100px;
}

.cnc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #0e639c;
    border-radius: 50%;
    cursor: pointer;
}

.cnc-status {
    margin-left: auto;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    color: #aaddff;
}

/* Example Selector */
.cnc-example-select {
    background: #2d2d2d;
    color: #d4d4d4;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    min-width: 160px;
}

.cnc-example-select:hover {
    border-color: #0e639c;
}

.cnc-example-select:focus {
    outline: none;
    border-color: #0e639c;
}

/* Split View: Editor + Debug */
.cnc-split-view {
    display: flex;
    height: 300px;
    border-top: 1px solid #333;
    background: #1e1e1e;
}

.cnc-editor-pane,
.cnc-debug-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.cnc-editor-pane {
    border-right: 1px solid #333;
}

.cnc-pane-header {
    background: #2d2d2d;
    padding: 5px 10px;
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    font-weight: bold;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

/* Monaco Editor container */
.cnc-editor-container {
    width: 100%;
    height: calc(100% - 28px);
    /* Subtract header height */
    position: absolute;
    top: 28px;
    left: 0;
}

.cnc-code-line {
    padding: 0;
    white-space: pre;
    color: #bbb;
    display: flex;
}

.cnc-line-num {
    color: #555;
    margin-right: 10px;
    min-width: 35px;
    text-align: right;
    user-select: none;
}

.cnc-line-content {
    flex: 1;
}

.cnc-code-line.active-line {
    background-color: #37373d;
    color: #fff;
}

.cnc-code-line.active-line .cnc-line-num {
    color: #fff;
}

/* Monaco Editor Active Line Decorations */
.active-line-decoration {
    background-color: rgba(255, 215, 0, 0.2) !important;
    /* Gold background */
}

.active-line-gutter {
    background: #ffd700;
    /* Gold bar in gutter */
    width: 3px !important;
    margin-left: 3px;
}

/* Debug Output */
.cnc-debug-output {
    padding: 10px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    color: #9cdcfe;
    height: 100%;
}

.debug-entry {
    margin-bottom: 4px;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 2px;
}

.debug-entry .var {
    color: #ce9178;
}

/* Strings/Vars */
.debug-entry .val {
    color: #b5cea8;
}

/* Numbers */
.debug-entry .Op {
    color: #569cd6;
}

/* Operators */

/* === SYNTAX HIGHLIGHTING === */

/* Comments (text in parentheses) */
.hl-comment {
    color: #6a9955;
    font-style: italic;
}

/* G-codes (movement commands) */
.hl-gcode {
    color: #4ec9b0;
    font-weight: bold;
}

/* M-codes (machine functions) */
.hl-mcode {
    color: #4fc1ff;
    font-weight: bold;
}

/* Variables #NNN */
.hl-variable {
    color: #c586c0;
    font-weight: bold;
}

/* Tool numbers T1, T2... */
.hl-tool {
    color: #ff9d00;
    font-weight: bold;
}

/* Spindle speed S#### */
.hl-spindle {
    color: #dcdcaa;
}

/* Feed rate F### */
.hl-feed {
    color: #b5cea8;
}

/* Axis letters X, Y, Z, etc. */
.hl-axis {
    color: #9cdcfe;
}

/* Coordinate values */
.hl-coord {
    color: #ce9178;
}

/* N line numbers */
.hl-nline {
    color: #858585;
}

/* Control structures (WHILE, IF, THEN, etc.) */
.hl-control {
    color: #c586c0;
    font-weight: bold;
}

/* Math functions (SIN, COS, etc.) */
.hl-math {
    color: #dcdcaa;
}

/* Program header O#### and % */
.hl-program {
    color: #ffd700;
    font-weight: bold;
}

/* === FLOATING PANELS === */

/* Debug/Calc Overlay - Floating over canvas */
.cnc-debug-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 200px;
    max-height: 150px;
    background: rgba(30, 30, 46, 0.85);
    border: 1px solid rgba(100, 100, 140, 0.5);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    z-index: 100;
    pointer-events: auto;
    transition: all 0.3s ease;
    overflow: hidden;
}

.cnc-debug-overlay.collapsed {
    width: auto;
    max-height: 32px;
}

.cnc-debug-overlay.collapsed .cnc-overlay-content {
    display: none;
}

.cnc-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(45, 45, 70, 0.9);
    border-bottom: 1px solid rgba(100, 100, 140, 0.3);
    font-size: 11px;
    color: #aaa;
}

.cnc-overlay-toggle {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
}

.cnc-overlay-toggle:hover {
    color: #fff;
}

.cnc-overlay-content {
    padding: 8px;
    font-size: 11px;
    max-height: 110px;
    overflow-y: auto;
}

/* Tools Panel - Collapsible on side */
.cnc-tools-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(30, 30, 46, 0.9);
    border: 1px solid rgba(100, 100, 140, 0.5);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    z-index: 100;
    transition: all 0.3s ease;
    overflow: hidden;
}

.cnc-tools-panel.collapsed .cnc-tools-content {
    display: none;
}

.cnc-tools-toggle {
    background: rgba(45, 45, 70, 0.9);
    border: none;
    color: #ccc;
    font-size: 18px;
    padding: 8px 12px;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

.cnc-tools-toggle:hover {
    background: rgba(65, 65, 90, 0.9);
}

.cnc-tools-content {
    width: 180px;
}

.cnc-tools-content .cnc-pane-header {
    padding: 6px 10px;
    font-size: 10px;
}

.cnc-tools-content .cnc-tool-list {
    padding: 8px;
    max-height: 150px;
    overflow-y: auto;
    font-size: 11px;
}

/* Example Bar */
.cnc-example-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: #252526;
    border-top: 1px solid #444;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.cnc-example-label {
    font-size: 12px;
    color: #888;
}

.cnc-example-bar .cnc-example-select {
    flex: 1;
    max-width: 250px;
}

/* Floating G-Code Editor Panel */
.cnc-editor-floating {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 400px;
    height: 320px;
    background: rgba(30, 30, 46, 0.5);
    border: 1px solid rgba(100, 100, 140, 0.4);
    border-radius: 8px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    overflow: hidden;
}

.cnc-editor-floating.collapsed {
    height: 36px;
    width: 200px;
}

.cnc-editor-floating.collapsed .cnc-editor-floating-content {
    display: none;
}

.cnc-editor-floating.maximized {
    width: 90%;
    height: 80%;
    top: 5%;
    left: 5%;
    right: auto;
    bottom: auto;
}

.cnc-editor-floating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(45, 45, 70, 0.7);
    border-bottom: 1px solid rgba(100, 100, 140, 0.3);
    cursor: grab;
    flex-shrink: 0;
}

.cnc-editor-floating-header:active {
    cursor: grabbing;
}

.cnc-editor-title {
    font-size: 12px;
    font-weight: 600;
    color: #e0e0e0;
}

.cnc-editor-controls {
    display: flex;
    gap: 4px;
}

.cnc-editor-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #aaa;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cnc-editor-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.cnc-editor-floating-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.cnc-editor-floating-content .cnc-editor-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Tablet Responsive */
@media (max-width: 1024px) {
    .cnc-simulator-container {
        margin: 10px auto;
    }

    .cnc-split-view {
        height: 280px;
    }

    .cnc-editor-pane {
        height: 260px;
        min-height: 260px;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .cnc-simulator-container {
        margin: 0;
        border-radius: 0;
    }

    .cnc-simulator-viewer {
        flex: 1;
        min-height: 0;
    }

    .cnc-debug-overlay {
        width: 120px;
        max-height: 80px;
        top: 5px;
        right: 5px;
        font-size: 9px;
    }

    .cnc-tools-panel {
        top: 5px;
        left: 5px;
    }

    .cnc-tools-content {
        width: 110px;
    }

    .cnc-example-bar {
        padding: 4px 6px;
        gap: 4px;
    }

    .cnc-example-bar .cnc-example-select {
        max-width: none;
        width: 100%;
        font-size: 11px;
    }

    .cnc-simulator-controls {
        flex-wrap: wrap;
        gap: 4px;
        padding: 4px 6px;
        justify-content: center;
    }

    .cnc-control-group {
        font-size: 10px;
    }

    .cnc-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .cnc-slider {
        width: 60px;
    }

    .cnc-status {
        font-size: 9px;
        margin-left: 0;
        width: 100%;
        text-align: center;
    }

    /* Floating editor - smaller on mobile */
    .cnc-editor-floating {
        width: 280px;
        height: 200px;
        bottom: 5px;
        right: 5px;
    }

    .cnc-editor-floating.collapsed {
        width: 150px;
        height: 30px;
    }

    .cnc-editor-floating.maximized {
        width: 95%;
        height: 70%;
        top: 15%;
        left: 2.5%;
    }

    .cnc-editor-floating-header {
        padding: 5px 8px;
    }

    .cnc-editor-title {
        font-size: 11px;
    }

    .cnc-editor-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .cnc-simulator-container {
        min-height: 450px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .cnc-simulator-controls {
        padding: 5px;
        gap: 5px;
    }

    .cnc-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .cnc-control-group {
        font-size: 9px;
    }

    .cnc-slider {
        width: 60px;
    }

    .cnc-example-select {
        font-size: 11px;
        padding: 3px 6px;
    }

    .cnc-split-view {
        height: 180px;
    }

    .cnc-editor-pane {
        height: 160px;
    }

    .cnc-pane-header {
        padding: 4px 8px;
        font-size: 10px;
    }

    .cnc-debug-overlay,
    .cnc-tools-panel {
        display: none;
    }
}