/* Compiler page: full-screen IDE layout (sidebar, toolbar, file tabs, editor, console). */

body:has(> #page-container .gdb) { overflow: hidden; }
body:has(> #page-container .gdb) #navigation, body:has(> #page-container .gdb) footer, body:has(> #page-container .gdb) #page-container > br,
body:has(> #page-container .gdb) #announcement, body:has(> #page-container .gdb) noscript { display: none !important; }
body:has(> #page-container .gdb) #page-container { padding: 0 !important; margin: 0 !important; min-height: 0; }
body:has(> #page-container .gdb) #content { max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important; }
body:has(> #page-container .gdb) #content-body { margin: 0; padding: 0; }

.gdb {
    --gdb-nav: #1d3f6e;
    --gdb-nav-hover: #26508a;
    --gdb-nav-text: #e8eef7;
    --gdb-nav-muted: #9fb3cf;
    --gdb-bar: #f3f4f6;
    --gdb-run: #2e8540;
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    background: var(--oe-bg);
    color: var(--oe-text);
    font-size: 14px;
    z-index: 5;
}
:root[data-theme="dark"] .gdb { --gdb-nav: #16273f; --gdb-nav-hover: #20385a; --gdb-bar: #26292f; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .gdb { --gdb-nav: #16273f; --gdb-nav-hover: #20385a; --gdb-bar: #26292f; }
}

/* ---------- left sidebar ---------- */

.gdb-nav {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--gdb-nav);
    color: var(--gdb-nav-text);
}
.gdb-brand { display: flex; align-items: center; padding: 12px 14px; min-height: 52px; color: #fff !important; text-decoration: none; }
.gdb-brand img, .gdb-brand svg { max-height: 30px; width: auto; }
.gdb-brand * { color: #fff !important; }
.gdb-links { display: flex; flex-direction: column; padding: 4px 0 8px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.gdb-links a, .gdb-links button {
    width: 100%; border: 0; border-radius: 0; background: none; box-shadow: none; font: inherit; cursor: pointer; text-align: left;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; color: var(--gdb-nav-text) !important; text-decoration: none; font-size: 14px;
}
.gdb-links button .fa, .gdb-links a .fa { width: 16px; text-align: center; color: var(--gdb-nav-muted); }
.gdb-links button:hover, .gdb-links a:hover { background: var(--gdb-nav-hover); }
.gdb-links a.active { background: rgba(255, 255, 255, .14); font-weight: 600; }
.gdb-links a.active .fa { color: #fff; }

.gdb-files { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.gdb-files-head { display: flex; align-items: center; gap: 2px; padding: 10px 8px 6px 16px; }
.gdb-files-head span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--gdb-nav-muted); }
.gdb-files-head button {
    width: 28px; height: 28px; padding: 0; border: 0; border-radius: 4px; background: none;
    color: var(--gdb-nav-muted); cursor: pointer; box-shadow: none;
}
.gdb-files-head button:hover { background: var(--gdb-nav-hover); color: #fff; }
.gdb-nav .ws-tree { flex: 1; overflow: auto; padding: 0 0 6px; user-select: none; }
.gdb-nav .ws-item {
    display: flex; align-items: center; gap: 7px; padding: 5px 10px; cursor: pointer;
    color: var(--gdb-nav-text); border-left: 3px solid transparent; white-space: nowrap;
}
.gdb-nav .ws-item .fa { color: var(--gdb-nav-muted); width: 14px; text-align: center; }
.gdb-nav .ws-item:hover { background: var(--gdb-nav-hover); }
.gdb-nav .ws-item.ws-current { background: rgba(255, 255, 255, .14); border-left-color: #8ab4ff; }
.gdb-nav .ws-item.ws-drop { outline: 1px dashed #fff; }
.gdb-nav .ws-empty { padding: 6px 16px; color: var(--gdb-nav-muted); font-size: 13px; }
.gdb-nav .ws-name-input { width: 100%; color: #1b2430; background: #fff; border: 0; border-radius: 3px; padding: 2px 4px; font: inherit; }
.gdb-files-foot { padding: 4px 16px 8px; font-size: 12px; color: var(--gdb-nav-muted); }

.gdb-bottom { border-top: 1px solid rgba(255, 255, 255, .12); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.gdb-lang { display: flex; gap: 4px; margin: 0; }
.gdb-lang button {
    flex: 1; padding: 4px 0; border: 1px solid rgba(255, 255, 255, .25); border-radius: 4px; background: none;
    color: var(--gdb-nav-text); font-size: 12px; cursor: pointer; box-shadow: none;
}
.gdb-lang button:hover { background: var(--gdb-nav-hover); }
.gdb-lang button.active { background: #fff !important; color: var(--gdb-nav) !important; font-weight: 600; }
.gdb-user { display: flex; align-items: center; gap: 8px; color: var(--gdb-nav-text) !important; text-decoration: none; font-size: 13px; overflow: hidden; }
.gdb-user img { border-radius: 50%; flex: none; }
.gdb-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- main column ---------- */

.gdb-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.gdb-toolbar {
    display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; overflow: hidden;
    padding: 6px 10px; min-height: 48px; background: var(--gdb-bar); border-bottom: 1px solid var(--oe-border);
}
.gdb-tool {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
    border: 1px solid transparent; border-radius: 4px; background: none; color: var(--oe-text) !important;
    font: inherit; font-size: 14px; cursor: pointer; box-shadow: none; white-space: nowrap;
}
.gdb-tool:hover:not(:disabled) { background: var(--oe-bg); border-color: var(--oe-border); }
.gdb-tool:disabled { opacity: .45; cursor: default; }
.gdb-tool.gdb-icon { width: 34px; padding: 0; justify-content: center; }
.gdb-tool .fa { font-size: 15px; }
.gdb-run-group { display: inline-flex; margin: 0 4px; }
.gdb-tool.gdb-run { background: var(--gdb-run); color: #fff !important; border-radius: 4px 0 0 4px; font-weight: 600; padding: 0 14px; }
.gdb-tool.gdb-run:hover:not(:disabled) { background: #256b34; border-color: transparent; }
.gdb-tool.gdb-run:disabled { opacity: .6; }
.gdb-tool.gdb-caret { border-radius: 0 4px 4px 0; padding: 0 8px; border-left: 1px solid rgba(255, 255, 255, .35); }
#cc-stop:not(:disabled) .fa { color: #c0392b; }
.gdb-spacer { flex: 1; }
@media (max-width: 1250px) { .gdb-label { display: none; } .gdb-lang-select select { min-width: 120px; } }
.gdb-status { color: var(--oe-muted); font-size: 13px; margin-right: 8px; white-space: nowrap; }
.gdb-lang-select { display: inline-flex; align-items: center; gap: 8px; margin: 0 4px 0 0; font-size: 14px; color: var(--oe-muted); }
.gdb-lang-select select {
    height: 32px; min-width: 150px; padding: 0 8px; border: 1px solid var(--oe-border); border-radius: 4px;
    background: var(--oe-bg); color: var(--oe-text); font: inherit;
}

.gdb-tabs { display: flex; align-items: flex-end; gap: 0; min-height: 36px; padding: 0 6px; background: var(--gdb-bar); border-bottom: 1px solid var(--oe-border); overflow-x: auto; }
.gdb-tab {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px 0 14px; margin-bottom: -1px;
    border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; cursor: pointer;
    color: var(--oe-muted); font-size: 14px; white-space: nowrap;
}
.gdb-tab:hover { color: var(--oe-text); }
.gdb-tab-active { background: var(--oe-bg); border-color: var(--oe-border); color: var(--oe-text); }
.gdb-tab-dirty { color: var(--oe-accent); font-size: 10px; }
button.gdb-tab-close {
    width: 20px; height: 20px; padding: 0; border: 0; border-radius: 3px; background: none; box-shadow: none;
    color: var(--oe-muted) !important; font-size: 16px; line-height: 1; cursor: pointer;
}
button.gdb-tab-close:hover { background: var(--oe-bg-hover); color: var(--oe-text) !important; }

.gdb-editor { flex: 1 1 auto; min-height: 120px; position: relative; }
.gdb-editor > * { height: 100%; }

.gdb-hsplit { height: 5px; flex: none; background: var(--oe-border); cursor: row-resize; }
.gdb-hsplit:hover, .gdb-hsplit.gdb-dragging { background: var(--oe-primary); }

.gdb-console { flex: 0 0 260px; display: flex; flex-direction: column; min-height: 0; background: var(--oe-bg); }
.gdb-console-head {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 8px 4px 12px; min-height: 36px;
    background: var(--gdb-bar); border-bottom: 1px solid var(--oe-border); font-size: 13px; color: var(--oe-muted);
}
.gdb-console-title { font-weight: 600; color: var(--oe-text); }
.gdb-args { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.gdb-args input {
    width: 180px; height: 26px; padding: 0 6px; border: 1px solid var(--oe-border); border-radius: 3px;
    background: var(--oe-bg); color: var(--oe-text); font-family: 'JetBrains Mono', Consolas, monospace; font-size: 13px;
}
.gdb-mode { display: inline-flex; align-items: center; gap: 10px; }
.gdb-mode label { display: inline-flex; align-items: center; gap: 4px; margin: 0; cursor: pointer; color: var(--oe-text); }
.gdb-mode input { margin: 0; }
.gdb-icon-btn {
    width: 28px; height: 28px; padding: 0; border: 0; border-radius: 3px; background: none; box-shadow: none;
    color: var(--oe-muted) !important; cursor: pointer;
}
.gdb-icon-btn:hover { background: var(--oe-bg-hover); color: var(--oe-text) !important; }
.gdb-console-body { flex: 1; display: flex; min-height: 0; }
.gdb-stdin {
    width: 34%; min-width: 160px; resize: none; border: 0; border-right: 1px solid var(--oe-border); padding: 8px 10px;
    background: var(--oe-bg-soft); color: var(--oe-text); font-family: 'JetBrains Mono', Consolas, monospace; font-size: 14px; outline: none;
}
.gdb-stdin[hidden] { display: none; }
#cc-terminal { flex: 1; min-width: 0; min-height: 0; padding: 6px 0 0 10px; }
#cc-terminal .xterm { height: 100%; }

.gdb-console.gdb-collapsed { flex-basis: 36px !important; }
.gdb-console.gdb-collapsed .gdb-console-body { display: none; }
.gdb-main.gdb-console-max .gdb-editor, .gdb-main.gdb-console-max .gdb-tabs, .gdb-main.gdb-console-max .gdb-hsplit { display: none; }
.gdb-main.gdb-console-max .gdb-console { flex: 1 1 auto !important; }

.ws-menu { z-index: 1000; }

.gdb-nav .ws-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.gdb-nav .ws-del {
    flex: none; width: 24px; height: 22px; padding: 0; border: 0; border-radius: 3px; background: none; box-shadow: none;
    color: var(--gdb-nav-muted) !important; cursor: pointer; visibility: hidden;
}
.gdb-nav .ws-item:hover .ws-del, .gdb-nav .ws-item.ws-current .ws-del { visibility: visible; }
.gdb-nav .ws-del:hover { color: #ff8a80 !important; background: rgba(255, 255, 255, .1); }
.gdb-nav .ws-del .fa { color: inherit; }

/* Projects dialog */
.pj-list { max-height: 50vh; overflow: auto; margin: 4px 0 8px; }
.pj-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 4px; cursor: pointer; }
.pj-row:hover { background: var(--oe-bg-hover); }
.pj-row.pj-current { font-weight: 600; }
.pj-row .fa { color: var(--oe-muted); width: 16px; text-align: center; }
.pj-row .pj-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-row .pj-count { color: var(--oe-muted); font-size: 12px; }
.pj-row button { width: 28px; height: 26px; padding: 0; border: 0; background: none; box-shadow: none; color: var(--oe-muted) !important; cursor: pointer; border-radius: 3px; }
.pj-row button:hover { color: var(--oe-bad) !important; background: var(--oe-bg); }
.pj-empty { padding: 12px 10px; color: var(--oe-muted); }
.oe-modal input[type=text].pj-input, .oe-modal select.pj-input {
    width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--oe-border); border-radius: 4px;
    background: var(--oe-bg); color: var(--oe-text); font: inherit;
}

/* Hide / show the sidebar */
.gdb-collapse {
    position: absolute; left: 230px; top: 50%; z-index: 6; transform: translateY(-50%);
    width: 14px; height: 54px; padding: 0; border: 0; border-radius: 0 6px 6px 0; box-shadow: none;
    background: var(--gdb-nav); color: var(--gdb-nav-text) !important; cursor: pointer; font-size: 10px; opacity: .85;
}
.gdb-collapse:hover { opacity: 1; background: var(--gdb-nav-hover); }
.gdb.gdb-nav-hidden { grid-template-columns: minmax(0, 1fr); }
.gdb.gdb-nav-hidden .gdb-nav { display: none; }
.gdb.gdb-nav-hidden .gdb-collapse { left: 0; }
.gdb.gdb-nav-hidden .gdb-main { padding-left: 14px; }

/* Toolbar order on desktop: the secondary tools live in .gdb-more so that phones can show them as a menu. */
.gdb-more { display: contents; }
.gdb-mobile, .gdb-mlabel, .gdb-backdrop { display: none; }
.gdb-args input::placeholder { color: transparent; }
#tb-new { order: 1; } #ws-upload { order: 2; } .gdb-run-group { order: 3; } #cc-stop { order: 4; }
#cc-share { order: 5; } #cc-save { order: 6; } #cc-format { order: 7; } #cc-download { order: 8; }
.gdb-toolbar > .gdb-spacer { order: 9; } .gdb-status { order: 10; } .gdb-lang-select { order: 11; } #cc-settings { order: 12; }

/* ---------- phones: app bar, side drawer, overflow menu ---------- */

@media (max-width: 860px) {
    .gdb { display: flex; flex-direction: column; height: 100vh; height: 100dvh; bottom: auto; }
    .gdb-collapse, .gdb-lang-text, .gdb-label { display: none !important; }
    .gdb-mobile { display: inline-flex; }

    .gdb-nav {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: min(82vw, 300px);
        transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 24px rgba(0, 0, 0, .35);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .gdb.gdb-nav-hidden .gdb-nav { display: flex; }
    .gdb.gdb-nav-hidden .gdb-main { padding-left: 0; }
    .gdb.gdb-drawer .gdb-nav { transform: none; }
    .gdb.gdb-drawer .gdb-backdrop { display: block; }
    .gdb-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .4); }
    .gdb-links a, .gdb-links button { padding: 12px 18px; }
    .gdb-nav .ws-item { padding: 9px 12px; }
    .gdb-nav .ws-del { visibility: visible; }
    .gdb-lang button { padding: 8px 0; }

    .gdb-main { flex: 1; position: relative; z-index: 0; }
    .gdb-toolbar { position: relative; z-index: 25; gap: 6px; padding: 6px 8px; overflow: visible; flex-wrap: wrap; }
    .gdb-toolbar > * { order: 0; }
    #gdb-menu { order: 0; }
    .gdb-lang-select { order: 1; flex: 1; min-width: 0; margin: 0; }
    .gdb-lang-select select { width: 100%; min-width: 0 !important; height: 36px; font-size: 16px; }
    #cc-stop { order: 2; width: 36px; padding: 0; justify-content: center; }
    .gdb-run-group { order: 3; margin: 0; }
    .gdb-tool { height: 36px; }
    .gdb-tool.gdb-icon { width: 36px; }
    .gdb-tool.gdb-run { padding: 0 12px; }
    .gdb-tool.gdb-caret { padding: 0 9px; }
    #gdb-more-btn { order: 4; }
    .gdb-toolbar > .gdb-spacer { display: none; }
    .gdb-status { order: 5; flex-basis: 100%; margin: 0; font-size: 12px; white-space: normal; }
    .gdb-status:empty { display: none; }

    .gdb-more {
        display: none; position: absolute; top: calc(100% + 2px); right: 6px; z-index: 26; min-width: 220px;
        flex-direction: column; padding: 6px 0; background: var(--oe-bg); border: 1px solid var(--oe-border);
        border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    }
    .gdb.gdb-more-open .gdb-more { display: flex; }
    .gdb-more .gdb-tool, .gdb-more .gdb-tool.gdb-icon {
        width: 100%; height: 44px; padding: 0 16px; gap: 12px; justify-content: flex-start; border: 0; border-radius: 0;
    }
    .gdb-more .gdb-tool .fa { width: 18px; text-align: center; color: var(--oe-muted); }
    .gdb-more .gdb-mlabel, .gdb-more .gdb-label { display: inline !important; }

    .gdb-tab { height: 36px; }
    .gdb-editor { flex: 1 1 auto; min-height: 0; }
    .gdb-hsplit { height: 10px; touch-action: none; }
    .gdb-console { flex-basis: 38%; }
    .gdb-console-head { gap: 8px 10px; padding: 4px 6px 4px 10px; }
    .gdb-console-title, .gdb-hint { display: none; }
    .gdb-mode { order: 5; flex-basis: 100%; }
    .gdb-args { flex: 1 1 0; min-width: 0; }
    .gdb-args input { flex: 1; width: auto; min-width: 0; height: 30px; font-size: 16px; }
    .gdb-args input::placeholder { color: var(--oe-muted); }
    .gdb-stdin { font-size: 16px; }
    .gdb-console-head .gdb-spacer { display: none; }
    .gdb-icon-btn { width: 34px; height: 34px; }
    .gdb-stdin { width: 40%; min-width: 0; }
    .gdb-main.gdb-console-max .gdb-console { flex-basis: auto !important; }
}
@media (max-width: 440px) { .gdb-run-label { display: none; } }
