/* ============================================================
 * 首页样式（index/index.html）
 * 依赖：theme.css → base.css → components.css → layout.css → 本文件
 * JS 契约类名（index/main.js 渲染模板，勿改）：
 *   .subject-tab(.active) / .study-tab(.active) / .chapter-item(.expanded)
 *   .section-list（JS 直接操作 style.display）/ .countdown-* / .prompt-* / .loading-*
 * ============================================================ */

/* ============================================================
 * Banner（考试类型 + 科目胶囊）
 * ============================================================ */
.banner {
    background: var(--gradient-light);
    border: 1px solid var(--primary-tint-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
    margin-bottom: var(--sp-5);
    position: relative;
    overflow: hidden;
}

.banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="rgba(216,38,22,0.1)"/></svg>');
    background-size: contain;
    opacity: 0.3;
}

.exam-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    margin-bottom: var(--sp-2);
}

.exam-title h1 {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
    color: var(--red-500);
    letter-spacing: 0.5px;
}

.banner-subtitle {
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-bottom: var(--sp-5);
}

.switch-exam {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    font-size: var(--fs-md);
    cursor: pointer;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-pill);
    transition: color var(--t-base) var(--ease),
                background-color var(--t-base) var(--ease);
}

.switch-exam:hover {
    color: var(--primary-tint-text);
    background: var(--primary-tint-bg-strong);
}

/* 科目胶囊（JS 渲染 .subject-tab + .active） */
.subject-tabs {
    display: flex;
    justify-content: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    position: relative;
}

.subject-tab {
    padding: 7px var(--sp-4);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: var(--fs-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    transition: color var(--t-base) var(--ease),
                background-color var(--t-base) var(--ease),
                border-color var(--t-base) var(--ease);
}

.subject-tab:not(.active):hover {
    color: var(--primary-tint-text);
    border-color: var(--primary-tint-border);
    background: var(--primary-tint-bg);
}

.subject-tab.active {
    background: var(--primary-tint-bg-strong);
    color: var(--primary-tint-text);
    border-color: var(--primary-tint-border);
    font-weight: var(--fw-medium);
}

/* ============================================================
 * 学习类型 Tab（章节练习 / 历年真题 / 模拟试题 / 我的题库）
 * ============================================================ */
.study-tabs {
    display: flex;
    gap: var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 0 var(--sp-5);
    margin-bottom: var(--sp-5);
}

.study-tab {
    position: relative;
    flex: 1;
    padding: var(--sp-4) var(--sp-2);
    text-align: center;
    cursor: pointer;
    font-size: var(--fs-md);
    color: var(--text-secondary);
    transition: color var(--t-base) var(--ease);
}

.study-tab:not(.active):hover {
    color: var(--primary);
}

.study-tab.active {
    color: var(--primary);
    font-weight: var(--fw-semibold);
}

.study-tab.active::after {
    content: '';
    position: absolute;
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: 0;
    height: 3px;
    border-radius: var(--radius-pill) var(--radius-pill) 0 0;
    background: var(--primary);
}

/* ============================================================
 * 章节列表
 * ============================================================ */
.chapter-list {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-xs);
}

.chapter-item {
    margin-bottom: var(--sp-3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

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

.chapter-item:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-xs);
}

.chapter-item.expanded {
    border-color: var(--primary-tint-border);
}

.chapter-header {
    display: flex;
    align-items: center;
    padding: var(--sp-3) var(--sp-4);
    cursor: pointer;
    transition: background-color var(--t-base) var(--ease);
}

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

.chapter-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-tint-bg-strong);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: var(--fw-semibold);
    margin-right: var(--sp-3);
    flex-shrink: 0;
}

.chapter-title {
    flex: 1;
    font-size: var(--fs-lg);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
}

.expand-icon {
    color: var(--text-muted);
    transition: color var(--t-base) var(--ease);
}

.expand-icon.fa-minus {
    color: var(--primary);
}

/* 小节列表（JS 同时操作 style.display 与 .expanded 类，保持双轨） */
.section-list {
    border-top: 1px solid var(--border-light);
    display: none;
}

.chapter-item.expanded .section-list {
    display: block;
}

.section-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-light);
    transition: background-color var(--t-fast) var(--ease);
}

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

.section-item:hover {
    background: var(--bg-hover);
}

.section-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.section-title {
    font-size: var(--fs-md);
    color: var(--text-primary);
}

.question-count {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.continue-btn {
    padding: 6px var(--sp-3);
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.continue-btn:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-primary);
}

/* ============================================================
 * 右栏
 * ============================================================ */
.right-panel {
    flex: 1;
    max-width: var(--right-panel-w);
}

/* 考试倒计时卡片 */
.countdown-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
    box-shadow: var(--shadow-xs);
    text-align: center;
}

