/* 小题快刷 - 自定义样式 */

/* 分类卡片悬浮效果 */
.category-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.12) !important;
}

/* 导航栏品牌字体 */
.navbar-brand {
    font-weight: 700;
    font-size: 1.3rem;
}

/* 表单卡片圆角 */
.card {
    border-radius: 0.75rem;
}

/* 统计卡片数字 */
.card h3 {
    font-weight: 700;
}

/* 按钮圆角 */
.btn {
    border-radius: 0.5rem;
}

/* 欢迎区域 */
.bg-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%) !important;
}

/* ===== 首页 Hero 区域 ===== */
.hero-section {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 50%, #084298 100%);
    color: #fff;
    border-radius: 1rem;
}

/* ===== 统计卡片 ===== */
.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* ===== 难度标签 ===== */
.badge-difficulty-1 {
    background-color: #198754;
    color: #fff;
}

.badge-difficulty-2 {
    background-color: #ffc107;
    color: #212529;
}

.badge-difficulty-3 {
    background-color: #dc3545;
    color: #fff;
}

/* ===== 选项交互样式 ===== */
.option-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.option-item:hover {
    border-color: #0d6efd;
    background-color: #f0f7ff;
}

.option-item.selected {
    border-color: #0d6efd;
    background-color: #e7f1ff;
}

/* 选项标签圆圈 */
.option-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: #e9ecef;
    font-weight: 700;
    font-size: 0.9rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.option-item.selected .option-label {
    background-color: #0d6efd;
    color: #fff;
}

/* 选项文字 */
.option-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.6;
    word-break: break-word;
}

