/* 寰宇周天 - 前台样式 */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --dark: #1e293b;
    --light: #f8fafc;
    /* 顶部导航栏实际高度，由 base.html 内的脚本实时测量后覆盖（此处为兜底值） */
    --nav-h: 58px;
}
body {
    font-family: -apple-system, "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background: #f5f6f8;
    color: #333;
}
.navbar-custom {
    background: linear-gradient(135deg, var(--dark), #334155);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    /* 顶部导航栏固定：页面下拉时始终停留在顶部 */
    position: sticky;
    top: 0;
    z-index: 1030;
}
.navbar-custom .navbar-brand { font-size: 1.3rem; }
.navbar-custom .nav-link:hover { color: #93c5fd !important; }
.navbar-custom .dropdown-menu-dark .dropdown-item:hover,
.navbar-custom .dropdown-menu-dark .dropdown-item.active,
.navbar-custom .dropdown-menu-dark .dropdown-item:active {
    background: #343a40;
    color: #fff;
}
.footer-custom {
    background: var(--dark);
    color: #cbd5e1;
    padding: 40px 0 20px;
    margin-top: 40px;
}
.footer-custom a { text-decoration: none; }
.footer-custom a:hover { color: #fff; }
.footer-custom .text-muted { color: #e2e8f0 !important; }
.footer-custom h5,
.footer-custom h6 { color: #f8f9fa; }
.article-card .card { transition: transform .2s, box-shadow .2s; }
.article-card .card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.avatar-circle {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}
.comment-item { padding: 12px 0; border-bottom: 1px solid #eee; }
.comment-pending { background: #fffbeb; border-radius: 8px; padding-left: 12px; padding-right: 12px; }
.article-content img { max-width: 100%; border-radius: 8px; }
.article-content pre { background: #f4f4f4; padding: 12px; border-radius: 6px; overflow-x: auto; }
.article-content h1, .article-content h2, .article-content h3 { margin-top: 1.5em; }
.article-content { line-height: 1.8; font-size: 16px; }
.article-content p { margin-bottom: 0.8em; }
.article-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 8px 16px; margin: 16px 0;
    background: #f8fafc; color: #64748b; border-radius: 0 8px 8px 0;
}
.article-content ul, .article-content ol { padding-left: 1.8em; margin-bottom: 0.8em; }
.article-content table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.article-content th, .article-content td { border: 1px solid #e2e8f0; padding: 8px 12px; text-align: left; }
.article-content th { background: #f1f5f9; font-weight: 600; }
.article-content code { background: #f4f4f4; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.article-content pre code { background: none; padding: 0; }
.article-content a { color: var(--primary); text-decoration: none; }
.article-content a:hover { text-decoration: underline; }
.article-content figure { margin: 16px 0; text-align: center; }
.article-content figcaption { color: #94a3b8; font-size: 0.85em; margin-top: 4px; }
.carousel-caption { background: rgba(0,0,0,.5); border-radius: 8px; padding: 15px; }
.card { border: 1px solid #e2e8f0; border-radius: 8px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ========== 前台列表筛选工具栏 ========== */
.frontend-filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.frontend-filter-bar .filter-search-box {
    width: 240px;
    height: 36px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
}
.frontend-filter-bar .filter-search-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.frontend-filter-bar .filter-select {
    height: 36px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
    outline: none;
}
.frontend-filter-bar .filter-select:focus {
    border-color: var(--primary);
}

/* ========== 前台分页器（与后台效果一致） ========== */
.pagination-bar {
    background: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-top: 20px;
    font-size: 13px;
    color: #64748b;
}
.pagination-bar .pagination-info,
.pagination-bar .pagination-pages,
.pagination-bar .pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pagination-bar .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid #dcdfe6;
    background: #fff;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: all .2s;
}
.pagination-bar .page-link:hover { border-color: var(--primary); color: var(--primary); }
.pagination-bar .page-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination-bar .page-link.disabled {
    color: #c0c4cc;
    pointer-events: none;
    background: #f5f7fa;
}
.pagination-bar .page-size-select,
.pagination-bar .goto-input {
    height: 32px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    padding: 0 8px;
    font-size: 13px;
    color: #333;
    background: #fff;
    outline: none;
}
.pagination-bar .goto-input {
    width: 56px;
    text-align: center;
}
.pagination-bar .goto-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
@media (max-width: 768px) {
    .frontend-filter-bar .filter-search-box { width: 100%; }
    .pagination-bar { justify-content: center; }
}

/* ===== 吸顶面包屑（文章详情页 / 分类页）===== */
/* 页面下拉时，面包屑停留在固定导航栏下方，不被正文顶走 */
.sticky-breadcrumb {
    position: sticky;
    top: var(--nav-h);
    z-index: 1020;
    background: #f5f6f8;          /* 与 body 背景一致，遮住下方滚过的正文 */
    padding: .55rem 0 .6rem;
    margin-bottom: .4rem;
}
.sticky-breadcrumb > .breadcrumb { margin-bottom: 0; }

/* ===== 吸顶侧栏（文章详情页「相关推荐」）===== */
/* 外层负责吸顶；卡片自身限高，列表在卡片内部滚动，
   条目很多时可滚到最上面/最下面一条，且不会超出可视范围 */
.sticky-sidebar {
    position: sticky;
    top: calc(var(--nav-h) + 16px);
}
.sticky-sidebar .related-card {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--nav-h) - 32px);
    overflow: hidden;
}
.sticky-sidebar .related-card > .card-header {
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
}
.sticky-sidebar .related-card > .list-group {
    flex: 1 1 auto;
    min-height: 0;                /* flex 子项允许收缩，滚动条才会出现 */
    overflow-y: auto;
    overscroll-behavior: contain; /* 列表滚到底后不带动整页滚动 */
}
.sticky-sidebar .related-card .list-group-item { white-space: normal; }

/* 小屏（<992px）下侧栏堆叠到正文之后，取消吸顶，避免遮挡正文 */
@media (max-width: 991.98px) {
    .sticky-sidebar { position: static; top: auto; }
    .sticky-sidebar .related-card { max-height: none; }
    .sticky-sidebar .related-card > .list-group { overflow: visible; }
}
