/* ---- styles.css ---- */

/* Global Styles */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

/* ---- Theme Variables ---- */
:root {
    --bg: #121212;
    --surface: #1e1e1e;
    --panel: #252526;
    --panel-alt: #1a1a2e;
    --border-main: rgba(255,255,255,0.08);
    --text: #f0f0f0;
    --text-muted: #9a9a9a;
    --accent: #00ff88;
    --accent-strong: #ffffff;
    --button-bg: #1a1a2e;
    --button-hover: #393948;
    --button-danger: #d53737;
    --button-warning: #f0c040;
    --shadow: rgba(0,0,0,0.18);
    --shadow-inset: rgba(0,0,0,0.25);
    --focus-ring: rgba(14,99,156,0.45);
    --overlay-bg: rgba(0,0,0,0.75);
    --input-bg: rgba(255,255,255,0.08);
    --surface-muted: rgba(255,255,255,0.08);
    --surface-strong: rgba(255,255,255,0.15);
    --surface-border: rgba(255,255,255,0.06);
    --panel-strong: rgba(30, 30, 30, 0.7);
    --panel-strong-hover: rgba(60, 60, 60, 0.95);
}

body.theme-light {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --panel: #ededed;
    --panel-alt: #d9d9d9;
    --border-main: rgba(0,0,0,0.08);
    --text: #111111;
    --text-muted: #555555;
    --accent: #0066cc;
    --accent-strong: #0a3e7f;
    --button-bg: #ffffff;
    --button-hover: #e2e2e2;
    --button-danger: #b92a2a;
    --button-warning: #b37400;
    --shadow: rgba(0,0,0,0.12);
    --shadow-inset: rgba(0,0,0,0.16);
    --focus-ring: rgba(0,102,204,0.35);
    --overlay-bg: rgba(0,0,0,0.5);
    --input-bg: rgba(0,0,0,0.06);
    --surface-muted: rgba(0,0,0,0.06);
    --surface-strong: rgba(0,0,0,0.1);
    --surface-border: rgba(0,0,0,0.08);
    --panel-strong: rgba(0,0,0,0.1);
    --panel-strong-hover: rgba(0,0,0,0.15);
}

body.theme-dark {
    --bg: #121212;
    --surface: #1e1e1e;
    --panel: #252526;
    --panel-alt: #1a1a2e;
    --border-main: rgba(255,255,255,0.08);
    --text: #f0f0f0;
    --text-muted: #9a9a9a;
    --accent: #00ff88;
    --accent-strong: #ffffff;
    --button-bg: #1a1a2e;
    --button-hover: #393948;
    --button-danger: #d53737;
    --button-warning: #f0c040;
    --shadow: rgba(0,0,0,0.18);
    --shadow-inset: rgba(0,0,0,0.25);
    --focus-ring: rgba(14,99,156,0.45);
    --overlay-bg: rgba(0,0,0,0.75);
    --input-bg: rgba(255,255,255,0.08);
    --surface-muted: rgba(255,255,255,0.08);
    --surface-strong: rgba(255,255,255,0.15);
    --surface-border: rgba(255,255,255,0.06);
    --panel-strong: rgba(30, 30, 30, 0.7);
    --panel-strong-hover: rgba(60, 60, 60, 0.95);
}

html, body {
    background: var(--bg);
    color: var(--text);
}

.wgc-container{
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---- Header Styles ---- */
.header-bar{

}

.header-left{

}


.header-right{

}


/* ---- Layout Toggle Styles ---- */
.layout-toggle{

}

.layout-btn{

}



.view-layout-tabs {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

#tab-canvas, #tab-console {

}

#close-console-btn {
}


/* ---- Workspace Styles ---- */
.workspace-area{
    position: relative;
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background-color: var(--panel);
}

