/**
 * WooCommerce Products Grid - Styles
 * 
 * Đường dẫn: wp-content/plugins/woo-products-elementor-widget/assets/css/products-grid.css
 */

/* ========== WRAPPER ========== */
.woo-products-widget {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* ========== PRODUCTS GRID ========== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    width: 100%;
}

/* Responsive columns */
@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== PRODUCT ITEM ========== */
.product-item {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.product-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* ========== PRODUCT IMAGE ========== */
.product-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: transparent;
    /* Bỏ màu nền */
}

/* Image ratio với ::before cho các tỷ lệ cố định */
.product-image:not(.ratio-original)::before {
    content: "";
    display: block;
    padding-top: 100%;
    /* Default 1:1 ratio */
}

/* Tỷ lệ gốc - không dùng ::before */
.product-image.ratio-original {
    position: relative;
}

.product-image.ratio-original img {
    position: relative;
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Image ratios */
.product-image.ratio-1-1::before {
    padding-top: 100%;
}

.product-image.ratio-4-3::before {
    padding-top: 75%;
}

.product-image.ratio-3-4::before {
    padding-top: 133.33%;
}

.product-image.ratio-16-9::before {
    padding-top: 56.25%;
}

.product-image.ratio-9-16::before {
    padding-top: 177.78%;
}

/* Image positioning cho tỷ lệ cố định */
.product-image:not(.ratio-original) img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-item:hover .product-image:not(.ratio-original) img {
    transform: scale(1.05);
}

.product-image a {
    display: block;
    width: 100%;
    height: 100%;
}

/* ========== PRODUCT CONTENT ========== */
.product-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ========== PRODUCT TITLE ========== */
.product-title {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.product-title a:hover {
    color: #0073aa;
}

/* ========== PRODUCT PRICE ========== */
.product-price {
    margin: 0 0 15px;
    font-size: 18px;
    font-weight: 700;
    color: #e74c3c;
}

.product-price .price-prefix {
    font-size: inherit;
    /* Dùng chung font-size với giá */
    font-weight: inherit;
    /* Dùng chung font-weight với giá */
    color: #666;
    /* Màu riêng cho tiền tố */
    margin-right: 5px;
}

.product-price .amount {
    color: inherit;
}

.product-price del {
    opacity: 0.5;
    font-weight: 400;
    margin-right: 8px;
}

.product-price ins {
    text-decoration: none;
}

/* ========== PRODUCT EXCERPT ========== */
.product-excerpt {
    margin: 0 0 15px;
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    flex: 1;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-line-clamp: 3;
    /* Mặc định 3 dòng */
}

.product-excerpt ul {
    list-style: none;
    padding: 0;
}

.product-excerpt ul li {
    padding: 2px 0;
}

/* ========== PRODUCT BUTTONS ========== */
.product-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.product-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    white-space: nowrap;
}

/* Icon color matches text color */
.product-button i,
.product-button svg {
    width: 16px;
    height: 16px;
    color: inherit;
    /* Icon dùng màu chung với text */
    fill: currentColor;
}

/* ========== THEME STYLE MODE ========== */
/* Khi dùng style của theme, các class này sẽ kế thừa từ theme */
.woo-products-widget[data-button-style="theme"] .product-button {
    /* Inherit from theme */
    all: revert;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ========== CUSTOM STYLE MODE ========== */
/* Default custom styles (có thể override bằng Elementor) */
.woo-products-widget[data-button-style="custom"] .product-button.add-to-cart {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.woo-products-widget[data-button-style="custom"] .product-button.add-to-cart:hover {
    background: #005a87;
    border-color: #005a87;
}

.woo-products-widget[data-button-style="custom"] .product-button.view-details {
    background: transparent;
    color: #333;
    border-color: #ddd;
}

.woo-products-widget[data-button-style="custom"] .product-button.view-details:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.woo-products-widget[data-button-style="custom"] .product-button.custom-button-1,
.woo-products-widget[data-button-style="custom"] .product-button.custom-button-2 {
    background: #6c757d;
    color: #fff;
    border-color: #6c757d;
}

.woo-products-widget[data-button-style="custom"] .product-button.custom-button-1:hover,
.woo-products-widget[data-button-style="custom"] .product-button.custom-button-2:hover {
    background: #5a6268;
    border-color: #5a6268;
}

/* Loading state */
.product-button.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* ========== PAGINATION ========== */
.products-pagination {
    margin: 30px 0 0;
    text-align: center;
}

/* Theme style mode */
.woo-products-widget[data-pagination-style="theme"] .products-pagination .page-numbers {
    /* Inherit from theme */
    all: revert;
}

/* Custom style mode */
.woo-products-widget[data-pagination-style="custom"] .products-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 3px;
    font-size: 14px;
    color: #333;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.woo-products-widget[data-pagination-style="custom"] .products-pagination .page-numbers:hover,
.woo-products-widget[data-pagination-style="custom"] .products-pagination .page-numbers.current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.woo-products-widget[data-pagination-style="custom"] .products-pagination .page-numbers.dots {
    border: none;
    background: transparent;
    cursor: default;
}

.woo-products-widget[data-pagination-style="custom"] .products-pagination .page-numbers.prev,
.woo-products-widget[data-pagination-style="custom"] .products-pagination .page-numbers.next {
    font-weight: 600;
}

/* ========== LOAD MORE BUTTON ========== */
.load-more-wrapper {
    text-align: center;
    margin: 30px 0 0;
}

/* Theme style mode */
.woo-products-widget[data-loadmore-style="theme"] .load-more-btn {
    /* Inherit from theme */
    all: revert;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Custom style mode */
.woo-products-widget[data-loadmore-style="custom"] .load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    background: #0073aa;
    border: 2px solid #0073aa;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.woo-products-widget[data-loadmore-style="custom"] .load-more-btn:hover:not(:disabled) {
    background: #005a87;
    border-color: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 115, 170, 0.3);
}

.load-more-btn:disabled,
.load-more-btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.load-more-btn.error {
    background: #e74c3c;
    border-color: #e74c3c;
}

/* Spinner animation */
.load-more-btn .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== NO PRODUCTS MESSAGE ========== */
.no-products-message {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-item {
    animation: fadeIn 0.4s ease forwards;
}

/* Stagger animation for grid items */
.product-item:nth-child(1) {
    animation-delay: 0s;
}

.product-item:nth-child(2) {
    animation-delay: 0.05s;
}

.product-item:nth-child(3) {
    animation-delay: 0.1s;
}

.product-item:nth-child(4) {
    animation-delay: 0.15s;
}

.product-item:nth-child(5) {
    animation-delay: 0.2s;
}

.product-item:nth-child(6) {
    animation-delay: 0.25s;
}

.product-item:nth-child(7) {
    animation-delay: 0.3s;
}

.product-item:nth-child(8) {
    animation-delay: 0.35s;
}

/* ========== RESPONSIVE ADJUSTMENTS ========== */
@media (max-width: 768px) {
    .product-content {
        padding: 12px;
    }

    .product-title {
        font-size: 14px;
    }

    .product-price {
        font-size: 16px;
    }

    .product-buttons {
        flex-direction: column;
    }

    .product-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .product-buttons {
        gap: 8px;
    }

    .product-button {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* ========== UTILITY CLASSES ========== */
/* Text alignment utilities */
.text-left {
    text-align: left !important;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-justify {
    text-align: justify !important;
}