:root {
    --bg-dark: #090c10;
    --panel-bg: #111827;
    --panel-border: rgba(255, 255, 255, 0.05);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --accent-primary: #10b981;
    --accent-glow: #34d399;
    --accent-secondary: #06b6d4;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
}

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

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

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-dark);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Views wrapper (direct child of main-content after topbar) */
.main-content > .view-container,
.main-content > [id^="view-"] {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 24px;
}

/* Sidebar Components */
.brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-main);
    border-bottom: 1px solid var(--panel-border);
}

.brand-icon {
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.4));
}

.nav-menu {
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 12px 8px;
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.03);
}

.nav-item.active {
    color: var(--accent-primary);
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.nav-item i {
    width: 18px;
    height: 18px;
}

/* Topbar */
.topbar {
    height: 70px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
}

.page-title {
    font-weight: 600;
    letter-spacing: 0.05em;
    display: flex;
    gap: 12px;
}

.text-glow {
    color: var(--accent-secondary);
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.text-muted {
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-dark);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 8px 12px;
    gap: 8px;
}

.search-bar i {
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-main);
    outline: none;
    font-size: 0.875rem;
    width: 200px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.05);
}

.indicator {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--panel-bg);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 12px;
    cursor: pointer;
}

.avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Dashboard Grid / Workspace */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.panel-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.panel-content.no-padding {
    padding: 0;
}

/* Challenge List Panel */
.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stats-row h4 {
    font-size: 1rem;
    font-weight: 600;
}

.stats-row span {
    font-size: 0.85rem;
}

.icon-btn-outline {
    background: none;
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    display: inline-flex;
    transition: 0.2s;
}

.icon-btn-outline:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--text-main);
}

.challenges {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.challenge-card {
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.challenge-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--panel-border);
    transition: 0.2s;
}

.challenge-card:hover, .challenge-card.selected {
    background-color: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.1);
}

.challenge-card.selected::before {
    background-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-glow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.card-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
}

.status-active { 
    background-color: rgba(16, 185, 129, 0.15); 
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}
.status-high { 
    background-color: rgba(239, 68, 68, 0.15); 
    color: #f87171; 
    border-color: rgba(239, 68, 68, 0.3);
}
.status-med { 
    background-color: rgba(245, 158, 11, 0.15); 
    color: #fbbf24; 
    border-color: rgba(245, 158, 11, 0.3);
}

.progress-bar-container {
    height: 4px;
    background-color: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 20px;
}

/* SPA Views */
.view-container {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.view-container.active {
    display: flex;
}

.challenge-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.challenge-card:hover {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255, 255, 255, 0.05);
}

.challenge-card.active {
    border-color: var(--accent-glow);
    background: rgba(16, 185, 129, 0.05);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.1);
}

.challenge-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.challenge-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
}

.challenge-card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.details-header {
    margin-bottom: 10px;
}

.markdown-content {
    line-height: 1.6;
    color: var(--text-muted);
}

.markdown-content h1, .markdown-content h2, .markdown-content h3 {
    color: var(--text-main);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.markdown-content p {
    margin-bottom: 1em;
}

.markdown-content code {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-glow));
    border-radius: 2px;
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.file-explorer {
    width: 200px;
    background-color: rgba(0,0,0,0.15);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
}

.file-explorer-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 16px;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.file-list {
    list-style: none;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
}

.file-item i {
    width: 16px;
    height: 16px;
}

.file-item:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--text-main);
}

.file-item.active {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--accent-primary);
}

.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Important for flex child to not overflow */
}

.editor-header {
    padding: 12px 20px;
    background-color: rgba(0,0,0,0.2);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--panel-border);
}

.code-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.markdown-preview-pane {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-muted);
    flex-direction: column;
    min-height: 0;
}

.markdown-preview-pane h1,
.markdown-preview-pane h2,
.markdown-preview-pane h3 {
    color: var(--text-main);
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--panel-border);
}

