/**
 * Category Products Widget Styles
 */

/* 容器样式 */
.kevinchen-category-products-widget {
    --kcp-image-aspect-ratio: 1;
    --kcp-image-border-radius: 5px;
    --kcp-grid-gap: 20px;
    --kcp-title-size: 16px;
    --kcp-title-color: #333;
    margin-bottom: 30px;
    width: 100%;
}

/* 加载状态 */
.kcp-products-container {
    position: relative;
    width: 100%;
}

.kcp-products-container.loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 5;
}

.kcp-products-container.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-radius: 50%;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    animation: kcp-spin 0.8s linear infinite;
    z-index: 6;
}

@keyframes kcp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 网格布局 */
.kcp-products-grid {
    display: grid;
    grid-gap: var(--kcp-grid-gap);
    margin-bottom: 20px;
    width: 100%;
}

/* 网格列数 */
.kcp-products-grid.columns-1 { grid-template-columns: repeat(1, 1fr); }
.kcp-products-grid.columns-2 { grid-template-columns: repeat(2, 1fr); }
.kcp-products-grid.columns-3 { grid-template-columns: repeat(3, 1fr); }
.kcp-products-grid.columns-4 { grid-template-columns: repeat(4, 1fr); }
.kcp-products-grid.columns-5 { grid-template-columns: repeat(5, 1fr); }
.kcp-products-grid.columns-6 { grid-template-columns: repeat(6, 1fr); }

/* 商品项 */
.kcp-product-item {
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    border-radius: var(--kcp-image-border-radius);
    overflow: hidden;
    transition: all 0.3s ease;
    background-color: #fff;
    width: 100%;
}

.kcp-product-item:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.kcp-product-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

/* 图片容器 - 维持固定宽高比 */
.kcp-product-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: calc(100% / var(--kcp-image-aspect-ratio)); /* 默认正方形 1:1 */
    overflow: hidden;
}

.kcp-product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.kcp-product-item:hover .kcp-product-image {
    transform: scale(1.05);
}

/* 商品标题 */
.kcp-product-title {
    padding: 10px;
    margin: 0;
    font-size: var(--kcp-title-size);
    color: var(--kcp-title-color);
    text-align: center;
    font-weight: 500;
    transition: color 0.3s ease;
}

.kcp-product-item:hover .kcp-product-title {
    color: #3498db;
}

/* 分页样式 */
.kcp-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    gap: 5px;
}

.kcp-pagination-numbers {
    display: flex;
    align-items: center;
    gap: 5px;
}

.kcp-pagination-prev,
.kcp-pagination-next,
.kcp-pagination-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: #f5f5f5;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.kcp-pagination-prev:hover,
.kcp-pagination-next:hover,
.kcp-pagination-number:hover {
    background-color: #e0e0e0;
    color: #000;
}

.kcp-pagination-number.current {
    background-color: #3498db;
    color: #fff;
    cursor: default;
}

.kcp-pagination-dots {
    padding: 0 5px;
    color: #666;
}

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* 修复前台显示问题 */
.elementor-widget-kevinchen_category_products .elementor-widget-container {
    width: 100%;
    overflow: visible !important;
}

.kcp-products-container {
    width: 100% !important;
    max-width: 100% !important;
}

.elementor-widget.elementor-widget-kevinchen_category_products {
    width: 100%;
    max-width: 100%;
}

/* 修复在页面中的网格显示 */
body:not(.elementor-editor-active) .kcp-products-grid {
    width: 100%;
    display: grid;
}

body:not(.elementor-editor-active) .kcp-product-item {
    min-width: 0;
}

/* 响应式设计 */
@media screen and (max-width: 1024px) {
    .kcp-products-grid.columns-5,
    .kcp-products-grid.columns-6 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .kcp-products-grid.columns-3,
    .kcp-products-grid.columns-4,
    .kcp-products-grid.columns-5,
    .kcp-products-grid.columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 480px) {
    .kcp-products-grid.columns-2,
    .kcp-products-grid.columns-3,
    .kcp-products-grid.columns-4,
    .kcp-products-grid.columns-5,
    .kcp-products-grid.columns-6 {
        grid-template-columns: repeat(1, 1fr);
    }
} 