/* filepath: /Users/irwan/src/linguineai/linguine/src/runner/styles.css */
/* Monochrome minimalist tech theme with dark/light modes */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Inter:wght@400;500;600&display=swap");

:root {
    color-scheme: light;
    /* Light mode palette */
    --bg: #ffffff;
    --fg: #16181d;
    --surface-1: #ffffff;
    --surface-2: #f3f5f7;
    --border: #d9dde2;
    --muted: #6a7179;
    --muted-strong: #34393f;
    --code-bg: #f5f7f9;
    --code-fg: #1e2227;
    --focus: #2563eb;
    --desc-bg: #ffffff;
    --desc-text: #1f2328;
    --desc-heading: #111418;
}

/* Disable dark mode override (was using prefers-color-scheme). Keeping commented for reference. */
/* @media (prefers-color-scheme: dark) { }
:root { }
*/

/* Base */
html, body {
    height: 100%;
}
body {
    margin: 0;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg);
    color: var(--fg);
}

/* Visually hidden but accessible label */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Header */
header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-1);
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
}

h1 {
    font-size: clamp(1rem, 0.9rem + 0.5vw, 1.2rem);
    margin: 0;
    font-weight: 600;
    letter-spacing: .2px;
}

/* Minimal loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: .5rem;
    border: 2px solid var(--border);
    border-top-color: var(--muted-strong);
    border-radius: 50%;
    animation: spinner-rot 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spinner-rot {
    to {
        transform: rotate(360deg);
    }
}

/* Inputs */
input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: .5rem .6rem;
    border-radius: 6px;
    min-width: 170px;
    flex: 1 1 220px;
}

/* Buttons - monochrome, unobtrusive */
button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: .55rem .9rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background: var(--surface-1);
}

button:focus-visible, input:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

#resetBtn {
    opacity: 0.9;
}

/* Status pill */
#status {
    font-size: .75rem;
    margin-left: auto;
    background: var(--surface-2);
    padding: .4rem .6rem;
    border-radius: 6px;
    letter-spacing: .5px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--muted-strong);
}

#status.ok {
    border-left: 3px solid var(--border);
}

#status.err {
    border-left: 3px solid var(--muted);
}

/* Loading indicator style */
#loading-indicator {
    margin-left: .5rem;
    padding: .25rem .45rem;
    font-size: .75rem;
    letter-spacing: .3px;
    color: var(--muted-strong);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* Slug input with embedded indicators */
.slug-wrap {
    position: relative;
    display: inline-flex;
    flex: 1 1 260px;
    max-width: 420px;
}

.slug-wrap input {
    width: 100%;
    padding-right: 130px; /* space for status + loading */
}

.slug-indicators {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: .65rem;
    pointer-events: none; /* allow clicks to fall through to input */
}

.slug-indicators #status,
.slug-indicators #loading-indicator {
    margin: 0;
    padding: .25rem .45rem;
    font-size: .6rem;
    letter-spacing: .4px;
    line-height: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    text-transform: uppercase;
    color: var(--muted-strong);
}

/* Status color tweak for ok/err inside slug */
.slug-indicators #status.ok {
    border-color: var(--border);
    color: var(--muted-strong);
}

.slug-indicators #status.err {
    border-color: var(--muted);
    color: var(--muted);
}

/* Layout */
main {
    display: block;
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.panes {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* Two-column layout for runner panes */
.panes.two-col {
    display: grid;
    grid-template-columns: 1fr; /* default: single column (mobile-first) */
    gap: 1rem;
}

.panes.two-col .col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0; /* prevent overflow in flex children */
}

@media (min-width: 1024px) {
    .panes.two-col {
        grid-template-columns: 1.2fr 0.8fr; /* left (code/output) wider, right (description) narrower */
        align-items: stretch;
    }

    .panes.two-col .col-left,
    .panes.two-col .col-right {
        min-height: 0;
    }

    .panes.two-col .desc-box {
        height: 100%;
    }

    .panes.two-col .desc-box .desc {
        height: 100%;
    }

    /* Panel height constraints and internal scrollbars on laptop/desktop */
    /* Avoid page-level long scroll by constraining panels */
    .panes.two-col .box {
        overscroll-behavior: contain; /* prevent scroll chaining to the page */
    }

    .panes.two-col .source-box,
    .panes.two-col .output-box {
        display: flex;
        flex-direction: column;
        max-height: 40vh; /* adjust as needed */
    }

    .panes.two-col .source-box pre,
    .panes.two-col .output-box pre {
        flex: 1 1 auto;
        overflow: auto; /* show vertical scrollbar when content exceeds */
    }

    .panes.two-col .desc-box {
        display: flex;
        flex-direction: column;
        max-height: 82vh; /* give description more room on the right */
    }

    .panes.two-col .desc-box .desc {
        flex: 1 1 auto;
        overflow-y: auto; /* vertical scrollbar for long descriptions */
    }

    /* Make left column (source + output) fill viewport height together */
    .panes.two-col .col-left {
        display: flex;
        flex-direction: column;
        height: 82vh; /* match description column */
        min-height: 0; /* allow children to shrink within */
    }

    .panes.two-col .col-left .source-box,
    .panes.two-col .col-left .output-box {
        flex: 1 1 0; /* split available height */
        min-height: 0; /* enable internal scrolling */
        max-height: none; /* override earlier cap */
        display: flex;
        flex-direction: column;
        overflow: auto; /* scrolling at box level to keep sticky header */
    }

    /* Right column description to use same fixed height */
    .panes.two-col .col-right .desc-box {
        height: 82vh;
        max-height: none;
        display: flex;
        flex-direction: column;
        overflow: auto;
    }
}

/* Sticky panel headers and copy button */
.box {
    position: relative;
}

.box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    position: sticky;
    top: 0;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    z-index: 2;
    padding-right: 48px; /* reserve room for top-right copy icon */
}

