/* Modernized CSS Variables */
:root {
    /* Light Theme Default */
    --bg-app: #f8f9fa;
    --bg-panel: #ffffff;
    --bg-dark: #f1f3f5;
    --text-main: #212529;
    --text-sub: #495057;
    --border: #dee2e6;
    --primary: #4f46e5;
    --accent: #4f46e5;
    --danger: #ef4444;
    --success: #10b981;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-ui: 'Outfit', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
    --bg-app: #09090b;
    --bg-panel: #121214;
    --bg-dark: #18181b;
    --text-main: #e4e4e7;
    --text-sub: #a1a1aa;
    --border: #27272a;
    --primary: #6366f1;
    --accent: #8b5cf6;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    /* overflow: hidden; Removed to allow home page scrolling */
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-main);
    color: var(--text-main);
}

.workspace-layout {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

/* Global Navbar */
.global-navbar {
    height: 60px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    /* Hidden by default (Desktop) */
}

.brand-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-links a:hover {
    color: var(--primary);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.login-link {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
}

/* Sidebar */
.sidebar {
    width: 120px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    z-index: 10;
    flex-shrink: 0;
    height: calc(100vh - 60px);
    /* Adjust for global navbar height */
}

.brand {
    /* Logo removed from sidebar as per request */
    display: none;
}

.logo-icon {
    filter: drop-shadow(0 0 8px var(--accent));
}

.brand h1,
.pro-badge,
.section-label,
.sidebar h4,
.sidebar p {
    display: none;
}

/* Scrollable Nav */
.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
    /* Reduced side padding slightly */
    scrollbar-width: none;
    /* Firefox */
}

.nav-menu::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Edge */
}

.nav-item {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-sub);
    width: 100%;
    height: 70px;
    /* Square-ish vertical button */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    /* Stack Icon and Text */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    /* For anchor tags */
    flex-shrink: 0;
}

.nav-item .lang-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 4px;
    object-fit: contain;
}

.nav-item .lang-name {
    display: block !important;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
}

.nav-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.nav-item.active {
    background: #f0fdf4;
    /* Light Green tinge like reference or just light primary */
    border-color: var(--success);
    /* Green border like reference image */
    color: var(--success);
}

/* Sidebar Footer */
.sidebar-bottom {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    width: 100%;
    display: flex;
    justify-content: center;
    background: var(--bg-panel);
}

.nav-item-bottom {
    background: transparent;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: color 0.2s;
}

.nav-item-bottom:hover {
    color: var(--text-main);
    background: var(--bg-dark);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 60px);
}

[data-theme="dark"] .main-content {
    background: var(--bg-dark);
}

/* Top Bar */
.top-bar {
    height: 70px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background: white;
}

.file-context {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.lang-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

#current-filename {
    font-family: var(--font-code);
    color: var(--text-main);
    font-weight: 500;
}

.pill-badge {
    font-family: var(--font-code);
    font-size: 0.85rem;
    font-weight: 500;
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-sub);
}

.status-badge {
    display: none;
    /* Hide local status for cleaner look */
}

.actions {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-family: var(--font-ui);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    background: white;
    color: var(--text-main);
}

.btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-primary {
    background: #111827;
    /* Dark black/gray button from reference */
    color: white;
    border: 1px solid transparent;
}

.btn-primary:hover {
    background: #000;
}

.btn-icon {
    padding: 0.5rem;
    background: white;
    color: var(--text-sub);
    border: none;
}

.btn-icon:hover {
    color: var(--text-main);
    background: transparent;
}

