/**
 * ShopLentor – Shopify-Style Premium Product Card
 * Extends the Modern Product Grid widget with premium features:
 * – Skeleton loader with shimmer
 * – Color swatches (circles)
 * – Size boxes with OOS treatment
 * – Contain-fit image with equal height
 * – Shopify-style black Add to Cart button
 *
 * @package WooLentor
 */

/* =========================================================
   SKELETON LOADER
   ========================================================= */

@keyframes wl-shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

/*
 * Skeleton is positioned absolutely over the image area.
 * This means it never contributes to layout height → zero CLS.
 * It fades out once JS adds .wl-img-loaded to the card.
 */
.wl-shopify-card .wl-skeleton-img {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: #e8e8e8;
    background-image: linear-gradient(
        90deg,
        #e8e8e8 0px,
        #f4f4f4 40px,
        #e8e8e8 80px
    );
    background-size: 600px 100%;
    animation: wl-shimmer 1.4s infinite linear;
    border-radius: inherit;
    transition: opacity 0.3s ease;
}

/* Hide skeleton placeholder once loaded */
.wl-shopify-card.wl-img-loaded .wl-skeleton-img {
    display: none;
}
.wl-shopify-card .woolentor-product-img {
    opacity: 0;
    transition: opacity 0.3s ease;
}
.wl-shopify-card.wl-img-loaded .woolentor-product-img {
    opacity: 1;
}

/* =========================================================
   SHOPIFY CARD – IMAGE AREA
   ========================================================= */

/*
 * The image container uses position:relative so the absolute-positioned
 * skeleton overlay does not add any height (zero CLS).
 * overflow:visible ensures object-fit:contain images are never cropped
 * by the container itself. The card-level overflow:hidden handles
 * border-radius clipping correctly.
 */
.wl-shopify-card .woolentor-product-image {
    position: relative;
    width: 100%;
    background: var(--wl-img-bg, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* NEVER crop — skeleton uses absolute positioning */
    box-sizing: border-box;
    /* Height: overridden by Elementor responsive slider; defaults below */
    height: var(--wl-img-height, 420px);
}

/* Inner link fills container */
.wl-shopify-card .woolentor-product-image > a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
    overflow: hidden; /* keeps image within the link area */
}

/*
 * The <img> itself:
 * – object-fit: contain — ALWAYS shows full product, no cropping
 * – object-position defaults to center; overridden via Elementor control
 * – width/height 100% fill the link container
 */
.wl-shopify-card .woolentor-product-image .woolentor-product-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: var(--wl-img-pos, center) !important;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    max-width: 100%;
}

/* Image zoom hover — subtle for contain mode */
.wl-shopify-card:hover .woolentor-product-image .woolentor-product-img {
    transform: scale(1.04);
}

/* ── Ratio modes ────────────────────────────────────────
   Applied as CSS classes from PHP; also driven by Elementor
   selector when the ratio SELECT is changed live.
   When a ratio class is present, height becomes auto so the
   aspect-ratio property governs the container dimensions.
   ──────────────────────────────────────────────────────── */
.wl-shopify-card .woolentor-product-image.wl-ratio-1-1   { aspect-ratio: 1 / 1;   height: auto !important; }
.wl-shopify-card .woolentor-product-image.wl-ratio-4-5   { aspect-ratio: 4 / 5;   height: auto !important; }
.wl-shopify-card .woolentor-product-image.wl-ratio-3-4   { aspect-ratio: 3 / 4;   height: auto !important; }
.wl-shopify-card .woolentor-product-image.wl-ratio-16-9  { aspect-ratio: 16 / 9;  height: auto !important; }

/* =========================================================
   COLOR SWATCHES
   ========================================================= */

.wl-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 10px 0 8px;
    align-items: center;
}

.wl-color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: inline-block;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
    box-sizing: border-box;
}

.wl-color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
}

.wl-color-swatch.wl-active,
.wl-color-swatch:focus {
    border-color: #111111;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #111111;
    transform: scale(1.1);
    outline: none;
}

/* Tooltip (screen-reader accessible) */
.wl-color-swatch[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #111;
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 20;
    pointer-events: none;
}

/* =========================================================
   SIZE BOXES
   ========================================================= */

.wl-size-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 10px;
    align-items: center;
}

.wl-size-box {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #111111;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    line-height: 1;
    position: relative;
    letter-spacing: 0.3px;
    box-sizing: border-box;
}

