/* Coding Arena Stylesheet | DevGainx */

:root {
    --bg-main: #0b0f19;
    --card-bg: rgba(17, 24, 39, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-glow: rgba(99, 102, 241, 0.15);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #10b981;
    --easy: #10b981;
    --medium: #f59e0b;
    --hard: #ef4444;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    overflow: hidden; /* Prevent body scrolling in desktop split-view */
    min-height: 100vh;
}

/* Glassmorphism Card Utility */
.card-glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Navigation Back button styles */
.nav-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fast);
}

.nav-back-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(99, 102, 241, 0.4);
    color: #fff;
    transform: translateX(-2px);
}

/* Arena Split Container */
.arena-split-container {
    display: flex;
    gap: 1.25rem;
    padding: 0.75rem 1.5rem;
    height: calc(100vh - 85px);
    margin-top: 85px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Preloader custom style overrides */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #090d16;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.loader-content {
    text-align: center;
}

.glow-orbit {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-right-color: #ec4899;
    animation: spin-loader 1s linear infinite;
    margin: 0 auto 20px auto;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

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

.loader-text {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}

.loader-subtext {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Left Pane: Problem Description */
.problem-pane {
    flex: 0 0 42%;
    border-radius: 20px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-sizing: border-box;
}

.problem-pane::-webkit-scrollbar {
    width: 6px;
}

.problem-pane::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.problem-pane::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.problem-header-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.category-tag-arena {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    padding: 0.3rem 0.75rem;
    border-radius: 30px;
    color: var(--text-muted);
}

.difficulty-badge-arena {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
}

.difficulty-badge-arena.easy { background: rgba(16, 185, 129, 0.12); color: var(--easy); }
.difficulty-badge-arena.medium { background: rgba(245, 158, 11, 0.12); color: var(--medium); }
.difficulty-badge-arena.hard { background: rgba(239, 68, 68, 0.12); color: var(--hard); }

.points-badge-arena {
    background: rgba(255, 255, 255, 0.05);
    color: #ffd700;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 3px;
}

.problem-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 1.25rem;
    line-height: 1.25;
}

.problem-body-content {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.description-section {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #cbd5e1;
}

.description-section p {
    margin-bottom: 0.75rem;
}

.description-section code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    color: #f43f5e;
}

/* Arena Card sections */
.arena-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: var(--transition-fast);
}

.arena-card:hover {
    border-color: rgba(99, 102, 241, 0.18);
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.05);
}

.section-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fff;
    margin-bottom: 1.1rem;
    border-left: 3px solid var(--primary);
    padding-left: 8px;
    line-height: 1;
}

/* Format Card details */
.format-block {
    margin-bottom: 1rem;
}

.format-block:last-child {
    margin-bottom: 0;
}

.format-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}

.format-text {
    font-size: 0.92rem;
    line-height: 1.5;
    color: #e2e8f0;
    white-space: pre-wrap;
}

/* Constraints & Limits Grid */
.constraints-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr 0.9fr;
    gap: 1rem;
}

@media (max-width: 480px) {
    .constraints-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

.constraint-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.constraint-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.constraint-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    color: #e2e8f0;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    display: inline-block;
    word-break: break-all;
}

/* Topic Tags */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.topic-tag {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    transition: var(--transition-fast);
}

.topic-tag:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Badges for hidden/sample test cases */
.sample-badge {
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.12);
    color: var(--easy);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    margin-left: 6px;
    letter-spacing: 0.03em;
    display: inline-block;
    vertical-align: middle;
}

.hidden-badge {
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    margin-left: 6px;
    letter-spacing: 0.03em;
    display: inline-block;
    vertical-align: middle;
}

/* Examples Section */
.examples-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.example-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.1rem;
}

.example-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.75rem;
}

.example-block {
    margin-bottom: 0.6rem;
}

.example-block:last-child {
    margin-bottom: 0;
}

.example-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.25rem;
}

.example-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    color: #e2e8f0;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    white-space: pre-wrap;
    display: block;
}

.example-explanation {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.4;
}

.example-explanation strong {
    color: #e2e8f0;
}

/* Right Pane: Code Editor & Compiler Console */
.editor-pane {
    flex: 1 1 58%;
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0.75rem;
    overflow: hidden;
    box-sizing: border-box;
}

/* Editor Header Bar */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 16px;
}

.lang-selector-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lang-selector-wrap label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin: 0;
    margin-top: 3px;
    line-height: 1;
}

