/* 刷题页面样式 */

/* 右侧边栏 */
.right-sidebar {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 8px;
    background: var(--bg-card);
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
    border-right: none;
}

.sidebar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.2s;
}

.sidebar-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.sidebar-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.sidebar-btn span {
    font-size: 11px;
    font-weight: 500;
}

.sidebar-btn.home-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* 布局 */
.quiz-layout {
    display: flex;
    height: calc(100vh - 64px);
    overflow: hidden;
    padding-right: 70px; /* 为右侧边栏留出空间 */
}

/* 左侧层级树面板 */
.tree-panel {
    width: 320px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.tree-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.tree-header h2 svg {
    width: 20px;
    height: 20px;
    fill: var(--primary);
}

.tree-collapse-icon {
    display: none;
    margin-left: auto;
    transition: transform 0.2s;
}

.tree-panel.collapsed .tree-collapse-icon {
    transform: rotate(-90deg);
}

@media (max-width: 900px) {
    .tree-collapse-icon {
        display: block;
    }
    
    .tree-header h2 {
        flex: 1;
        display: flex;
        align-items: center;
    }
}

.btn-refresh {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.btn-refresh:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.btn-refresh svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* 树节点样式 */
.tree-node {
    margin-bottom: 4px;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.tree-node-header:hover {
    background: var(--bg-hover);
}

.tree-node-header.active {
    background: rgba(99, 102, 241, 0.1);
}

.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--text-muted);
    transition: all 0.2s;
    flex-shrink: 0;
}

.tree-toggle svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    transition: transform 0.2s;
}

.tree-node.expanded > .tree-node-header .tree-toggle svg {
    transform: rotate(90deg);
}

.tree-toggle.empty {
    visibility: hidden;
}

.tree-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tree-icon svg {
    width: 18px;
    height: 18px;
}

.tree-icon.course svg {
    fill: #6366f1;
}

.tree-icon.chapter svg {
    fill: #f59e0b;
}

.tree-icon.section svg {
    fill: #10b981;
}

.tree-icon.exam svg {
    fill: #ef4444;
}

.tree-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.tree-children {
    margin-left: 28px;
    display: none;
}

.tree-node.expanded > .tree-children {
    display: block;
}

.tree-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 12px;
}

.tree-loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* 点击套题高亮 */
.tree-node-header.exam-node:hover {
    background: rgba(239, 68, 68, 0.1);
}

.tree-node-header.exam-node.selected {
    background: rgba(239, 68, 68, 0.15);
    border-left: 3px solid #ef4444;
    margin-left: -3px;
}

/* 右侧刷题面板 */
.quiz-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

/* 占位符状态 */
.quiz-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.placeholder-icon {
    width: 80px;
    height: 80px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.placeholder-icon svg {
    width: 40px;
    height: 40px;
    fill: var(--text-muted);
}

.quiz-placeholder h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.quiz-placeholder p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 刷题内容区 */
.quiz-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 顶部信息栏 */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.quiz-info {
    display: flex;
    flex-direction: column;
}

.quiz-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.quiz-path {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-progress span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* 题目区域 */
.quiz-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* 题目卡片 */
.question-card {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.question-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(99, 102, 241, 0.02));
    border-bottom: 1px solid var(--border);
}

.question-num {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
}

.question-num span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 12px;
}

.question-text {
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.8;
}