.countdown-card h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    margin-bottom: var(--sp-4);
    color: var(--text-primary);
}

.countdown-card h3 i {
    color: var(--primary);
    margin-right: 4px;
}

.countdown-days {
    font-family: var(--font-num);
    font-size: 48px;
    font-weight: var(--fw-semibold);
    color: var(--primary);
    line-height: 1;
    margin-bottom: var(--sp-2);
}

.countdown-label {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: var(--sp-3);
}

.countdown-exam-name {
    font-size: var(--fs-md);
    color: var(--text-primary);
    font-weight: var(--fw-medium);
    margin-bottom: 4px;
}

.countdown-exam-date {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.countdown-empty {
    color: var(--text-muted);
    font-size: var(--fs-md);
    padding: var(--sp-3) 0;
}

.countdown-urgent {
    animation: home-pulse 1.5s ease-in-out infinite;
}

@keyframes home-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================================
 * 考试类型选择弹窗（#examTypeModal，自绘 modal）
 * ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(16, 24, 40, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--sp-4);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: var(--sp-6) var(--sp-6) var(--sp-4);
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.modal-header h3 {
    margin: 0 0 var(--sp-2) 0;
    font-size: var(--fs-xl);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.modal-subtitle {
    margin: 0;
    font-size: var(--fs-md);
    color: var(--text-secondary);
}

.modal-close {
    position: absolute;
    top: var(--sp-5);
    right: var(--sp-5);
    background: none;
    border: none;
    font-size: var(--fs-2xl);
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--t-base) var(--ease),
                color var(--t-base) var(--ease);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--text-secondary);
}

.modal-body {
    padding: var(--sp-5) var(--sp-6);
    flex: 1;
    overflow-y: auto;
}

.exam-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--sp-3);
}

.exam-type-item {
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: var(--sp-4) var(--sp-3);
    text-align: center;
    cursor: pointer;
    position: relative;
    background: var(--bg-card);
    transition: border-color var(--t-base) var(--ease),
                background-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.exam-type-item:hover {
    border-color: var(--primary-tint-border);
    background: var(--primary-tint-bg);
    box-shadow: var(--shadow-sm);
}

.exam-type-item.selected {
    border-color: var(--primary);
    background: var(--primary-tint-bg);
}

.exam-type-item.selected::after {
    content: '✓';
    position: absolute;
    bottom: var(--sp-2);
    right: var(--sp-2);
    width: 20px;
    height: 20px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
}

.exam-type-name {
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    margin-bottom: 4px;
}

.modal-footer {
    padding: var(--sp-4) var(--sp-6) var(--sp-6);
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.confirm-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--sp-3) var(--sp-8);
    font-size: var(--fs-lg);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: background-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.confirm-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-primary);
}

.confirm-btn:disabled {
    background: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
}

/* ============================================================
 * 加载状态（.loading-* 为 JS 模板类名）
 * ============================================================ */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}

.loading-spinner {
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: home-spin 1s linear infinite;
    margin-bottom: var(--sp-3);
}

.loading-text {
    font-size: var(--fs-lg);
    color: var(--text-secondary);
}

@keyframes home-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================
 * 练习恢复提示（右下角浮层，.prompt-* 为 JS 模板类名）
 * ============================================================ */
.practice-resume-prompt {
    position: fixed;
    top: calc(var(--header-h) + var(--sp-5));
    right: var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-5);
    z-index: var(--z-toast);
    max-width: 320px;
    animation: home-slide-in 0.3s ease-out;
    transition: opacity var(--t-base) ease;
}

.prompt-content {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
}

.prompt-icon {
    font-size: var(--fs-2xl);
    flex-shrink: 0;
}

.prompt-text {
    flex: 1;
}

.prompt-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: 5px;
}

.prompt-desc {
    font-size: var(--fs-md);
    color: var(--text-secondary);
    line-height: 1.4;
}

.prompt-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
}

.prompt-btn {
    padding: 8px var(--sp-4);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--fs-md);
    cursor: pointer;
    transition: background-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
}

.prompt-btn.primary {
    background: var(--primary);
    color: #fff;
}

.prompt-btn.primary:hover {
    background: var(--primary-hover);
}

.prompt-btn.secondary {
    background: var(--gray-100);
    color: var(--text-secondary);
}

.prompt-btn.secondary:hover {
    background: var(--gray-200);
}

@keyframes home-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================================
 * 布局与响应式
 * ============================================================ */
.main-content {
    display: flex;
    gap: var(--sp-5);
}

.left-panel {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .right-panel {
        max-width: none;
    }

    .banner {
        padding: var(--sp-4);
    }

    .exam-title {
        flex-direction: column;
        gap: var(--sp-2);
    }
}
