/* Ensure the editor textarea and CodeMirror fill available space and do not push the console off screen */


#codeEditor {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    resize: none;
    display: block;
}

.CodeMirror {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    display: block;
    font-size: 14px;
    line-height: 1.4;
}


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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1e1e1e;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

#statusBar {
    background: #2d2d2d;
    padding: 0.5rem 1rem;
    border-top: 1px solid #404040;
    font-size: 0.85rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    z-index: 100;
}

.header {
    background: #2d2d2d;
    padding: 1rem;
    border-bottom: 1px solid #404040;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #8892b0;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

select, button {
    background: #404040;
    color: white;
    border: 1px solid #555;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

select:hover, button:hover {
    background: #4a4a4a;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.main-container {
    display: flex;
    height: calc(100vh - 112px); /* 80px header + 32px status bar */
    min-height: 0;
    position: relative;
    z-index: 1;
}

.file-explorer {
    width: 300px;
    background: #252526;
    border-right: 1px solid #404040;
    display: flex;
    flex-direction: column;
}

.explorer-header {
    background: #2d2d2d;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.explorer-controls {
    display: flex;
    gap: 0.5rem;
}

.explorer-controls button {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

@media (max-width: 480px) {
    .explorer-controls {
        flex-wrap: wrap;
    }
    .explorer-controls button {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.9rem;
    margin: 1px 0;
}

.file-item:hover {
    background: #404040;
}

.file-item.selected {
    background: #0e639c;
}

.file-item.directory {
    font-weight: 500;
}

.file-icon {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.expand-icon {
    width: 12px;
    height: 12px;
    margin-right: 0.25rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.expand-icon.expanded {
    transform: rotate(90deg);
}

.file-children {
    margin-left: 1rem;
    display: none;
}

.file-children.expanded {
    display: block;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.editor-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #404040;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    /* Allow shrinking when output-panel is resized */
    height: 0;
}

.editor-header {
    flex: 0 0 auto;
    background: #2d2d2d;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-panel {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 80px;
    max-height: 80vh;
    height: 20vh;
    overflow: auto;
    position: relative;
    resize: none;
}

.output-resizer {
    height: 9px;
    background: #222;
    cursor: ns-resize;
    width: 100%;
    position: absolute;
    top: -3px;
    left: 0;
    z-index: 10;
    padding-bottom: 6px;
    border-top: 1px solid #444;
    border-bottom: 1px solid #111;
    transition: background 0.2s;
}
.output-resizer:hover {
    background: #444;
}

.output-header {
    background: #2d2d2d;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.output {
    flex: 1;
    background: #1a1a1a;
    padding: 1rem;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    white-space: pre-wrap;
    color: #e6e6e6;
}

.info {
    color: #8892b0;
}

.loading {
    color: #64ffda;
}

.error {
    color: #ff6b6b;
}

.success {
    color: #69db7c;
}

.demo-list {
    margin-left: auto;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.modal-info {
    display: none;
    font-size: 0.95em;
    color: #b0b0b0;
    margin-bottom: 0.5em;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2d2d2d;
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid #404040;
    min-width: 300px;
}

.gh-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.7);
    display: none;
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
.gh-overlay-content {
    background: #232323;
    padding: 2em 3em;
    border-radius: 8px;
    color: #fff;
    font-size: 1.2em;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 320px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.gh-overlay-content span {
    margin-bottom: 1em;
    text-align: center;
    font-size: 1.1em;
}
.gh-overlay-content button {
    margin-top: 1em;
    padding: 0.5em 1.5em;
    font-size: 1em;
    background: #404040;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.gh-overlay-content button:hover {
    background: #4a4a4a;
}
.gh-menu {
    position: absolute;
    background: #232323;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: none;
    min-width: 160px;
    z-index: 3000;
}
.gh-menu div {
    padding: 0.5em 1em;
    cursor: pointer;
}
.gh-menu div:hover {
    background: #404040;
}

/* Progress bar overlay for GitHub loading */
.progress-bar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.progress-bar-container {
    background: #232323;
    padding: 2em 3em;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 320px;
}
.progress-bar-label {
    color: #fff;
    font-size: 1.1em;
    margin-bottom: 1em;
    text-align: center;
}
.progress-bar-track {
    width: 300px;
    height: 16px;
    background: #333;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.5em;
    border: 1px solid #444;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #64ffda 0%, #69db7c 100%);
    width: 0%;
    transition: width 0.2s;
}

.modal h3 {
    margin-bottom: 1rem;
    color: #ffffff;
}

.modal input {
    width: 100%;
    padding: 0.5rem;
    background: #404040;
    border: 1px solid #555;
    border-radius: 4px;
    color: white;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

@media (max-width: 1024px) {
    .file-explorer {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .file-explorer {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #404040;
    }

    .editor-container {
        flex-direction: column;
    }

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid #404040;
    }

    .controls {
        font-size: 0.8rem;
    }
}

.context-menu {
    display: none;
    position: fixed;
    background: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 4px;
    padding: 0.25rem 0;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.context-menu-item:hover {
    background: #404040;
}

.context-menu-separator {
    height: 1px;
    background: #404040;
    margin: 4px 0;
    border: none;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tab bar styles */
#tabBar {
    display: flex;
    background: #1e1e1e;
    height: 36px;
    border-bottom: 1px solid #404040;
    position: relative;
    overflow: hidden;
}

.tab-container {
    display: flex;
    overflow-x: scroll;
    overflow-y: hidden;
    flex: 1 1 auto;
    margin: 0 24px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    white-space: nowrap;
}

.tab-container::-webkit-scrollbar {
    display: none;
}

.tab {
    display: inline-flex;
    align-items: center;
    height: 35px;
    padding: 0 8px;
    background: #1e1e1e;
    border-right: 1px solid #404040;
    color: #969696;
    cursor: pointer;
    white-space: nowrap;
    min-width: 100px;
    user-select: none;
    flex-shrink: 0;
}

.tab.active {
    background: #2d2d2d;
    color: #ffffff;
    border-bottom: 1px solid #0e639c;
    margin-bottom: -1px;
}

.tab:hover:not(.active) {
    background: #2a2a2a;
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.1s;
}

.tab:hover .tab-close {
    opacity: 0.7;
}

.tab:hover .tab-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.tab-nav-button {
    position: absolute;
    width: 24px;
    height: 36px;
    background: #1e1e1e;
    border: none;
    color: #969696;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    top: 0;
    z-index: 2;
    transition: background-color 0.1s, color 0.1s;
    flex-shrink: 0;
}

.tab-nav-button.left {
    left: 0;
    border-right: 1px solid #404040;
}

.tab-nav-button.right {
    right: 0;
    border-left: 1px solid #404040;
}

.tab-nav-button:not(:disabled):hover {
    background: #2a2a2a;
    color: #ffffff;
}

.tab-nav-button:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}
