/* ==========================================================================
   PL/SW IDE -- App styles (Catppuccin Mocha theme)
   ========================================================================== */

/* --- 3-column wizard layout --- */
#app.plsw-layout {
    display: grid;
    grid-template-columns: 15% 1fr;
    height: 100%;
    overflow: hidden;
}

/* Left side panel: controls + wizard steps */
.side-panel {
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: var(--mantle);
    border-right: 1px solid var(--surface1);
    gap: 8px;
    overflow-y: auto;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-section-label {
    font-size: 0.7em;
    color: var(--overlay0);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 4px;
}

.sidebar-btn {
    width: 100%;
    padding: 7px 8px;
    background: var(--surface0);
    color: var(--blue);
    border: 1px solid var(--surface1);
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--mono);
    font-weight: bold;
    font-size: 0.75em;
    transition: all 0.15s;
}

.sidebar-btn:hover {
    background: var(--surface1);
    border-color: var(--blue);
}

.sidebar-select {
    width: 100%;
    padding: 6px 8px;
    background: var(--surface0);
    color: var(--text);
    border: 1px solid var(--surface1);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.75em;
    cursor: pointer;
}

.sidebar-select:focus {
    outline: none;
    border-color: var(--blue);
}

.sidebar-demo-desc {
    font-size: 0.7em;
    color: var(--overlay0);
    line-height: 1.3;
    padding: 0 2px;
}

.sidebar-divider {
    height: 1px;
    background: var(--surface1);
    margin: 4px 0;
}

.sidebar-spacer {
    flex: 1;
}

.sidebar-link {
    display: block;
    padding: 7px 8px;
    color: var(--overlay2);
    text-decoration: none;
    font-size: 0.75em;
    font-weight: bold;
    border-radius: 4px;
    transition: color 0.15s;
}

.sidebar-link:hover {
    color: var(--blue);
}

.sidebar-link .ext-icon {
    font-size: 0.8em;
}

/* Column 2: Wizard steps */
.wizard-steps {
    display: flex;
    flex-direction: column;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 4px;
    margin-bottom: 3px;
    cursor: default;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.wizard-step.active {
    background: var(--surface0);
    border-color: var(--blue);
}

.wizard-step.completed {
    cursor: pointer;
}

.wizard-step.completed:hover {
    background: rgba(137, 180, 250, 0.08);
}

.wizard-step.completed .step-indicator {
    color: var(--green);
}

.wizard-step.disabled {
    opacity: 0.35;
}

.step-indicator {
    font-size: 1em;
    width: 18px;
    text-align: center;
    color: var(--blue);
}

.step-label {
    color: var(--subtext1);
    font-size: 0.8em;
}

.wizard-action-btn {
    margin-top: 14px;
    padding: 9px 14px;
    background: var(--blue);
    color: var(--crust);
    border: none;
    border-radius: 4px;
    font-family: var(--mono);
    font-weight: bold;
    font-size: 0.82em;
    cursor: pointer;
    transition: all 0.2s;
    animation: wizard-btn-glow 1.8s ease-in-out infinite;
}

@keyframes wizard-btn-glow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(137, 180, 250, 0.5), 0 0 16px rgba(137, 180, 250, 0.3);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px rgba(137, 180, 250, 0.8), 0 0 40px rgba(137, 180, 250, 0.5);
        transform: scale(1.02);
    }
}

.wizard-action-btn:hover {
    background: var(--lavender);
}

.wizard-spacer {
    flex: 1;
}

/* Column 3: Notebook cells */
.notebook-cells {
    overflow-y: auto;
    padding: 12px;
    padding-bottom: calc(100vh - 150px);
    scroll-behavior: smooth;
    background: var(--base);
}

.notebook-cell {
    background: var(--mantle);
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid var(--surface0);
}