/* 选项内 Markdown 渲染内容适配 */
.option-text p {
    margin-bottom: 0.3em;
}
.option-text p:last-child {
    margin-bottom: 0;
}
.option-text code {
    background: #f0f0f0;
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.9em;
    color: #d63384;
}
.option-text pre {
    background: #f8f9fa;
    padding: 0.5em 0.75em;
    border-radius: 0.25rem;
    overflow-x: auto;
    margin-bottom: 0.3em;
}
.option-text pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.option-text img {
    max-width: 100%;
    height: auto;
}
.option-text .katex-display {
    margin: 0.5em 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* ===== 答题结果页 ===== */
.result-correct {
    background: linear-gradient(135deg, #198754 0%, #157347 100%) !important;
    --bs-card-color: #fff;
}

.result-wrong {
    background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%) !important;
    --bs-card-color: #fff;
}

.result-partial {
    background: linear-gradient(135deg, #f0ad4e, #ec971f) !important;
    --bs-card-color: #fff;
    color: #fff !important;
}

.result-partial h2,
.result-partial .result-icon i {
    color: #fff !important;
}

.result-partial-hint {
    border-left: 4px solid #f0ad4e !important;
    background-color: #fff9ef;
}

.missed-option {
    background-color: #fff3cd;
    border-color: #f0ad4e !important;
}

/* 结果页选项状态 */
.option-result-item.correct {
    border-color: #198754 !important;
    background-color: #d1e7dd;
}

.option-result-item.wrong {
    border-color: #dc3545 !important;
    background-color: #f8d7da;
}

/* ===== 管理后台侧边栏 ===== */
.admin-sidebar {
    min-height: calc(100vh - 56px);
    width: 220px;
    flex-shrink: 0;
}

.admin-sidebar .nav-link {
    color: #495057;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.admin-sidebar .nav-link:hover {
    background-color: #e9ecef;
    color: #0d6efd;
}

.admin-sidebar .nav-link.active {
    background-color: #0d6efd;
    color: #fff;
}

.admin-sidebar .nav-link i {
    margin-right: 0.5rem;
    width: 1.2rem;
    text-align: center;
}

/* ===== 计时器 ===== */
#timer, .timer {
    font-family: monospace;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

/* ===== 题目列表项悬浮效果 ===== */
.list-group-item-action:hover {
    transform: translateX(4px);
    transition: transform 0.15s ease;
}

/* ===== 选项正确/错误状态（兼容两种命名）===== */
.option-item.correct,
.option-result-item.correct {
    border-color: #198754 !important;
    background-color: #d1e7dd;
}

.option-item.wrong,
.option-result-item.wrong {
    border-color: #dc3545 !important;
    background-color: #f8d7da;
}

/* ===== 响应式适配 ===== */
@media (max-width: 768px) {
    .admin-sidebar {
        min-height: auto;
        width: 100%;
        border-right: none !important;
        border-bottom: 1px solid #dee2e6;
    }

    .admin-sidebar .nav {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .admin-sidebar .nav-link {
        font-size: 0.8rem;
        padding: 0.375rem 0.625rem;
    }

    .hero-section {
        padding: 1.5rem !important;
    }

    .hero-section h2 {
        font-size: 1.5rem;
    }

    .stat-card {
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 576px) {
    .option-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .option-label {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.8rem;
    }

    .result-correct .card-body,
    .result-wrong .card-body,
    .result-partial .card-body {
        padding: 2rem 1rem !important;
    }

    .result-icon i {
        font-size: 3rem !important;
    }
}

/* ===== Markdown 渲染样式 ===== */
.md-content {
    line-height: 1.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
    margin-top: 0.8em;
    margin-bottom: 0.4em;
    font-weight: 600;
}

.md-content h1 { font-size: 1.5rem; }
.md-content h2 { font-size: 1.3rem; }
.md-content h3 { font-size: 1.15rem; }

.md-content p {
    margin-bottom: 0.6em;
}

.md-content code {
    background-color: #f4f4f4;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
    color: #d63384;
}

.md-content pre {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1em;
    overflow-x: auto;
}

.md-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.md-content blockquote {
    border-left: 4px solid #dee2e6;
    padding-left: 1em;
    margin-left: 0;
    color: #6c757d;
}

.md-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

.md-content th,
.md-content td {
    border: 1px solid #dee2e6;
    padding: 0.5em 0.75em;
    text-align: left;
}

.md-content th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.md-content img {
    max-width: 100%;
    height: auto;
}

.md-content ul,
.md-content ol {
    padding-left: 1.5em;
    margin-bottom: 0.6em;
}

/* KaTeX 块级公式居中显示 */
.md-content .katex-display {
    margin: 1em 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.md-content .katex-display > .katex {
    text-align: center;
}

/* ===== 列表页 Markdown 预览（固定高度，不影响布局）===== */
.md-excerpt-preview {
    height: 4.5em;              /* 固定 3 行高度，统一题目框高度 */
    overflow: hidden;
    line-height: 1.5;
    font-size: 0.9rem;
    color: #495057;
    word-wrap: break-word;
    overflow-wrap: break-word;
    pointer-events: none;       /* 列表项整体可点击，内部不拦截 */
    position: relative;
}

/* 底部渐隐遮罩，提示内容被截断 */
.md-excerpt-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.5em;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
    pointer-events: none;
}

/* 内部元素尺寸限制，防止撑高容器 */
.md-excerpt-preview h1,
.md-excerpt-preview h2,
.md-excerpt-preview h3,
.md-excerpt-preview h4,
.md-excerpt-preview h5,
.md-excerpt-preview h6 {
    font-size: 0.95rem;
    margin: 0 0 0.2em;
    font-weight: 600;
}

.md-excerpt-preview p {
    margin: 0 0 0.2em;
}

.md-excerpt-preview img {
    display: none;              /* 列表预览中不加载图片，加快显示速度 */
}

.md-excerpt-preview pre {
    max-height: 2.5em;
    overflow: hidden;
    font-size: 0.8rem;
    margin: 0;
    padding: 0.2em 0.5em;
}

.md-excerpt-preview code {
    font-size: 0.85em;
}

.md-excerpt-preview blockquote {
    border-left: 3px solid #dee2e6;
    padding-left: 0.6em;
    margin: 0;
    color: #6c757d;
}

.md-excerpt-preview ul,
.md-excerpt-preview ol {
    padding-left: 1.2em;
    margin: 0;
}

.md-excerpt-preview table {
    display: none;              /* 列表中不显示表格 */
}

.md-excerpt-preview .katex-display {
    margin: 0;
    overflow: hidden;
    max-height: 1.5em;
}

/* ===== 轻量 Markdown 编辑器 ===== */
.md-editor-wrap {
    display: flex;
    flex-direction: column;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
    resize: vertical;
    min-height: 200px;
}

/* 全屏模式 */
.md-editor-wrap.md-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    border: none;
    border-radius: 0;
    resize: none;
    background: #fff;
}

.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #495057;
    cursor: pointer;
    transition: background 0.15s;
}
.md-btn:hover { background: #e9ecef; color: #212529; }
.md-btn:active { background: #dee2e6; }

.md-sep {
    display: inline-block;
    width: 1px;
    height: 18px;
    margin: 0 4px;
    background: #dee2e6;
}

.md-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

/* 全屏时 md-body 自动填满剩余空间（flex:1 生效，无需固定 calc） */
.md-fullscreen .md-body {
    height: auto;
}

.md-body textarea {
    flex: 1;
    min-width: 0;
    min-height: 0;
    border: none;
    outline: none;
    resize: none;
    padding: 12px;
    font-family: 'Meiryo UI', 'Microsoft YaHei', monospace;
    font-size: 14px;
    line-height: 1.6;
    background: #fff;
    box-sizing: border-box;
    overflow-y: auto;
}

.md-preview {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 12px;
    border-left: 1px solid #dee2e6;
    overflow-y: auto;
    background: #fdfdfd;
    box-sizing: border-box;
}

/* ===== 选项编辑器（共用工具栏 + 焦点跟踪预览） ===== */
.md-options-editor {
    display: flex;
    flex-direction: column;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
    resize: vertical;
    min-height: 260px;
    height: 380px;
}

/* 选项编辑器全屏模式 */
.md-options-editor.md-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    border: none;
    border-radius: 0;
    resize: none;
    background: #fff;
}

.md-options-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.md-options-list {
    flex: 1;
    min-width: 0;
    padding: 12px;
    overflow-y: auto;
}

.md-options-preview {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 12px;
    border-left: 1px solid #dee2e6;
    overflow-y: auto;
    background: #fdfdfd;
    box-sizing: border-box;
}

.md-options-footer {
    padding: 8px 12px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
}

/* 选项预览区：每个选项分组样式 */
.md-option-preview-item {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e9ecef;
}
.md-option-preview-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.md-option-preview-label {
    margin-bottom: 4px;
}

@media (max-width: 768px) {
    .md-body { flex-direction: column; }
    .md-preview { border-left: none; border-top: 1px solid #dee2e6; max-height: 200px; }
    .md-options-body { flex-direction: column; }
    .md-options-preview { border-left: none; border-top: 1px solid #dee2e6; max-height: 160px; }
}
