/* ==========================================================================
   QuizHub 医学在线考试系统 - 全局样式
   主题：中西医结合
   —— 临床医学：青绿（医疗环境色，冷静专业）
   —— 中医：琥珀药材色点缀 + 衬线标题（岐黄书卷气）
   ========================================================================== */

:root {
    /* Bootstrap 变量覆写（5.3 支持 CSS 变量驱动） */
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #115e59;
    --bs-link-hover-color-rgb: 17, 94, 89;
    --bs-body-bg: #f5faf8;

    /* 项目自定义变量 */
    --qz-primary: #0f766e;          /* 临床青绿 */
    --qz-primary-dark: #115e59;
    --qz-tcm: #b45309;              /* 中医药材琥珀 */
    --qz-tcm-light: #fef3c7;
    --qz-light: #f0f7f5;
    --qz-border: #d8e8e4;
    --qz-danger: #dc3545;
    --qz-warning: #f59e0b;
    --qz-success: #16a34a;
    --qz-serif: "Noto Serif SC", "Source Han Serif SC", "STZhongsong", "SimSun", serif;
}

/* ---------------------- 基础 ---------------------- */
body {
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    background-color: var(--bs-body-bg);
}

/* 衬线标题（书卷气，用于 Hero / 打印标题 / 品牌名） */
.brand-serif {
    font-family: var(--qz-serif);
    letter-spacing: .02em;
}

/* ---------------------- Bootstrap 组件主色统一 ---------------------- */
.btn-primary {
    --bs-btn-bg: var(--qz-primary);
    --bs-btn-border-color: var(--qz-primary);
    --bs-btn-hover-bg: var(--qz-primary-dark);
    --bs-btn-hover-border-color: var(--qz-primary-dark);
    --bs-btn-active-bg: var(--qz-primary-dark);
    --bs-btn-active-border-color: var(--qz-primary-dark);
    --bs-btn-disabled-bg: var(--qz-primary);
    --bs-btn-disabled-border-color: var(--qz-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--qz-primary);
    --bs-btn-border-color: var(--qz-primary);
    --bs-btn-hover-bg: var(--qz-primary);
    --bs-btn-hover-border-color: var(--qz-primary);
    --bs-btn-active-bg: var(--qz-primary);
    --bs-btn-active-border-color: var(--qz-primary);
}
.text-primary { color: var(--qz-primary) !important; }
.bg-primary { background-color: var(--qz-primary) !important; }
.bg-light { background-color: var(--qz-light) !important; }

.form-control:focus,
.form-select:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .15);
}
.form-check-input:checked { background-color: var(--qz-primary); border-color: var(--qz-primary); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .15); }

.page-link { color: var(--qz-primary); }
.page-item.active .page-link {
    background-color: var(--qz-primary);
    border-color: var(--qz-primary);
}
.progress-bar { background-color: var(--qz-primary); }
.nav-pills .nav-link.active { background-color: var(--qz-primary); }

/* ---------------------- 链接与按钮 ---------------------- */
a { text-decoration: none; }
.btn { border-radius: .375rem; }

/* ---------------------- 顶部导航 ---------------------- */
.navbar-main {
    background: linear-gradient(90deg, #0f766e 0%, #115e59 60%, #134e4a 100%);
    position: relative;
    z-index: 1030;  /* 高于首页 Hero 的 overflow:hidden stacking context */
}

/* ---------------------- 卡片 ---------------------- */
.card {
    border: none;
    border-radius: .5rem;
    box-shadow: 0 .125rem .25rem rgba(15, 60, 55, .08);
    margin-bottom: 1rem;
}
.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--qz-border);
    font-weight: 600;
}

