/**
 * Divi WooCommerce Catalog - Frontend Styles
 */

/* Container and Grid */
.dwc-catalog-wrapper {
    position: relative;
}

.dwc-catalog-wrapper.dwc-loading {
    opacity: 0.5;
    pointer-events: none;
}

.dwc-catalog-wrapper.dwc-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #FEDD00;
    border-top-color: transparent;
    border-radius: 50%;
    animation: dwc-spin 0.8s linear infinite;
    z-index: 999;
}

.dwc-catalog-container {
    width: 100%;
    padding: 20px 0;
}

.dwc-products-grid {
    display: grid;
    gap: 30px;
    margin: 0;
}

/* Column Classes */
.dwc-columns-2 { grid-template-columns: repeat(2, 1fr); }
.dwc-columns-3 { grid-template-columns: repeat(3, 1fr); }
.dwc-columns-4 { grid-template-columns: repeat(4, 1fr); }
.dwc-columns-5 { grid-template-columns: repeat(5, 1fr); }
.dwc-columns-6 { grid-template-columns: repeat(6, 1fr); }

/* Product Item */
.dwc-product-item {
    position: relative;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.dwc-product-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(44, 42, 41, 0.1);
    border-color: #FEDD00;
}

.dwc-product-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Sale Badge */
.dwc-sale-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #FEDD00;
    color: #2C2A29;
    padding: 5px 15px;
    border-radius: 25px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(254, 221, 0, 0.3);
}

/* Product Image - Improved sizing with contain */
.dwc-product-image {
    position: relative;
    width: 100%;
    height: 250px;
    background: #ffffff;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f0f0f0;
}

.dwc-product-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
}

.dwc-product-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
    display: block;
}

/* Fallback for browsers without object-fit support */
.dwc-product-image img.no-object-fit {
    position: static;
    transform: none;
}

.dwc-product-item:hover .dwc-product-image img {
    transform: scale(1.05);
}

/* Ensure placeholder images also fit properly */
.dwc-product-image .woocommerce-placeholder {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
}

/* Product Rating */
.dwc-product-rating {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dwc-product-rating .star-rating {
    font-size: 12px;
    width: auto;
    height: 12px;
}

/* Product Content */
.dwc-product-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 120px;
}

.dwc-product-title {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    min-height: 44px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dwc-product-title a {
    color: #2C2A29;
    text-decoration: none;
    transition: color 0.3s ease;
}

.dwc-product-title a:hover {
    color: #FEDD00;
}

/* Product Price */
.dwc-product-price {
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 700;
    color: #2C2A29;
    flex-grow: 1;
    display: flex;
    align-items: flex-end;
}

.dwc-product-price del {
    color: #999;
    font-weight: 400;
    margin-right: 8px;
    font-size: 16px;
}

.dwc-product-price ins {
    text-decoration: none;
    color: green;
}

/* Product Actions */
.dwc-product-actions {
    margin-top: auto;
}

.dwc-add-to-cart,
.dwc-out-of-stock {
    width: 100%;
    padding: 12px 20px;
    background: #2C2A29;
    color: #ffffff;
    border: 2px solid #2C2A29;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.dwc-add-to-cart:hover {
    background: #FEDD00;
    color: #2C2A29;
    border-color: #FEDD00;
}

.dwc-add-to-cart.loading {
    pointer-events: none;
    opacity: 0.7;
}

.dwc-add-to-cart.loading .dwc-btn-text {
    visibility: hidden;
}

.dwc-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: dwc-spin 0.8s linear infinite;
    display: none;
}

.dwc-add-to-cart.loading .dwc-loading-spinner {
    display: block;
}

.dwc-out-of-stock {
    background: #e0e0e0;
    color: #999;
    border-color: #e0e0e0;
    cursor: not-allowed;
}

/* No Products Message */
.dwc-no-products {
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: #666;
}

/* Pagination */
.dwc-pagination {
    margin-top: 40px;
    text-align: center;
}

.dwc-pagination a,
.dwc-pagination span {
    display: inline-block;
    padding: 8px 15px;
    margin: 0 5px;
    background: #f5f5f5;
    color: #2C2A29;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    font-weight: 600;
}

.dwc-pagination a:hover,
.dwc-pagination .current {
    background: #FEDD00;
    color: #2C2A29;
}

/* YITH Filter Compatibility */
.yith-wcan-filters ~ .dwc-catalog-wrapper {
    margin-top: 20px;
}