.lang-selector-dropdown {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 0.45rem 1rem;
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lang-selector-dropdown:focus {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.lang-selector-dropdown option {
    background: #0f172a;
    color: #fff;
}

.editor-reset-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.45rem 1rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.editor-reset-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* Monaco Container */
.monaco-editor-outer {
    flex: 1 1 auto;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    min-height: 250px;
}

.monaco-arena-container {
    width: 100%;
    height: 100%;
}

/* Panel Resizer Slider */
.panel-resizer {
    height: 12px;
    cursor: ns-resize;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: -4px 0; /* overlap gap slightly */
    z-index: 10;
}

.resizer-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: background var(--transition-fast), width var(--transition-fast);
}

.panel-resizer:hover .resizer-handle,
.panel-resizer.dragging .resizer-handle {
    background: var(--primary);
    width: 60px;
}

/* Stdin / Stdout Terminal Panel */
.console-panel {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
}

/* Console Header Tabs */
.console-header-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--glass-border);
    padding: 0 0.5rem;
}

.console-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
}

.console-tab-btn:hover {
    color: #fff;
}

.console-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Console Body & Tabs */
.console-body {
    flex: 1 1 auto;
    padding: 0.75rem;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.15);
}

.console-body::-webkit-scrollbar {
    width: 6px;
}

.console-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.console-tab-content {
    display: none;
    height: 100%;
}

.console-tab-content.active {
    display: block;
}

/* Tab 1: Terminal styles */
#tab-terminal {
    display: none;
    flex-direction: column;
    height: 100%;
    gap: 0.75rem;
}

#tab-terminal.active {
    display: flex;
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.terminal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #f59e0b; }
.terminal-dot.green { background: #10b981; }

.terminal-status {
    color: var(--text-muted);
    margin-left: 6px;
}

.terminal-screen {
    flex: 1 1 auto;
    background: #070a13;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: #e2e8f0;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.5;
    box-sizing: border-box;
    margin: 0;
}

.terminal-screen::-webkit-scrollbar {
    width: 4px;
}

.terminal-screen::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
}

/* Tab 2: Custom Stdin */
.stdin-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

#custom-stdin-input {
    width: 100%;
    height: 60px;
    background: #070a13;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    padding: 0.75rem;
    resize: none;
    outline: none;
    box-sizing: border-box;
    transition: var(--transition-fast);
}

#custom-stdin-input:focus {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.15);
}

/* Tab 3: Predefined Test cases results */
.testcases-status-list {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    box-sizing: border-box;
    align-items: center;
}

.testcase-status-row {
    flex: 1 1 0px;
    min-width: 120px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.5rem;
    gap: 0.4rem;
    box-sizing: border-box;
    transition: var(--transition-fast);
}

.testcase-status-row > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
}

.case-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}

.case-status {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.case-status.pending {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.case-status.passed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--easy);
}

.case-status.failed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--hard);
}

.case-status.running {
    background: rgba(245, 158, 11, 0.15);
    color: var(--medium);
    animation: blink-loader 1s infinite alternate;
}

@keyframes blink-loader {
    to { opacity: 0.5; }
}

/* Run and Submit buttons row */
.console-action-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
}

.console-action-footer button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.45rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}

.console-btn-run {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border) !important;
    color: var(--text-main);
}

.console-btn-run:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

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

.console-btn-submit:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Background Blobs */
.bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background-color: var(--bg-main) !important;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: #5850ec;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 45vw;
    height: 45vw;
    background: #ec4899;
}

.blob-3 {
    top: 40%;
    left: 50%;
    width: 35vw;
    height: 35vw;
    background: #3b82f6;
}

/* Fullscreen Editor Mode */
.arena-split-container.editor-fullscreen .problem-pane {
    display: none !important;
}
.arena-split-container.editor-fullscreen .editor-pane {
    flex: 1 1 100% !important;
}

/* Responsive Rules */
@media (max-width: 992px) {
    body {
        overflow-y: auto; /* Allow window scrolling in mobile stacked-view */
    }

    .arena-split-container {
        flex-direction: column;
        height: auto;
        margin-top: 80px;
        overflow: visible;
        padding: 1.25rem 1rem;
        gap: 1.25rem;
    }

    .problem-pane {
        flex: 1 1 auto;
        height: auto;
        overflow-y: visible;
        border-radius: 16px;
    }

    .editor-pane {
        flex: 1 1 auto;
        height: auto;
        overflow: visible;
        gap: 1.25rem;
    }

    .monaco-editor-outer {
        height: 350px;
    }

    .console-panel {
        flex: 1 1 auto;
        height: auto;
        min-height: 300px;
    }

    #custom-stdin-input {
        height: 80px;
    }
}
