/* ================================================================
   THEME VARIABLES — Catppuccin Mocha (dark) & Latte (light)
   ================================================================ */

body,
body.theme-dark {
    --bg: #1e1e2e;
    --surface: #282840;
    --surface-alt: #313244;
    --border: #44446a;
    --text: #cdd6f4;
    --text-muted: #6c7086;
    --accent: #89b4fa;
    --accent-hover: #b9d0fc;
    --accent-text: #1e1e2e;
    --error: #f38ba8;
    --success: #a6e3a1;
    --kbd-bg: #313244;
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

body.theme-light {
    --bg: #eff1f5;
    --surface: #e6e9ef;
    --surface-alt: #dce0e8;
    --border: #acb0be;
    --text: #4c4f69;
    --text-muted: #9ca0b0;
    --accent: #1e66f5;
    --accent-hover: #3478f7;
    --accent-text: #ffffff;
    --error: #d20f39;
    --success: #40a02b;
    --kbd-bg: #dce0e8;
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

/* ================================================================
   RESET & BASE
   ================================================================ */

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

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100%;
    overflow: hidden;
    transition: background 0.2s, color 0.2s;
}

/* Pass height through Blazor's wrapper chain */
#app,
main {
    height: 100%;
}

/* ================================================================
   PAGE WRAPPER
   ================================================================ */

.page-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    padding: 0.75rem 1rem 0.5rem;
    gap: 0.5rem;
    overflow-y: auto;
}

/* ================================================================
   TOP BAR
   ================================================================ */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.01em;
}

.theme-toggle {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
    background: var(--surface-alt);
    border-color: var(--accent);
}

/* ================================================================
   TOOLBAR
   ================================================================ */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: 0.75rem;
}

.toolbar-run {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.example-select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 200px;
    transition: border-color 0.15s, background 0.15s;
}

.example-select:focus {
    outline: none;
    border-color: var(--accent);
}

.example-select option {
    background: var(--surface);
    color: var(--text);
}

.keyboard-hint {
    font-size: 0.73rem;
    color: var(--text-muted);
    background: var(--kbd-bg);
    border: 1px solid var(--border);
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    white-space: nowrap;
}

.run-button {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    padding: 0.4rem 1.1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.run-button:hover:not(:disabled) {
    background: var(--accent-hover);
}

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

/* ================================================================
   PLAYGROUND LAYOUT
   ================================================================ */

.playground-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
}

.editor-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Monaco renders a div directly inside editor-panel — give it full height */
.editor-panel > div {
    flex: 1;
    min-height: 0;
}

.output-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background 0.2s, border-color 0.2s;
}

/* ================================================================
   PANEL HEADER
   ================================================================ */

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.stats {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
    font-family: var(--font-mono);
}

/* ================================================================
   OUTPUT CONTENT
   ================================================================ */

.output-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.output {
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.83rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--success);
    flex: 1;
}

.output.muted {
    color: var(--text-muted);
}

.errors {
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.83rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--error);
    border-top: 1px solid var(--border);
}

/* ================================================================
   LIMITATIONS BANNER
   ================================================================ */

.limitations-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.limitations-icon {
    flex-shrink: 0;
    color: var(--accent);
    font-size: 0.9rem;
    line-height: 1.5;
}

.limitations-text {
    flex: 1;
    line-height: 1.5;
}

.limitations-text code {
    font-family: var(--font-mono);
    background: var(--surface-alt);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.73rem;
    color: var(--text);
}

.limitations-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 0.25rem;
    line-height: 1;
    transition: color 0.15s;
}

.limitations-dismiss:hover {
    color: var(--text);
}

/* ================================================================
   SHOWCASES SECTION
   ================================================================ */

.showcases-section {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
}

.showcases-heading {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.showcase-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
    transition: border-color 0.15s, background 0.2s;
}

.showcase-card:hover {
    border-color: var(--accent);
}

.showcase-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s;
    text-align: left;
}

.showcase-header:hover {
    background: var(--surface-alt);
}

.showcase-title {
    flex: 1;
}

.showcase-chevron {
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.showcase-body {
    border-top: 1px solid var(--border);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.showcase-code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.55;
    overflow-x: auto;
    color: var(--text);
    white-space: pre;
    margin: 0;
}

.showcase-code code {
    font-family: inherit;
    font-size: inherit;
    background: none;
    padding: 0;
}

.showcase-output-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.showcase-output {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--success);
    white-space: pre;
    overflow-x: auto;
    margin: 0;
}

.showcase-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.showcase-download-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.showcase-download-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ================================================================
   LOADING SCREEN
   ================================================================ */

/* ================================================================
   TOOLBAR ACTIONS
   ================================================================ */

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.action-button:hover {
    background: var(--surface-alt);
    border-color: var(--accent);
}

.share-button {
    min-width: 6.5rem;
    text-align: center;
}

/* ================================================================
   COPY OUTPUT BUTTON
   ================================================================ */

.panel-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    min-width: 5.5rem;
    text-align: center;
}

.copy-button:hover {
    background: var(--surface-alt);
    color: var(--text);
    border-color: var(--accent);
}

/* ================================================================
   VERSION FOOTER
   ================================================================ */

.version-footer {
    flex-shrink: 0;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.25rem 0 0.5rem;
    letter-spacing: 0.03em;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 900px) {
    body {
        overflow: auto;
        height: auto;
    }

    #app,
    main {
        height: auto;
    }

    .page-wrapper {
        height: auto;
        padding-bottom: 1rem;
    }

    .playground-container {
        grid-template-columns: 1fr;
        flex: none;
        height: auto;
    }

    .editor-panel {
        height: 50vh;
        min-height: 300px;
    }

    .output-panel {
        height: 40vh;
        min-height: 200px;
    }

    .toolbar-actions {
        flex-wrap: wrap;
    }
}
