/* ===== 全局左侧导航栏 ===== */
/* body.has-sidebar { display: flex } 已在 styles.css 中定义 */

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #16181d;
    color: #e8e8e8;
    overflow-y: auto;
    z-index: 2000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2f3a;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid #2a2f3a;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #e8e8e8;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 2px;
    background: linear-gradient(135deg, #00d4aa, #00b4d8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: #16181d;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    color: #e8e8e8;
}

.sidebar-logo-sub {
    font-size: 0.75rem;
    color: #6a6f7a;
    font-weight: 400;
}

/* 导航分组 */
.sidebar-section {
    padding: 12px 0;
    border-bottom: 1px solid #2a2f3a;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section-title {
    padding: 4px 16px 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6a6f7a;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin: 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #6a6f7a;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
    border-left: 2px solid transparent;
}

.sidebar-nav a:hover {
    background: #1e2229;
    color: #e8e8e8;
}

.sidebar-nav a.active {
    background: #1e2229;
    color: #00d4aa;
    border-left-color: #00d4aa;
    font-weight: 500;
}

.sidebar-nav a .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

/* 可展开的子菜单 */
.sidebar-expandable > a {
    cursor: pointer;
    user-select: none;
}

.sidebar-expandable > a::after {
    content: '';
    margin-left: auto;
    width: 0;
    height: 0;
    border-left: 4px solid #6a6f7a;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    transition: transform 0.2s;
}

.sidebar-expandable.open > a::after {
    transform: rotate(90deg);
}

.sidebar-submenu {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    background: #111318;
}

.sidebar-expandable.open .sidebar-submenu {
    display: block;
}

.sidebar-submenu a {
    padding: 6px 16px 6px 44px;
    font-size: 0.8125rem;
    color: #6a6f7a;
}

.sidebar-submenu a:hover {
    color: #e8e8e8;
}

.sidebar-submenu a.active {
    color: #00d4aa;
    background: rgba(0, 212, 170, 0.06);
}

/* 二级子菜单（章节下的小节） */
.sidebar-submenu .sidebar-expandable > a {
    padding-left: 44px;
}

.sidebar-submenu .sidebar-submenu a {
    padding-left: 60px;
    font-size: 0.75rem;
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #2a2f3a;
    margin-top: auto;
    flex-shrink: 0;
}

.sidebar-footer p {
    font-size: 0.6875rem;
    color: #6a6f7a;
    text-align: center;
}

/* 移动端汉堡按钮 */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 2001;
    width: 40px;
    height: 40px;
    border-radius: 2px;
    background: #16181d;
    color: #e8e8e8;
    border: 1px solid #2a2f3a;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #e8e8e8;
    position: relative;
}

.sidebar-toggle span::before,
.sidebar-toggle span::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: #e8e8e8;
    left: 0;
}

.sidebar-toggle span::before { top: -6px; }
.sidebar-toggle span::after { top: 6px; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1999;
}

.sidebar-overlay.show {
    display: block;
}

/* ===== 主内容区域 ===== */
.main-content {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
}

/* 隐藏旧的顶部导航栏（在课程页面中） */
.course-page .navbar,
body.has-sidebar .navbar {
    display: none;
}

.course-page {
    padding-top: 0 !important;
}

/* ===== 交互式练习系统 ===== */

/* 练习容器 */
.quiz-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
}

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

.quiz-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-light);
}

.quiz-progress-bar {
    width: 120px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* 单个题目 */
.quiz-question {
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-light);
    transition: all 0.3s ease;
}

.quiz-question.answered {
    border-color: rgba(0,212,170,0.3);
    background: rgba(0,212,170,0.05);
}

.quiz-question.wrong {
    border-color: rgba(239,68,68,0.3);
    background: rgba(239,68,68,0.05);
}

.quiz-question.correct {
    border-color: rgba(0,212,170,0.3);
    background: rgba(0,212,170,0.05);
}

.question-number {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.question-type-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0284c7;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

.question-text {
    font-size: 0.9375rem;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.6;
}

.question-text code {
    background: var(--bg-dark);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

/* 选项 */
.question-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.question-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
    user-select: none;
}

.question-option:hover {
    border-color: var(--primary-light);
    background: rgba(0,212,170,0.05);
}

.question-option.selected {
    border-color: var(--primary);
    background: rgba(0,212,170,0.08);
}

.question-option.disabled {
    pointer-events: none;
    cursor: default;
}

.question-option.correct-answer {
    border-color: #22c55e;
    background: rgba(34,197,94,0.08);
}

.question-option.wrong-answer {
    border-color: #ef4444;
    background: rgba(239,68,68,0.08);
}

.option-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
    position: relative;
    transition: all 0.2s;
}

