/* ===== BASE STYLES ===== */
body {
    font-family: 'Fira Mono', 'Consolas', monospace;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

/* ===== HEADER SECTION ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px 12px 32px;
    background: var(--header-bg);
    color: var(--header-text);
    border-bottom: 1px solid #222;
}

header h1 {
    font-size: 2rem;
    margin: 0;
    background: linear-gradient(to right, #ff8a00, #e52e71);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* ===== MAIN LAYOUT ===== */
.playground-wrapper {
    display: flex;
    flex-direction: row;
    gap: 24px;
    padding: 24px 32px 80px 32px;
    box-sizing: border-box;
}

.editor-section,
.output-section {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ===== EDITOR SECTION ===== */
.editor-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    height: 600px;
    /*overflow: auto;*/
    border: 1px solid #444;
    background: var(--editor-bg, #232323);
    border-radius: 8px 8px 0 0;

}

/* Line numbers */
#line-numbers {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    background: var(--line-number-bg);
    color: var(--line-number-color);
    padding: 12px 8px 12px 0;
    user-select: none;
    min-width: 36px;
    border-right: 1px solid var(--line-number-border);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    height: auto;
    /*min-height: 100%;*/
}

/* Editor container (layers code and highlight) */
.editor-container {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    background: transparent;
    overflow-y: auto;
    /*overflow-x: hidden;*/
    /*overflow: hidden;*/
}

/* ===== EDITOR LAYERS ===== */
#code-text,
#highlighted-code {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    padding: 12px;
    background: transparent;
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
    height: auto;
    min-height: 100%;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    /*overflow: visible;*/
    margin: 0;

    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    /* Ensure proper text rendering */
    font-variant-ligatures: none;
    text-rendering: optimizeSpeed;
    box-sizing: border-box;
}

#highlighted-code {
    z-index: 0;
    pointer-events: none;
    color: var(--text);
    overflow: hidden;
    /* Ensure background layer doesn't interfere with cursor */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Allow scrolling for proper layer synchronization */
    overflow-x: auto;
    overflow-y: auto;
    /* Hide scrollbars but maintain scroll functionality */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#highlighted-code::-webkit-scrollbar {
    display: none;
}

#code-text {
    z-index: 1;
    color: transparent;
    caret-color: var(--caret, var(--text));
    overflow: hidden;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    /* Fix cursor positioning at end of content */
    resize: none;
    /* Ensure cursor is visible at the end */
    min-height: calc(100% + 1.5em);
}

/* ===== LINE NUMBER STYLES ===== */
#line-numbers span {
    display: block;
    padding: 0 4px;
    text-align: right;
    line-height: 1.5;
    color: var(--line-number-color);
    transition: all 0.2s ease;
}

#line-numbers span.active-line {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-weight: bold;
    border-radius: 3px;
}

/* ===== OUTPUT SECTION ===== */
.output-section {
    background: var(--output-bg, #1a1a1a);
    border: 1px solid #333;
    border-radius: 8px 8px 0 0;
    padding: 16px;
    height: 570px;
    overflow: auto;
    font-size: 12px;
    margin-left: 0;
}

#output {
    width: 100%;
    min-height: 300px;
    font-family: inherit;
    background: transparent;
    /*margin: 0;*/
    /*padding: 0;*/
    color: var(--text);
    overflow: auto;
}

/* ===== FOOTER ===== */
footer {
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
}

#summary-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 8px 32px;
    font-size: 14px;
    border-top: 1px solid #333;
}

#exec-time {
    font-weight: bold;
}

#summary-icons {
    display: flex;
    gap: 16px;
    font-size: 13px;
}



/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 900px) {
    .playground-wrapper {
        flex-direction: column;
        gap: 16px;
        padding: 16px 8px 80px 8px;
    }

    .editor-section,
    .output-section {
        min-width: 0;
    }

    #summary-bar {
        padding-left: 8px;
        padding-right: 8px;
    }

    .editor-wrapper {
        height: 220px;
    }

    #code-text,
    #highlighted-code {
        font-size: 13px;
        padding: 6px;
    }
}

@media (max-width: 600px) {
    header,
    #summary-bar {
        padding-left: 4px;
        padding-right: 4px;
        font-size: 13px;
    }

    .editor-section,
    .output-section {
        padding: 0;
    }

    .editor-wrapper {
        height: 140px;
    }

    #code-text,
    #highlighted-code {
        min-height: 140px;
        font-size: 12px;
        padding: 4px;
    }
}