/* =========================================
   ONLINE COMPILER STYLES
   ========================================= */

.compiler-wrapper {
    padding: 2rem 0 4rem;
    max-width: 100%;
}

/* --- HEADER --- */
.compiler-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.compiler-icon {
    font-size: 2.5rem;
    background: rgba(37, 99, 235, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.compiler-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-header);
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.compiler-sub {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* --- CONTROLS & SEARCH --- */
.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Custom Language Selector */
.lang-selector-container {
    position: relative;
    width: 250px;
}

.lang-search-input {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
}

.lang-search-input:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

.lang-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    z-index: 50;
    display: none; 
    margin-top: 5px;
}

.lang-list.show {
    display: block;
}

.lang-option {
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover, .lang-option.selected {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

/* Run Button */
.btn-run {
    background-color: #22c55e;
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-run:hover {
    background-color: #16a34a;
}

.btn-run:disabled {
    background-color: #86efac;
    cursor: wait;
}

/* --- MAIN GRID --- */
.compiler-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    height: 700px;
}

/* --- PANELS --- */
.editor-container, .io-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
}

.panel-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Editor Specifics */
#editor {
    flex-grow: 1;
    border-radius: 0.5rem;
    border: 1px solid #333; 
    min-height: 400px;
}

/* IO Box Styling */
.io-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* FORCED DARK THEME FOR TERMINAL LOOK */
.io-textarea, .io-output {
    width: 100%;
    height: 100%;
    min-height: 150px;
    padding: 1rem;
    background-color: #1e1e1e !important; 
    color: #e2e8f0 !important;
    border: 1px solid #333;
    border-radius: 0.5rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem;
    resize: none;
    line-height: 1.5;
}

.io-output {
    white-space: pre-wrap;
    overflow-y: auto;
}

.io-textarea:focus {
    outline: 1px solid var(--primary);
    border-color: var(--primary);
}

/* =========================================
   MOBILE OPTIMIZATIONS (Max Width 768px)
   ========================================= */
@media (max-width: 768px) {
    
    .compiler-header {
        flex-direction: column;
        align-items: stretch; /* Stretch children to full width */
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .header-left {
        justify-content: center; /* Center logo and title */
        text-align: center;
        flex-direction: column; /* Stack logo on top of title */
    }

    .compiler-icon {
        margin-bottom: 0.5rem;
    }

    .compiler-title {
        font-size: 1.5rem;
    }

    /* Stack Controls (Selector + Button) */
    .controls {
        flex-direction: column;
        width: 100%;
    }

    .lang-selector-container {
        width: 100%; /* Full width selector */
    }

    .btn-run {
        width: 100%; /* Full width button */
        justify-content: center;
        padding: 0.8rem; /* Larger touch target */
    }

    /* Stack Editor and IO */
    .compiler-grid {
        display: flex;
        flex-direction: column;
        height: auto; /* Allow content to grow naturally */
    }

    .editor-container {
        height: auto;
    }

    /* Adjust Editor Height for Mobile */
    #editor {
        min-height: 50vh; /* Takes up half the screen height */
        height: 500px;    /* Max height to prevent getting lost */
    }

    .io-container {
        gap: 1.5rem; /* More space between Input and Output */
    }

    /* Fixed heights for IO boxes on mobile to ensure scrollability */
    .io-textarea, .io-output {
        min-height: 200px; 
    }
}