.markdown-preview-pane h1 { font-size: 1.5rem; }
.markdown-preview-pane h2 { font-size: 1.2rem; }
.markdown-preview-pane h3 { font-size: 1rem; }

.markdown-preview-pane p { margin-bottom: 1em; }

.markdown-preview-pane code {
    background: rgba(0,0,0,0.3);
    padding: 2px 7px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--accent-primary);
}

.markdown-preview-pane pre {
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 20px 24px;
    /* No overflow set here — let it expand to full height naturally */
    overflow: visible;
    margin-bottom: 1.5em;
    margin-left: -16px;
    margin-right: -16px;
    width: calc(100% + 32px);
    box-sizing: border-box;
}

.markdown-preview-pane pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
    font-size: 0.92rem;
    line-height: 1.7;
    white-space: pre;
    display: block;
    overflow-x: auto;  /* horizontal scroll lives here, not on pre */
    min-width: 100%;
}

.markdown-preview-pane ul, .markdown-preview-pane ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}

.markdown-preview-pane li { margin-bottom: 4px; }

.markdown-preview-pane strong { color: var(--text-main); font-weight: 600; }

.markdown-preview-pane blockquote {
    border-left: 3px solid var(--accent-primary);
    margin: 0 0 1em;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 0 6px 6px 0;
    color: var(--text-muted);
}

.CodeMirror {
    flex: 1;
    height: 100%;
    font-family: var(--font-mono) !important;
    font-size: 0.95rem;
    background-color: transparent !important;
}

.CodeMirror-gutters {
    background-color: rgba(0,0,0,0.2) !important;
    border-right: 1px solid var(--panel-border) !important;
}

/* Terminal Panel */
.terminal-container {
    height: 200px;
    background-color: #121212;
    border-top: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background-color: rgba(0,0,0,0.3);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #e0e0e0;
    white-space: pre-wrap;
}
.terminal-output.error {
    color: var(--danger);
}
.terminal-output.success {
    color: #10b981;
}

/* Custom Scrollbar for editor */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--panel-bg); 
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2); 
}

.editor-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #059669);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.btn-submit {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--panel-border);
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    color: var(--text-main);
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.05);
}

/* Right Column */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.graph-panel {
    flex: 0 0 250px;
}

.center-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mock-graph {
    width: 100%;
    height: 100%;
    position: relative;
}

.graph-svg {
    width: 100%;
    height: 100%;
}

.glow-line {
    filter: drop-shadow(0px 4px 6px rgba(52, 211, 153, 0.5));
    animation: dash 5s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: 0;
  }
}

.logs-panel {
    flex: 1;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.logs-table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--panel-border);
    background-color: rgba(0,0,0,0.2);
}

.logs-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    color: #e2e8f0;
    font-family: var(--font-mono);
}

.logs-table tr:hover {
    background-color: rgba(255,255,255,0.02);
}

.priority-high { color: var(--danger); }
.priority-med { color: var(--warning); }
.priority-low { color: var(--accent-secondary); }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--panel-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    text-align: center;
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.1);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--accent-primary);
    background-color: rgba(16, 185, 129, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-icon i {
    width: 32px;
    height: 32px;
}

.modal-content h2 {
    margin-bottom: 12px;
    color: white;
}

.modal-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 24px;
}

/* Wide Modal Variant */
.modal-content.wide {
    width: 750px;
    max-width: 95vw;
    height: 80vh; /* 80% of viewport height */
    display: flex;
    flex-direction: column;
    text-align: left;
    padding: 30px;
}

.modal-content.wide h2 {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.modal-content.wide .modal-icon {
    margin-bottom: 10px;
    flex-shrink: 0;
}

.modal-body {
    flex: 1;
    overflow-y: auto; /* Enable scrolling for content */
    padding-right: 10px; /* Space for scrollbar */
}

.modal-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-body strong {
    color: var(--accent-glow);
}

.modal-footer {
    display: flex;
    justify-content: center;
    padding-top: 20px;
    border-top: 1px solid var(--panel-border);
    flex-shrink: 0;
}