/* 统计卡片 */
.stat-card {
    border-left: 4px solid var(--qz-primary);
    transition: transform .15s ease-in-out;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .stat-label {
    color: #6c757d;
    font-size: .875rem;
}

/* ---------------------- 表格 ---------------------- */
.table > :not(caption) > * > * {
    padding: .65rem .75rem;
    vertical-align: middle;
}
.table thead th {
    background-color: var(--qz-light);
    font-weight: 600;
    white-space: nowrap;
}

/* ---------------------- 首页 Hero ---------------------- */
.hero {
    background:
        radial-gradient(circle at 85% 20%, rgba(94, 234, 212, .18) 0, transparent 45%),
        linear-gradient(135deg, #0f766e 0%, #115e59 55%, #0c3f3b 100%);
    color: #fff;
    border-radius: .75rem;
    padding: 3rem 2rem;
    position: relative;
    overflow: hidden;
}
.hero::after {
    /* 中医药纹样：右下角淡 decor 圆环 */
    content: "";
    position: absolute;
    right: -60px;
    bottom: -80px;
    width: 260px;
    height: 260px;
    border: 2px solid rgba(253, 230, 138, .25);
    border-radius: 50%;
    pointer-events: none;
}
.hero .btn-light { font-weight: 600; }
.hero h1 {
    font-family: var(--qz-serif);
    letter-spacing: .04em;
}
.hero .tcm-slogan {
    color: #fde68a;
    font-family: var(--qz-serif);
    letter-spacing: .15em;
}

.feature-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .75rem;
    background-color: rgba(15, 118, 110, .1);
    color: var(--qz-primary);
    font-size: 1.5rem;
}

/* 中医特色标签 */
.badge-tcm {
    background-color: var(--qz-tcm-light);
    color: var(--qz-tcm);
    border: 1px solid #fcd34d;
    font-weight: 600;
}
.badge-western {
    background-color: rgba(15, 118, 110, .1);
    color: var(--qz-primary);
    border: 1px solid #99f6e4;
    font-weight: 600;
}

/* ---------------------- 答题页 ---------------------- */
.exam-header {
    background-color: #fff;
    border-bottom: 2px solid var(--qz-border);
    position: sticky;
    top: 0;
    z-index: 1020;
    padding: .75rem 0;
}

/* 倒计时 */
.countdown {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--qz-primary);
}
.countdown.is-warning { color: var(--qz-warning); }
.countdown.is-danger {
    color: var(--qz-danger);
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* 答题卡 */
.answer-card {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: .5rem;
}
.answer-card-item {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--qz-border);
    border-radius: .375rem;
    font-weight: 600;
    cursor: pointer;
    background-color: #fff;
    transition: all .15s;
}
.answer-card-item:hover { border-color: var(--qz-primary); }
.answer-card-item.answered {
    background-color: var(--qz-primary);
    color: #fff;
    border-color: var(--qz-primary);
}
.answer-card-item.marked {
    background-color: var(--qz-warning);
    color: #000;
    border-color: var(--qz-warning);
}
.answer-card-item.current {
    outline: 2px solid var(--qz-primary);
    outline-offset: 2px;
}

/* 题目内容 */
.question-content {
    font-size: 1.05rem;
    line-height: 1.8;
}
.question-content img { max-width: 100%; height: auto; }

/* 选项 */
.option-item {
    border: 1px solid var(--qz-border);
    border-radius: .5rem;
    padding: .75rem 1rem;
    margin-bottom: .75rem;
    cursor: pointer;
    transition: all .15s;
    background-color: #fff;
}
.option-item:hover { border-color: var(--qz-primary); background-color: #f0fdfa; }
.option-item.selected {
    border-color: var(--qz-primary);
    background-color: rgba(15, 118, 110, .08);
}

/* 成绩详情中的正确/错误标记 */
.answer-correct { color: var(--qz-success); font-weight: 600; }
.answer-wrong { color: var(--qz-danger); font-weight: 600; }

/* ---------------------- 富文本编辑器工具栏 ---------------------- */
.editor-toolbar {
    border: 1px solid var(--qz-border);
    border-bottom: none;
    border-radius: .375rem .375rem 0 0;
    padding: .35rem;
    background-color: var(--qz-light);
}
.editor-toolbar .btn { padding: .15rem .5rem; }
.rich-text-editor { border-radius: 0 0 .375rem .375rem; }

/* ---------------------- 加载动画 ---------------------- */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, .7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ---------------------- 空状态 ---------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}
.empty-state i {
    font-size: 3rem;
    color: var(--qz-border);
    display: block;
    margin-bottom: 1rem;
}

/* ---------------------- 徽章 ---------------------- */
.badge-role-student { background-color: #14b8a6; color: #fff; }
.badge-role-teacher { background-color: #0d9488; }
.badge-role-admin { background-color: #b45309; }

/* ---------------------- 页脚 ---------------------- */
.footer {
    font-size: .875rem;
}

/* ---------------------- 打印样式（成绩单 / 试卷） ---------------------- */
@media print {
    nav.navbar, .footer, .no-print,
    .btn, .alert, .pagination {
        display: none !important;
    }
    body {
        background-color: #fff !important;
        font-size: 12pt;
    }
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
        page-break-inside: avoid;
    }
    .container { max-width: 100%; }
    .print-title {
        text-align: center;
        margin-bottom: 1.5rem;
        font-weight: 700;
        font-family: var(--qz-serif);
    }
}

/* ---------------------- 移动端适配 ---------------------- */
@media (max-width: 768px) {
    .stat-card .stat-value { font-size: 1.35rem; }
    .table-responsive { font-size: .875rem; }
    .countdown { font-size: 1.2rem; }
    .hero { padding: 2rem 1.25rem; }
    .answer-card { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
    .answer-card-item { width: 38px; height: 38px; }
}