/* Dark Mode Overrides for High Contrast Buttons */
[data-theme="dark"] .nav-item {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item.active {
    background: #fff;
    color: #000;
    border-color: var(--primary);
}

[data-theme="dark"] .btn,
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-secondary {
    background: #fff;
    color: #000;
    border-color: transparent;
    font-weight: 700;
}

[data-theme="dark"] .btn:hover {
    background: #e0e0e0;
}

[data-theme="dark"] .btn-icon {
    background: #fff;
    color: #000;
    border: none;
}

[data-theme="dark"] .btn-icon:hover {
    background: #ddd;
}

[data-theme="dark"] .global-navbar {
    background: #1e1e1e;
    border-color: #333;
    color: #fff;
}

[data-theme="dark"] .nav-links a,
[data-theme="dark"] .brand-logo,
[data-theme="dark"] .login-link {
    color: #fff !important;
}

[data-theme="dark"] .top-bar {
    background: #1e1e1e;
    border-color: #333;
}

[data-theme="dark"] .lang-title {
    color: #fff;
}

.hidden {
    display: none !important;
}

.shortcut-hint {
    font-size: 0.7rem;
    opacity: 0.7;
    font-weight: normal;
    margin-left: 4px;
}

/* Workspace */
/* Workspace (Side-by-Side) */
.workspace-split {
    flex: 1;
    display: flex;
    flex-direction: row;
    /* Side by Side */
    height: calc(100vh - 60px);
    /* Full height minus header */
}

/* Editor Section (Left) */
.editor-wrapper {
    flex: 1;
    position: relative;
    border-right: 1px solid var(--border);
    order: 1;
    height: 100%;
}

#editor-container {
    width: 100%;
    height: 100%;
}

/* Output Section (Right) */
.output-panel-wrapper {
    flex: 1;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    order: 2;
    height: 100%;
    border-top: none;
    border-bottom: none;
}

.panel-header {
    height: 48px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
}

.panel-tabs {
    display: flex;
    height: 100%;
    gap: 1.5rem;
}

.panel-tab {
    background: none;
    border: none;
    color: var(--text-sub);
    height: 100%;
    cursor: pointer;
    font-family: var(--font-ui);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.panel-tab.active {
    color: var(--text-main);
    border-bottom-color: var(--primary);
}

.counter {
    background: #3f3f46;
    color: white;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 0.7rem;
}

.panel-tools {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.metric {
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--text-sub);
}

.clear-terminal {
    background: none;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    opacity: 0.6;
}

.clear-terminal:hover {
    opacity: 1;
}

.panel-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view-content {
    position: absolute;
    inset: 0;
    padding: 1rem;
    overflow-y: auto;
    display: none;
    font-family: var(--font-code);
    font-size: 0.9rem;
}

.view-content.active {
    display: block;
}

/* Terminal Styling */
.log-line {
    margin-bottom: 4px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.log-stdout {
    color: var(--text-main);
}

.log-stderr {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    padding: 2px 4px;
    border-radius: 2px;
}

.log-system {
    color: var(--info);
    font-style: italic;
}

/* Analysis Cards */
.analysis-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

.analysis-card h4 {
    margin: 0 0 0.5rem 0;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analysis-card p {
    margin: 0 0 0.8rem 0;
    color: var(--text-sub);
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: var(--font-ui);
}

.code-fix {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.8rem;
    border-radius: 4px;
    color: var(--success);
    font-size: 0.85rem;
    overflow-x: auto;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-panel);
    width: 400px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.input-field {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    padding: 0.8rem;
    border-radius: 6px;
    color: white;
    margin-top: 0.5rem;
    font-family: var(--font-code);
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-desc {
    font-size: 0.8rem;
    color: var(--text-sub);
    line-height: 1.4;
}

.setting-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Loader */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.loader-content {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    /* Show Hamburger */
    .menu-toggle {
        display: block !important;
        background: none;
        border: none;
        color: var(--text-main);
        padding: 0.5rem;
        margin-right: 0.5rem;
        cursor: pointer;
    }

    /* Off-Canvas Sidebar */
    .sidebar {
        display: flex !important;
        position: fixed !important;
        top: 60px !important;
        /* Below Navbar */
        left: -200px !important;
        /* Hide off-screen */
        width: 200px !important;
        height: calc(100vh - 60px) !important;
        background: var(--bg-panel);
        transition: left 0.3s ease;
        z-index: 1000 !important;
        border-right: 1px solid var(--border);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    }

    .sidebar.mobile-open {
        left: 0 !important;
        /* Slide in */
    }

    .nav-menu {
        display: flex;
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .main-content {
        padding: 5px;
    }

    .workspace-split {
        flex-direction: column;
    }

    .output-panel-wrapper {
        order: 1;
        height: 35vh;
        min-height: 150px;
        border-right: none;
        border-bottom: 2px solid var(--border);
    }

    .editor-wrapper {
        order: 2;
        height: 50vh;
        min-height: 300px;
    }

    .top-bar {
        padding: 0.5rem;
    }

    .file-context {
        font-size: 0.8rem;
    }

    .actions .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}