/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222636;
    --bg-input: #262a38;
    --border: #2e3348;
    --text: #e4e6ef;
    --text-dim: #8892a8;
    --text-bright: #ffffff;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --purple: #a855f7;
    --orange: #f97316;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --glow-accent: 0 0 20px rgba(99, 102, 241, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
    padding: 40px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

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

.app-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 8px;
}

.app-subtitle {
    color: var(--text-dim);
    font-size: 15px;
    margin-bottom: 20px;
}

.app-nav {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover { color: var(--text); background: var(--bg-card); }
.nav-link.active { color: var(--accent); background: rgba(99, 102, 241, 0.1); }

/* ── Upload Section ──────────────────────────────────────────────────────── */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.upload-card, .features-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.upload-card {
    text-align: center;
}

.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-card h2 { font-size: 22px; margin-bottom: 8px; color: var(--text-bright); }
.upload-hint { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon-big { font-size: 56px; margin-bottom: 12px; }
.drop-text { font-size: 16px; color: var(--text-dim); margin-bottom: 8px; }
.or-text { color: var(--text-dim); font-size: 13px; margin-bottom: 12px; }
.file-info { color: var(--accent); font-size: 14px; margin-top: 12px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 28px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); }

/* ── Progress ────────────────────────────────────────────────────────────── */
.upload-progress { margin-top: 16px; }
.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-text { font-size: 14px; color: var(--text-dim); }

/* ── Features Card ───────────────────────────────────────────────────────── */
.features-card h3 { font-size: 18px; margin-bottom: 16px; color: var(--text-bright); }
.features-list { list-style: none; }
.features-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}
.features-list li:last-child { border-bottom: none; }
.features-list li strong { color: var(--text-bright); }

/* ── Processing Page ──────────────────────────────────────────────────────── */
.processing-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
}

.spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 32px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing-steps { text-align: left; max-width: 400px; margin: 0 auto; }

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: all 0.3s;
}

.step-icon { font-size: 20px; width: 32px; text-align: center; }
.step-text { flex: 1; font-size: 15px; font-weight: 500; }
.step-status { font-size: 13px; font-weight: 600; }
.step-status.pending { color: var(--text-dim); }
.step-status.running { color: var(--yellow); }
.step-status.done { color: var(--green); }
.step-status.error { color: var(--red); }

.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.exam-name { margin-top: 24px; font-size: 14px; color: var(--text-dim); }
.processing-tip { margin-top: 12px; font-size: 13px; color: var(--text-dim); opacity: 0.7; }

.error-msg {
    margin-top: 24px;
    padding: 16px;
    background: var(--red-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
}
.error-msg p { margin-bottom: 16px; color: var(--red); }

/* ══════════════════════════════════════════════════════════════════════════
   Dashboard — Result Page
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Dashboard Row (2-col grid) ───────────────────────────────────────────── */
.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ── Score Card (left side of row 1) ──────────────────────────────────────── */
.dashboard-score {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    display: flex;
    align-items: center;
    gap: 28px;
    box-shadow: var(--shadow);
}

.score-ring-wrap {
    position: relative;
    flex-shrink: 0;
}

.score-ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.score-ring-pct {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-bright);
    line-height: 1;
}

.score-ring-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

.score-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    flex: 1;
}

.score-detail-item {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.sd-icon { font-size: 18px; display: block; margin-bottom: 4px; }
.sd-val { font-size: 20px; font-weight: 700; display: block; color: var(--text-bright); }
.sd-val.green { color: var(--green); }
.sd-val.red { color: var(--red); }
.sd-val.gold { color: var(--yellow); }
.sd-label { font-size: 12px; color: var(--text-dim); }

/* ── Chart Card (generic) ─────────────────────────────────────────────────── */
.dashboard-chart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.chart-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 16px;
}