.cell-header {
    padding: 8px 12px;
    background: var(--surface0);
    color: var(--yellow);
    font-weight: bold;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cell-header-example {
    font-weight: bold;
    font-size: 0.85em;
    color: var(--yellow);
    font-style: italic;
}

.cell-content {
    padding: 0;
}

/* --- Source editor (textarea + highlight overlay) --- */
.editor-container {
    position: relative;
    min-height: 300px;
    height: 50vh;
}

.editor-highlight,
.editor-textarea {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 12px;
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.5;
    border: none;
    white-space: pre;
    overflow: auto;
    tab-size: 2;
    word-wrap: normal;
}

.editor-highlight {
    background: var(--mantle);
    color: var(--text);
    pointer-events: none;
    z-index: 1;
}

.editor-highlight code {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.editor-textarea {
    background: transparent;
    color: transparent;
    caret-color: var(--text);
    resize: none;
    outline: none;
    z-index: 2;
    -webkit-text-fill-color: transparent;
}

.editor-textarea::selection {
    background: rgba(137, 180, 250, 0.25);
    -webkit-text-fill-color: transparent;
}

/* --- Syntax highlighting colors (Catppuccin Mocha) --- */
.hl-keyword {
    color: var(--mauve);
    font-weight: bold;
}

.hl-comment {
    color: var(--overlay1);
    font-style: italic;
}

.hl-string {
    color: var(--green);
}

.hl-number {
    color: var(--peach);
}

.hl-macro {
    color: var(--yellow);
    font-weight: bold;
}

.hl-asm {
    color: var(--red);
    font-weight: bold;
}

.hl-asm-text {
    color: var(--teal);
}

/* --- Macro editor --- */
.macro-header-actions {
    display: flex;
    gap: 4px;
}

.macro-action-btn {
    padding: 2px 8px;
    background: var(--surface1);
    color: var(--blue);
    border: 1px solid var(--surface2);
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.85em;
    font-weight: bold;
    transition: all 0.15s;
}

.macro-action-btn:hover {
    background: var(--surface2);
    border-color: var(--blue);
}

.macro-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 32px;
    color: var(--overlay1);
    font-size: 0.9em;
}

.macro-empty-hint {
    font-size: 0.8em;
    color: var(--overlay0);
}

/* Horizontal scrolling container for macro file panels */
.macro-file-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px;
    scroll-snap-type: x proximity;
}

.macro-file-cell {
    flex: 0 0 calc(45% - 4px);
    min-width: 300px;
    border: 1px solid var(--surface1);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    scroll-snap-align: start;
}

.macro-file-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--surface0);
    flex-shrink: 0;
}

.macro-collapse-btn {
    padding: 0 4px;
    background: none;
    color: var(--overlay2);
    border: none;
    cursor: pointer;
    font-size: 0.7em;
    transition: color 0.15s;
}

.macro-collapse-btn:hover {
    color: var(--blue);
}

