:root {
    --bg-main: #1E1E1E;
    /* VS Code dark background */
    --bg-sidebar: #252526;
    /* VS Code dark sidebar */
    --bg-panel: #2D2D2D;
    --border-color: #3C3C3C;
    /* VS Code border */

    --text-main: #CCCCCC;
    --text-highlight: #FFFFFF;
    --text-muted: #858585;

    --color-primary: #3178C6;
    /* TypeScript Blue */
    --color-success: #4CAF50;
    --color-danger: #F44336;
    --color-warning: #FF9800;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-layout {
    display: flex;
    height: 100%;
}

.hidden {
    display: none !important;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-primary);
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-highlight);
    letter-spacing: -0.03em;
}

.filters {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filters select {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
}

.progress-txt {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.challenge-list {
    flex: 1;
    overflow-y: auto;
}

.challenge-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.challenge-item:hover {
    background: var(--bg-panel);
}

.challenge-item.active {
    background: rgba(49, 120, 198, 0.15);
    border-left: 3px solid var(--color-primary);
}

.ci-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-highlight);
    margin-bottom: 0.4rem;
    display: flex;
    justify-content: space-between;
}

.ci-badges {
    display: flex;
    gap: 0.5rem;
    font-size: 0.7rem;
}

.badge {
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
}

.badge.easy {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.badge.medium {
    background: rgba(255, 152, 0, 0.2);
    color: #FF9800;
}

.badge.hard {
    background: rgba(244, 67, 54, 0.2);
    color: #F44336;
}

.badge.extreme {
    background: rgba(156, 39, 176, 0.2);
    color: #9C27B0;
}

.status-icon {
    font-size: 0.9rem;
}

/* Main Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.challenge-header {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.challenge-header h2 {
    font-size: 1.3rem;
    color: var(--text-highlight);
    margin-bottom: 0.5rem;
}

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

.btn {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: #235a97;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--border-color);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Workspace Split */
.workspace {
    flex: 1;
    display: flex;
    min-height: 0;
}

.description-panel {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    padding: 1.5rem;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.description-panel h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.desc-content {
    font-size: 0.9rem;
    line-height: 1.6;
}

.desc-content code {
    background: var(--bg-panel);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.hints-area {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid rgba(255, 152, 0, 0.3);
    padding: 1rem;
    border-radius: 6px;
}

.hints-area ul {
    margin-left: 1.2rem;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.test-results {
    background: var(--bg-panel);
    padding: 1rem;
    border-radius: 6px;
}

.status-indicator {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.status-indicator.pass {
    color: var(--color-success);
}

.status-indicator.fail {
    color: var(--color-danger);
}

#diagnostics-list {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-danger);
    list-style: none;
    margin-top: 0.5rem;
}

#diagnostics-list li {
    margin-bottom: 0.3rem;
}

.editor-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #1E1E1E;
    /* default monaco dark */
}

#monaco-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

/* Loader Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 30, 30, 0.9);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-mono);
    color: var(--color-primary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(49, 120, 198, 0.3);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spin 1s ease-in-out infinite;
}

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