/* ============================================
 * quiz.html - 自适应测验系统样式
 * ============================================ */

:root {
    --quiz-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --quiz-success: #10b981;
    --quiz-error: #ef4444;
    --quiz-warning: #f59e0b;
    --quiz-bg: #0a0c1a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--quiz-bg);
    color: #f0f3ff;
    min-height: 100vh;
}

/* ========== 测验选择页 ========== */
.quiz-select-container {
    max-width: 800px;
    margin: 30px auto 40px;
    padding: 20px;
}

.quiz-select-header {
    text-align: center;
    margin-bottom: 36px;
}
.quiz-select-header h1 {
    font-size: 28px;
    background: var(--quiz-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}
.quiz-select-header p { color: rgba(240,243,255,0.5); font-size: 15px; }

.quiz-mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
@media (max-width: 640px) { .quiz-mode-grid { grid-template-columns: 1fr; } }

.quiz-mode-card {
    background: rgba(15, 18, 35, 0.8);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.quiz-mode-card:hover {
    transform: translateY(-4px);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 12px 40px rgba(102,126,234,0.15);
}
.quiz-mode-card.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
    box-shadow: 0 0 30px rgba(102,126,234,0.12) inset;
}
.quiz-mode-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 24px;
    color: white;
}
.quiz-mode-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.quiz-mode-desc { font-size: 13px; color: rgba(240,243,255,0.45); line-height: 1.5; }
.quiz-mode-meta { font-size: 12px; color: #667eea; margin-top: 10px; font-weight: 500; }

/* ========== 测验进行中页面 ========== */
.quiz-active-container {
    max-width: 900px;
    margin: 60px auto 40px;
    padding: 0 20px;
}

/* 进度条 */
.quiz-progress-bar {
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}
.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.quiz-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: rgba(240,243,255,0.5);
    margin-bottom: 24px;
}
.quiz-progress-info .score-display {
    color: #10b981;
    font-weight: 600;
    font-size: 15px;
}

