/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* 页面样式 */
.page {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 20px;
    background-color: #fff;
    overflow-y: scroll;
}

.page.active {
    display: flex;
}

/* 科目选择页面样式 */
.subject-list {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.subject-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.subject-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.subject-item h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.subject-item p {
    font-size: 1rem;
    opacity: 0.9;
}

/* 首页样式 */
#chapterSelection h1 {
    text-align: center;
    /* margin-bottom: 30px; */
    width: 50vw;
    color: #2c3e50;
    font-size: 1.4rem !important;
}
#wrongQuestionsTitle{
    text-align: center;
    /* margin-bottom: 30px; */
    width: 50vw;
    color: #2c3e50;
    font-size: 1.4rem !important;
}

.chapter-list {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.chapter-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    margin-bottom: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chapter-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.chapter-item h3 {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.chapter-item p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.wrong-questions-btn {
    background-color: #e74c3c;
    color: white;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.wrong-questions-btn:hover {
    background-color: #c0392b;
}

/* 头部样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.back-btn {
    background-color: #95a5a6;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.back-btn:hover {
    background-color: #7f8c8d;
}

.progress {
    font-weight: bold;
    color: #2c3e50;
}

/* 答题页面样式 */
.quiz-container {
    flex-grow: 1;
    display: flex;
    gap: 20px;
}

.question-section {
    flex: 3;
    display: flex;
    flex-direction: column;
}

.question-container h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #2c3e50;
    line-height: 1.5;
}

.options {
    flex-grow: 1;
    margin-bottom: 20px;
}

.option {
    background-color: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.option:hover {
    background-color: #d5dbdb;
    transform: translateX(5px);
}

.option.selected {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
}

.option.correct {
    background-color: #2ecc71;
    color: white;
    border-color: #27ae60;
}

.option.incorrect {
    background-color: #e74c3c;
    color: white;
    border-color: #c0392b;
}

.countdown {
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: #3498db;
    margin-top: 10px;
    padding: 10px;
    background-color: #e3f2fd;
    border-radius: 5px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.navigation {
    display: flex;
    justify-content: space-between;
}

.nav-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.nav-btn:hover:not(:disabled) {
    background-color: #2980b9;
}

.nav-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

/* 题目预览面板样式 */
.preview-panel {
    flex: 1;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    /* 防止预览面板影响整体布局 */
    contain: layout style;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.preview-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.preview-controls {
    display: flex;
    gap: 5px;
}

.toggle-preview-btn, .expand-preview-btn {
    background-color: #95a5a6;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.toggle-preview-btn:hover, .expand-preview-btn:hover {
    background-color: #7f8c8d;
}

.preview-content {
    flex-grow: 1;
    overflow-y: auto;
    /* 固定最大高度，防止影响布局 */
    max-height: calc(100vh - 300px);
    /* 添加平滑滚动 */
    scroll-behavior: smooth;
}

.preview-question {
    padding: 8px 12px;
    margin-bottom: 8px;
    background-color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
}

.preview-question::before {
    content: attr(data-id) ". ";
    font-weight: bold;
    color: #3498db;
}

.preview-question:hover {
    background-color: #e3f2fd;
    transform: translateX(3px);
}

.preview-question.current {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
}

.preview-question.current::before {
    color: white;
}

.preview-question.answered {
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.preview-question.wrong {
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* 展开状态的预览面板 */
.preview-panel.expanded {
    position: fixed;
    top: 10%;
    left: 5%;
    width: 90%;
    height: 80%;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.preview-panel.expanded .preview-content {
    max-height: calc(100% - 60px);
}

/* 预览面板遮罩层 */
.preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.preview-overlay.active {
    display: block;
}

/* 错题本页面样式 */
.wrong-questions-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: #f8f9fa;
}

.wrong-question-item {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.wrong-question-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.wrong-question-item h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #2c3e50;
    line-height: 1.4;
}

.wrong-question-item .chapter-info {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 10px;
    padding: 5px 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    display: inline-block;
}

.wrong-question-item .options {
    margin: 10px 0;
    flex-grow: 1;
}

.wrong-question-item .option {
    font-size: 0.9rem;
    padding: 10px;
    margin-bottom: 8px;
}

.remove-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    align-self: flex-end;
    margin-top: 10px;
    transition: all 0.3s;
    font-weight: 500;
}

.remove-btn:hover {
    background-color: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.remove-btn:active {
    transform: translateY(0);
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.page.active {
    animation: fadeIn 0.5s ease;
}

.option {
    animation: fadeIn 0.3s ease;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    #chapterSelection h1 {
        font-size: 1.5rem;
    }
    
    .chapter-item {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    .question-container h2 {
        font-size: 1.1rem;
    }
    
    .option {
        padding: 12px;
        font-size: 0.95rem;
    }
    
    .nav-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    /* 移动端答题页面布局 */
    .quiz-container {
        flex-direction: column;
    }
    
    .question-section {
        flex: 1;
    }
    
    .preview-panel {
        flex: 1;
        margin-top: 20px;
        /* 使用视口高度的百分比，确保不会过大 */
        max-height: 40vh;
    }
    
    .preview-content {
        /* 根据面板高度调整内容区域 */
        max-height: calc(40vh - 80px);
    }
    
    /* 移动端预览题目样式优化 */
    .preview-question {
        font-size: 0.9rem;
        padding: 10px 12px;
        margin-bottom: 6px;
        line-height: 1.3;
    }
}

@media (max-width: 480px) {
    .preview-panel {
        /* 在小屏幕上进一步减小高度 */
        max-height: 75vh;
    }
    
    .preview-content {
        max-height: calc(35vh - 80px);
    }
    
    .preview-question {
        font-size: 0.85rem;
        padding: 8px 10px;
        margin-bottom: 5px;
        -webkit-line-clamp: 2; /* 移动端显示较少行数 */
    }
    
    .preview-controls {
        gap: 3px;
    }
    
    .toggle-preview-btn, .expand-preview-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

@media (max-width: 360px) {
    .preview-panel {
        max-height: 30vh;
        padding: 10px;
    }
    
    .preview-content {
        max-height: calc(30vh - 80px);
    }
    
    .preview-question {
        font-size: 0.8rem;
        padding: 6px 8px;
        margin-bottom: 4px;
    }
    
    .preview-header h3 {
        font-size: 1rem;
    }
}