.macro-name-input {
    flex: 1;
    padding: 3px 6px;
    background: var(--mantle);
    color: var(--yellow);
    border: 1px solid transparent;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 0.8em;
    font-weight: bold;
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.macro-name-input:focus {
    border-color: var(--blue);
}

.macro-remove-btn {
    padding: 0 6px;
    background: none;
    color: var(--overlay1);
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    transition: color 0.15s;
}

.macro-remove-btn:hover {
    color: var(--red);
}

.macro-file-textarea {
    flex: 1;
    min-height: 200px;
    height: 30vh;
    margin: 0;
    padding: 10px;
    background: var(--mantle);
    color: var(--text);
    border: none;
    border-top: 1px solid var(--surface0);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
    overflow: auto;
    white-space: pre;
    word-wrap: normal;
    tab-size: 2;
}

/* Macro syntax highlighting */
.hl-macro-keyword {
    color: var(--flamingo);
    font-weight: bold;
}

.hl-directive {
    color: var(--sky);
    font-weight: bold;
}

.hl-gen-string {
    color: var(--teal);
}

.hl-gen-param {
    color: var(--peach);
    font-weight: bold;
}

.hl-type-hint {
    color: var(--lavender);
    font-style: italic;
}

/* --- Macro expansion view --- */
.macro-expansion-view {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 50vh;
    overflow-y: auto;
}

.expansion-line {
    display: flex;
    align-items: baseline;
    padding: 0 12px;
    min-height: 20px;
}

.expansion-line-num {
    width: 36px;
    min-width: 36px;
    text-align: right;
    padding-right: 10px;
    color: var(--overlay0);
    font-size: 0.85em;
    user-select: none;
}

.expansion-line-text {
    flex: 1;
    white-space: pre;
    color: var(--text);
}

.expansion-include .expansion-line-text {
    color: var(--sky);
    font-weight: bold;
}

.expansion-block {
    border-left: 2px solid transparent;
}

.expansion-block:hover {
    border-left-color: var(--yellow);
}

.expansion-invocation {
    display: flex;
    align-items: baseline;
    padding: 1px 12px;
    cursor: pointer;
    background: rgba(249, 226, 175, 0.05);
    border-radius: 2px;
    transition: background 0.15s;
}

.expansion-invocation:hover {
    background: rgba(249, 226, 175, 0.1);
}

.expansion-toggle {
    width: 16px;
    min-width: 16px;
    text-align: center;
    font-size: 0.7em;
    color: var(--yellow);
    user-select: none;
}

.expansion-badge {
    font-size: 0.75em;
    color: var(--overlay1);
    padding: 1px 6px;
    background: var(--surface0);
    border-radius: 3px;
    margin-left: 8px;
    white-space: nowrap;
}

.expansion-content {
    margin-left: 46px;
    padding: 4px 0;
    border-left: 2px solid var(--yellow);
    background: rgba(249, 226, 175, 0.03);
}

.expansion-gen-line {
    display: flex;
    align-items: baseline;
    padding: 0 8px;
    min-height: 20px;
}

.expansion-gutter {
    width: 16px;
    min-width: 16px;
    text-align: center;
    color: var(--surface2);
    user-select: none;
}

.expansion-gen-text {
    flex: 1;
    white-space: pre;
}

.expansion-no-macros {
    padding: 20px;
    text-align: center;
    color: var(--overlay1);
    font-size: 0.9em;
    font-style: italic;
}

/* --- Pipeline output --- */
.pipeline-output {
    margin: 0;
    padding: 12px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: var(--mantle);
    overflow-x: auto;
    white-space: pre;
    max-height: 40vh;
    overflow-y: auto;
}

.compile-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--overlay1);
    font-size: 0.95em;
}

.compile-spinner {
    font-size: 1.2em;
    animation: spin 1s linear infinite;
}

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

.compile-error {
    padding: 12px;
    background: rgba(243, 139, 168, 0.1);
    border-left: 3px solid var(--red);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.error-label {
    color: var(--red);
    font-weight: bold;
}

.compile-note {
    padding: 8px 12px;
    color: var(--overlay0);
    font-size: 0.8em;
    border-top: 1px solid var(--surface0);
}

.cell-header-stats {
    font-size: 0.75em;
    color: var(--overlay1);
    font-weight: normal;
}

.cell-status-ok {
    font-size: 0.85em;
    color: var(--green);
    font-weight: bold;
}

.cell-status-error {
    font-size: 0.85em;
    color: var(--red);
    font-weight: bold;
}

/* --- Notebook placeholder --- */
.notebook-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    background: var(--mantle);
    border-radius: 6px;
    border: 2px dashed var(--surface1);
    color: var(--overlay1);
    font-size: 1em;
}

/* --- Pipeline note --- */
.pipeline-note {
    padding: 12px;
    color: var(--overlay0);
    font-size: 0.8em;
    text-align: center;
}

/* --- File upload (hidden input + label) --- */
.file-upload-input {
    display: none;
}

.file-upload-label {
    display: block;
    width: 100%;
    padding: 7px 8px;
    background: var(--surface0);
    color: var(--blue);
    border: 1px solid var(--surface1);
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--mono);
    font-weight: bold;
    font-size: 0.75em;
    text-align: center;
    transition: all 0.15s;
}

.file-upload-label:hover {
    background: var(--surface1);
    border-color: var(--blue);
}