.box-header h2 {
    margin: 0;
    padding: .6rem .8rem;
    border-bottom: 0; /* prevent double border (separator is on .box-header) */
}

.copy-btn {
    margin-right: 0; /* no margin when absolutely positioned */
    padding: .25rem;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0; /* hide any accidental text */
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--fg);
    cursor: pointer;
    position: absolute;
    top: 6px;
    right: 8px;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.copy-btn:hover {
    background: var(--surface-1);
}

/* transient tooltip after copy */
.copy-btn.show-status::after {
    content: attr(data-status);
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface-1);
    color: var(--muted-strong);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    font-size: .7rem;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    z-index: 3;
}

/* Override panel scrolling to happen at the box level (so headers stay sticky) */
@media (min-width: 1024px) {
    .panes.two-col .source-box,
    .panes.two-col .output-box,
    .panes.two-col .desc-box {
        max-height: 40vh; /* default for left; desc overridden below */
        overflow: auto; /* vertical scroll lives on the box */
        display: flex;
        flex-direction: column;
    }

    .panes.two-col .desc-box {
        max-height: 82vh;
    }

    /* Let pre only scroll horizontally; vertical handled by box */
    .panes.two-col .source-box pre,
    .panes.two-col .output-box pre {
        flex: 0 0 auto;
        overflow-y: visible;
        overflow-x: auto;
    }

    /* Description content should not create a nested vertical scroll */
    .panes.two-col .desc-box .desc {
        overflow: visible;
        flex: 0 0 auto;
    }
}

/* Final override to ensure full-height split on desktop */
@media (min-width: 1024px) {
    .panes.two-col .col-left {
        height: 82vh;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .panes.two-col .col-left .source-box,
    .panes.two-col .col-left .output-box {
        flex: 1 1 0;
        max-height: none;
        min-height: 0;
        overflow: auto;
        display: flex;
        flex-direction: column;
    }

    .panes.two-col .col-right .desc-box {
        height: 82vh;
        max-height: none;
    }

    .panes.two-col .col-left .source-box pre,
    .panes.two-col .col-left .output-box pre {
        flex: 1 1 auto;
        overflow: auto;
    }
}

.box {
    min-height: 280px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.box h2 {
    margin: 0;
    font-size: .75rem;
    letter-spacing: .6px;
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    color: var(--muted);
}

pre, code {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(.8rem, .76rem + .2vw, 1rem);
    line-height: 1.5;
}

pre {
    margin: 0;
    padding: 1rem;
    overflow: auto;
    white-space: pre;
    flex: 1;
}

/* Console style for Source and Output */
#source, #output {
    background: var(--code-bg);
    color: var(--code-fg);
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(.68rem, .62rem + .25vw, .9rem);
    line-height: 1.4;
}

#output {
    white-space: pre; /* preserve newlines and spaces; do not wrap */
    word-wrap: normal; /* disable forced word wrapping */
    overflow: auto; /* allow horizontal/vertical scrollbars if needed */
    font-variant-ligatures: none; /* avoid glyph ligatures that can affect alignment */
}

/* Keep Source non-wrapping as well for consistency */
#source {
    white-space: pre;
    overflow: auto;
    font-variant-ligatures: none;
}

/* Slightly reduce font size on very small screens to improve fit */
@media (max-width: 420px) {
    #source, #output {
        font-size: 0.9rem;
    }
}

/* Description - Modern normal style */
.desc {
    margin: 0;
    padding: 1.5rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--desc-text);
    background: var(--desc-bg);
    overflow-y: auto;
    flex: 1;
}

.desc h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--desc-heading);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.desc h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--desc-heading);
    letter-spacing: -0.005em;
    line-height: 1.4;
}

.desc h3:first-child,
.desc h4:first-child {
    margin-top: 0;
}

.desc p {
    margin: 0 0 1rem 0;
    line-height: 1.7;
}

.desc p:last-child {
    margin-bottom: 0;
}

.desc ul, .desc ol {
    margin: 0 0 1rem 0;
    padding-left: 1.5rem;
    line-height: 1.7;
}

.desc li {
    margin-bottom: 0.5rem;
}

.desc li:last-child {
    margin-bottom: 0;
}

.desc strong {
    font-weight: 600;
    color: var(--desc-heading);
}

.desc em {
    font-style: italic;
    color: var(--desc-text);
}

.desc code {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
    background: var(--surface-2);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    border: 1px solid var(--border);
}

footer {
    text-align: center;
    padding: 1rem;
    font-size: .75rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

footer a {
    color: var(--muted-strong);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--fg);
}