.workspace-left-panel, .workspace-right-panel{
    flex: 1;
    position: relative;
    min-width: 0; /* Important for flex children to allow proper shrinking */;
    min-height: 0; /* Important for flex children to allow proper shrinking */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace-left-toolbar{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: auto;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    min-width: 0;
}

.toolbar-menu-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
}

.menu-button-group {
    position: relative;
    display: inline-flex;
    align-items: center;
}



.script-title-text{
    font-size: .95rem;
    color: var(--text);
    margin: 0;
    font-family: monospace;
}


/* ---- Editor and Console Styles ---- */
.compile-button-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---- Compile Button Styles ---- */
.compile-btn{
    position: static;
    width: 2rem;
    height: 2rem;
    z-index: 1;
    background: var(--button-bg);
    color: var(--accent);
    border: none;
    padding: 0.5rem;
    border-radius: 0.35rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
    box-shadow: 0 4px 8px var(--shadow);
    outline: none;
}

.compile-btn:hover {
    background: var(--button-hover);
}

.compile-btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px var(--shadow-inset);
}

.compile-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.compile-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---- Stop Button Styles ---- */
.stop-btn{
    position: static;
    font-size: 1.2rem;
    width: 2rem;
    height: 2rem;
    z-index: 1;
    background: var(--button-bg);
    color: var(--button-danger);
    border: none;
    border-radius: 0.35rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
    box-shadow: 0 4px 8px var(--shadow);
    outline: none;
}

.stop-btn:hover {
    background: var(--button-hover);
}

.stop-btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px var(--shadow-inset);
}

.stop-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.stop-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---- Pause Button Styles ---- */
.pause-btn{
    position: static;
    font-size: .9rem;
    width: 2rem;
    height: 2rem;
    z-index: 1;
    background: var(--button-bg);
    color: var(--text);
    border: none;
    padding: 0.5rem;
    border-radius: 0.35rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
    box-shadow: 0 4px 8px var(--shadow);
    outline: none;
}

.pause-btn:hover {
    background: var(--button-hover);
}

.pause-btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px var(--shadow-inset);
}

.pause-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.pause-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.pause-btn.paused {
    background: var(--panel-alt);
    color: var(--button-warning);         /* yellow tint to signal "currently paused" */
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}



.compile-status {
    display: inline-flex;
    align-items: center;
    margin-right: 0.75rem;
    color: var(--text);
    opacity: 0.85;
    font-size: 0.88rem;
    line-height: 1;
    font-family: monospace;
    min-width: 6rem;
    justify-content: flex-end;
}

.compile-status.hidden {
    display: none;
}

.compile-status.loading::before {
    content: '';
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    margin-right: 0.45rem;
    border: 2px solid var(--surface-muted);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

/* ---- File Explorer Styles ---- */
#file-button,
#settings-button {
    background: transparent;
    color: var(--text);
    border: none;
    height: 100%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 0 0.65rem;
    border-radius: 0.35rem;
    transition: background 0.15s ease;
}

#file-button:hover,
#settings-button:hover {
    background: var(--surface-muted);
}


.file-menu-container {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    width: 12rem;
}

#file-menu {
    /* list down menu styles */

    display: flex;
    flex-direction: column;
    align-items: stretch;
    /*display: none;*/
    background: var(--surface);
    border: 1px solid var(--border-main);
    border-radius: 0.35rem;
    box-shadow: 0 4px 8px var(--shadow);
    padding: 0.5rem 0;
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    color: var(--text);
}

.file-menu-item {
    background: transparent;
    border: none;
    padding: 0.5rem 1.5rem;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    transition: background-color 0.1s ease;
}

.file-menu-item:hover {
    background: var(--surface-muted);
}


/* ---- Editor and Console Styles ---- */
.editor-container{
    display: flex;
    flex: 1;
    min-height: 0;
    background-color: var(--surface);
    border: 1px solid var(--border-main);
    box-sizing: border-box;
    color: var(--text);
}

