* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d2d;
    --bg-hover: #3c3c3c;
    --border-color: #3c3c3c;
    --text-primary: #cccccc;
    --text-secondary: #858585;
    --accent: #007acc;
    --accent-hover: #0098ff;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --info: #2196f3;
    /* Language Colors */
    --html-color: #e44d26;
    --css-color: #264de4;
    --js-color: #f7df1e;
    --python-color: #3776ab;
    --react-color: #61dafb;
    --node-color: #339933;
    --c-color: #555555;
    --cpp-color: #00599c;
    --csharp-color: #9b4f96;
    --java-color: #f89820;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* Accessible focus outline for all interactive elements */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.activity-btn:focus-visible,
.file-tab:focus-visible,
.editor-tab:focus-visible,
.file-type-option:focus-visible,
.add-file-btn:focus-visible,
.preview-actions button:focus-visible,
.console-actions button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ==================== HEADER ==================== */
.header {
    height: 50px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
}

.logo i { color: var(--accent); }

.logo-button {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
}

.logo-button:hover {
    color: white;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover { background: var(--border-color); }

.ml-5 {
    margin-left: 5px;
}

.hidden-input {
    display: none;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== MAIN CONTAINER ==================== */
.main-container {
    display: flex;
    height: calc(100vh - 50px);
}

.left-sidebar {
    width: 300px;
    min-width: 52px;
    max-width: 520px;
    display: flex;
    border-right: 1px solid var(--border-color);
}

.activity-bar {
    width: 52px;
    background: #181818;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
    gap: 8px;
}

.activity-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.2s;
}

.activity-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.activity-btn.active {
    color: var(--text-primary);
    border-left-color: var(--accent);
}

/* ==================== SIDEBAR (EXPLORER) ==================== */
.sidebar {
    flex: 1;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar.hidden {
    display: none;
}

.sidebar-panel {
    display: none;
    height: 100%;
    flex-direction: column;
}

.sidebar-panel.active {
    display: flex;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    transform: translateX(-100%);
    overflow: hidden;
}

.sidebar-header {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-tabs {
    flex: 1;
    overflow-y: auto;
}

.file-section {
    margin-bottom: 8px;
}

.file-section-header {
    padding: 8px 16px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.file-section-header i {
    transition: transform 0.2s;
}

.file-section-header.collapsed i {
    transform: rotate(-90deg);
}

.file-section-content {
    display: block;
}

.file-section-content.collapsed {
    display: none;
}

.file-tab {
    display: flex;
    align-items: center;
    padding: 8px 16px 8px 24px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    gap: 10px;
}

.file-tab:hover {
    background: var(--bg-tertiary);
}

.file-tab.active {
    background: var(--bg-tertiary);
    border-left-color: var(--accent);
}

.file-tab i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.file-tab .file-name {
    flex: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-tab .close-tab {
    opacity: 0;
    padding: 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.file-tab:hover .close-tab {
    opacity: 1;
}

.file-tab .close-tab:hover {
    background: var(--error);
    color: white;
}

.add-file-btn {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.add-file-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.import-panel-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.import-file-btn {
    width: fit-content;
}

.inline-import-icon {
    vertical-align: -2px;
    margin-right: 6px;
}

.import-panel-content small {
    color: var(--text-secondary);
    opacity: 0.85;
    line-height: 1.4;
}

/* ==================== SIDEBAR RESIZER ==================== */
.sidebar-resizer {
    width: 5px;
    background: var(--border-color);
    cursor: col-resize;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sidebar-resizer:hover,
.sidebar-resizer.active {
    background: var(--accent);
}

.sidebar-resizer.hidden {
    display: none;
}



/* ==================== EDITOR AREA ==================== */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-area.full-width {
    width: 100%;
}

.editor-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.editor-tab {
    padding: 12px 20px;
    cursor: pointer;
    border-right: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 150px;
}

.editor-tab:hover {
    background: var(--bg-tertiary);
}

.editor-tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent);
}

.editor-tab i {
    font-size: 1rem;
}

.editor-tab .close-editor-tab {
    margin-left: auto;
    opacity: 0;
    padding: 4px;
    border-radius: 3px;
}

.editor-tab:hover .close-editor-tab {
    opacity: 1;
}

.editor-tab .close-editor-tab:hover {
    background: var(--error);
    color: white;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.code-editor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.code-editor.active {
    display: block;
}

.editor-wrapper {
    position: relative;
    height: 100%;
    overflow: hidden;
}

.line-numbers {
    position: absolute;
    left: 0;
    top: 0;
    width: 55px;
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 15px 10px;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    text-align: right;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
}

.code-editor textarea {
    position: absolute;
    left: 55px;
    top: 0;
    width: calc(100% - 55px);
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    padding: 15px 10px;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

/* ==================== PREVIEW AREA ==================== */
.preview-area {
    width: 50%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    min-width: 300px;
}

.preview-area.hidden {
    display: none;
}

.preview-header {
    height: 40px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.preview-title {
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.preview-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.preview-frame {
    flex: 1;
    background: white;
    border: none;
}

/* ==================== CONSOLE PANEL ==================== */
.console-panel {
    height: 200px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: height 0.3s ease;
}

.console-panel.collapsed {
    height: 0;
    overflow: hidden;
}

.console-header {
    height: 35px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.console-title {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.console-title i { color: var(--warning); }

.console-actions {
    display: flex;
    gap: 8px;
}

.console-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.console-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.console-output {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
}

.console-log {
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 3px;
    display: flex;
    gap: 10px;
    word-break: break-all;
}

.console-log.log {
    background: rgba(76, 175, 80, 0.1);
    border-left: 3px solid var(--success);
}

.console-log.warn {
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid var(--warning);
}

.console-log.error {
    background: rgba(244, 67, 54, 0.1);
    border-left: 3px solid var(--error);
}

.console-log.info {
    background: rgba(33, 150, 243, 0.1);
    border-left: 3px solid var(--info);
}

.console-log .timestamp {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ==================== RESIZER ==================== */
.resizer {
    width: 5px;
    background: var(--border-color);
    cursor: col-resize;
    transition: background 0.2s;
    flex-shrink: 0;
}

.resizer.hidden {
    display: none;
}

.resizer:hover {
    background: var(--accent);
}

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal {
    background: linear-gradient(135deg, rgba(37, 37, 37, 0.75), rgba(22, 22, 22, 0.75));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 24px;
    width: 450px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 2px 12px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: transform 0.3s ease, opacity 0.3s ease;
    will-change: transform, opacity;
}

.modal-overlay.active .modal {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
}

.icon-btn:hover { background: var(--bg-tertiary); }

.modal h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.modal input, .modal select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    font-family: 'Inter', sans-serif;
}

.modal input:focus, .modal select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Hamburger button (hidden on desktop) */
.hamburger-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding: 6px 8px;
    cursor: pointer;
}

/* Mobile-specific layout adjustments */
@media (max-width: 900px) {
    .header { padding: 0 10px; }
    .hamburger-btn { display: inline-flex; align-items: center; margin-right: 8px; }
    .status-indicator { display: none; }
    .header-actions .ml-5 { display: none; }
    .btn { padding: 8px; }

    .main-container { flex-direction: column; height: calc(100vh - 50px); }

    /* Hide left sidebar from normal flow (overlay will be used) */
    .left-sidebar { display: none; }

    /* Remove resizers on mobile */
    .sidebar-resizer, .resizer { display: none; }

    /* Editor on top, preview below */
    .editor-area { order: 1; height: 55vh; }
    .preview-area { order: 2; width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--border-color); height: 45vh; }
    .preview-frame { height: 100%; }

    /* Make editor stretch and allow scrolling */
    .editor-content { height: 100%; }
    .code-editor .code, .code-editor textarea { height: 100%; }

    /* Compact the editor tabs */
    .editor-tab { min-width: 110px; padding: 10px 12px; font-size: 0.85rem; }

    /* Mobile sidebar overlay */
    .left-sidebar.mobile-open { display: block; position: fixed; top: 50px; left: 0; height: calc(100% - 50px); z-index: 2000; width: 78%; max-width: 360px; box-shadow: 2px 0 18px rgba(0,0,0,0.6); }
    .left-sidebar.mobile-open .activity-bar { display: flex; }
    .mobile-backdrop { display: block; position: fixed; inset: 50px 0 0 0; background: rgba(0,0,0,0.45); z-index: 1500; opacity: 0; visibility: hidden; transition: opacity 0.2s; }
    .mobile-backdrop.open { opacity: 1; visibility: visible; }

    /* Hide import activity by default to keep only files tab visible */
    .activity-btn:not(#activityFilesBtn) { display: none; }
    .sidebar { width: 100%; max-width: none; }
    .sidebar.collapsed { transform: translateX(0); }
}

/* Ensure mobile backdrop hidden on desktop */
.mobile-backdrop { display: none; }

.file-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.file-type-option {
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-type-option:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.file-type-option.selected {
    border-color: var(--accent);
    background: rgba(0, 122, 204, 0.1);
}

.file-type-option i {
    font-size: 1.5rem;
}

.file-type-option span {
    font-size: 0.8rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.info-block h4 {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.info-block ul {
    list-style: disc;
    padding-left: 18px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.info-block p {
    margin: 0 0 8px;
    color: var(--text-secondary);
}

.link-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.pill-link:hover { border-color: var(--accent); color: white; }

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==================== AUTO-RUN INDICATOR ==================== */
.auto-run-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--success);
    padding: 4px 10px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 4px;
}

/* ==================== TOAST NOTIFICATION ==================== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1001;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }

    .left-sidebar {
        width: 100%;
        min-width: 0;
        max-width: none;
        height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .activity-bar {
        width: 46px;
    }
    
    .sidebar {
        height: 100%;
    }

    .sidebar-resizer {
        display: none;
    }
    
    .preview-area {
        width: 100%;
        height: 50%;
    }
    
    .editor-area {
        height: 50%;
    }
    
    .resizer {
        display: none;
    }
}

/* ==================== LANGUAGE BADGES ==================== */
.lang-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    margin-left: 5px;
}
