/* =====================================================================
   Zasmobel Product Grid — Styles
   Version: 1.0.0
   ===================================================================== */

/* ── CSS Custom Properties ─────────────────────────────────────────── */
:root {
    --zmg-columns: 4;
    --zmg-gap: 24px;
    --zmg-card-bg: #ffffff;
    --zmg-card-radius: 0;
    --zmg-title-color: #1a1a1a;
    --zmg-title-size: 14px;
    --zmg-price-color: #1a1a1a;
    --zmg-price-size: 18px;
    --zmg-star-color: #f5a623;
    --zmg-star-empty: #d4d4d4;
    --zmg-star-size: 12px;
    --zmg-btn-bg: #c8102e;
    --zmg-btn-color: #ffffff;
    --zmg-btn-hover: #a50d24;
    --zmg-btn-radius: 3px;
    --zmg-btn-font-size: 11px;
    --zmg-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Grid Container ────────────────────────────────────────────────── */
.zmg-grid-wrapper {
    width: 100%;
    box-sizing: border-box;
}

.zmg-grid {
    display: grid;
    grid-template-columns: repeat(var(--zmg-columns, 4), 1fr);
    gap: var(--zmg-gap, 24px);
    width: 100%;
    box-sizing: border-box;
}

/* ── Grid Title ────────────────────────────────────────────────────── */
.zmg-grid-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 20px;
    padding: 0;
    text-align: center;
}

/* ── Product Card ──────────────────────────────────────────────────── */
.zmg-product-card {
    background-color: var(--zmg-card-bg);
    border-radius: var(--zmg-card-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--zmg-transition), transform var(--zmg-transition);
    position: relative;
}

.zmg-product-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* ── Product Image ─────────────────────────────────────────────────── */
.zmg-product-link {
    display: block;
    text-decoration: none;
    overflow: hidden;
}

.zmg-product-image {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 aspect ratio */
    overflow: hidden;
    background-color: #f5f5f5;
}

.zmg-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

.zmg-product-card:hover .zmg-product-image img {
    transform: scale(1.05);
}

.zmg-no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9f9f9;
}

/* ── Product Info ──────────────────────────────────────────────────── */
.zmg-product-info {
    padding: 16px 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    flex-grow: 1;
}

/* ── Title ─────────────────────────────────────────────────────────── */
.zmg-product-title-link {
    text-decoration: none;
    color: inherit;
}

.zmg-product-title-link:hover {
    text-decoration: none;
    color: inherit;
}