/* ---- File Explorer Styles ---- */
.explorer-panel{
    display: none;
    width: auto;
    border-right: 1px solid var(--border-main);
    box-sizing: border-box;
    padding: 1rem;
    font-family : "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;  
    font-size: 0.9rem;
    line-height: 1.25rem;  
    position: relative; 
}

#explorer-toggle-btn {
    background: var(--surface-muted);
    color: var(--text-muted);
    border: none;
    border-radius: 0.35rem;
    cursor: pointer;
    width: 2rem;
    height: 1rem;
    top: 2rem;
    right: .1rem;
    position: absolute;
}

.explorer-toolbar{
    display: flex;
}

#new-file-btn {
    background: var(--surface-muted);
    margin-left: auto;
    color: var(--text-muted);
    border: none;
    padding: 0.5rem;
    border-radius: 0.35rem;
    cursor: pointer;
}

.explorer-tree-file {
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    cursor: pointer;
    color: var(--text);
    user-select: none;
}

.explorer-tree-file:hover {
    background-color: var(--surface-muted);
}

.explorer-tree-file.selected {
    background-color: var(--surface-strong);
    color: var(--text);
}

/* ---- Editor and Console Styles ---- */
#monaco-editor-container {
    flex: 1;
    display: flex;
    min-width: 0; /* Important for flex children to allow proper shrinking */
    min-height: 0;
    overflow: hidden;
}


/* ---- Split Handle Styles ---- */
.split-handle{
    width: 8px;
    background-color: var(--surface-muted);
    cursor: col-resize;
    align-self: stretch;
}

.horizontal-split-handle{
    height: 8px;
    background-color: var(--surface-muted);
    cursor: row-resize;
    flex-shrink: 0;
}


/* ---- Canvas and Console Styles ---- */
.canvas-console-container{
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.canvas-container{
    flex: 1;
    min-height: 0;
    background-color: var(--panel-alt);
    border: 1px solid var(--border-main);
    padding: 0;
    font-family: "Cascadia Code", Menlo, Monaco, Consolas,
                 "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.25rem;
    position: relative;
    overflow-y: hidden;
    box-sizing: border-box;
    color: var(--text);
    white-space: pre-wrap;
}

#output-canvas {
    position:absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block; /* Remove default inline spacing */
}

#canvas-title-overlay {
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    pointer-events: none;
    white-space: nowrap;
}

#console-output-container{
    position: relative;
    flex: none;
    height: 24vh;
    max-height: 40vh;
    min-height: 2.5rem;
    background-color: var(--surface);
    border: 1px solid var(--border-main);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.console-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.5rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--surface-border);
}

#console-title-overlay {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    pointer-events: none;
    margin: 0;
}

#console-log-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    min-height: 0;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.25rem;
    color: var(--text);
    white-space: pre-wrap;
    box-sizing: border-box;
}

.layout-toggle-container{
    display: flex;
}

.layout-btn{
    z-index: 1;
    background: var(--surface-muted);
    color: var(--text-muted);
    border: none;
    padding: 0.5rem;
    border-radius: 0.35rem;
}


/* ---- Shared Styles ---- */
.share-container{
    position: absolute;
    z-index: 20;
    top: 50%;
    left: 50%;
    width: 35%;
    height: 45%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--overlay-bg);
    color: var(--text);
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 1rem;
}

.share-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    z-index: -1;
}

.share-header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.5rem 1rem;
    box-sizing: border-box;
}

.share-title{
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.close-btn{
    background: var(--surface-muted);
    color: var(--text-muted);
    border: none;
    border-radius: 0.35rem;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    margin-top: 1rem;
}

.close-btn:hover{
    background: var(--surface-strong);
}

.close-btn:active{
    background: var(--surface-strong);
}

.share-description{
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.25rem 0 1rem;
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
}   

.share-data-container{
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: left;
    width: 100%;
    padding: 0 1rem ;
    padding-bottom: 2.5rem;
    box-sizing: border-box;
}



.share-url-container{
    display: flex;
    align-items: left;
    width: 100%;
    margin-top: 0.5rem;
}

.share-btn{
    background: var(--surface-muted);
    color: var(--text-muted);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.35rem;
    cursor: pointer;
    margin-top: 0.5rem;
}

#sketch-name{
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0.25rem 0 1rem;
    text-align: left;
    margin-left: 1rem;
    width: 100%;
    font-style: italic;
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
}

