/* ============================================
 * Categories Masonry Layout
 * Modern card-based category system with stats panel
 * ============================================ */

/* ============================================
 * 1. 统计面板容器
 * ============================================ */
.category-stats-panel {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: 12px;
    transition: all 0.3s ease;
    overflow: hidden;
    /* ✅ 修复1：防止内容溢出 */
}

/* Light Background - Stats Panel */
body.light-background .category-stats-panel,
body:not(.dark-background) .category-stats-panel {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Dark Background - Stats Panel */
body.dark-background .category-stats-panel {
    background: rgba(255, 255, 255, 0.12) !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* ============================================
 * 2. 左侧内容区域
 * ============================================ */
.stats-panel-left {
    flex: 1;
    min-width: 0;
    /* 允许收缩 */
}

/* Header with Icon */
.header-with-icon {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.header-main-icon {
    font-size: 40px;
    line-height: 1;
    flex-shrink: 0;
}

.header-text-group {
    flex: 1;
    min-width: 0;
}

.stats-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 8px 0;
    line-height: 1.2;
}

/* Light Background - Title */
body.light-background .stats-title,
body:not(.dark-background) .stats-title {
    color: #2a2a2a !important;
}

/* Dark Background - Title */
body.dark-background .stats-title {
    color: #ffffff !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.stats-subtitle {
    font-size: 14px;
    margin: 0;
    line-height: 1.6;
}

.subtitle-line {
    display: block;
}

/* Light Background - Subtitle */
body.light-background .stats-subtitle,
body:not(.dark-background) .stats-subtitle {
    color: #666;
}

/* Dark Background - Subtitle */
body.dark-background .stats-subtitle {
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
 * 3. 快速筛选按钮
 * ============================================ */
.quick-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    outline: none;
}

/* Light Background - Filter Buttons */
body.light-background .filter-btn,
body:not(.dark-background) .filter-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #2a2a2a;
}

body.light-background .filter-btn:hover,
body:not(.dark-background) .filter-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

body.light-background .filter-btn.active,
body:not(.dark-background) .filter-btn.active {
    background: var(--theme-color, #667eea);
    color: #ffffff;
    border-color: var(--theme-color, #667eea);
}

/* Dark Background - Filter Buttons */
body.dark-background .filter-btn {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

body.dark-background .filter-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

body.dark-background .filter-btn.active {
    background: var(--theme-color, #667eea);
    color: #ffffff;
    border-color: var(--theme-color, #667eea);
}

.filter-btn.hot::before {
    content: '🔥 ';
}

/* ============================================
 * 4. 右侧统计卡片区域（✅ 修复核心）
 * ============================================ */
.stats-panel-right {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 1;
    /* ✅ 修复2：允许收缩 */
    min-width: 0;
    /* ✅ 修复2：允许最小宽度为0 */
    max-width: 500px;
    /* ✅ 修复2：减小最大宽度 */
}

/* ============================================
 * 5. 单个统计卡片
 * ============================================ */
.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    /* ✅ 修复3：允许收缩 */
    padding: 12px 8px;
    /* ✅ 修复3：减小内边距 */
    border-radius: 10px;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 80px;
    /* 最小宽度保证可读性 */
}

/* Light Background - Stat Card */
body.light-background .stat-card,
body:not(.dark-background) .stat-card {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-background .stat-card:hover,
body:not(.dark-background) .stat-card:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Dark Background - Stat Card */
body.dark-background .stat-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

body.dark-background .stat-card:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 24px;
    /* ✅ 修复3：减小字体 */
    margin-bottom: 6px;
    line-height: 1;
}

.stat-value {
    font-size: 18px;
    /* ✅ 修复3：减小字体 */
    font-weight: 700;
    margin: 4px 0;
    line-height: 1;
}

/* Light Background - Stat Value */
body.light-background .stat-value,
body:not(.dark-background) .stat-value {
    color: #2a2a2a !important;
}

/* Dark Background - Stat Value */
body.dark-background .stat-value {
    color: #ffffff !important;
}

.stat-label {
    font-size: 10px;
    /* ✅ 修复3：减小字体 */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Light Background - Stat Label */
body.light-background .stat-label,
body:not(.dark-background) .stat-label {
    color: #666666 !important;
}

/* Dark Background - Stat Label */
body.dark-background .stat-label {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* ============================================
 * 6. Masonry 网格布局
 * ============================================ */
.category-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* ============================================
 * 7. Masonry 卡片
 * ============================================ */
.masonry-card {
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-left: 5px solid var(--category-color, #999);
}

/* Light Background - Masonry Card */
body.light-background .masonry-card,
body:not(.dark-background) .masonry-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

body.light-background .masonry-card:hover,
body:not(.dark-background) .masonry-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Dark Background - Masonry Card */
body.dark-background .masonry-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

body.dark-background .masonry-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* Card Sizes */
.masonry-card.size-small {
    grid-column: span 1;
}

.masonry-card.size-medium {
    grid-column: span 2;
}

.masonry-card.size-large {
    grid-column: span 2;
    grid-row: span 2;
}

.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 20px;
}

/* ============================================
 * 8. 卡片头部
 * ============================================ */
.card-header-compact {
    margin-bottom: 15px;
}

.card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-icon-inline {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

.card-title-inline {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

/* Light Background - Card Title */
body.light-background .card-title-inline,
body:not(.dark-background) .card-title-inline {
    color: #2a2a2a;
}

/* Dark Background - Card Title */
body.dark-background .card-title-inline {
    color: #ffffff;
}

.card-count-inline {
    font-size: 14px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Light Background - Count */
body.light-background .card-count-inline,
body:not(.dark-background) .card-count-inline {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

/* Dark Background - Count */
body.dark-background .card-count-inline {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
}

/* ============================================
 * 9. 卡片主体内容
 * ============================================ */
.card-body {
    margin-top: 10px;
}

.card-body-detailed {
    margin-top: 15px;
}

.card-stats-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.mini-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.mini-stat-icon {
    font-size: 18px;
}

.mini-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    opacity: 0.7;
}

.mini-stat-value {
    font-size: 14px;
    font-weight: 600;
}

/* Light Background - Mini Stat */
body.light-background .mini-stat-value,
body:not(.dark-background) .mini-stat-value {
    color: #2a2a2a;
}

/* Dark Background - Mini Stat */
body.dark-background .mini-stat-value {
    color: #ffffff;
}

/* ============================================
 * 10. 子分类标签
 * ============================================ */
.subcategory-tags-detailed {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sub-tag-detailed {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    transition: all 0.2s ease;
}

/* Light Background - Sub Tags */
body.light-background .sub-tag-detailed,
body:not(.dark-background) .sub-tag-detailed {
    background: rgba(0, 0, 0, 0.05);
    color: #2a2a2a;
}

body.light-background .sub-tag-detailed:hover,
body:not(.dark-background) .sub-tag-detailed:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Dark Background - Sub Tags */
body.dark-background .sub-tag-detailed {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

body.dark-background .sub-tag-detailed:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sub-tag-name {
    font-weight: 500;
}

.sub-tag-count {
    font-size: 10px;
    opacity: 0.7;
}

/* ============================================
 * 11. 特殊状态
 * ============================================ */
.latest-post {
    font-size: 13px;
    opacity: 0.7;
}

.empty-notice {
    font-size: 13px;
    font-style: italic;
    opacity: 0.5;
}

/* ============================================
 * 12. 响应式设计
 * ============================================ */

/* 平板设备 */
@media screen and (max-width: 1024px) {
    .stats-panel-right {
        max-width: 400px;
    }

    .stat-card {
        min-width: 70px;
        padding: 10px 6px;
    }

    .stat-icon {
        font-size: 20px;
    }

    .stat-value {
        font-size: 16px;
    }

    .masonry-card.size-medium,
    .masonry-card.size-large {
        grid-column: span 1;
        grid-row: span 1;
    }
}

/* 小屏设备 */
@media screen and (max-width: 768px) {
    .category-stats-panel {
        flex-direction: column;
        padding: 20px;
    }

    .stats-panel-right {
        width: 100%;
        max-width: none;
        justify-content: center;
    }

    .stat-card {
        flex: 0 1 auto;
        min-width: 70px;
    }

    .category-masonry {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .masonry-card.size-medium,
    .masonry-card.size-large {
        grid-column: span 1;
        grid-row: span 1;
    }

    .header-with-icon {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-title {
        font-size: 28px;
    }
}

/* 超小屏设备 */
@media screen and (max-width: 480px) {
    .stats-panel-right {
        gap: 8px;
    }

    .stat-card {
        min-width: 60px;
        padding: 8px 4px;
    }

    .stat-icon {
        font-size: 18px;
    }

    .stat-value {
        font-size: 14px;
    }

    .stat-label {
        font-size: 9px;
    }
}

/* ============================================
 * 13. 打印样式
 * ============================================ */
@media print {

    .category-stats-panel,
    .masonry-card {
        break-inside: avoid;
        box-shadow: none;
    }

    .filter-btn {
        display: none;
    }
}

/* ============================================
 * 14. ⚠️ 强制覆盖规则 - 确保文字可见
 * ============================================ */

/* 强制统计卡片背景和文字颜色 - Light */
.category-stats-panel .stats-panel-right .stat-card,
body.light-background .category-stats-panel .stats-panel-right .stat-card,
body:not(.dark-background) .category-stats-panel .stats-panel-right .stat-card {
    background: rgba(0, 0, 0, 0.04) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* 强制统计卡片背景和文字颜色 - Dark */
body.dark-background .category-stats-panel .stats-panel-right .stat-card {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* 强制统计数值颜色 */
.category-stats-panel .stat-card .stat-value,
body.light-background .category-stats-panel .stat-card .stat-value,
body:not(.dark-background) .category-stats-panel .stat-card .stat-value {
    color: #1a1a1a !important;
    font-weight: 700 !important;
}

body.dark-background .category-stats-panel .stat-card .stat-value {
    color: #ffffff !important;
    font-weight: 700 !important;
}

/* 强制统计标签颜色 */
.category-stats-panel .stat-card .stat-label,
body.light-background .category-stats-panel .stat-card .stat-label,
body:not(.dark-background) .category-stats-panel .stat-card .stat-label {
    color: #555555 !important;
}

body.dark-background .category-stats-panel .stat-card .stat-label {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* 强制图标可见性 */
.category-stats-panel .stat-card .stat-icon {
    opacity: 0.8 !important;
    filter: none !important;
}