/* =========================================
   CHALLENGE DETAIL PAGE - Task Solver
   ========================================= */

/* Page Container */
.challenge-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Background Effects */
.challenge-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(20, 184, 166, 0.1), transparent);
    pointer-events: none;
    z-index: 0;
}

/* Main Container */
.challenge-container {
    flex: 1;
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 1.25rem;
    padding: 1.7rem 1.5rem 1rem;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    align-items: start;
    min-height: calc(100vh - var(--nav-height) - 32px);
}

/* =========================================
   SIDEBAR - Task Description
   ========================================= */
.task-sidebar {
    background: rgba(28, 25, 23, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--nav-height) - 48px);
}

.task-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    transition: color 0.2s ease;
}

.task-back-link:hover {
    color: var(--primary-400);
}

.task-back-link i {
    width: 16px;
    height: 16px;
}

.task-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

/* Task Badge in Sidebar */
.task-sidebar .task-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.25rem;
}

.task-sidebar .difficulty-1 {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.task-sidebar .difficulty-2 {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.task-sidebar .difficulty-3 {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Task Description */
.task-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

.task-description p {
    margin: 0 0 1rem 0;
}

.task-description ul, .task-description ol {
    margin: 0 0 1rem 0;
    padding-left: 1.5rem;
}

.task-description li {
    margin-bottom: 0.5rem;
}

.task-description code {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-400);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.task-description pre {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.task-description pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.task-description h1, .task-description h2, .task-description h3 {
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem 0;
}

.task-description h1 { font-size: 1.25rem; }
.task-description h2 { font-size: 1.1rem; }
.task-description h3 { font-size: 1rem; }

.task-description strong {
    color: var(--text-primary);
}

/* Hint Box */
.task-hint-box {
    display: flex;
    gap: 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1.5rem;
}

.task-hint-box i {
    width: 20px;
    height: 20px;
    color: var(--primary-400);
    flex-shrink: 0;
    margin-top: 2px;
}

.task-hint-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.task-hint-content strong {
    color: var(--primary-400);
}

.task-hint-content code {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-300);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* =========================================
   EDITOR AREA - Code/Quiz
   ========================================= */
.editor-area {
    background: rgba(28, 25, 23, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--nav-height) - 48px);
    overflow: visible;
}

/* Vue Island Wrapper */
.vue-island-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

/* =========================================
   MONACO EDITOR
   ========================================= */
#monaco-editor {
    flex: 1;
    min-height: 400px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

/* =========================================
   CONTROLS
   ========================================= */
.controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.run-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

.run-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.run-btn i {
    width: 18px;
    height: 18px;
}

/* =========================================
   OUTPUT PANEL
   ========================================= */
.output-panel {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
    min-height: 80px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.output-panel.output-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.output-panel.output-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

/* =========================================
   QUIZ WRAPPER
   ========================================= */
.quiz-wrapper {
    flex: 1;
    min-height: 0;
}

.quiz-container-inner {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 100%;
}

#quiz-container,
#quiz-container > div {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.quiz-header i {
    width: 24px;
    height: 24px;
    color: var(--primary-400);
}

/* Quiz Question Block */
.quiz-question-block {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem;
    transition: border-color 0.2s ease;
}

.quiz-question-block.success-border {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.05);
}

.quiz-question-block.error-border {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.05);
}

.quiz-question-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Quiz Options Group */
.quiz-options-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Quiz Option */
.quiz-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    color: var(--text-secondary);
    min-width: 0;
    overflow-wrap: anywhere;
}

.quiz-option:hover {
    border-color: var(--primary-500);
    background: rgba(99, 102, 241, 0.05);
}

.quiz-option.selected {
    border-color: var(--primary-500);
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.quiz-option input[type="radio"],
.quiz-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-500);
    cursor: pointer;
}

/* Submit Quiz Button */
.submit-quiz-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
    align-self: flex-start;
}

.submit-quiz-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.submit-quiz-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-quiz-btn i {
    width: 18px;
    height: 18px;
}

/* Quiz Result Message */
.quiz-result-message {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
}

.quiz-result-message.text-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.quiz-result-message.text-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* =========================================
   CUSTOM SCROLLBAR
   ========================================= */
.task-sidebar::-webkit-scrollbar {
    width: 6px;
}

.task-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.task-sidebar::-webkit-scrollbar-thumb {
    background: var(--bg-muted);
    border-radius: 3px;
}

.task-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-disabled);
}

/* =========================================
   RESPONSIVE STYLES
   ========================================= */
@media (max-width: 1024px) {
    .challenge-container {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        height: auto;
        max-height: none;
    }

    .task-sidebar {
        position: relative;
        top: 0;
        max-height: none;
    }

    .editor-area {
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    .challenge-container {
        padding: 1rem;
        gap: 1rem;
        height: auto;
        max-height: none;
    }

    .task-sidebar {
        padding: 1.25rem;
    }

    .editor-area {
        padding: 1.25rem;
        min-height: 0;
        height: auto;
        overflow: visible;
    }

    .task-title {
        font-size: 1.25rem;
    }

    #monaco-editor {
        min-height: 300px;
    }

    .controls {
        flex-direction: column;
    }

    .run-btn, .submit-quiz-btn {
        width: 100%;
        justify-content: center;
    }

    .vue-island-wrapper,
    .quiz-container-inner {
        min-height: 0;
    }
}

@media (max-width: 480px) {
    .challenge-container {
        padding: 0.75rem;
        height: auto;
        max-height: none;
    }

    .task-sidebar,
    .editor-area {
        padding: 1rem;
        border-radius: 12px;
    }

    #monaco-editor {
        min-height: 240px;
    }

    .quiz-option {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}

/* =========================================
   MARKDOWN CONTENT - KaTeX FORMULAS
   ========================================= */
.markdown-content {
    color: var(--text-secondary);
    line-height: 1.7;
}

.markdown-content p {
    margin: 0 0 0.75rem 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0 0 0.75rem 0;
    padding-left: 1.25rem;
}

.markdown-content li {
    margin-bottom: 0.35rem;
}

.markdown-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-content em {
    font-style: italic;
}

.markdown-content code {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-400);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.markdown-content pre {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.85rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    color: var(--text-primary);
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
}

.markdown-content h1 { font-size: 1.15rem; }
.markdown-content h2 { font-size: 1.05rem; }
.markdown-content h3 { font-size: 1rem; }
.markdown-content h4 { font-size: 0.95rem; }

/* KaTeX Formula Styles */
.markdown-content .katex {
    font-size: 1em;
    color: var(--text-primary);
}

.markdown-content .katex-display {
    margin: 0.75rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0;
}

.markdown-content .katex-display > .katex {
    white-space: normal;
}

/* Inline math */
.markdown-content .katex-inline {
    padding: 0 0.2rem;
}

/* Block math */
.markdown-content .katex-block {
    display: block;
    text-align: center;
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.remediation-panel {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.08);
}

.remediation-title {
    margin-bottom: 0.7rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 700;
}

.remediation-concepts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.remediation-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.25rem 0.65rem;
    border: 1px solid rgba(245, 158, 11, 0.32);
    border-radius: 999px;
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.1);
    font-size: 0.82rem;
}

.remediation-link {
    display: block;
    width: fit-content;
    margin-top: 0.45rem;
    color: var(--primary-400);
    font-weight: 600;
    text-decoration: none;
}

.remediation-link:hover {
    color: var(--accent-400);
}
