/* ========================================
   前台公共样式 - frontend.css
   ======================================== */

/* --- CSS Variables --- */
:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #818cf8;
    --gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
}

/* --- Base --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #f8fafc;
}

/* ========================================
   公共组件
   ======================================== */

/* --- Navbar --- */
.navbar-custom {
    padding: 14px 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.navbar-custom .navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}
.navbar-custom .nav-link {
    color: #475569;
    font-weight: 500;
}
.navbar-custom .nav-link:hover {
    color: var(--primary);
}

/* --- Footer --- */
.site-footer {
    background: #1e293b;
    color: #94a3b8;
    padding: 30px 0 20px;
}
.site-footer a {
    color: #94a3b8;
    text-decoration: none;
}
.site-footer a:hover {
    color: #fff;
}

/* ========================================
   首页 (index)
   ======================================== */

/* Navbar (首页特殊样式 - 透明背景 + fixed) */
.navbar-home {
    padding: 16px 0;
    transition: all 0.3s;
    background: transparent;
}
.navbar-home.scrolled {
    background: #fff;
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
    padding: 10px 0;
}
.navbar-home .navbar-brand { color: #fff; }
.navbar-home.scrolled .navbar-brand { color: var(--primary); }
.navbar-home .nav-link { color: rgba(255,255,255,0.85); }
.navbar-home.scrolled .nav-link { color: #475569; }
.navbar-home .nav-link:hover { color: #fff; }
.navbar-home.scrolled .nav-link:hover { color: var(--primary); }

/* Hero */
.hero {
    background: var(--gradient);
    color: #fff;
    padding: 120px 0 90px;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}
.hero::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
}
.hero h1 { font-size: 3rem; font-weight: 800; line-height: 1.2; }
.hero .lead { font-size: 1.2rem; opacity: 0.9; }
.hero .btn-light { font-weight: 600; padding: 12px 32px; border-radius: 50px; }
.hero .btn-outline-light { padding: 12px 32px; border-radius: 50px; border-width: 2px; }
.hero-icon-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.hero-icon-item {
    background: rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(4px);
}
.hero-icon-item i { font-size: 2rem; display: block; margin-bottom: 6px; opacity: 0.9; }
.hero-icon-item span { font-size: 0.85rem; opacity: 0.75; }

/* Stats */
.stats { padding: 60px 0; background: #fff; border-bottom: 1px solid #e2e8f0; }
.stat-item { text-align: center; padding: 20px; }
.stat-number { font-size: 2.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { color: #64748b; font-size: 0.95rem; margin-top: 8px; }
.stat-icon { font-size: 1.5rem; color: var(--primary-light); margin-bottom: 8px; }

/* Section common */
.section-title { font-size: 2rem; font-weight: 700; text-align: center; margin-bottom: 12px; }
.section-subtitle { text-align: center; color: #64748b; margin-bottom: 50px; font-size: 1.1rem; }

/* Categories */
.categories { padding: 80px 0; background: #f8fafc; }
.category-card { border: none; border-radius: 16px; overflow: hidden; transition: all 0.3s; height: 100%; }
.category-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(0,0,0,0.08); }
.category-header { background: var(--gradient); color: #fff; padding: 20px 24px; }
.category-header h5 { font-weight: 700; margin: 0; }
.category-header .badge { background: rgba(255,255,255,0.2); font-size: 0.8rem; }
.category-body { padding: 20px 24px; background: #fff; }
.subject-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.subject-item:last-child { border-bottom: none; }
.subject-item .subject-name { font-size: 0.95rem; color: #334155; font-weight: 500; }
.subject-item .question-count { font-size: 0.8rem; color: #94a3b8; background: #f1f5f9; padding: 2px 10px; border-radius: 20px; }

/* Stats Charts */
.stats-section { padding: 80px 0; background: #fff; }
.chart-card { border: none; border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); height: 100%; }
.chart-card .card-header { background: transparent; border-bottom: 1px solid #f1f5f9; padding: 20px 24px; }
.chart-card .card-header h6 { font-weight: 700; margin: 0; color: #1e293b; }
.chart-card .card-body { padding: 24px; }
.bar-item { margin-bottom: 20px; }
.bar-item:last-child { margin-bottom: 0; }
.bar-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.9rem; }
.bar-label .name { color: #475569; font-weight: 500; }
.bar-label .count { color: #94a3b8; }
.bar-track { height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width 1s ease; }

/* Features */
.features { padding: 80px 0; background: #f8fafc; }
.feature-card { border: none; border-radius: 16px; transition: all 0.3s; height: 100%; }
.feature-card:hover { transform: translateY(-6px); box-shadow: 0 20px 40px rgba(0,0,0,0.08); }
.feature-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #fff; }

/* CTA */
.cta { background: var(--gradient); padding: 80px 0; text-align: center; color: #fff; }
.cta h2 { font-size: 2rem; font-weight: 700; margin-bottom: 16px; }
.cta .btn-light { padding: 14px 40px; border-radius: 50px; font-weight: 600; font-size: 1.1rem; }

/* ========================================
   品类页 (exam/all)
   ======================================== */

/* Page Hero */
.page-hero {
    background: var(--gradient);
    color: #fff;
    padding: 80px 0 60px;
    position: relative;
    overflow: hidden;
}
.page-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 500px;
    height: 500px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}
.page-hero h1 { font-size: 2.5rem; font-weight: 800; }
.page-hero .lead { font-size: 1.1rem; opacity: 0.9; max-width: 700px; }

/* Stats bar */
.stats-bar { background: #fff; padding: 24px 0; border-bottom: 1px solid #e2e8f0; }
.stats-bar .stat-item { text-align: center; }
.stats-bar .stat-num { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stats-bar .stat-text { color: #94a3b8; font-size: 0.85rem; margin-top: 4px; }

/* Category section */
.category-section { padding: 40px 0; }
.category-group { margin-bottom: 40px; }
.category-group-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
}
.category-group-header h2 { font-size: 1.35rem; font-weight: 700; color: #1e293b; margin: 0; }
.category-group-header .count { font-size: 0.85rem; color: #94a3b8; }

/* Category grid */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    color: #334155;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}
.category-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79,70,229,0.1);
}
.category-link .arrow { color: #cbd5e1; font-size: 0.85rem; transition: color 0.2s; }
.category-link:hover .arrow { color: var(--primary); }

/* Subject grid */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.subject-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    color: #334155;
    transition: all 0.2s;
}
.subject-link:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79,70,229,0.1);
}
.subject-link .subj-info { display: flex; align-items: center; gap: 10px; }
.subject-link .subj-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(79,70,229,0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.subject-link .subj-name { font-weight: 600; font-size: 0.95rem; color: #1e293b; }
.subject-link .subj-count { font-size: 0.8rem; color: #94a3b8; }
.subject-link .arrow { color: #cbd5e1; font-size: 0.85rem; }
.subject-link:hover .arrow { color: var(--primary); }

/* CTA (品类页) */
.cta-section { background: var(--gradient); padding: 60px 0; text-align: center; color: #fff; }
.cta-section h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 12px; }
.cta-section .btn-light { padding: 12px 36px; border-radius: 50px; font-weight: 600; }

/* ========================================
   题目列表页 (exam/questions)
   ======================================== */

/* Page header */
.page-header {
    background: var(--gradient);
    color: #fff;
    padding: 48px 0 36px;
}
.page-header h1 { font-size: 2rem; font-weight: 800; margin: 0; }
.page-header .breadcrumb-custom {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    margin-top: 8px;
}
.page-header .breadcrumb-custom a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
}
.page-header .breadcrumb-custom a:hover { color: #fff; }

/* Layout */
.main-content { padding: 30px 0 60px; }
.filter-sidebar { position: sticky; top: 20px; }

/* Filter panel */
.filter-panel {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    margin-bottom: 20px;
}
.filter-panel h6 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}
.filter-item {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    cursor: pointer;
}
.filter-item:hover { background: rgba(79,70,229,0.06); color: var(--primary); }
.filter-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.filter-item .count { float: right; font-size: 0.8rem; opacity: 0.7; }

/* Search bar */
.search-bar {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 16px 20px;
    margin-bottom: 20px;
}
.search-bar .form-control { border-radius: 8px; border-color: #e2e8f0; font-size: 0.9rem; }
.search-bar .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.search-bar .btn-search {
    background: var(--primary);
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 6px 20px;
    font-size: 0.9rem;
}

/* Filter tags */
.filter-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: rgba(79,70,229,0.08);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
}
.filter-tag a { color: var(--primary); text-decoration: none; font-size: 0.75rem; }

/* Question card */
.question-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    transition: all 0.2s;
}
.question-card:hover { border-color: var(--primary-light); box-shadow: 0 4px 12px rgba(79,70,229,0.08); }
.question-card .q-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.question-card .q-index { font-size: 0.8rem; color: #94a3b8; font-weight: 600; }
.question-card .q-type { font-size: 0.75rem; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.q-type-1 { background: #eff6ff; color: #2563eb; }
.q-type-2 { background: #f0fdf4; color: #16a34a; }
.q-type-3 { background: #fefce8; color: #ca8a04; }
.q-type-4 { background: #fdf4ff; color: #a855f7; }
.q-type-5 { background: #fff7ed; color: #ea580c; }
.question-card .q-difficulty { font-size: 0.75rem; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.q-diff-1 { background: #f0fdf4; color: #16a34a; }
.q-diff-2 { background: #fefce8; color: #ca8a04; }
.q-diff-3 { background: #fef2f2; color: #dc2626; }
.question-card .q-content { font-size: 0.95rem; color: #334155; line-height: 1.6; margin-bottom: 10px; }
.question-card .q-content img { max-width: 100%; height: auto; }
.question-card .q-meta { display: flex; align-items: center; gap: 16px; font-size: 0.82rem; color: #94a3b8; }
.question-card .q-meta i { font-size: 0.75rem; }
.question-card .q-link { color: var(--primary); text-decoration: none; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.question-card .q-link:hover { text-decoration: underline; }

/* Pagination */
.pagination-custom { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 30px; }
.pagination-custom a,
.pagination-custom span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-decoration: none;
    color: #475569;
    border: 1px solid #e2e8f0;
    transition: all 0.15s;
}
.pagination-custom a:hover { border-color: var(--primary); color: var(--primary); }
.pagination-custom .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-custom .disabled { color: #cbd5e1; cursor: not-allowed; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state i { font-size: 3rem; color: #cbd5e1; }
.empty-state p { color: #94a3b8; margin-top: 12px; }

/* ========================================
   题目详情页 (exam/question)
   ======================================== */

/* Question detail card */
.question-detail-card { background: #fff; border-radius: 16px; border: 1px solid #e2e8f0; overflow: hidden; }
.question-detail-header {
    padding: 24px 28px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.question-detail-header .q-index { font-size: 1rem; font-weight: 700; color: var(--primary); }

/* Question detail body */
.question-detail-body { padding: 28px; }
.question-content { font-size: 1.05rem; color: #1e293b; line-height: 1.8; margin-bottom: 24px; }
.question-content img { max-width: 100%; height: auto; border-radius: 8px; }

/* Options */
.options-list { list-style: none; padding: 0; margin: 0 0 24px; }
.options-list li {
    padding: 14px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: #334155;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.15s;
}
.options-list li:hover { border-color: var(--primary-light); background: rgba(79,70,229,0.02); }
.options-list .opt-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(79,70,229,0.08);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.options-list .opt-text { flex: 1; line-height: 1.6; padding-top: 2px; }
.options-list .opt-text img { max-width: 100%; height: auto; }

/* Answer reveal section */
.answer-reveal-section {
    margin-top: 32px;
    padding: 32px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    border: 2px dashed #cbd5e1;
    text-align: center;
    position: relative;
}
.answer-reveal-section .reveal-icon { font-size: 2.5rem; color: var(--primary); margin-bottom: 12px; }
.answer-reveal-section h5 { font-size: 1.1rem; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.answer-reveal-section p { color: #64748b; font-size: 0.9rem; margin-bottom: 20px; }
.btn-reveal {
    background: var(--gradient);
    border: none;
    color: #fff;
    padding: 12px 32px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(79,70,229,0.3);
}
.btn-reveal:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79,70,229,0.4); }

/* QR Code Modal */
.qr-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
.qr-modal-overlay.show { display: flex; }
.qr-modal-box {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    position: relative;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.qr-modal-box .close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
}
.qr-modal-box .close-btn:hover { color: #475569; }
.qr-modal-box h4 { font-size: 1.2rem; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.qr-modal-box .subtitle { color: #64748b; font-size: 0.85rem; margin-bottom: 24px; }
.qr-code-placeholder {
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #e2e8f0;
}
.qr-code-placeholder i { font-size: 3rem; color: var(--primary); margin-bottom: 8px; }
.qr-code-placeholder span { font-size: 0.8rem; color: #94a3b8; }
.qr-modal-box .tip { font-size: 0.82rem; color: #94a3b8; }
.qr-modal-box .tip i { color: #22c55e; }

/* Meta info */
.question-meta-bar {
    padding: 16px 28px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.85rem;
    color: #94a3b8;
    flex-wrap: wrap;
}
.question-meta-bar i { font-size: 0.75rem; }

/* Question navigation */
.question-nav { display: flex; justify-content: space-between; margin-top: 24px; gap: 12px; }
.question-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    color: #475569;
    font-size: 0.9rem;
    transition: all 0.2s;
    flex: 1;
    max-width: 48%;
}
.question-nav a:hover { border-color: var(--primary); color: var(--primary); }
.question-nav a .nav-label { font-size: 0.75rem; color: #94a3b8; }
.question-nav a .nav-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.question-nav .nav-next { text-align: right; margin-left: auto; }

/* ========================================
   响应式
   ======================================== */
@media (max-width: 768px) {
    /* 首页 */
    .hero h1 { font-size: 2rem; }
    .hero { padding: 80px 0 60px; }
    .stat-number { font-size: 2rem; }
    .hero-icon-grid { grid-template-columns: repeat(2, 1fr); }

    /* 品类页 */
    .page-hero h1 { font-size: 1.8rem; }
    .page-hero { padding: 60px 0 40px; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    .subject-grid { grid-template-columns: 1fr; }
    .stats-bar .stat-num { font-size: 1.4rem; }

    /* 题目列表页 */
    .page-header h1 { font-size: 1.5rem; }
    .page-header { padding: 36px 0 24px; }
    .filter-sidebar { position: static; margin-bottom: 20px; }

    /* 题目详情页 */
    .question-detail-body { padding: 20px; }
    .answer-reveal-section { padding: 24px 16px; }
    .question-nav { flex-direction: column; }
    .question-nav a { max-width: 100%; }
}
