.materials-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    background: #f8fbff;
    border-radius: 12px;
    contain: layout style;
}

.category-section {
    margin-bottom: 30px;
}

.parent-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    justify-content: center;
    padding: 20px;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.subcategory-section {
    margin-top: 10px;
}

.subcategory-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.1);
}

.category-item {
    position: relative;
    margin: 5px;
}

.category-link, .subcategory-link {
    display: block;
    padding: 12px 20px;
    text-decoration: none;
    color: #1e40af;
    border-radius: 20px;
    background: #ffffff;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid transparent;
}

.category-link.active,
.subcategory-link.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.category-link:hover,
.subcategory-link:hover {
    background: #dbeafe;
    color: #1e40af;
    border-color: #3b82f6;
}

.search-container {
    margin-left: auto;
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 24px;
    padding: 4px;
    border: 2px solid rgba(59, 130, 246, 0.15);
}

.search-container input[type="text"] {
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    outline: none;
    width: 200px;
    background: transparent;
    color: #1e40af;
    font-size: 14px;
}

.search-container input[type="text"]::placeholder {
    color: #94a3b8;
}

.search-button {
    padding: 10px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.search-button:hover {
    background: #2563eb;
}

.materials-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
    padding: 15px 0;
    contain: layout style paint;
    will-change: auto;
}

.material-item {
    cursor: pointer;
    text-align: center;
    border: none;
    padding: 0;
    border-radius: 16px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 240px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.15);
    contain: layout style paint;
}

.material-item:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.material-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    flex-shrink: 0;
    will-change: opacity;
    contain: layout style paint;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    cursor: pointer;
}

.material-item img.lazy-load {
    opacity: 0.6;
    background: #f0f0f0;
}

.material-item img.loaded {
    opacity: 1;
}

.material-item img.error {
    opacity: 0.4;
    background: #ffebee;
    border: 1px dashed #f44336;
}



.material-item h5 {
    margin: 0;
    padding: 16px 12px;
    font-size: 14px;
    line-height: 1.4;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e40af;
    font-weight: 600;
    background: #ffffff;
}

/* 分页信息样式 */
.pagination-info {
    text-align: center;
    margin: 20px 0 10px;
    color: #666;
    font-size: 14px;
}

/* WordPress分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 0;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    margin: 0;
    text-decoration: none;
    color: #1e40af;
    background: #ffffff;
    border: 2px solid rgba(59, 130, 246, 0.15);
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    min-width: 44px;
}

.pagination .page-numbers:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

.pagination .page-numbers.current {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.pagination .page-numbers.dots {
    border: none;
    background: none;
    color: #94a3b8;
    cursor: default;
}

.pagination .page-numbers.dots:hover {
    background: none;
    color: #94a3b8;
}

.modal {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    background-color: #ffffff;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #ddd;
    width: 80%;
    max-width: 600px;
    text-align: center;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.download-button, .login-button {
    display: inline-block;
    padding: 10px 20px;
    margin-top: 10px;
    color: #fff;
    background: #3b82f6;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s ease;
    border: none;
    cursor: pointer;
}

.download-button:hover, .login-button:hover {
    background: #2563eb;
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .materials-container {
        max-width: 1000px;
    }
}

@media (max-width: 1200px) {
    .materials-container {
        max-width: 900px;
        padding: 0 15px;
    }
    
    .materials-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .materials-container {
        padding: 15px;
        margin: 8px;
        overflow-x: hidden;
    }
    
    .parent-categories {
        gap: 8px;
        padding: 15px;
        flex-wrap: wrap;
    }
    
    .category-link, .subcategory-link {
        padding: 8px 14px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .materials-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        justify-items: center;
    }
    
    .material-item {
        min-height: 180px;
    }
    
    .material-item img {
        height: 120px;
        object-fit: cover;
    }
    
    .material-item h5 {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .search-container {
        margin: 10px auto;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .search-container input[type="text"] {
        width: 140px;
        padding: 6px 10px;
        min-width: 120px;
    }
    
    .search-button {
        padding: 6px 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .pagination .page-numbers {
        margin: 2px;
    }
}

@media (max-width: 480px) {
    .materials-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .material-item {
        min-height: 160px;
        max-width: 280px;
        margin: 0 auto;
    }
    
    .material-item img {
        height: 100px;
        object-fit: cover;
    }
    
    .material-item h5 {
        font-size: 12px;
        margin: 8px 0 0 0;
    }
    
    .pagination {
        padding: 20px 0 100px 0;
        margin-bottom: 50px;
    }
    
    .pagination .page-numbers {
        padding: 8px 10px;
        font-size: 12px;
        min-width: 36px;
    }
}

/* 覆盖footer的底部内边距，避免与页面内容重叠 */
.footer {
    padding-bottom: 0 !important;
}

/* 动态边距计算优化 - CSS辅助样式 */
.materials-container {
    /* 确保缩放时的平滑过渡 */
    transition: transform 0.3s ease, margin-bottom 0.3s ease;
    /* 防止缩放时出现水平滚动条 */
    max-width: 100%;
    overflow-x: hidden;
    /* 修复缩放时的布局问题 */
    transform-origin: top center;
    will-change: transform;
}

/* 针对不同缩放比例的微调 */
@media (max-width: 768px) {
    .materials-container {
        /* 移动端额外优化 */
        transform-origin: top center !important;
        padding: 0 10px;
    }
    
    .material-item {
        min-height: 180px;
    }
    
    .material-item img {
        height: 120px;
    }
}

/* 确保分页组件在缩放后仍然可见 */
.pagination {
    position: relative;
    z-index: 10;
    clear: both;
}

/* 分页与页脚之间的额外间隔 */
.pagination::after {
    content: '';
    display: block;
    height: 60px;
    width: 100%;
}

/* 移动端的额外间隔调整 */
@media (max-width: 768px) {
    .pagination::after {
        height: 40px;
    }
    
    .pagination .page-numbers {
        padding: 6px 12px;
        margin: 2px;
        font-size: 14px;
    }
}

/* 小屏幕设备的额外间隔调整 */
@media (max-width: 480px) {
    .pagination::after {
        height: 30px;
    }
    
    .pagination .page-numbers {
        padding: 4px 8px;
        margin: 1px;
        font-size: 12px;
    }
}