/**
 * 布局与显示优化：合理布局、统一间距、视觉层级
 */

/* ========== 电脑宽屏：整页约 80% 视觉缩放 + 两侧留白感（视口宽度小于 1200px 的平板等保持原样）========== */
/* 写在 #ct-page-scale 上而非 body：body 上的 zoom 会让 position:fixed 的 .modal-backdrop 只盖住缩放区域 */
@media (min-width: 1200px) {
    html:not(.ct-no-desktop-scale) #ct-page-scale {
        zoom: 0.8;
    }
}

:root {
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 2.5rem;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --card-header-bg: #f8fafc;
    --border-subtle: rgba(0,0,0,0.06);
}

/* ========== 主容器与间距 ========== */
.container {
    max-width: 1400px;
}
@media (min-width: 1200px) {
    .container { padding-left: 1.5rem; padding-right: 1.5rem; }
}
.row.mb-4 {
    margin-bottom: var(--space-xxl) !important;
}
.row.mb-4:last-child {
    margin-bottom: var(--space-xl) !important;
}

/* ========== 卡片与区块 ========== */
.card {
    margin-bottom: var(--space-lg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}
.card-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--card-header-bg) !important;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
}
.card-header h5,
.card-header h6 {
    font-weight: 600;
    letter-spacing: 0.01em;
}
.card-header .fas,
.card-header .far,
.card-header .fab {
    margin-right: var(--space-sm);
    opacity: 0.85;
}
.card-body {
    padding: var(--space-lg);
}

/* 可点击卡片悬停效果（引导页、录入页等） */
.hover-shadow {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.hover-shadow:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* 学习报告等小卡片：内容区紧凑统一 */
.report-cards-row .card .card-body {
    padding: var(--space-md) var(--space-lg);
}
.report-cards-row .card .card-body .d-flex {
    padding: var(--space-xs) 0;
    border-bottom: 1px dashed var(--border-subtle);
}
.report-cards-row .card .card-body .d-flex:last-child {
    border-bottom: none;
}

/* ========== 统计数字块（计划/已完成/待复习 等） ========== */
.card .row.text-center .border.rounded,
.card .row.text-center .border.rounded.p-2,
.card .row.text-center .border.rounded.p-3 {
    min-height: 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-sm) !important;
    border-color: var(--border-subtle) !important;
    background: #fafbfc;
}
.card .row.text-center .border.rounded h3,
.card .row.text-center .border.rounded h4 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1d21;
    margin-bottom: 2px;
}
.card .row.text-center .border.rounded small {
    font-size: 0.8rem;
    color: #6c757d;
}

/* 整体统计行（5 个指标） */
.card .row .col-6.col-md-4.col-lg .card,
.card .row .col-md-3 .card.border-primary,
.card .row .col-md-3 .card.border-success {
    margin-bottom: 0;
}
.card .row .col-6.col-md-4.col-lg .card-body,
.card .row .col-md-3 .card-body {
    padding: var(--space-md) var(--space-lg);
}
.card .row .col-6.col-md-4.col-lg .card-body h2,
.card .row .col-md-3 .card-body h2 {
    font-size: 1.75rem;
    font-weight: 700;
}
.card .row .col-6.col-md-4.col-lg .card-body h6,
.card .row .col-md-3 .card-body h6 {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: none;
}

/* ========== 进度条 ========== */
.progress {
    border-radius: var(--radius-sm);
    background-color: #e9ecef;
}
.progress-bar {
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ========== 小节标题（卡片内 h6） ========== */
.card-body h6 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
}
.card-body h6.border-bottom {
    border-color: var(--border-subtle) !important;
}

/* ========== 列表组 ========== */
.list-group-item {
    padding: var(--space-md) var(--space-lg);
}
.list-group-flush .list-group-item {
    padding-left: var(--space-lg);
}
.list-group-item .badge {
    font-weight: 600;
}