.question-images {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.question-images img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.question-images img:hover {
    box-shadow: var(--shadow);
    transform: scale(1.02);
}

/* 选项列表 */
.options-list {
    padding: 20px 24px;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.option-item:last-child {
    margin-bottom: 0;
}

.option-item:hover:not(.disabled) {
    border-color: var(--primary-light);
    background: rgba(99, 102, 241, 0.03);
}

.option-item.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.option-item.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.option-item.wrong {
    border-color: var(--error);
    background: var(--error-light);
}

.option-item.disabled {
    cursor: default;
}

/* 图片选项题样式 - 当选项只有字母没有文字时 */
.option-item.image-option {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 20px;
    min-height: auto;
}

.option-item.image-option .option-label {
    width: 36px;
    height: 36px;
    font-size: 16px;
    font-weight: 700;
}

.option-item.image-option .option-content {
    flex: none;
    padding: 0;
}

.option-item.image-option .option-text:empty {
    display: none;
}

/* 图片选项题横向排列 */
.options-list:has(.option-item.image-option) {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.options-list:has(.option-item.image-option) .option-item {
    flex: 1 1 calc(50% - 6px);
    min-width: 80px;
    max-width: calc(50% - 6px);
    margin-bottom: 0;
    justify-content: center;
}

/* 响应式：小屏幕恢复纵向排列 */
@media (max-width: 600px) {
    .options-list:has(.option-item.image-option) .option-item {
        flex: 1 1 calc(50% - 6px);
        min-width: 70px;
    }
}

.option-label {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all 0.2s;
}

.option-item.selected .option-label {
    background: var(--primary);
    color: white;
}

.option-item.correct .option-label {
    background: var(--success);
    color: white;
}

.option-item.wrong .option-label {
    background: var(--error);
    color: white;
}

.option-content {
    flex: 1;
    padding-top: 5px;
}

.option-text {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.6;
}

.option-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.option-images img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.option-images img:hover {
    box-shadow: var(--shadow-sm);
}

.option-indicator {
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.option-indicator svg {
    width: 20px;
    height: 20px;
}

.option-item.correct .option-indicator,
.option-item.wrong .option-indicator {
    display: flex;
}

.option-item.correct .option-indicator svg {
    fill: var(--success);
}

.option-item.wrong .option-indicator svg {
    fill: var(--error);
}

/* 答案解析区域 */
.answer-section {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.answer-correct {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
}

.answer-correct.success {
    color: var(--success);
}

.answer-correct.error {
    color: var(--error);
}

.answer-correct svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.answer-analysis {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.answer-analysis strong {
    color: var(--text-primary);
}

.answer-knowledge {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 8px;
    border-left: 3px solid #f59e0b;
    margin-top: 10px;
}

.answer-knowledge strong {
    color: var(--text-primary);
}

/* 底部操作栏 */
.quiz-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.score-display {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 确认提交按钮 */
.btn-confirm {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-confirm:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 结果界面 */
.quiz-result {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

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

.result-ring {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 24px;
}

.result-ring svg {
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.result-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.result-percent span {
    font-size: 36px;
}

.result-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.result-desc {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 32px;
}

.stat-item {
    text-align: center;
}

.stat-num {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-item.correct .stat-num {
    color: var(--success);
}

.stat-item.wrong .stat-num {
    color: var(--error);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

/* 图片预览模态框 */
.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 40px;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.image-modal-close svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ==================== 响应式适配 ==================== */

/* 平板适配 */
@media (max-width: 900px) {
    .quiz-layout {
        flex-direction: column;
        padding-right: 0;
    }
    
    .tree-panel {
        width: 100%;
        max-height: 40vh;
        min-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        position: relative;
    }
    
    /* 层级树收起状态 */
    .tree-panel.collapsed {
        max-height: 56px;
        min-height: 56px;
        overflow: hidden;
    }
    
    .tree-panel.collapsed .tree-container {
        display: none;
    }
    
    .quiz-panel {
        flex: 1;
        min-height: 0;
    }
    
    .right-sidebar {
        top: auto;
        bottom: 20px;
        right: 20px;
        transform: none;
        flex-direction: row;
        border-radius: 12px;
        border: 1px solid var(--border);
        padding: 8px 12px;
    }
    
    .sidebar-btn {
        flex-direction: row;
        padding: 8px 12px;
    }
    
    .sidebar-btn span {
        font-size: 12px;
    }
}

/* 手机适配 */
@media (max-width: 600px) {
    /* 导航栏精简 */
    .navbar {
        padding: 0 12px;
        height: 56px;
    }
    
    .navbar-brand span {
        display: none;
    }
    
    .navbar-brand-icon {
        width: 36px;
        height: 36px;
    }
    
    /* 层级树 */
    .tree-header {
        padding: 12px 16px;
    }
    
    .tree-header h2 {
        font-size: 14px;
    }
    
    .tree-container {
        padding: 8px;
    }
    
    .tree-node-header {
        padding: 12px 10px;
    }
    
    .tree-label {
        font-size: 13px;
    }
    
    .tree-children {
        margin-left: 20px;
    }
    
    /* 刷题区域头部 */
    .quiz-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 12px 16px;
    }
    
    .quiz-title {
        font-size: 14px;
    }
    
    .quiz-path {
        font-size: 11px;
    }
    
    .quiz-body {
        padding: 12px;
    }
    
    /* 题目卡片 */
    .question-card {
        border-radius: 12px;
    }
    
    .question-header {
        padding: 16px;
    }
    
    .question-num {
        font-size: 12px;
        margin-bottom: 8px;
    }
    
    .question-num span {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .question-text {
        font-size: 15px;
        line-height: 1.7;
    }
    
    .question-images img {
        max-width: 100%;
        max-height: 150px;
    }
    
    /* 选项卡片 - 增大触控区域 */
    .options-list {
        padding: 12px 16px 16px;
    }
    
    .option-item {
        padding: 14px 12px;
        margin-bottom: 10px;
        min-height: 52px;
    }
    
    .option-label {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
    
    .option-text {
        font-size: 14px;
    }
    
    .option-images img {
        max-width: 100%;
        max-height: 120px;
    }
    
    /* 答案解析 */
    .answer-section {
        padding: 16px;
    }
    
    .answer-correct {
        font-size: 13px;
    }
    
    .answer-analysis {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    /* 底部操作栏 - 全宽按钮 */
    .quiz-footer {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        z-index: 10;
    }
    
    .quiz-footer .btn {
        width: 100%;
        justify-content: center;
        padding: 14px;
    }
    
    .footer-right {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .score-display {
        text-align: center;
        font-size: 13px;
    }
    
    /* 右侧边栏移到顶部 */
    .right-sidebar {
        bottom: auto;
        top: 70px;
        right: 10px;
        padding: 6px;
    }
    
    .sidebar-btn {
        padding: 8px;
    }
    
    .sidebar-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .sidebar-btn span {
        display: none;
    }
    
    /* 占位符状态 */
    .quiz-placeholder {
        padding: 30px 20px;
    }
    
    .placeholder-icon {
        width: 60px;
        height: 60px;
    }
    
    .quiz-placeholder h3 {
        font-size: 16px;
    }
    
    .quiz-placeholder p {
        font-size: 13px;
    }
    
    /* 结果页面 */
    .quiz-result {
        padding: 20px;
    }
    
    .result-ring {
        width: 120px;
        height: 120px;
        margin-bottom: 20px;
    }
    
    .result-percent {
        font-size: 24px;
    }
    
    .result-percent span {
        font-size: 30px;
    }
    
    .result-title {
        font-size: 20px;
    }
    
    .result-desc {
        font-size: 14px;
        margin-bottom: 24px;
    }
    
    .result-stats {
        gap: 24px;
        margin-bottom: 24px;
    }
    
    .stat-num {
        font-size: 24px;
    }
    
    .result-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .result-actions .btn {
        width: 100%;
    }
}

/* 超小屏幕 (iPhone SE 等) */
@media (max-width: 380px) {
    .question-text {
        font-size: 14px;
    }
    
    .option-text {
        font-size: 13px;
    }
    
    .tree-children {
        margin-left: 16px;
    }
    
    .quiz-footer .btn {
        padding: 12px;
        font-size: 13px;
    }
}