.zmg-product-title {
    font-family: inherit;
    font-size: var(--zmg-title-size, 14px);
    font-weight: 400;
    color: var(--zmg-title-color, #1a1a1a);
    margin: 0;
    padding: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Star Rating ───────────────────────────────────────────────────── */
.zmg-product-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    line-height: 1;
}

.zmg-stars {
    display: inline-flex;
    gap: 1px;
    align-items: center;
}

.zmg-star {
    font-size: var(--zmg-star-size, 12px);
    line-height: 1;
    display: inline-block;
}

.zmg-star--full {
    color: var(--zmg-star-color, #f5a623);
}

.zmg-star--half {
    color: var(--zmg-star-color, #f5a623);
    position: relative;
    display: inline-block;
}

.zmg-star--empty {
    color: var(--zmg-star-empty, #d4d4d4);
}

/* ── Price ──────────────────────────────────────────────────────────── */
.zmg-product-price {
    font-size: var(--zmg-price-size, 18px);
    font-weight: 700;
    color: var(--zmg-price-color, #1a1a1a);
    line-height: 1.3;
    margin: 2px 0 4px;
    text-align: center;
}

.zmg-product-price del {
    font-size: 0.8em;
    color: #999;
    font-weight: 400;
    margin-right: 6px;
}

.zmg-product-price ins {
    text-decoration: none;
    font-weight: 700;
}

/* ── Button ────────────────────────────────────────────────────────── */
.zmg-product-button {
    display: inline-block;
    background-color: var(--zmg-btn-bg, #c8102e);
    color: var(--zmg-btn-color, #ffffff);
    font-size: var(--zmg-btn-font-size, 11px);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-decoration: none;
    text-align: center;
    padding: 9px 18px;
    border: none;
    border-radius: var(--zmg-btn-radius, 3px);
    cursor: pointer;
    transition: background-color var(--zmg-transition), transform var(--zmg-transition), box-shadow var(--zmg-transition);
    align-self: center;
    line-height: 1.3;
    margin-top: auto;
}

.zmg-product-button:hover {
    background-color: var(--zmg-btn-hover, #a50d24);
    color: var(--zmg-btn-color, #ffffff);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.35);
    text-decoration: none;
}

.zmg-product-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(200, 16, 46, 0.25);
}

/* ── No Products ───────────────────────────────────────────────────── */
.zmg-no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #888;
    font-size: 16px;
}

/* ── Pagination ────────────────────────────────────────────────────── */
.zmg-pagination {
    margin-top: 40px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.zmg-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background-color: #ffffff;
    color: #1a1a1a;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--zmg-transition);
}

.zmg-pagination .page-numbers:hover {
    background-color: #c8102e;
    color: #ffffff;
    border-color: #c8102e;
    text-decoration: none;
}

.zmg-pagination .page-numbers.current {
    background-color: #c8102e;
    color: #ffffff;
    border-color: #c8102e;
    font-weight: 700;
}

.zmg-pagination .page-numbers.dots {
    border: none;
    background: transparent;
    color: #888;
    cursor: default;
    pointer-events: none;
}

/* ── Load More Container & Progress Bar ────────────────────────────── */
.zmg-load-more-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}

.zmg-load-more-counter {
    font-family: inherit;
    font-size: 15px;
    font-weight: 400;
    color: #1a1a1a;
    margin-bottom: 12px;
    text-align: center;
}

.zmg-load-more-bar-container {
    width: 100%;
    height: 6px;
    background-color: #e5e5e5;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 24px;
}

.zmg-load-more-bar {
    height: 100%;
    background-color: #d13d25;
    width: 0;
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Load More Button (Updated) ────────────────────────────────────── */
.zmg-pagination .zmg-load-more {
    display: inline-block;
    width: 100%;
    padding: 16px 30px;
    background-color: var(--zmg-btn-bg, #c8102e);
    color: var(--zmg-btn-color, #ffffff);
    border: 1px solid var(--zmg-btn-bg, #c8102e);
    border-radius: 0;
    font-size: 15px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: all var(--zmg-transition);
    box-sizing: border-box;
}

.zmg-pagination .zmg-load-more:hover {
    background-color: #ffffff;
    color: var(--zmg-btn-bg, #c8102e);
    border-color: var(--zmg-btn-bg, #c8102e);
    box-shadow: none;
    transform: none;
}

.zmg-pagination .zmg-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--zmg-btn-bg, #c8102e);
    color: var(--zmg-btn-color, #ffffff);
    border-color: var(--zmg-btn-bg, #c8102e);
}

.zmg-load-more.zmg-loading {
    position: relative;
    color: transparent !important;
}

.zmg-load-more.zmg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: zmg-spin 0.6s linear infinite;
}

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

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .zmg-grid {
        --zmg-columns: 3;
    }
}

@media (max-width: 768px) {
    .zmg-grid {
        --zmg-columns: 2;
        gap: 16px;
    }

    .zmg-product-info {
        padding: 12px 0 6px;
    }

    .zmg-product-title {
        font-size: 13px;
    }

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

@media (max-width: 575px) {
    .zmg-grid {
        --zmg-columns: var(--zmg-columns-mobile, 1);
        gap: 16px;
    }

    .zmg-product-image {
        padding-top: 65%;
    }
}

/* ── Infinite scroll trigger (hidden button) ───────────────────────── */
.zmg-infinite-trigger {
    visibility: hidden;
    height: 1px;
    padding: 0;
    margin: 0;
    border: none;
}

/* ── YITH Filter Compatibility ─────────────────────────────────────── */
/* Ensure smooth transitions when YITH replaces content */
.zmg-grid-wrapper.yith-wcan-container {
    transition: opacity 0.3s ease;
}

.zmg-grid-wrapper.yith-wcan-container.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* YITH active filter badges — blend with our design */
.yith-wcan-filters .yith-wcan-filter .filter-items a {
    transition: all var(--zmg-transition);
}

/* ── Fade-in animation for products ────────────────────────────────── */
.zmg-product-card {
    animation: zmg-fadeInUp 0.4s ease forwards;
    opacity: 0;
}

@keyframes zmg-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation delay for first load */
.zmg-product-card:nth-child(1)  { animation-delay: 0.02s; }
.zmg-product-card:nth-child(2)  { animation-delay: 0.06s; }
.zmg-product-card:nth-child(3)  { animation-delay: 0.10s; }
.zmg-product-card:nth-child(4)  { animation-delay: 0.14s; }
.zmg-product-card:nth-child(5)  { animation-delay: 0.18s; }
.zmg-product-card:nth-child(6)  { animation-delay: 0.22s; }
.zmg-product-card:nth-child(7)  { animation-delay: 0.26s; }
.zmg-product-card:nth-child(8)  { animation-delay: 0.30s; }
.zmg-product-card:nth-child(9)  { animation-delay: 0.34s; }
.zmg-product-card:nth-child(10) { animation-delay: 0.38s; }
.zmg-product-card:nth-child(11) { animation-delay: 0.42s; }
.zmg-product-card:nth-child(12) { animation-delay: 0.46s; }

/* ── Elementor editor preview ──────────────────────────────────────── */
.elementor-editor-active .zmg-product-card {
    animation: none;
    opacity: 1;
}