.question-option.selected .option-radio {
    border-color: var(--primary);
}

.question-option.selected .option-radio::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.question-option.correct-answer .option-radio {
    border-color: #22c55e;
    background: #22c55e;
}

.question-option.correct-answer .option-radio::after {
    content: '\2713';
    color: white;
    font-size: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: transparent;
    border-radius: 0;
}

.question-option.wrong-answer .option-radio {
    border-color: #ef4444;
    background: #ef4444;
}

.question-option.wrong-answer .option-radio::after {
    content: '\2717';
    color: white;
    font-size: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: transparent;
    border-radius: 0;
}

.option-label {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.5;
}

/* 填空题输入框 */
.fill-input {
    width: 200px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9375rem;
    transition: all 0.2s;
    outline: none;
}

.fill-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,212,170,0.1);
}

.fill-input.correct {
    border-color: #22c55e;
    background: #f0fdf4;
}

.fill-input.wrong {
    border-color: #ef4444;
    background: #fef2f2;
}

.fill-input:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* 判断题 */
.tf-options {
    display: flex;
    gap: 12px;
}

.tf-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
    user-select: none;
}

.tf-option:hover {
    border-color: var(--primary-light);
    background: rgba(0,212,170,0.05);
}

.tf-option.selected {
    border-color: var(--primary);
    background: rgba(0,212,170,0.08);
}

.tf-option.disabled {
    pointer-events: none;
}

.tf-option.correct-answer {
    border-color: #22c55e;
    background: rgba(34,197,94,0.08);
}

.tf-option.wrong-answer {
    border-color: #ef4444;
    background: rgba(239,68,68,0.08);
}

/* 提交按钮 */
.quiz-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.quiz-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 答案解析区域 */
.answer-explanation {
    display: none;
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid rgba(0,212,170,0.2);
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text);
}

.answer-explanation.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.answer-explanation-title {
    font-weight: 600;
    color: #16a34a;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.answer-explanation code {
    background: var(--bg-dark);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.8125rem;
}

/* 实操题代码区域 */
.code-editor-area {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    background: #1e293b;
    color: #e2e8f0;
    tab-size: 4;
}

.code-editor-area:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 得分显示 */
.quiz-score {
    display: none;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid rgba(0,212,170,0.2);
    border-radius: var(--radius);
    margin-top: 16px;
    text-align: center;
}

.quiz-score.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.quiz-score-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.quiz-score-label {
    font-size: 0.875rem;
    color: var(--text-light);
}

.quiz-score-pass {
    color: #16a34a;
    font-weight: 600;
}

.quiz-score-fail {
    color: #ef4444;
    font-weight: 600;
}

/* 试卷容器 */
.exam-container {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-top: 24px;
}

.exam-paper-header {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.exam-paper-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.exam-paper-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 0.875rem;
    color: var(--text-light);
}

.exam-paper-info span {
    padding: 4px 12px;
    background: var(--surface-light);
    border-radius: 6px;
}

/* 章节页面内容区 */
.chapter-content-area {
    padding: 32px 40px;
    max-width: 900px;
}

.chapter-content-area h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.chapter-content-area .chapter-breadcrumb {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 24px;
}

.chapter-content-area .chapter-breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.chapter-content-area .chapter-breadcrumb a:hover {
    text-decoration: underline;
}

/* 知识点卡片 */
.knowledge-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.knowledge-card h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.knowledge-card p {
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 8px;
}

.knowledge-card .code-block {
    background: var(--bg-dark);
    color: #e2e8f0;
    padding: 14px 18px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    overflow-x: auto;
    margin: 12px 0;
}

/* 自检问题 */
.self-check {
    background: rgba(217,119,6,0.05);
    border: 1px solid rgba(217,119,6,0.2);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 20px 0;
}

.self-check h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 10px;
}

.self-check ol {
    padding-left: 20px;
}

.self-check li {
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.8;
    margin-bottom: 4px;
}

/* 拓展素材 */
.resource-list {
    background: rgba(0,180,216,0.05);
    border: 1px solid rgba(0,180,216,0.2);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 16px 0;
}

.resource-list h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 10px;
}

.resource-list ul {
    padding-left: 20px;
}

.resource-list li {
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.8;
}

.resource-list a {
    color: var(--primary);
    text-decoration: underline;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: none;
    }

    .sidebar-overlay.show {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 260px;
    }

    .chapter-content-area {
        padding: 16px 12px;
    }

    .quiz-question {
        padding: 14px;
    }

    .exam-container {
        padding: 20px 16px;
    }
}
