/* ============================================== */
/* CODE EDITOR — code-editor.css (Premium Side-by-Side) */
/* ============================================== */

/* Main Layout */
.editor-main {
    padding-top: 70px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-alt);
    overflow: hidden;
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    z-index: 10;
}

.editor-layout {
    display: flex;
    flex-direction: row; /* Side-by-side */
    flex: 1;
    overflow: hidden;
    gap: 1.25rem;
    padding: 1rem;
    background: var(--bg-alt);
}

/* Back Button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-alt);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.back-btn:hover {
    background: #ffffff;
    color: var(--primary);
    border-color: var(--primary-light);
}

/* Run Button */
.run-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(88, 80, 236, 0.2);
}

/* Sections */
.code-section, .preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}

.code-section {
    flex: 1.1; /* Editor slightly wider */
}

/* Tabs & Control Bars */
.editor-tabs, .preview-header {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--glass-border);
    min-height: 48px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0 1.25rem;
    height: 48px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(88, 80, 236, 0.03);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #ffffff;
}

.lang-select {
    background: #ffffff;
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    outline: none;
    margin-left: 0.5rem;
}

/* Monaco Editor */
.monaco-container {
    flex: 1;
    width: 100%;
    position: relative; /* Fix for cursor offset */
    overflow: hidden;
    background: #1e1e1e;
}

/* Fix for cursor overlap and character drift */
.monaco-editor, .monaco-editor .inputarea.ime-input {
    letter-spacing: normal !important;
    word-spacing: normal !important;
}

.monaco-editor .view-lines {
    font-variant-ligatures: none !important;
}

/* Preview Area */
#live-preview {
    flex: 1;
    width: 100%;
    border: none;
    background: white;
}

/* Terminal / Console */
.console-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    overflow: hidden;
}

.run-status {
    padding: 0.75rem 1.25rem;
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #334155;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #475569; }
.status-dot.success { background: #10b981; box-shadow: 0 0 10px #10b981; }
.status-dot.error { background: #ef4444; box-shadow: 0 0 10px #ef4444; }
.status-dot.running { background: #3b82f6; animation: pulse 1.5s infinite; }

.unified-console-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.section-label { padding: 0.75rem 1.25rem 0.25rem; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; }
#terminal-input { background: transparent; color: #e2e8f0; border: none; padding: 0.5rem 1.25rem 1rem; font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; outline: none; width: 100%; resize: none; }
#terminal-content { flex: 1; padding: 1rem 1.25rem; margin: 0; color: #f1f5f9; font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; line-height: 1.6; overflow-y: auto; white-space: pre-wrap; }

.error-text { color: #fca5a5 !important; }
.info-text { color: #93c5fd !important; }

/* Refresh Button */
.refresh-btn {
    background: var(--bg-alt);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    color: var(--primary);
    background: #ffffff;
}

/* Workspace Selection Overlay */
.workspace-overlay {
    position: fixed;
    inset: 70px 0 0 0;
    background: radial-gradient(circle at top right, rgba(88, 80, 236, 0.08), transparent 40%),
                radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.08), transparent 40%),
                #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 2rem;
}

.workspace-cards-container { text-align: center; max-width: 900px; width: 100%; }
.workspace-title { font-size: clamp(2rem, 5vw, 3rem); font-weight: 900; color: var(--text-main); margin-bottom: 0.75rem; letter-spacing: -0.03em; }
.workspace-subtitle { color: var(--text-dim); font-size: 1.1rem; margin-bottom: 4rem; opacity: 0.8; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 2.5rem; }
.workspace-card { background: #ffffff; border: 1px solid var(--glass-border); border-radius: 32px; padding: 3.5rem 2.5rem; cursor: pointer; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 4px 30px rgba(0,0,0,0.03); }
.workspace-card:hover { transform: translateY(-12px); border-color: var(--primary-light); box-shadow: 0 25px 50px rgba(88, 80, 236, 0.1); }

.card-icon { width: 80px; height: 80px; border-radius: 24px; display: flex; justify-content: center; align-items: center; margin: 0 auto 2rem; color: white; box-shadow: 0 15px 30px rgba(0,0,0,0.1); }
.web-icon { background: linear-gradient(135deg, #f06529, #e34c26); }
.prog-icon { background: linear-gradient(135deg, #3776ab, #2b5b84); }

.workspace-card h3 { font-size: 1.75rem; font-weight: 800; color: var(--text-main); margin-bottom: 1rem; }
.workspace-card p { color: var(--text-dim); line-height: 1.6; }

/* Responsiveness */
@media (max-width: 900px) {
    .editor-layout {
        flex-direction: column;
        overflow-y: auto;
    }
    .code-section, .preview-section {
        min-height: 500px;
        flex: none;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ── Navbar Styling Overrides for Code Editor ────────────────── */
#navbar {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
    padding: 0 5%;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#navbar .nav-links a {
    color: var(--text-dim);
}

#navbar .nav-links a:hover,
#navbar .nav-links a.active {
    color: var(--primary);
}

/* Ensure editor layouts and overlay start precisely after the 70px navbar */
.editor-main {
    padding-top: 70px !important;
}

.workspace-overlay {
    inset: 70px 0 0 0 !important;
}