* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-dim: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #e2e8f0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== TOP NAVIGATION ===== */

.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.portfolio-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.portfolio-btn:hover {
    background: var(--accent);
    color: var(--bg);
}

/* ===== MAIN CONTENT ===== */

#app-root {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* ===== LOADING ===== */

#loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 1rem;
}

.loader {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== PLATFORM SELECTOR ===== */

#platform-selector h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
}

.platform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.platform-box {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.platform-box:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.2);
}

.platform-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin: 0 auto 1rem;
    display: block;
}

.platform-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.platform-box h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.platform-box p {
    color: var(--text-dim);
    font-size: 1rem;
}

/* ===== FOLDER VIEW ===== */

.back-button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    margin-bottom: 2rem;
    transition: all 0.2s;
}

.back-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#folder-title {
    font-size: 2.2rem;
    margin-bottom: 2rem;
}

#folder-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.folder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.folder-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.folder-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.folder-card-path {
    color: var(--text-dim);
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    margin-bottom: 0.5rem;
}

.folder-card-count {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== PROBLEM VIEW ===== */

#problem-view {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.problem-header {
    margin-bottom: 3rem;
}

.problem-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.nav-link {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.nav-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.nav-button {
    font-family: inherit;
}

.problem-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.problem-subtitle {
    color: var(--text-dim);
    font-size: 1.2rem;
}

/* ===== CONTENT LAYOUT ===== */

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.content-wrapper.stacked {
    grid-template-columns: 1fr;
    max-width: 1000px;
}

.visual-panel,
.code-panel {
    min-width: 0;
}

/* Images */
.image-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.image-box img {
    width: 100%;
    display: block;
}

.image-label {
    padding: 1rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.03);
}

/* Code */
.code-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.code-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1.1rem;
}

.code-wrapper {
    position: relative;
    overflow: auto;
    max-height: none;
}

.code-wrapper pre {
    margin: 0;
    padding: 1.5rem;
    background: #1e1e1e;
    overflow: visible;
}

.code-wrapper code {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Multi-image grid */
.multi-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .top-nav {
        padding: 1rem;
    }
    
    #app-root {
        padding: 2rem 1rem;
    }
    
    #platform-selector h1 {
        font-size: 2rem;
    }
    
    .platform-grid {
        grid-template-columns: 1fr;
    }
    
    #folder-cards {
        grid-template-columns: 1fr;
    }
    
    .multi-image-grid {
        grid-template-columns: 1fr;
    }
    
    .problem-title {
        font-size: 2rem;
    }
    
    .platform-image {
        width: 100px;
        height: 100px;
    }
}


/* ========================================
   CODEMIRROR OVERRIDES
   ======================================== */

.CodeMirror {
    height: 100% !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
}

.CodeMirror-gutters {
    background: #272822 !important;
    border-right: 1px solid #3e3e42 !important;
}

.CodeMirror-linenumber {
    color: #75715e !important;
}



/* ========================================
   INLINE EDITOR STYLES
   ======================================== */

.inline-action-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: #3e3e42;
    color: #fff;
}

.inline-action-btn:hover {
    background: #4e4e52;
    transform: translateY(-1px);
}

.inline-action-btn:active {
    transform: translateY(0);
}

.inline-action-btn.run-btn {
    background: #4CAF50;
}

.inline-action-btn.run-btn:hover {
    background: #45a049;
}

.inline-action-btn.run-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   INTERACTIVE EDITOR MODAL STYLES (Legacy - kept for compatibility)
   ======================================== */

/* Modal Overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Modal Content */
.modal-content {
    background: #1e1e1e;
    border-radius: 12px;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Modal Header */
.modal-header {
    background: #252526;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3e3e42;
}

.modal-header h2 {
    color: #fff;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: #3e3e42;
    color: #fff;
}

.action-btn:hover {
    background: #4e4e52;
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
}

.run-btn {
    background: #4CAF50;
}

.run-btn:hover {
    background: #45a049;
}

.run-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

.close-btn {
    background: #d32f2f;
}

.close-btn:hover {
    background: #c62828;
}

/* Modal Body */
.modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem;
    gap: 1rem;
}

/* Editor Container */
.editor-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    min-height: 0;
}

.editor-section {
    display: flex;
    flex-direction: column;
    background: #252526;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #3e3e42;
}

.section-header {
    padding: 0.75rem 1rem;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    font-weight: 600;
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-btn {
    padding: 0.25rem 0.75rem;
    background: #3e3e42;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s ease;
}

.clear-btn:hover {
    background: #4e4e52;
}

/* Code Editor Textarea */
#code-editor {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    border: none;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

/* Better syntax-like appearance for editor */
#code-editor::selection {
    background: #264f78;
}

#code-editor::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#code-editor::-webkit-scrollbar-track {
    background: #1e1e1e;
}

#code-editor::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
}

#code-editor::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* Code Output */
#code-output {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#code-output pre {
    margin: 0;
    color: #d4d4d4;
}

/* Test Input Section */
.test-input-section {
    height: 150px;
    display: flex;
    flex-direction: column;
    background: #252526;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #3e3e42;
}

.test-input-section .section-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

#test-input {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    border: none;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
}

#test-input::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#test-input::-webkit-scrollbar-track {
    background: #1e1e1e;
}

#test-input::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
}

#test-input::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* Pyodide Loading Indicator */
.pyodide-status {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: #2d2d30;
    border-top: 1px solid #3e3e42;
    color: #fff;
    font-size: 0.9rem;
}

.loader-small {
    width: 20px;
    height: 20px;
    border: 3px solid #3e3e42;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Run Code Button in Navigation */
.run-code-nav {
    background: #4CAF50 !important;
    color: white !important;
    font-weight: 600;
}

.run-code-nav:hover {
    background: #45a049 !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .editor-container {
        grid-template-columns: 1fr;
    }
    
    .test-input-section {
        height: 120px;
    }
    
    .modal-content {
        height: 95vh;
    }
}

@media (max-width: 768px) {
    .modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .modal-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .action-btn {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .test-input-section {
        height: 120px;
    }
}