
:root {
    --bg: #1e1e1e;
    --sidebar: #181818;
    --panel: #1e1e1e;
    --titlebar: #181818;
    --tab: #1f1f1f;
    --border: #2b2b2b;
    --text: #cccccc;
    --muted: #858585;
    --accent: #007acc;
    --green: #2ea043;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 13px;
}

/* Application header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0 18px;
    background: var(--titlebar);
    border-bottom: 1px solid var(--border);
}

    header h1 {
        margin: 0;
        font-size: 14px;
        font-weight: 600;
        letter-spacing: .2px;
    }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
}

button {
    border: 1px solid #454545;
    border-radius: 4px;
    padding: 8px 14px;
    background: #303030;
    color: #e6e6e6;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s ease;
}

    button:hover:not(:disabled) {
        background: #414141;
    }

    button:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    button:disabled {
        opacity: .5;
        cursor: not-allowed;
    }

#runButton {
    background: #238636;
    border-color: #238636;
    color: white;
    font-weight: 600;
}

    #runButton:hover:not(:disabled) {
        background: #2ea043;
    }

#resetButton {
    background: #303030;
}

/* Execution status */
#status {
    padding: 8px 18px;
    color: var(--muted);
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

/* Editor and terminal workspace */
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    gap: 1px;
    background: var(--border);
    min-height: calc(100vh - 130px);
}

.panel {
    min-width: 0;
    overflow: hidden;
    background: var(--panel);
    border: 0;
    border-radius: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    min-height: 37px;
    padding: 0 16px;
    background: var(--tab);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 400;
    color: #dddddd;
}

/* CodeMirror editor */
.CodeMirror {
    height: calc(100vh - 180px);
    min-height: 360px;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: Consolas, "Cascadia Code", monospace;
    font-size: 14px;
    line-height: 1.65;
}

.CodeMirror-gutters {
    background: #1e1e1e;
    border-right: 0;
}

.CodeMirror-linenumber {
    color: #858585;
    padding: 0 12px 0 8px;
}

.CodeMirror-activeline-background {
    background: #262626;
}

.CodeMirror-cursor {
    border-left: 2px solid #aeafad;
}

/* Terminal output */
#output {
    margin: 0;
    padding: 16px;
    min-height: 360px;
    max-height: calc(100vh - 180px);
    overflow: auto;
    background: #181818;
    color: #d4d4d4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: 13px/1.7 Consolas, "Cascadia Code", monospace;
}

/* Mobile layout */
@media (max-width: 800px) {
    header {
        padding: 12px 16px;
    }

    .toolbar {
        padding: 10px 16px;
    }

    #status {
        padding: 8px 16px;
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto;
        min-height: 0;
    }

    .CodeMirror {
        height: 45vh;
        min-height: 240px;
    }

    #output {
        min-height: 180px;
        max-height: 35vh;
    }

    button {
        min-height: 40px;
    }
}

#themeSelect {
    background: #303030;
    color: #e6e6e6;
    border: 1px solid #454545;
    border-radius: 4px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    min-height: 36px;
}

    #themeSelect:hover {
        border-color: #007acc;
    }

    #themeSelect:focus-visible {
        outline: 2px solid #007acc;
        outline-offset: 2px;
    }

.toolbar label {
    color: #aaaaaa;
    font-size: 12px;
}

/* Highlight the active editor line */
.CodeMirror-activeline-background {
    background: rgba(128, 128, 128, 0.10);
}

/* Improve bracket visibility */
.CodeMirror-matchingbracket {
    outline: 1px solid #888888;
    border-radius: 2px;
}


/* Milestone 7.5 - Integrated Terminal */

.terminal-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.terminal-title {
    justify-content: space-between;
    gap: 12px;
}

.terminal-language {
    color: #858585;
    font-size: 11px;
    font-weight: 400;
}

.terminal-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: #181818;
}

    .terminal-body #output {
        min-height: 0;
        max-height: none;
        overflow: visible;
        background: transparent;
        margin: 0;
        padding: 16px;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        font: 13px/1.7 Consolas, "Cascadia Code", monospace;
    }

.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #202020;
    border-top: 1px solid #333333;
}

.terminal-prompt {
    color: #4ec9b0;
    font: 600 16px Consolas, monospace;
}

#terminalInput {
    flex: 1;
    min-width: 0;
    border: 1px solid #454545;
    border-radius: 4px;
    padding: 9px 10px;
    background: #252526;
    color: #e6e6e6;
    font: 13px Consolas, monospace;
    outline: none;
}

    #terminalInput:focus {
        border-color: #007acc;
    }

    #terminalInput:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

#terminalSend {
    background: #0e639c;
    border-color: #0e639c;
    color: white;
}

    #terminalSend:hover:not(:disabled) {
        background: #1177bb;
    }

@media (max-width: 800px) {
    .terminal-input-row {
        padding: 10px;
        gap: 8px;
    }

    #terminalInput {
        min-height: 40px;
    }

    #terminalSend {
        min-height: 40px;
    }
}


/* Output panel toolbar */

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 36px;
}

.output-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.output-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 5px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: #a0a0a0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

    .output-icon-btn:hover {
        background: rgba(255, 255, 255, 0.09);
        color: #ffffff;
    }

    .output-icon-btn:active {
        background: rgba(255, 255, 255, 0.15);
    }

    .output-icon-btn svg {
        width: 16px;
        height: 16px;
    }
