/* Compiler IDE shell: break the narrow centered .page-container out to the
   full available width (same :has() pattern as notfound.css for the 404).
   Must live in a globally-linked stylesheet (not scoped CSS): the container
   is rendered by MainLayout, outside this component's scope. */
.page-container:has(> .compiler-wrap) {
    min-height: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* Compiler toolbar inside the app header (same 52px bar height — compact
   32px controls, icon-only run on small screens). */
.cmp-hd-lang {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.cmp-hd-lang select {
    height: 32px;
    max-width: 30vw;
    background: #020617;
    color: #e2e8f0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: .75rem;
    padding: 0 6px;
    outline: none;
    cursor: pointer;
}

.cmp-hd-ver {
    font-size: .62rem;
    font-family: ui-monospace, Consolas, monospace;
    color: var(--text-secondary);
    background: rgba(148,163,184,.12);
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.cmp-hd-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cmp-hd-actions .icon-btn {
    width: 32px;
    height: 32px;
}

.cmp-hd-run {
    height: 32px;
    padding: 0 12px;
    border: none;
    border-radius: 8px;
    background: #22c55e;
    color: #04120a;
    font-size: .75rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.cmp-hd-run:disabled {
    opacity: .6;
    cursor: wait;
}

.cmp-hd-run .btn-spinner {
    width: 12px;
    height: 12px;
    border-width: 2px;
}

@media (max-width: 560px) {
    .cmp-hd-ver { display: none; }
    .cmp-hd-lang select { max-width: 26vw; }
    .cmp-hd-run { padding: 0 9px; }
    .cmp-hd-run .lbl { display: none; }
}

/* ===== NMU Compiler page styles (global file by project convention:
   scoped *.razor.css bundles are not linked by either host, so all real
   page styling lives here) ===== */
.compiler-wrap {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    /* Fill the viewport: header (~52px) + paddings. Editor flex-fills below. */
    min-height: 70vh;
    min-height: calc(100dvh - 130px);
    padding: 16px 16px 20px;
    overflow-x: clip;
    animation: cmp-in .25s ease;
}

@media (max-width: 700px) {
    .compiler-wrap {
        padding: 10px 10px 16px;
        min-height: calc(100dvh - 200px);
    }
}

@media (max-width: 700px) {
    .compiler-wrap {
        padding: 10px 10px 22px;
        min-height: calc(100dvh - 210px);
    }
}

/* Background decor (same idea as .nf-wash / .nf-glow on the 404). */
.cmp-wash {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

.cmp-wash-top {
    top: 0;
    height: 300px;
    background: linear-gradient(180deg, rgba(56,189,248,.13), transparent);
}

.cmp-glow {
    position: absolute;
    top: 240px;
    left: 50%;
    transform: translateX(-50%);
    width: min(760px, 94vw);
    aspect-ratio: 2 / 1;
    background: radial-gradient(ellipse, rgba(56,189,248,.09) 0%, transparent 65%);
    pointer-events: none;
}

/* Keep flow content above the decor. The floating console is excluded:
   it is position:fixed (out of flow) with its own z-index, and this
   selector's :not() specificity would otherwise override it. */
.compiler-wrap > :not(.cmp-wash):not(.cmp-glow):not(.floating) {
    position: relative;
}

@keyframes cmp-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* (toolbar card retired: controls live in the app header — see above) */

.cmp-btn {
    border-radius: 8px;
    padding: 6px 11px;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid rgba(148,163,184,.25);
    transition: transform .08s ease, background .15s ease;
}

.cmp-btn:disabled {
    opacity: .55;
    cursor: wait;
}

.cmp-btn.ghost {
    background: transparent;
    color: var(--text-primary, #e2e8f0);
}

.cmp-btn.ghost:hover:not(:disabled) {
    background: rgba(148,163,184,.12);
}

.cmp-btn.run {
    background: #22c55e;
    border-color: #22c55e;
    color: #04120a;
}

.cmp-btn:active { transform: scale(.97); }

/* ---------- Panes ---------- */
.cmp-pane {
    background: var(--card, #0f172a);
    border: 1px solid rgba(148,163,184,.2);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-shadow: 0 12px 30px rgba(2,6,23,.3);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.cmp-pane:focus-within {
    border-color: rgba(56,189,248,.55);
    box-shadow: 0 12px 30px rgba(2,6,23,.3), 0 0 0 3px rgba(56,189,248,.14);
}

.cmp-pane-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface-hover);
}

.cmp-pane-title {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.cmp-pane-title i.fa-solid { color: var(--primary); }

/* macOS window dots */
.win-dots { display: inline-flex; gap: 6px; }
.win-dots i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.win-dots i:nth-child(1) { background: #f87171; box-shadow: 0 0 6px rgba(248,113,113,.5); }
.win-dots i:nth-child(2) { background: #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,.5); }
.win-dots i:nth-child(3) { background: #34d399; box-shadow: 0 0 6px rgba(52,211,153,.5); }

.cmp-file {
    font-family: ui-monospace, Consolas, monospace;
    font-size: .75rem;
    color: var(--primary);
    background: rgba(56,189,248,.1);
    border: 1px solid rgba(56,189,248,.25);
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.cmp-head-right {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.icon-mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: .78rem;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.icon-mini-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(148,163,184,.1);
}

.icon-mini-btn:hover {
    color: #7dd3fc;
    border-color: rgba(56,189,248,.5);
    background: rgba(56,189,248,.1);
}

.icon-mini-btn.danger { color: #f87171; border-color: rgba(239,68,68,.4); }
.icon-mini-btn.danger:hover {
    color: #fecaca;
    border-color: rgba(239,68,68,.7);
    background: rgba(239,68,68,.12);
}

/* ---------- Full-height smart editor (fills the interface) ---------- */
.editor-pane {
    margin-top: 2px;
    /* Grows into the wrap's free space; card hugs head + editor exactly. */
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.code-editor {
    position: relative;
    width: 100%;
    /* Flex-fill first (grows with the wrap); dvh fallback for old engines. */
    flex: 1;
    min-height: 340px;
    height: max(340px, calc(100dvh - 330px));
    background: #020617;
    overflow: hidden;
}

.code-mirror { display: none; }

/* Monaco host fills the editor card. */
.monaco-host {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

/* Fallback plain textarea (only if Monaco fails to load). */
.code-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 16px 18px;
    background: #020617;
    color: #e8eef7;
    caret-color: #7dd3fc;
    border: none;
    outline: none;
    resize: none;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Cascadia Code", monospace;
    font-size: 14px;
    line-height: 1.7;
    tab-size: 4;
    direction: ltr;
    text-align: left;
    white-space: pre;
}

.code-fallback::selection { background: rgba(56,189,248,.3); }
.code-fallback::placeholder { color: #475569; }

.cmp-hint-inline {
    font-size: .72rem;
    font-weight: 400;
    color: var(--text-secondary);
    white-space: nowrap;
}

@media (max-width: 700px) {
    .cmp-hint-inline { display: none; }
}

/* ---------- Floating console (bottom sheet over the editor) ---------- */
.console-pane { margin-top: 2px; }

.console-pane.floating {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 12000;
    max-height: 72dvh;
    animation: cmp-sheet-in .25s ease;
    box-shadow: 0 -14px 44px rgba(0,0,0,.55);
}

@media (max-width: 700px) {
    .console-pane.floating {
        left: 8px;
        right: 8px;
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    }
}

@keyframes cmp-sheet-in {
    from { opacity: 0; transform: translateY(26px); }
    to { opacity: 1; transform: none; }
}

.console-grip {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 14px;
    cursor: ns-resize;
    background: var(--bg-surface-hover);
    border-bottom: 1px solid var(--border-color);
    touch-action: none;
    user-select: none;
}

.console-grip span {
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-color);
    transition: background .15s ease, width .15s ease;
}

.console-grip:hover span, .console-grip:active span {
    background: var(--primary);
    width: 64px;
}

.console-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    background: var(--bg-surface-hover);
    border-bottom: 1px solid var(--border-color);
}

.console-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 700;
    padding: 10px 14px 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: color .15s ease, border-color .15s ease;
}

.console-tab i.fa-solid { font-size: .75rem; }
.console-tab small { font-weight: 400; opacity: .7; }

.console-tab:hover { color: var(--text-primary); }

.console-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

span.console-tab { cursor: default; }

.console-tabs-right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.console-body {
    height: 260px;
    max-height: 62dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #020617;
}

.console-body .cmp-output {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.console-body .is-compile { flex: 0 0 auto; }

.console-stdin {
    flex: 1;
    min-height: 0;
}

/* ---------- Live terminal (single console, no separate boxes) ---------- */
.term-transcript {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.term-line { display: block; }
.term-line:empty::after { content: "\00a0"; }

.term-out { color: #d1fae5; }
.term-err { color: #fecaca; }
.term-sys { color: #64748b; }
.term-in { color: #7dd3fc; }

.term-inputrow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #020617;
    border-top: 1px solid rgba(56,189,248,.25);
}

.term-prompt {
    color: #38bdf8;
    font-weight: 700;
    font-family: ui-monospace, Consolas, monospace;
}

.term-prompt.pulse { animation: cmp-blink 1s ease-in-out infinite; }

.term-input {
    flex: 1;
    min-width: 0;
    background: rgba(56,189,248,.07);
    border: 1px solid rgba(56,189,248,.4);
    border-radius: 9px;
    color: #e8eef7;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13.5px;
    padding: 8px 11px;
    outline: none;
    direction: ltr;
    text-align: left;
}

.term-input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56,189,248,.18);
}

.term-input::placeholder { color: #475569; }

.term-go { padding: 8px 14px; white-space: nowrap; }

.term-busy {
    font-size: .8rem;
    color: var(--text-secondary);
    justify-content: center;
}

.term-staging { padding: 4px 0 8px; overflow-y: auto; }

.term-staging-title {
    padding: 10px 14px 4px;
    font-size: .85rem;
    color: var(--text-primary);
}

.term-staging .term-line { padding: 1px 14px; }

.term-staging-hint {
    padding: 6px 14px 0;
    font-size: .76rem;
    color: var(--text-secondary);
}

/* ---------- stdin ---------- */
.cmp-stdin {
    width: 100%;
    background: #020617;
    color: #e8eef7;
    border: none;
    outline: none;
    resize: none;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Cascadia Code", monospace;
    font-size: 14px;
    line-height: 1.7;
    padding: 14px 16px;
    direction: ltr;
    text-align: left;
    tab-size: 4;
    caret-color: #7dd3fc;
}

.cmp-stdin::selection { background: rgba(56,189,248,.28); }
.cmp-stdin::placeholder { color: #475569; }

.cmp-hint {
    padding: 9px 14px 12px;
    font-size: .78rem;
    color: var(--text-secondary);
    line-height: 1.9;
}

.cmp-hint code {
    background: rgba(56,189,248,.12);
    border: 1px solid rgba(56,189,248,.2);
    padding: 1px 7px;
    border-radius: 6px;
    color: var(--primary);
    font-size: .74rem;
}

.cmp-output {
    margin: 0;
    padding: 14px 16px;
    background: #020617;
    color: #d1fae5;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 150px;
    max-height: 380px;
    overflow: auto;
    direction: ltr;
    text-align: left;
}

.cmp-output.is-error { color: #fecaca; }
.cmp-output.is-compile {
    color: #fde68a;
    min-height: 60px;
    max-height: 200px;
    border-top: 1px dashed rgba(148,163,184,.25);
}

.cmp-compile-head {
    padding: 8px 14px 0;
    font-size: .75rem;
    font-weight: 700;
    color: #f59e0b;
    background: #020617;
}

/* ---------- Status pill ---------- */
.cmp-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    font-family: ui-monospace, Consolas, monospace;
    padding: 4px 11px;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

.cmp-status.st-ok { background: rgba(34,197,94,.15); color: #15803d; border: 1px solid rgba(34,197,94,.3); }
.cmp-status.st-err { background: rgba(239,68,68,.15); color: #b91c1c; border: 1px solid rgba(239,68,68,.3); }
.cmp-status.st-run { background: rgba(56,189,248,.15); color: #0369a1; border: 1px solid rgba(56,189,248,.3); }
.cmp-status.st-run::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: cmp-blink 1s ease-in-out infinite;
}

@keyframes cmp-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
}

/* ---------- Spinner (compiler variant; the header has its own) ---------- */
.cmp-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,0,0,.25);
    border-top-color: #04120a;
    border-radius: 50%;
    animation: cmp-spin .7s linear infinite;
    vertical-align: -2px;
}

.cmp-hd-run .cmp-spinner {
    width: 12px;
    height: 12px;
    border-width: 2px;
}

/* ---------- Extra-packages row (pandas language) ---------- */
.compiler-moderow {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background:
        linear-gradient(135deg, rgba(168,85,247,.08), rgba(168,85,247,0) 55%),
        var(--card, #0f172a);
    border: 1px solid rgba(168,85,247,.28);
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 10px 28px rgba(2,6,23,.3);
}

.pkg-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: .82rem;
    color: var(--text-primary);
    flex-basis: 100%;
}

.pkg-row label { font-weight: 700; }

.pkg-input {
    flex: 1;
    min-width: 180px;
    background: #020617;
    color: #e2e8f0;
    border: 1px solid rgba(168,85,247,.45);
    border-radius: 10px;
    padding: 8px 11px;
    font-size: .82rem;
    font-family: ui-monospace, Consolas, monospace;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.pkg-input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(168,85,247,.2);
}

.pkg-input::placeholder { color: #475569; }

@keyframes cmp-spin { to { transform: rotate(360deg); } }

/* ---------- Dark mode: keep the sky accents on dark chrome ---------- */
[data-theme="dark"] .cmp-pane-title i.fa-solid { color: #38bdf8; }
[data-theme="dark"] .cmp-file { color: #7dd3fc; }
[data-theme="dark"] .console-tab.active { color: #7dd3fc; border-bottom-color: #38bdf8; }
[data-theme="dark"] .cmp-status.st-ok { color: #4ade80; }
[data-theme="dark"] .cmp-status.st-err { color: #f87171; }
[data-theme="dark"] .cmp-status.st-run { color: #7dd3fc; }
[data-theme="dark"] .cmp-hint code { color: #7dd3fc; }
[data-theme="dark"] .icon-mini-btn:hover { color: #7dd3fc; border-color: rgba(56,189,248,.5); background: rgba(56,189,248,.1); }
[data-theme="dark"] .console-grip:hover span, [data-theme="dark"] .console-grip:active span { background: #38bdf8; }

/* ---------- Light mode: editor chrome follows the light surface ---------- */
[data-theme="light"] .code-editor { background: #ffffff; }
[data-theme="light"] .code-fallback {
    background: #ffffff;
    color: #0f172a;
    caret-color: #0369a1;
}
[data-theme="light"] .code-fallback::placeholder { color: #94a3b8; }
[data-theme="light"] .cmp-hd-lang select {
    background: #ffffff;
    color: #0f172a;
}
[data-theme="light"] .pkg-input {
    background: #ffffff;
    color: #0f172a;
}