/* ========== 表格 ========== */
.table {
    margin-bottom: 0;
}
.table thead th {
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 2px solid var(--border-subtle);
    white-space: nowrap;
}
.table tbody td {
    padding: var(--space-md) var(--space-lg);
    vertical-align: middle;
}
.table-sm thead th,
.table-sm tbody td {
    padding: var(--space-sm) var(--space-md);
}
.table-responsive {
    border-radius: var(--radius-sm);
    /* 勿用 overflow: hidden，会裁切表内下拉/浮层；横滚交给 Bootstrap 的 overflow-x:auto */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== 全部错题：筛选卡片 ========== */
.filter-card .card-header {
    border-bottom: 1px solid var(--border-subtle);
}
.filter-card .form-label {
    font-size: 0.8125rem;
}
.filter-card .row.g-3 {
    row-gap: var(--space-sm);
}

/* ========== 表单：筛选区等 ========== */
.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: var(--space-xs);
}
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: #dee2e6;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color, #3498db);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.15);
}
.card .card-body .row.g-3 {
    row-gap: var(--space-md);
}

/* ========== 提示与警告框 ========== */
.alert {
    border-radius: var(--radius-sm);
    border-left-width: 4px;
}
.alert-warning { border-left-color: #f0ad4e; }
.alert-success { border-left-color: #5cb85c; }
.alert-info { border-left-color: #5bc0de; }
.alert-danger { border-left-color: #d9534f; }
.alert-primary { border-left-color: #3498db; }

/* ========== 按钮组与快捷入口 ========== */
.btn-group .btn,
.d-flex.gap-2 .btn {
    border-radius: var(--radius-sm);
}
.card-body .btn + .btn {
    margin-left: var(--space-sm);
}

/* ========== 首页：今日目标行（目标条统一样式） ========== */
.goal-strip {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--border-subtle);
}
body.dark-mode .goal-strip {
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
    border-color: var(--border-subtle);
}
.card-body .row.text-center.mb-2.mt-2.pt-3.border-top,
.card-body .row.text-center.mt-3.pt-3.border-top {
    padding-top: var(--space-lg) !important;
    margin-top: var(--space-md) !important;
    border-top-color: var(--border-subtle) !important;
}
.card-body .row.text-center .col-md-4 {
    padding-top: var(--space-xs);
    padding-bottom: var(--space-xs);
}

/* ========== 统计页：本月 vs 上月 对比卡片 ========== */
.card .card-body .row .border.rounded.p-3.text-center {
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: var(--radius-sm) !important;
    border-color: var(--border-subtle) !important;
    background: #fafbfc;
}
.card .card-body .row .border.rounded.p-3.text-center h6 {
    font-size: 0.8rem;
    margin-bottom: 4px;
}
.card .card-body .row .border.rounded.p-3.text-center h4 {
    font-size: 1.35rem;
    font-weight: 700;
}
.card .card-body .row .border.rounded.p-3.text-center small {
    font-size: 0.75rem;
    color: #6c757d;
}

/* ========== 复习耗时统计列表 ========== */
.card-body .list-group.list-group-flush li {
    padding: var(--space-sm) 0;
}

/* ========== 分页 ========== */
.pagination {
    margin-bottom: 0;
}
.pagination .page-item .page-link {
    border-radius: var(--radius-sm) !important;
    padding: var(--space-sm) var(--space-md);
}

/* ========== 响应式：小屏更紧凑 ========== */
@media (max-width: 767px) {
    .card-body { padding: var(--space-md); }
    .card-header { padding: var(--space-md) var(--space-md); }
    .report-cards-row .col-md-4 { margin-bottom: var(--space-md); }
    .report-cards-row .col-md-4:last-child { margin-bottom: 0; }
    .table thead th,
    .table tbody td { padding: var(--space-sm); font-size: 0.875rem; }
}

/* ========== 深色模式 ========== */
body.dark-mode {
    --card-header-bg: #2d3136;
    --border-subtle: rgba(255,255,255,0.08);
}
body.dark-mode .card .row.text-center .border.rounded,
body.dark-mode .card .row.text-center .border.rounded.p-2,
body.dark-mode .card .row.text-center .border.rounded.p-3 {
    background: rgba(255,255,255,0.04);
    border-color: var(--border-subtle);
}
body.dark-mode .card .row.text-center .border.rounded h3,
body.dark-mode .card .row.text-center .border.rounded h4 {
    color: #e4e6eb;
}
body.dark-mode .card .card-body .row .border.rounded.p-3.text-center {
    background: rgba(255,255,255,0.04);
    border-color: var(--border-subtle);
}