.share-url-input{
    flex: 1;
    background: var(--input-bg);
    color: var(--text);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.35rem;
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.copy-btn{
    background: var(--surface-muted);
    color: var(--text-muted);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.35rem;
    cursor: pointer;
}

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

.copy-btn:active{
    background: var(--surface-strong);
}

/* ---- Panel Minimize/Expand Toggle Buttons ---- */

/* Canvas and console toggles: absolute top-right corner */
.panel-toggle-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    left: auto;
    z-index: 6;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    border-radius: 0.25rem;
    background: var(--panel-strong);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.45;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.panel-toggle-btn:hover {
    opacity: 1;
    background: var(--panel-strong-hover);
}

/* Code panel toggle: inline in toolbar */
.code-panel-toggle-btn {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 0.35rem;
    background: var(--button-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 4px 8px var(--shadow);
    transition: background 0.1s ease, color 0.1s ease;
    flex-shrink: 0;
}
.code-panel-toggle-btn:hover {
    background: var(--button-hover);
    color: var(--text);
}

/* Collapsed: left/code panel */
.workspace-left-panel.collapsed {
    flex: none;
    width: 2.5rem;
    min-width: 2.5rem;
    overflow: hidden;
}
.workspace-left-panel.collapsed .editor-container {
    display: none;
}
.workspace-left-panel.collapsed .workspace-left-toolbar > :not(.compile-button-container) {
    display: none;
}
.workspace-left-panel.collapsed .compile-button-container > :not(#collapse-code-btn) {
    display: none;
}
.workspace-left-panel.collapsed .workspace-left-toolbar {
    justify-content: center;
    padding: 0.5rem 0;
}
.workspace-left-panel.collapsed .compile-button-container {
    justify-content: center;
}

/* Panel-collapsed: center title label when minimized */
.canvas-container.panel-collapsed #canvas-title-overlay {
    top: 50%;
    right: auto;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ===== Settings Menu ===== */
.settings-menu-container {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    width: 12rem;
}

#settings-menu {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border-main);
    border-radius: 0.35rem;
    box-shadow: 0 4px 8px var(--shadow);
    padding: 0.5rem 0;
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    color: var(--text);
}

/* ===== Styles Modal ===== */
.styles-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.styles-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
}

.styles-modal-panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-main);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px var(--shadow);
    padding: 1.25rem 1.5rem;
    min-width: 18rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.styles-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.styles-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
}

.styles-modal-body {
    display: flex;
    gap: 1rem;
}

/* ===== Theme Option Cards ===== */
.theme-option-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0.5rem;
    background: var(--panel);
    border: 2px solid var(--border-main);
    border-radius: 0.4rem;
    cursor: pointer;
    color: var(--text);
    font-family: "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.85rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.theme-option-btn:hover {
    background: var(--surface-muted);
    border-color: var(--accent);
}

.theme-option-btn.active {
    border-color: var(--accent);
    background: var(--surface-strong);
}

.theme-option-swatch {
    width: 3.5rem;
    height: 2.2rem;
    border-radius: 0.3rem;
    border: 1px solid var(--border-main);
    display: block;
}

.theme-swatch-dark {
    background: #1e1e1e;
}

.theme-swatch-light {
    background: #f5f5f5;
}

.theme-option-label {
    font-size: 0.8rem;
    color: var(--text);
}

.theme-option-check {
    font-size: 0.85rem;
    color: var(--accent);
    opacity: 0;
}

.theme-option-btn.active .theme-option-check {
    opacity: 1;
}
