* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --bg-hover: #3f3f46;
    --border-color: #27272a;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Language Colors - Enhanced for Dark Mode */
    --html-color: #f97316;
    --css-color: #3b82f6;
    --js-color: #eab308;
    --python-color: #38bdf8;
    --react-color: #22d3ee;
    --node-color: #22c55e;
    --c-color: #94a3b8;
    --cpp-color: #60a5fa;
    --csharp-color: #c084fc;
    --java-color: #f97316;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e5e5e5;
    --bg-hover: #d4d4d4;
    --border-color: #e5e5e5;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

body.resizing {
    cursor: col-resize !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

body.resizing * {
    cursor: col-resize !important;
    user-select: none !important;
    pointer-events: none;
}

body.resizing .resizer,
body.resizing .sidebar-resizer,
body.resizing .console-resizer {
    pointer-events: auto;
}

h1, h2, h3, h4, h5, h6, .logo, .preview-title, .sidebar-header, .btn, .file-type-option span {
    font-family: 'Outfit', sans-serif;
}


/* 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;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Outfit', sans-serif;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn i {
    font-size: 1rem;
}

/* Global icon improvements */
i, .fa, .fas, .fab, .far {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-style: normal;
}

.header {
    height: 55px;
    background: rgba(24, 24, 27, 0.85); /* Glassmorphic header */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 50;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.logo i { 
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
    font-size: 1.3rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.logo-button {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.15rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.logo-button:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.logo-button i {
    color: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-glow));
    font-size: 1.3rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn i {
    font-size: 1rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover { 
    background: linear-gradient(135deg, var(--accent-hover), #a5b4fc); 
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.6);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(39, 39, 42, 0.6);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover { 
    background: var(--bg-hover); 
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.ml-5 {
    margin-left: 5px;
}

.hidden-input {
    display: none;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.run-mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-family: inherit;
}

.run-mode-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.run-mode-toggle:active {
    transform: scale(0.98);
}

.run-mode-toggle .status-dot {
    margin: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

.run-mode-toggle.auto-mode .status-dot {
    background: var(--accent);
    animation: pulse-fast 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-fast {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

/* ==================== 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 svg {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.activity-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    transform: scale(1.05);
}

.activity-btn.active {
    color: var(--text-primary);
    border-left-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

/* ==================== SIDEBAR (EXPLORER) ==================== */
.sidebar {
    flex: 1;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
    position: relative;
}

.sidebar.hidden {
    display: none;
}

.sidebar-panel {
    display: none;
    height: 100%;
    flex-direction: column;
    position: relative;
}

.sidebar-panel.active {
    display: flex;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    transform: translateX(-100%);
    overflow: hidden;
}

.sidebar-header {
    padding: 14px 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.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: 10px 16px 10px 24px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 10px;
}

.file-tab:hover {
    background: rgba(255, 255, 255, 0.03);
}

.file-tab.active {
    background: rgba(99, 102, 241, 0.08); /* slight accent tint */
    border-left-color: var(--accent);
    color: white;
}

.file-tab i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.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;
    font-size: 0.85rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.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: 8px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--border-color) 50%, 
        transparent 100%);
    cursor: col-resize;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.sidebar-resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-resizer:hover::before,
.sidebar-resizer.active::before {
    opacity: 1;
}

.sidebar-resizer:hover,
.sidebar-resizer.active {
    background: linear-gradient(90deg, 
        rgba(99, 102, 241, 0.1) 0%, 
        var(--accent) 50%, 
        rgba(99, 102, 241, 0.1) 100%);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
    width: 10px;
}

.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: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(24, 24, 27, 0.95) 100%);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.editor-tabs::-webkit-scrollbar {
    height: 6px;
}

.editor-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.editor-tabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.editor-tabs::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.editor-tab {
    padding: 10px 16px;
    cursor: pointer;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    min-width: auto;
    position: relative;
}

.editor-tab span {
    display: inline-block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-tab .file-name-editable {
    cursor: text;
}

.editor-tab .file-name-editable:hover {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
}

.rename-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    min-width: 80px;
    max-width: 150px;
}

.editor-tab::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.editor-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.editor-tab.active {
    background: var(--bg-primary);
    color: white;
    border-bottom: 3px solid var(--accent);
    box-shadow: 
        inset 0 2px 0 0 rgba(255, 255, 255, 0.03),
        0 2px 8px rgba(0, 0, 0, 0.15);
}

.editor-tab.active::before {
    transform: scaleX(1);
}

.editor-tab i {
    font-size: 1rem;
    flex-shrink: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.editor-tab:hover i {
    transform: scale(1.05);
}

.editor-tab .close-editor-tab {
    opacity: 0;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 1rem;
    margin-left: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.editor-tab:hover .close-editor-tab,
.editor-tab.active .close-editor-tab {
    opacity: 1;
}

.editor-tab .close-editor-tab:hover {
    background: var(--error);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Download/Export icon styling */
.editor-tab .fa-download {
    opacity: 0;
    transition: all 0.2s ease;
    font-size: 1rem;
    padding: 4px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.editor-tab:hover .fa-download,
.editor-tab.active .fa-download {
    opacity: 1;
}

.editor-tab .fa-download:hover {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.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;
}

/* CodeMirror Styling */
.code-editor .cm-editor {
    height: 100%;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
}

.code-editor .cm-scroller {
    overflow: auto;
    font-family: 'Fira Code', monospace;
}

.code-editor .cm-content {
    padding: 10px 0;
    font-family: 'Fira Code', monospace;
}

.code-editor .cm-line {
    padding: 0 10px;
}

.code-editor .cm-gutters {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.code-editor .cm-activeLineGutter {
    background: rgba(255, 255, 255, 0.05);
}

.code-editor .cm-activeLine {
    background: rgba(255, 255, 255, 0.02);
}

/* Fallback textarea styling */
.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;
    position: relative;
}

.preview-area.console-only .preview-frame,
.preview-area.console-only .console-resizer {
    display: none;
}

.preview-area.console-only .console-panel {
    height: 100%;
    flex: 1;
}

.preview-area.console-only .console-output {
    flex: 1;
}

.preview-area.hidden {
    display: none;
}

.preview-header {
    height: 48px;
    background: rgba(24, 24, 27, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.preview-actions button i {
    font-size: 1rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.preview-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: scale(1.05);
}

.preview-actions button:active {
    transform: scale(0.95);
}

.preview-frame {
    flex: 1;
    background: white;
    border: none;
}

/* ==================== CONSOLE PANEL ==================== */
.console-panel {
    height: var(--console-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-resizer {
    height: 12px;
    background: linear-gradient(180deg, 
        rgba(255,255,255,0.08) 0%, 
        rgba(255,255,255,0.02) 100%);
    cursor: row-resize;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 10;
}

.console-resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.05);
    transition: all 0.3s ease;
}

.console-resizer::after {
    content: '⋮⋮⋮';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
    letter-spacing: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.console-resizer:hover::after,
.console-resizer.active::after {
    opacity: 1;
}

.console-resizer:hover,
.console-resizer.active {
    background: linear-gradient(180deg, 
        rgba(99, 102, 241, 0.25) 0%, 
        rgba(99, 102, 241, 0.1) 100%);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
    height: 14px;
}

.console-resizer:hover::before,
.console-resizer.active::before {
    background: var(--accent);
    width: 100px;
    height: 5px;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.console-resizer.hidden {
    display: none;
}

.console-resize-hint {
    position: absolute;
    right: 12px;
    min-width: 80px;
    padding: 8px 14px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(79, 70, 229, 0.95));
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 100;
    letter-spacing: 0.5px;
}

.console-resize-hint.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.console-resize-hint::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(99, 102, 241, 0.95);
}

.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: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.console-actions button i {
    font-size: 0.9rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.console-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.console-actions button:active {
    transform: translateY(0);
}

.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;
}

/* Console Input */
.console-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.console-prompt {
    color: var(--accent);
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.console-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

.console-input:focus {
    border-color: var(--accent);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.console-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ==================== RESIZER ==================== */
.resizer {
    width: 8px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--border-color) 50%, 
        transparent 100%);
    cursor: col-resize;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.resizer:hover::before,
.resizer.active::before {
    opacity: 1;
}

.resizer.hidden {
    display: none;
}

.resizer:hover,
.resizer.active {
    background: linear-gradient(90deg, 
        rgba(99, 102, 241, 0.1) 0%, 
        var(--accent) 50%, 
        rgba(99, 102, 241, 0.1) 100%);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
    width: 10px;
}

/* ==================== 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: 16px;
    padding: 32px;
    width: 480px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s 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);
}

.file-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.file-type-option {
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.file-type-option:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.file-type-option.selected {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2), inset 0 0 20px rgba(99, 102, 241, 0.1);
}

.file-type-option i {
    font-size: 1.8rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.file-type-option span {
    font-size: 0.85rem;
    font-weight: 500;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ==================== INFO MODAL ==================== */
.info-modal {
    width: 700px;
    max-width: 95%;
    max-height: 85vh;
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 8px;
}

.info-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
}

.info-section h4 {
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.info-section h4 i {
    color: var(--accent);
    font-size: 1.2rem;
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.feature-item i {
    color: var(--accent);
    font-size: 1.1rem;
    margin-top: 2px;
    flex-shrink: 0;
}

/* Guide Lists */
.guide-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guide-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.guide-list li i {
    color: var(--accent);
    margin-top: 3px;
    flex-shrink: 0;
}

/* Shortcuts Grid */
.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.shortcut-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    text-align: center;
}

.shortcut-item kbd {
    background: var(--bg-tertiary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: 'Fira Code', monospace;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.shortcut-item span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Tips List */
.tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tips-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.tips-list li i {
    color: var(--warning);
    margin-top: 3px;
    flex-shrink: 0;
}

/* About Section */
.about-section {
    text-align: center;
}

.about-section p {
    margin: 0 0 16px 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Desktop/Mobile Only Sections */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
    
    .info-modal {
        width: 95%;
        max-height: 90vh;
    }
    
    .info-content {
        max-height: 75vh;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
    
    .shortcuts-grid {
        grid-template-columns: 1fr;
    }
    
    .info-section {
        padding: 16px;
    }
}

.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: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 3px solid var(--bg-primary); /* creates a padded look */
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* For code editor specifically */
textarea::-webkit-scrollbar-thumb {
    border: 3px solid var(--bg-primary);
}

/* ==================== 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;
}

.auto-run-indicator.auto-mode {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.auto-run-indicator.auto-mode i {
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==================== 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) {
    /* Tablet Layout */
    .header {
        padding: 8px 12px;
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .logo-button {
        order: 1;
        flex: 0 0 auto;
    }
    
    .logo-text {
        display: none;
    }
    
    .status-indicator {
        order: 2;
        flex: 1;
        justify-content: center;
        margin: 0 8px;
    }
    
    .run-mode-toggle {
        padding: 6px 10px;
        font-size: 0.8rem;
        border-radius: 16px;
    }
    
    .run-mode-toggle span {
        display: none;
    }
    
    .run-mode-toggle::after {
        content: 'Manual';
        font-size: 0.8rem;
        margin-left: 4px;
    }
    
    .run-mode-toggle.auto-mode::after {
        content: 'Auto';
    }
    
    .auto-run-indicator {
        display: none !important;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .desktop-run-btn {
        display: none !important;
    }
    
    .mobile-run-btn {
        display: flex !important;
        order: 3;
        flex: 0 0 auto;
    }
    
    .header-actions {
        order: 4;
        width: 100%;
        position: relative;
        top: auto;
        left: auto;
        background: transparent;
        border: none;
        flex-direction: row;
        flex-wrap: nowrap;
        padding: 0;
        gap: 8px;
        z-index: auto;
        transform: none;
        transition: none;
        box-shadow: none;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .header-actions::-webkit-scrollbar {
        display: none;
    }
    
    .header-actions .btn {
        flex: 0 0 auto;
        min-width: 48px;
        max-width: none;
        justify-content: center;
        padding: 10px 12px;
        white-space: nowrap;
        font-size: 1.1rem;
    }
    
    .header-actions .btn-text {
        display: none !important;
    }
    
    .main-container {
        flex-direction: column;
        height: calc(100vh - 110px);
    }
    
    .left-sidebar {
        position: fixed;
        top: 110px;
        left: 0;
        width: 100%;
        height: calc(100vh - 110px);
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
    }
    
    .left-sidebar.mobile-visible {
        transform: translateX(0);
    }
    
    .activity-bar {
        width: 100%;
        height: 50px;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0;
        justify-content: center;
        background: var(--bg-secondary);
    }
    
    .activity-btn {
        width: 50px;
        height: 50px;
        border-left: none;
        border-bottom: 2px solid transparent;
    }
    
    .activity-btn.active {
        border-left: none;
        border-bottom-color: var(--accent);
    }
    
    .sidebar {
        width: 100% !important;
        height: calc(100% - 50px);
        position: absolute;
        top: 50px;
        left: 0;
    }
    
    .sidebar-resizer {
        display: none;
    }
    
    .editor-area {
        width: 100% !important;
        height: 50vh;
        min-height: 300px;
    }
    
    .preview-area {
        width: 100% !important;
        height: 50vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
    
    .resizer {
        display: none;
    }
    
    .editor-tabs {
        overflow-x: auto;
        scrollbar-width: thin;
    }
    
    .editor-tab {
        padding: 10px 12px;
        gap: 6px;
        font-size: 0.85rem;
    }
    
    .editor-tab span {
        max-width: 100px;
        font-size: 0.85rem;
    }
    
    .editor-tab i {
        font-size: 0.95rem;
    }
    
    .editor-tab .close-editor-tab,
    .editor-tab .fa-download {
        opacity: 1;
        font-size: 0.85rem;
        padding: 4px 5px;
    }
}

@media (max-width: 768px) {
    /* Mobile Layout */
    .header {
        height: auto;
        min-height: 55px;
        padding: 6px 8px;
    }
    
    .logo-button {
        font-size: 1rem;
        padding: 4px 8px;
    }
    
    .status-indicator {
        display: flex !important;
        margin: 0 4px;
        flex: 1;
        justify-content: center;
    }
    
    .run-mode-toggle {
        padding: 5px 8px;
        font-size: 0.75rem;
        border-radius: 14px;
        display: flex !important;
    }
    
    .run-mode-toggle .status-dot {
        width: 6px;
        height: 6px;
    }
    
    .run-mode-toggle::after {
        font-size: 0.75rem;
        margin-left: 3px;
    }
    
    .mobile-run-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .header-actions {
        width: 100%;
        gap: 6px;
    }
    
    .header-actions .btn {
        padding: 10px;
        font-size: 1.1rem;
        min-width: 44px;
    }
    
    .header-actions .btn-text {
        display: none !important;
    }
    
    .main-container {
        height: calc(100vh - 100px);
    }
    
    .left-sidebar {
        top: 100px;
        height: calc(100vh - 100px);
    }
    
    .editor-area {
        height: 60vh;
    }
    
    .preview-area {
        height: 40vh;
        transition: height 0.3s ease;
    }
    
    /* Hide console by default on mobile */
    .console-panel {
        height: 0 !important;
        min-height: 0 !important;
        display: none;
        transition: height 0.3s ease, opacity 0.3s ease;
        opacity: 0;
    }
    
    .console-panel.mobile-visible {
        display: flex !important;
        height: 200px !important;
        flex-direction: column;
        opacity: 1;
        animation: slideUpConsole 0.3s ease;
    }
    
    @keyframes slideUpConsole {
        from {
            height: 0;
            opacity: 0;
        }
        to {
            height: 200px;
            opacity: 1;
        }
    }
    
    .console-resizer {
        display: none !important;
    }
    
    .preview-area.console-visible {
        height: calc(40vh - 200px);
    }
    
    .preview-area.console-visible .preview-frame {
        height: calc(100% - 48px);
    }
    
    .modal {
        width: 95%;
        max-width: 95%;
        padding: 20px;
    }
    
    .snippets-modal {
        width: 95%;
    }
    
    .snippets-grid {
        grid-template-columns: 1fr;
    }
    
    .collab-modal {
        width: 95%;
    }
    
    .file-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .editor-tab {
        padding: 8px 10px;
        font-size: 0.8rem;
        gap: 5px;
    }
    
    .editor-tab span {
        max-width: 80px;
        font-size: 0.8rem;
    }
    
    .editor-tab i {
        font-size: 0.9rem;
    }
    
    .editor-tab .close-editor-tab,
    .editor-tab .fa-download {
        opacity: 1 !important;
        font-size: 0.85rem;
        padding: 5px 6px;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 4px;
    }
    
    .editor-tab .close-editor-tab:active {
        background: var(--error);
    }
    
    .editor-tab .fa-download:active {
        background: rgba(16, 185, 129, 0.3);
        color: var(--success);
    }
    
    .file-tab {
        padding: 8px 12px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    /* Hide text labels on very small screens */
    .ml-5 {
        display: none;
    }
    
    .mobile-run-btn .ml-5 {
        display: inline;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .header {
        padding: 4px 6px;
        min-height: 50px;
    }
    
    .logo-button {
        font-size: 0.9rem;
        padding: 3px 6px;
    }
    
    .status-indicator {
        margin: 0 2px;
    }
    
    .run-mode-toggle {
        padding: 4px 6px;
        font-size: 0.7rem;
        border-radius: 12px;
    }
    
    .run-mode-toggle .status-dot {
        width: 5px;
        height: 5px;
    }
    
    .run-mode-toggle::after {
        font-size: 0.7rem;
        margin-left: 2px;
    }
    
    .mobile-run-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .header-actions .btn {
        padding: 8px;
        font-size: 1rem;
        min-width: 40px;
    }
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    padding: 8px;
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

.hamburger-line {
    width: 24px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:active .hamburger-line {
    background: var(--accent);
}

/* Hamburger animation when active */
.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Run Button */
.mobile-run-btn {
    display: none;
}

/* Tablet/Mobile Sidebar Toggle Button */
.mobile-sidebar-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 12px var(--accent-glow);
    cursor: pointer;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.mobile-sidebar-toggle:active {
    transform: scale(0.95);
}

@media (max-width: 1024px) {
    .mobile-sidebar-toggle {
        display: flex;
    }
}

/* Smooth scrolling for mobile */
@media (max-width: 768px) {
    .editor-content,
    .preview-frame {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better touch targets */
    button,
    .file-tab,
    .editor-tab,
    .activity-btn {
        min-height: 44px;
    }
}

/* Landscape mode for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .editor-area {
        height: 100vh;
    }
    
    .preview-area {
        height: 100vh;
    }
    
    .main-container {
        flex-direction: row;
    }
    
    .editor-area {
        width: 50% !important;
    }
    
    .preview-area {
        width: 50% !important;
        border-left: 1px solid var(--border-color);
        border-top: 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;
}

/* ==================== SNIPPETS MODAL ==================== */
.snippets-modal {
    width: 700px;
    max-width: 95%;
}

.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-height: 60vh;
    overflow-y: auto;
}

.snippet-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.snippet-card:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.snippet-card h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.snippet-card p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.snippet-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.snippet-badge.html { background: rgba(249, 115, 22, 0.2); color: var(--html-color); }
.snippet-badge.css { background: rgba(59, 130, 246, 0.2); color: var(--css-color); }
.snippet-badge.js { background: rgba(234, 179, 8, 0.2); color: var(--js-color); }
.snippet-badge.python { background: rgba(56, 189, 248, 0.2); color: var(--python-color); }

/* Theme transition */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ==================== COLLABORATION MODAL ==================== */
.collab-modal {
    width: 550px;
    max-width: 95%;
}

.collab-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.collab-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.collab-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.collab-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.collab-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.collab-panel {
    display: none;
}

.collab-panel.active {
    display: block;
}

.collab-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    padding: 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.collab-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.collab-section h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.collab-section h4 i {
    color: var(--accent);
}

.collab-section input {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'Fira Code', monospace;
}

.collab-section input:focus {
    outline: none;
    border-color: var(--accent);
}

.room-code {
    margin-top: 8px;
}

.room-code label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.room-code-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 2px dashed var(--accent);
    border-radius: 8px;
}

.room-code-box span {
    flex: 1;
    font-family: 'Fira Code', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 2px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.collab-status {
    margin-top: 8px;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: none;
}

.collab-status.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.collab-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.collab-status.info {
    display: block;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--info);
    color: var(--info);
}

.collab-users {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.collab-user {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 20px;
    font-size: 0.8rem;
}

.collab-user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Connected state indicator */
#collabIcon.connected {
    color: var(--success);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 4px var(--success));
    }
    50% {
        filter: drop-shadow(0 0 8px var(--success));
    }
}

/* ==================== MOBILE OPTIMIZATIONS ==================== */

/* Better button text visibility */
.btn-text {
    display: inline;
}

.desktop-run-btn {
    display: inline-flex;
}

.mobile-run-btn {
    display: none;
}

@media (min-width: 1025px) {
    .mobile-menu-toggle,
    .mobile-run-btn,
    .mobile-sidebar-toggle {
        display: none !important;
    }
}

/* Logo text responsive */
.logo-text {
    display: inline;
}

@media (max-width: 1024px) {
    .logo-text {
        display: none;
    }
}

/* Prevent text selection on mobile for better UX */
@media (max-width: 768px) {
    .header,
    .activity-bar,
    .sidebar-header,
    .file-section-header,
    .editor-tabs,
    .preview-header {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Mobile overlay for sidebar */
@media (max-width: 1024px) {
    .left-sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: -1;
    }
    
    .left-sidebar.mobile-visible::before {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Improve touch scrolling */
@media (max-width: 768px) {
    .file-tabs,
    .editor-tabs,
    .console-output {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* Mobile-friendly console */
@media (max-width: 768px) {
    .console-panel {
        max-height: 250px;
    }
    
    .console-panel.mobile-visible {
        border-top: 2px solid var(--accent);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .console-log {
        font-size: 0.75rem;
        padding: 6px;
    }
    
    .console-output {
        max-height: 150px;
        overflow-y: auto;
    }
}

/* Better modal experience on mobile */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }
    
    .modal {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal h3 {
        font-size: 1rem;
    }
    
    .modal input,
    .modal select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .editor-area {
        height: 55vh;
    }
    
    .preview-area {
        height: 45vh;
    }
}

/* Improve code editor on mobile */
@media (max-width: 768px) {
    .code-editor textarea {
        font-size: 13px;
        line-height: 1.5;
        padding: 12px 8px;
    }
    
    .line-numbers {
        width: 45px;
        font-size: 13px;
        padding: 12px 6px;
    }
    
    .code-editor textarea {
        left: 45px;
        width: calc(100% - 45px);
    }
}

/* Mobile floating action button animation */
@media (max-width: 1024px) {
    .mobile-sidebar-toggle {
        animation: pulse-float 2s ease-in-out infinite;
    }
    
    @keyframes pulse-float {
        0%, 100% {
            transform: translateY(0);
            box-shadow: 0 4px 12px var(--accent-glow);
        }
        50% {
            transform: translateY(-5px);
            box-shadow: 0 8px 20px var(--accent-glow);
        }
    }
}

/* Hide unnecessary elements on small screens */
@media (max-width: 480px) {
    .auto-run-indicator {
        display: none !important;
    }
    
    .status-indicator {
        display: flex !important;
        flex: 1;
        justify-content: center;
        margin: 0 2px;
    }
    
    .header {
        justify-content: space-between;
    }
}

/* ==================== HORIZONTAL SCROLL FOR MOBILE HEADER ==================== */
@media (max-width: 1024px) {
    .header {
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .header::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .header-actions {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .header-actions::-webkit-scrollbar {
        display: none;
    }
}
