:root {
    /* Fallback values */
    --bg-workspace: #f8f9fa;
    --bg-toolbox:   #87CEFA;
    --softBlue-accent:  #2c6d9f;
    --secondary-color: #3b9396;
    --text-color:    #2d2d2d;
}

body {
    /* No zoom here — CSS zoom distorts Blockly's SVG coordinate system,
       causing block fields and labels to render outside their block boundaries.
       Zoom is applied on #mainAppContent instead, which only scales the UI
       chrome (toolbar + output pane) without touching the Blockly SVG layer. */
    margin: 0;
    font-family: sans-serif;
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: auto;
    background-color: var(--bg-workspace);
    color: var(--text-color);
    box-sizing: border-box;
}

/* #loadingOverlay base rule is in the Shell Mode section below,
   shared by both shell and workspace modes. */

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top: 5px solid var(--softBlue-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#appTitle {
    color: var(--text-color);
    margin-right: 20px;
    font-size: 20px;
    text-align: center;
}

label {
    text-align: center;
    color: var(--text-color);
}

#mainAppContent {
    /* zoom here scales only the UI chrome (toolbar, buttons, selects, output pane).
       Blockly injects its own SVG element *inside* #blocklyDiv which is a child of
       this element, but Blockly calls Blockly.svgResize() after inject and on every
       resize event, so it correctly measures the zoomed container and redraws
       block coordinates to match — no field-overflow bug. */
    zoom: 0.9;
    display: none;
    flex-direction: column;
    height: 100vh;
}

#pageContainer {
    width: 100%;
    height: 100%;
    overflow: hidden;            /* Changed to hidden to prevent double scrollbars */
    margin: auto;
    display: flex;
    flex-direction: column;      /* FOR HORIZONTAL: Change to 'row' */
    flex: 1;
}

#blocklyDiv {
    flex: 7 1 60%;
    width: 100%;
    overflow: hidden;
}

/* Resizer Bar Styles */
#resizer {
    background: var(--softBlue-accent);
    height: 6px;                /* FOR HORIZONTAL: Change to 100% height */
    /* width: 100%; */           /* FOR HORIZONTAL: Change to 10px width */
    cursor: ns-resize;           /* FOR HORIZONTAL: Change to ew-resize */
    transition: background 0.2s;
    z-index: 10;
    opacity: 0.3;
}

#resizer:hover {
    opacity: 1;
}

#outputPane {
    flex-grow: 1;
    flex-basis: 20%;             /* Ensures a minimum height of 20% */
    height: auto;
    overflow-y: auto;            /* Vertical scrolling */
    overflow-x: auto;            /* Enable horizontal scroll ONLY if a single word is too long */
    border-style: ridge;
    border-top: 2px solid var(--softBlue-accent);
    background: var(--bg-workspace);
    color: var(--text-color);
}

pre,
code {
    white-space: pre-wrap;       /* Maintains formatting but wraps text */
    overflow-wrap: normal;       /* Do not force-break words */
    word-break: keep-all;        /* Prevents breaking words in the middle */
    flex-grow: 1;
    margin: 0;                   /* Remove default pre margins */
    padding: 10px;
}

.setupSelector select {
    background-color: var(--bg-workspace);
    color: var(--text-color);
    border: 1px solid var(--softBlue-accent);
    padding: 5px;
    border-radius: 4px;
    cursor: pointer;
}

#auxiliar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

button {
    background-color: var(--softBlue-accent);
    color: white;
    border: none;
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

button:hover {
    background-color: var(--secondary-color);
}

.btn {
    color: var(--text-color);
    text-decoration: none;
    font-weight: bold;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

#controls {
    background-color: var(--bg-toolbox);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 2px solid var(--softBlue-accent);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group input[type="number"] {
    width: 50px;
    padding: 5px;
    border: 1px solid var(--softBlue-accent);
    border-radius: 4px;
}

#resetInterval {
    width: 40px; 
    /*padding: 5px; */
    font-size: 14px;
    text-align: center;
}

#outputList details {
    border-bottom: 1px solid var(--blockly-toolbar-bg, #ccc);
    padding: 4px 0;
}

#outputList summary {
    font-size: 0.8em;
    cursor: pointer;
    padding: 6px 8px;
    font-weight: bold;
    user-select: none;
    list-style: none;
}

#outputList summary::before {
    content: '▶ ';
    font-size: 0.7em;
}

details[open] > summary::before {
    content: '▼ ';
}

#outputList pre {
    margin: 0;
    padding: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85em;
}
/* ══════════════════════════════════════════════════════════════════════════
   SHELL MODE  — styles for the tab host page (no ?slot)
   Previously inline in index.html; consolidated here for single-source CSS.
   ══════════════════════════════════════════════════════════════════════════ */

/* Override workspace body rules that shrink the shell and leave side gaps */
body.shell-mode {
    zoom: 1 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

#tabShell {
    display: none;               /* Shown via JS when shell mode is active */
    flex-direction: column;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Tab bar — only as tall as the buttons */
#tabBar {
    display: flex;
    align-items: flex-end;       /* Tabs sit flush against the bottom border */
    gap: 2px;
    padding: 4px 6px 0;
    background: #e9ecef;
    border-bottom: 2px solid #adb5bd;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    background: #d0d7de;
    cursor: pointer;
    font-size: 12px;
    color: #444;
    white-space: nowrap;
    line-height: 1;
    user-select: none;
    transition: opacity 0.15s;
}

.tab-btn.active {
    background: #fff;
    border-color: #adb5bd;
    border-bottom-color: #fff;   /* Merges visually with the content area */
    color: #111;
    font-weight: 600;
    position: relative;
    bottom: -2px;                /* Covers the tab bar's bottom border */
    padding-bottom: 7px;
}

.tab-btn.drag-over {
    outline: 2px dashed #2c6d9f;
    outline-offset: -2px;
}

.tab-btn.dragging { opacity: 0.4; }

.tab-close {
    font-size: 10px;
    color: #888;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-left: 2px;
}

.tab-close:hover { color: #c0392b; }

#addTab {
    padding: 4px 9px;
    background: none;
    border: 1px solid #adb5bd;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 15px;
    color: #555;
    line-height: 1;
    flex-shrink: 0;
    align-self: center;
    margin-bottom: 2px;
}

#addTab:hover { background: #dee2e6; }

/* iframe container — fills everything below the tab bar */
#iframeContainer {
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

#iframeContainer iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: none;
}

#iframeContainer iframe.visible { display: block; }

/* Loading overlay — shared between shell and workspace modes.
   Uses var(--bg-workspace) so it respects the active theme;
   falls back to white before CSS custom properties are resolved. */
#loadingOverlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-workspace, white);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

/* Hidden by default; JS sets display:block once the workspace is ready */
#mainAppContent { display: none; }
