/* ===== 内容网格组件 - 优化版 ===== */

/* 网格容器 - 优化渲染性能 */
.grid-container {
    display: grid;
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 0 0 16px 16px;
    overflow: hidden; /* 保持，但注意性能影响 */
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    gap: 24px; /* 增加间距提高可读性 */
    width: 100%;
    align-items: start;
    background: white;
    padding: 0;
    
    /* 优化GPU加速 */
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 网格布局优化 */
.grid-2 { 
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 { 
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 { 
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* 网格项性能优化 */
.grid-item {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    min-height: 0;
    
    /* 优化渲染 */
    contain: layout style; /* 提升性能 */
    transform: translateZ(0); /* 触发GPU加速 */
}

/* 确保卡片填满网格项 */
.grid-item > * {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    
    /* 优化渲染 */
    will-change: transform;
    backface-visibility: hidden;
}

/* ===== 筛选器 - 性能与稳定性优化 ===== */
.grid-filters {
    /* 基础样式 */
    background: #f8f9fa;
    max-width: 1200px;
    margin: 0 auto 30px auto;
    padding: 20px;
    border-radius: 8px;
    
    /* Flex布局 - 优化性能 */
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 15px;
    flex-wrap: wrap;
    flex-direction: row;
    
    /* 盒模型 */
    box-sizing: border-box;
    width: 100%;
    
    /* 位置稳定性 */
    position: relative;
    left: 0;
    right: 0;
    top: 0;
    
    /* 尺寸稳定性 */
    min-height: 80px;
    overflow: visible;
    clear: both;
    
    /* 优化渲染 */
    will-change: transform;
    contain: layout style; /* 提升性能 */
}

/* 筛选组 - 优化交互 */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
    max-width: 200px;
    flex: 0 0 auto; /* 防止伸缩 */
    position: relative;
    
    /* 优化性能 */
    will-change: transform;
}

.filter-group label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    
    /* 优化字体渲染 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.filter-group select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    min-width: 160px;
    max-width: 200px;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out; /* 缩短动画时间 */
    
    /* 优化渲染 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
    
    /* 优化焦点状态 */
    outline: none;
}

.filter-group select:hover {
    border-color: #007cba;
}

.filter-group select:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

/* 筛选按钮 - 优化交互 */
.grid-filters button[type="submit"] {
    padding: 10px 25px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.15s ease-in-out, transform 0.1s ease; /* 优化动画 */
    height: 40px;
    min-width: 80px;
    flex-shrink: 0;
    
    /* 优化字体 */
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    
    /* 优化交互 */
    user-select: none;
}

.grid-filters button[type="submit"]:hover {
    background: #005a87;
}

.grid-filters button[type="submit"]:active {
    transform: translateY(1px); /* 微妙的点击反馈 */
}

/* 重置按钮优化 */
.reset-btn {
    padding: 10px 20px;
    color: #666;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: all 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    min-width: 80px;
    box-sizing: border-box;
    flex-shrink: 0;
    
    /* 优化字体 */
    font-size: 14px;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
}

.reset-btn:hover {
    background: #f8f9fa;
    border-color: #bbb;
    color: #333;
}

.reset-btn:active {
    transform: translateY(1px);
}

/* ===== 分页 - 性能优化 ===== */
.grid-pagination {
    margin-top: 40px;
    margin-bottom: 30px;
    text-align: center;
    
    /* 优化渲染 */
    contain: layout style;
}

.grid-pagination .page-numbers {
    display: inline-block;
    padding: 10px 18px;
    margin: 0 5px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    text-decoration: none;
    color: #007cba;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
    
    /* 优化交互 */
    user-select: none;
}

.grid-pagination .page-numbers:hover {
    background: #f8f9fa;
    border-color: #007cba;
}

.grid-pagination .current {
    background: #007cba;
    color: white;
    border-color: #007cba;
    
    /* 优化渲染 */
    font-weight: 600;
}

.grid-pagination .dots {
    border: none;
    padding: 10px 5px;
    cursor: default;
    color: #6c757d;
}

/* ===== 空状态 ===== */
.no-results {
    padding: 60px 20px;
    text-align: center;
    grid-column: 1 / -1;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
    color: #666;
    font-size: 16px;
    
    /* 优化字体 */
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

.no-results a {
    display: inline-block;
    margin-top: 15px;
    padding: 8px 20px;
    background: #007cba;
    color: white;
    text-decoration: none;
    font-weight: 500;
    border-radius: 4px;
    transition: background-color 0.15s ease-in-out;
    
    /* 优化字体 */
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.no-results a:hover {
    background: #005a87;
}

/* ===== 响应式设计优化 ===== */

/* 大屏幕优化 */
@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* 平板优化 */
@media (max-width: 992px) {
    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* 移动端优化 */
@media (max-width: 768px) {
    .grid-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 12px; /* 减小间距 */
    }
    
    .filter-group {
        min-width: 100%;
        max-width: 100%;
    }
    
    .filter-group select {
        min-width: 100%;
        max-width: 100%;
    }
}

/* 小屏幕优化 */
@media (max-width: 576px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 20px; /* 减小间距 */
    }
    
    .grid-filters button[type="submit"],
    .reset-btn {
        width: 100%;
        text-align: center;
    }
    
    /* 移动端触摸优化 */
    .filter-group select,
    .grid-filters button[type="submit"],
    .reset-btn {
        min-height: 44px; /* 最小触摸目标尺寸 */
        padding: 12px 16px; /* 增大触摸区域 */
    }
}

/* ===== 性能优化补充 ===== */

/* 减少重绘区域 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 打印样式优化 */
@media print {
    .grid-filters,
    .grid-pagination {
        display: none !important;
    }
    
    .grid-container {
        box-shadow: none !important;
        border-radius: 0 !important;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .grid-filters {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .filter-group select {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .filter-group label {
        color: #e2e8f0;
    }
    
    .no-results {
        background: #2d3748;
        border-color: #4a5568;
        color: #cbd5e0;
    }
}