.chart-wrap {
    max-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrap canvas {
    max-height: 260px;
}

/* ── Full-Width Chart ─────────────────────────────────────────────────────── */
.chart-full-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.chart-wrap-wide {
    height: 220px;
    position: relative;
}

.chart-placeholder {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-dim);
    font-size: 14px;
}

/* ── Weak Points ──────────────────────────────────────────────────────────── */
.weak-card {
    background: linear-gradient(135deg, rgba(234,179,8,0.08), rgba(249,115,22,0.08));
    border: 1px solid rgba(234, 179, 8, 0.25);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.weak-card h3 { font-size: 16px; margin-bottom: 8px; color: var(--orange); }
.weak-card p { font-size: 15px; color: var(--text); line-height: 1.7; }

/* ── Summary Section (kept for backwards compat) ──────────────────────────── */
.summary-section { margin-bottom: 24px; }

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 16px;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.summary-header h2 { font-size: 20px; color: var(--text-bright); }
.exam-filename { font-size: 13px; color: var(--text-dim); max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.summary-item {
    text-align: center;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.summary-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}
.summary-label { font-size: 13px; color: var(--text-dim); }
.summary-item.total .summary-value { color: var(--accent); }
.summary-item.correct .summary-value { color: var(--green); }
.summary-item.wrong .summary-value { color: var(--red); }
.summary-item.score .summary-value { color: var(--yellow); }

/* ── Questions Section ───────────────────────────────────────────────────── */
.questions-section { margin-bottom: 24px; }
.questions-section h2 { font-size: 20px; margin-bottom: 16px; color: var(--text-bright); }

.questions-list { display: flex; flex-direction: column; gap: 12px; }

.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: all 0.25s;
    box-shadow: var(--shadow);
}
.question-card:hover { background: var(--bg-card-hover); transform: translateX(2px); }
.question-card.correct { border-left-color: var(--green); }
.question-card.wrong { border-left-color: var(--red); }

.q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.q-number { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.q-badge { font-size: 13px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.badge-correct { background: var(--green-bg); color: var(--green); }
.badge-wrong { background: var(--red-bg); color: var(--red); }

.q-content { font-size: 15px; margin-bottom: 12px; line-height: 1.7; }

.q-answers {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.q-answer { font-size: 14px; }
.answer-label { color: var(--text-dim); margin-right: 6px; }
.answer-value { font-weight: 600; }
.student-wrong { color: var(--red); }
.correct-ans { color: var(--green); }

.q-explanation {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.6;
}
.explanation-label { color: var(--accent); font-weight: 600; }

.q-knowledge {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(255, 167, 38, 0.1);
    border-left: 3px solid #ffa726;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
}
.knowledge-label { color: #ffa726; font-weight: 600; }
.knowledge-value { color: var(--text-dim); }

/* ── Vocabulary Section ──────────────────────────────────────────────────── */
.vocab-section { margin-bottom: 24px; }
.vocab-section h2 { font-size: 20px; margin-bottom: 16px; color: var(--text-bright); }

.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.vocab-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.vocab-card:hover { background: var(--bg-card-hover); }

.vocab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.vocab-word {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
}

.vocab-meaning { font-size: 14px; color: var(--text); margin-bottom: 8px; }
.vocab-example { font-size: 13px; color: var(--text-dim); font-style: italic; margin-bottom: 8px; }

.vocab-category {
    display: inline-block;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Category color coding */
.cat-词汇, .cat-vocabulary { background: rgba(59,130,246,0.15); color: #3b82f6; }
.cat-语法, .cat-grammar { background: rgba(168,85,247,0.15); color: #a855f7; }
.cat-固定搭配, .cat-collocation { background: rgba(34,197,94,0.15); color: #22c55e; }
.cat-时态, .cat-tense { background: rgba(249,115,22,0.15); color: #f97316; }
.cat-其他, .cat-unknown { background: rgba(107,114,128,0.15); color: #6b7280; }

/* ── Recommend Section ────────────────────────────────────────────────────── */
.recommend-section { margin-bottom: 24px; }
.recommend-section h2 { font-size: 20px; margin-bottom: 16px; color: var(--text-bright); }

.recommend-card {
    background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(168,85,247,0.08));
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: var(--radius);
    padding: 24px 28px;
    box-shadow: var(--shadow);
}
.recommend-card p { font-size: 15px; line-height: 1.8; color: var(--text); }

/* ── Actions ──────────────────────────────────────────────────────────────── */
.actions-section {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
}

/* ── History ──────────────────────────────────────────────────────────────── */
.history-section h2 { font-size: 20px; margin-bottom: 20px; color: var(--text-bright); }

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.history-card:hover { background: var(--bg-card-hover); transform: translateX(4px); }

.history-info { flex: 1; min-width: 0; }
.history-filename { font-size: 15px; font-weight: 600; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-time { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.history-stats { text-align: right; flex-shrink: 0; }
.stat-badge { font-size: 14px; font-weight: 600; }
.stat-correct { color: var(--green); }
.stat-sep { color: var(--text-dim); }
.stat-total { color: var(--text); }
.stat-percent { color: var(--yellow); margin-left: 4px; }
.stat-tags { font-size: 12px; color: var(--text-dim); margin-top: 4px; max-width: 200px; }
.badge-pending { color: var(--text-dim); }
.badge-processing { color: var(--yellow); }
.badge-error { color: var(--red); }

.history-arrow {
    font-size: 18px;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; color: var(--text-bright); }
.empty-state p { color: var(--text-dim); margin-bottom: 24px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    .dashboard-score {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .chart-wrap-wide {
        height: 180px;
    }
}

@media (max-width: 640px) {
    .app-container { padding: 0 12px 40px; }
    .app-title { font-size: 22px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .upload-area { padding: 32px 16px; }
    .vocab-grid { grid-template-columns: 1fr; }
    .score-details { grid-template-columns: 1fr 1fr; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Multi-File Upload
   ══════════════════════════════════════════════════════════════════════════ */

.file-list {
    margin-top: 16px;
    text-align: left;
}

.file-list-items {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: 12px;
    max-height: 240px;
    overflow-y: auto;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.file-list-item:last-child { border-bottom: none; }

.file-page {
    font-size: 16px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.file-name {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--text-dim);
    font-size: 12px;
    flex-shrink: 0;
}

.upload-btn {
    width: 100%;
}

/* ══════════════════════════════════════════════════════════════════════════
   Reading Passage Section
   ══════════════════════════════════════════════════════════════════════════ */

.reading-section { margin-bottom: 24px; }
.reading-section h2 { font-size: 20px; margin-bottom: 16px; color: var(--text-bright); }

.reading-passages { display: flex; flex-direction: column; gap: 16px; }

.reading-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    border-left: 4px solid var(--accent);
    box-shadow: var(--shadow);
}

.reading-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.reading-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-bright);
}

.reading-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reading-tag {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.tag-theme {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.tag-genre {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.reading-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-dim);
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
}

/* ══════════════════════════════════════════════════════════════════════════
   Question Type Badge
   ══════════════════════════════════════════════════════════════════════════ */

.q-badges {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.q-type-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.q-passage-ref {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
}

.passage-ref-icon {
    font-size: 14px;
}

/* ══════════════════════════════════════════════════════════════════════════
   Reading Vocabulary Filters
   ══════════════════════════════════════════════════════════════════════════ */

.vocab-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.vocab-filter {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-input);
    color: var(--text-dim);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.vocab-filter:hover {
    border-color: var(--accent);
    color: var(--text);
}

.vocab-filter.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.cat-highfreq {
    background: rgba(234, 179, 8, 0.15) !important;
    color: #eab308 !important;
}

.cat-uncommon {
    background: rgba(168, 85, 247, 0.15) !important;
    color: #c084fc !important;
}