/* 题目卡片 */
.quiz-question-card {
    background: rgba(15, 18, 35, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 32px;
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.quiz-q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.quiz-q-number { font-size: 13px; color: #667eea; font-weight: 600; }
.quiz-q-difficulty {
    font-size: 11px; padding: 3px 10px; border-radius: 12px;
    background: rgba(245,158,11,0.15); color: #fbbf24;
}
.quiz-q-difficulty.easy { background: rgba(16,185,129,0.15); color: #34d399; }
.quiz-q-difficulty.hard { background: rgba(239,68,68,0.15); color: #f87171; }

.quiz-q-content {
    font-size: 18px;
    line-height: 1.7;
    color: #fff;
    margin-bottom: 28px;
    font-weight: 500;
}

/* 选择题选项 */
.quiz-options { display: flex; flex-direction: column; gap: 12px; }
.quiz-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(255,255,255,0.02);
    user-select: none;
}
.quiz-option:hover {
    border-color: rgba(102, 126, 234, 0.4);
    background: rgba(102, 126, 234, 0.05);
    transform: translateX(4px);
}
.quiz-option.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}
.quiz-option.correct {
    border-color: #10b981;
    background: rgba(16,185,129,0.1);
}
.quiz-option.wrong {
    border-color: #ef4444;
    background: rgba(239,68,68,0.1);
}
.quiz-option.disabled { pointer-events: none; opacity: 0.7; }

.quiz-option-letter {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; flex-shrink: 0;
    transition: all 0.25s;
}
.quiz-option.selected .quiz-option-letter {
    background: linear-gradient(135deg, #667eea, #764ba2); color: white;
}
.quiz-option.correct .quiz-option-letter { background: #10b981; color: white; }
.quiz-option.wrong .quiz-option-letter { background: #ef4444; color: white; }

.quiz-option-text { font-size: 15px; color: #e2e8f0; line-height: 1.5; }

/* 填空题/简答题输入 */
.quiz-input-answer {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.25s;
    font-family: inherit;
}
.quiz-input-answer:focus { border-color: #667eea; }
.quiz-input-answer::placeholder { color: rgba(240,243,255,0.3); }

/* 操作按钮区 */
.quiz-actions {
    display: flex; justify-content: space-between; gap: 12px;
    margin-top: 28px;
}
.quiz-btn {
    padding: 12px 28px; border: none; border-radius: 10px; font-size: 15px;
    font-weight: 600; cursor: pointer; transition: all 0.25s;
    display: flex; align-items: center; gap: 8px;
}
.quiz-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2); color: white;
    box-shadow: 0 4px 15px rgba(102,126,234,0.3);
}
.quiz-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102,126,234,0.4); }
[data-theme="day"] .quiz-btn-primary {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    box-shadow: 0 4px 15px rgba(59,130,246,0.3);
}
[data-theme="day"] .quiz-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(59,130,246,0.4);
}
.quiz-btn-primary:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none;
}
.quiz-btn-secondary {
    background: rgba(255,255,255,0.08); color: #cbd5e1; border: 1px solid rgba(255,255,255,0.12);
}
.quiz-btn-secondary:hover { background: rgba(255,255,255,0.14); }

/* 反馈区域 */
.quiz-feedback {
    margin-top: 20px; padding: 18px 22px; border-radius: 12px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.quiz-feedback.correct {
    background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.25);
}
.quiz-feedback.wrong {
    background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25);
}
.quiz-feedback-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.quiz-feedback.correct .quiz-feedback-title { color: #34d399; }
.quiz-feedback.wrong .quiz-feedback-title { color: #f87171; }
.quiz-feedback-body { font-size: 14px; color: rgba(240,243,255,0.7); line-height: 1.6; }
.quiz-hint { font-size: 13px; color: #fbbf24; margin-top: 8px; font-style: italic; }

/* 能力指示器 */
.ability-indicator {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: rgba(240,243,255,0.5);
}
.ability-bar {
    width: 60px; height: 4px; background: rgba(255,255,255,0.1);
    border-radius: 2px; overflow: hidden;
}
.ability-fill { height: 100%; background: #667eea; border-radius: 2px; transition: width 0.4s; }

/* ========== 结果页 ========== */
.quiz-result-container {
    max-width: 700px; margin: 60px auto 40px; text-align: center;
}
.quiz-result-score-big {
    font-size: 72px; font-weight: 800;
    background: var(--quiz-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    line-height: 1;
}
.quiz-result-label { font-size: 16px; color: rgba(240,243,255,0.5); margin-top: 8px; }
.quiz-result-mastery {
    font-size: 22px; font-weight: 600; margin: 20px 0 28px;
}
.quiz-result-stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    margin: 28px 0;
}
.quiz-stat-box {
    background: rgba(15,18,35,0.8); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; padding: 16px 12px;
}
.quiz-stat-value { font-size: 24px; font-weight: 700; color: #fff; }
.quiz-stat-label { font-size: 11px; color: rgba(240,243,255,0.4); margin-top: 4px; }

/* 错题回顾列表 */
.quiz-review-list { text-align: left; margin-top: 28px; }
.quiz-review-item {
    background: rgba(15,18,35,0.7); border-left: 3px solid #ef4444;
    border-radius: 0 10px 10px 0; padding: 14px 18px; margin-bottom: 10px;
}
.quiz-review-question { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.quiz-review-answer { font-size: 13px; color: rgba(240,243,255,0.55); }
.quiz-review-correct { color: #34d399; }

.quiz-result-actions {
    display: flex; gap: 12px; justify-content: center; margin-top: 32px;
}

/* 计时器 */
.quiz-timer {
    display: flex; align-items: center; gap: 6px;
    font-size: 15px; font-weight: 600; color: #fbbf24;
    font-variant-numeric: tabular-nums;
}
.quiz-timer.warning { color: #ef4444; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* 加载状态 */
.quiz-loading {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 400px; color: rgba(240,243,255,0.4);
}
.quiz-loading i { font-size: 36px; color: #667eea; animation: spin 1s linear infinite; margin-bottom: 12px; }

@keyframes shake {
    0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)}
}

/* 日间模式适配 */
[data-theme="day"] body { background: #f8fafc; color: #1e293b; }
[data-theme="day"] .quiz-select-header h1 { color: #1E293B; }
[data-theme="day"] .quiz-select-header p { color: #64748B; }
[data-theme="day"] .quiz-mode-card,
[data-theme="day"] .quiz-question-card,
[data-theme="day"] .quiz-stat-box,
[data-theme="day"] .quiz-review-item,
[data-theme="day"] .quiz-custom-options {
    background: rgba(255, 255, 255, 0.82); border-color: #e2e8f0;
    backdrop-filter: blur(40px) saturate(1.4);
    -webkit-backdrop-filter: blur(40px) saturate(1.4);
}
[data-theme="day"] .quiz-mode-title { color: #1E293B; }
[data-theme="day"] .quiz-mode-desc { color: #64748B; }
[data-theme="day"] .quiz-stat-value { color: #1E293B; }
[data-theme="day"] .quiz-stat-label { color: #94A3B8; }
[data-theme="day"] .quiz-review-question { color: #1E293B; }
[data-theme="day"] .quiz-review-answer { color: #64748B; }
[data-theme="day"] .quiz-option {
    border-color: #e2e8f0; color: #334155;
}
[data-theme="day"] .quiz-option-text { color: #475569; }
[data-theme="day"] .quiz-option-letter { background: #F1F5F9; color: #475569; }
[data-theme="day"] .quiz-q-content { color: #1e293b; }
[data-theme="day"] .quiz-q-number { color: #4F6EF6; }
[data-theme="day"] .quiz-progress-info { color: #64748B; }
[data-theme="day"] .ability-indicator { color: #64748B; }
[data-theme="day"] .quiz-option-text { color: #475569; }

/* ========== 自定义选项面板 ========== */
.quiz-custom-options {
    background: rgba(15, 18, 35, 0.8);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.08);
}
.quiz-custom-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.quiz-custom-field {
    flex: 1;
}
.quiz-custom-field label {
    font-size: 13px;
    color: rgba(240,243,255,0.7);
    display: block;
    margin-bottom: 6px;
}
.quiz-custom-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: border-color 0.25s;
}
.quiz-custom-field input:focus {
    border-color: #667eea;
}
/* 日间模式 - 自定义选项 */
[data-theme="day"] .quiz-custom-field label {
    color: #475569;
}
[data-theme="day"] .quiz-custom-field input {
    border-color: #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
}
[data-theme="day"] .quiz-custom-field input:focus {
    border-color: #667eea;
}