/* Built-in Filter Widget */
.dwc-filters-wrapper {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.dwc-filter-section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid #e0e0e0;
}

.dwc-filter-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.dwc-filter-title {
    margin: 0 0 15px;
    font-size: 16px;
    font-weight: 600;
    color: #2C2A29;
}

.dwc-filter-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dwc-filter-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: color 0.3s ease;
}

.dwc-filter-item:hover {
    color: #FEDD00;
}

.dwc-filter-item input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.dwc-filter-label {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dwc-filter-count {
    color: #999;
    font-size: 14px;
    margin-left: 10px;
}

/* Category Tree */
.dwc-category-item {
    position: relative;
}

.dwc-subcategories {
    margin-left: 20px;
    margin-top: 10px;
}

.dwc-level-0 > .dwc-filter-item {
    font-weight: 600;
}

.dwc-level-1 > .dwc-filter-item {
    font-size: 14px;
}

.dwc-level-2 > .dwc-filter-item {
    font-size: 13px;
}

/* Filter Actions */
.dwc-filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.dwc-apply-filters,
.dwc-reset-filters {
    flex: 1;
    padding: 10px 20px;
    border: 2px solid #2C2A29;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dwc-apply-filters {
    background: #2C2A29;
    color: #ffffff;
}

.dwc-apply-filters:hover {
    background: #FEDD00;
    color: #2C2A29;
    border-color: #FEDD00;
}

.dwc-reset-filters {
    background: #ffffff;
    color: #2C2A29;
}

.dwc-reset-filters:hover {
    background: #f8f9fa;
}

/* Filter Widget in Sidebar */
.widget_dwc_filter_widget {
    margin-bottom: 30px;
}

.widget_dwc_filter_widget .dwc-filters-wrapper {
    padding: 15px;
    margin-bottom: 0;
}

.widget_dwc_filter_widget .dwc-filter-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
}

.widget_dwc_filter_widget .dwc-filter-title {
    font-size: 14px;
    margin-bottom: 12px;
}

/* Loading State for Filters */
.dwc-filters-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .dwc-filters-wrapper {
        padding: 15px;
    }
    
    .dwc-filter-actions {
        flex-direction: column;
    }
    
    .dwc-apply-filters,
    .dwc-reset-filters {
        width: 100%;
    }
}

/* Animations */
@keyframes dwc-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .dwc-columns-6 { grid-template-columns: repeat(4, 1fr); }
    .dwc-columns-5 { grid-template-columns: repeat(4, 1fr); }
    
    .dwc-product-image {
        height: 220px;
    }
}

@media (max-width: 1024px) {
    .dwc-columns-6 { grid-template-columns: repeat(3, 1fr); }
    .dwc-columns-5 { grid-template-columns: repeat(3, 1fr); }
    .dwc-columns-4 { grid-template-columns: repeat(3, 1fr); }
    
    .dwc-products-grid {
        gap: 20px;
    }
    
    .dwc-product-image {
        height: 200px;
    }
}

@media (max-width: 768px) {
    .dwc-columns-6 { grid-template-columns: repeat(2, 1fr); }
    .dwc-columns-5 { grid-template-columns: repeat(2, 1fr); }
    .dwc-columns-4 { grid-template-columns: repeat(2, 1fr); }
    .dwc-columns-3 { grid-template-columns: repeat(2, 1fr); }
    
    .dwc-products-grid {
        gap: 15px;
    }
    
    .dwc-product-image {
        height: 180px;
    }
    
    .dwc-sale-badge {
        top: 10px;
        left: 10px;
        padding: 4px 12px;
        font-size: 11px;
    }
    
    .dwc-product-content {
        padding: 15px;
        min-height: 100px;
    }
    
    .dwc-product-title {
        font-size: 14px;
        min-height: 40px;
    }
    
    .dwc-product-price {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .dwc-columns-6,
    .dwc-columns-5,
    .dwc-columns-4,
    .dwc-columns-3,
    .dwc-columns-2 {
        grid-template-columns: 1fr;
    }
    
    .dwc-products-grid {
        gap: 15px;
    }
    
    .dwc-product-image {
        height: 250px;
    }
    
    .dwc-product-item {
        max-width: 400px;
        margin: 0 auto;
    }
    
    .dwc-pagination a,
    .dwc-pagination span {
        padding: 6px 12px;
        font-size: 14px;
    }
}