.wl-size-box:hover:not(.wl-oos) {
    border-color: #111111;
    background: #111111;
    color: #ffffff;
}

.wl-size-box.wl-active {
    border-color: #111111;
    background: #111111;
    color: #ffffff;
}

/* Out of Stock */
.wl-size-box.wl-oos {
    color: #9ca3af;
    background: #f3f4f6;
    border-color: #e5e7eb;
    cursor: not-allowed;
    pointer-events: none;
}

/* Crossed line for OOS */
.wl-size-box.wl-oos::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1.5px;
    background: #9ca3af;
    transform: rotate(-35deg);
    pointer-events: none;
}

/* =========================================================
   ADD TO CART BUTTON – SHOPIFY BLACK STYLE
   ========================================================= */

.wl-shopify-card .woolentor-product-actions {
    margin-top: auto;
    width: 100%;
}

.wl-shopify-card .woolentor-product-actions .woolentor-cart-btn,
.wl-shopify-card .woolentor-product-actions .button,
.wl-shopify-card .woolentor-product-actions .add_to_cart_button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: #111111 !important;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    padding: 13px 20px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    gap: 8px;
    min-height: 46px;
    position: relative;
    overflow: hidden;
}

.wl-shopify-card .woolentor-product-actions .woolentor-cart-btn:hover,
.wl-shopify-card .woolentor-product-actions .button:hover,
.wl-shopify-card .woolentor-product-actions .add_to_cart_button:hover {
    background: #333333 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    color: #ffffff !important;
}

/* Loading state */
.wl-shopify-card .woolentor-cart-btn.loading,
.wl-shopify-card .add_to_cart_button.loading {
    pointer-events: none;
}

/* Cart spinner */
.wl-shopify-card .woolentor-cart-btn.loading::after,
.wl-shopify-card .add_to_cart_button.loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: wl-spin 0.65s linear infinite;
    margin-left: 8px;
}

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

/* Added success state */
.wl-shopify-card .add_to_cart_button.added::after {
    font-family: 'WooCommerce';
    content: '\e017';
    margin-left: 6px;
    vertical-align: bottom;
}

/* Hide "View cart" link that WooCommerce appends */
.wl-shopify-card .woolentor-product-actions a.added_to_cart {
    display: none !important;
}

/* =========================================================
   PRODUCT TITLE – 2-LINE CLAMP
   ========================================================= */

.wl-shopify-card .woolentor-product-title {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: calc(1.4em * 2);
}

/* =========================================================
   CARD LAYOUT / SPACING
   ========================================================= */

.wl-shopify-card.woolentor-grid-card {
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.wl-shopify-card.woolentor-grid-card:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    transform: translateY(-3px);
}

.wl-shopify-card .woolentor-product-content {
    padding: 16px;
}

/* =========================================================
   SUCCESS TOAST NOTIFICATION
   ========================================================= */

.wl-atc-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111111;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 99999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
}

.wl-atc-toast.wl-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =========================================================
   RTL SUPPORT
   ========================================================= */

[dir="rtl"] .wl-color-swatch[title]:hover::after {
    left: auto;
    right: 50%;
    transform: translateX(50%);
}

[dir="rtl"] .wl-size-boxes,
[dir="rtl"] .wl-color-swatches {
    direction: rtl;
}

/* =========================================================
   RESPONSIVE DEFAULTS
   Desktop: 420px  |  Tablet: 340px  |  Mobile: 260px
   These are overridden by Elementor responsive slider controls.
   ========================================================= */

/* Desktop default (also the base value) */
.wl-shopify-card .woolentor-product-image {
    height: var(--wl-img-height, 420px);
}

/* Tablet (≤ 1024px) */
@media (max-width: 1024px) {
    .wl-shopify-card .woolentor-product-image {
        height: var(--wl-img-height-tablet, 340px);
    }
}

/* Mobile (≤ 767px) */
@media (max-width: 767px) {
    .wl-shopify-card .woolentor-product-image {
        height: var(--wl-img-height-mobile, 260px);
    }
    .wl-color-swatch {
        width: 20px;
        height: 20px;
    }
    .wl-size-box {
        min-width: 32px;
        height: 32px;
        font-size: 11px;
    }
}

/* When ratio is active (set via JS detecting --wl-img-ratio var) the
   JS adds data-wl-ratio attr and height becomes auto via the rule below */
.wl-shopify-card .woolentor-product-image[data-wl-ratio] {
    height: auto !important;
}
