/**
 * Product Card Design 2
 * Matches Reference 1 (Normal State) and Reference 2 (Hover State)
 * Modern clean grocery/pharma/ecommerce layout with:
 * - Top-left discount percentage badge
 * - Top-right wishlist button
 * - Zoom on hover with overflow protection
 * - Centered pill Quick View button appearing on hover
 * - Clean title, price, dynamic variant pills
 * - Social proof / purchase indicator ("1+ people have bought this")
 * - Full-width solid Add to Cart button
 * - Full independent admin customizability (visibility, ordering, spacing, colors)
 */

:root {
    --nt-d2-primary: var(--theme-primary-color, #e11d48);
    --nt-d2-primary-hover: color-mix(in srgb, var(--nt-d2-primary) 85%, #000000);
    --nt-d2-bg-color: #ffffff;
    --nt-d2-border-color: #f1f3f5;
    --nt-d2-hover-border-color: #e2e8f0;
    --nt-d2-hover-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    --nt-d2-card-radius: 14px;
    --nt-d2-card-padding: 12px 14px 16px 14px;
    --nt-d2-card-bottom-padding: 16px;
    --nt-d2-card-height: auto;
    --nt-d2-card-min-height: 0px;
    --nt-d2-card-max-height: none;
    --nt-d2-grid-gap: 24px;

    /* Image area */
    --nt-d2-img-height: 220px;
    --nt-d2-img-padding: 10px;
    --nt-d2-img-bg: #ffffff;
    --nt-d2-img-radius: 10px;
    --nt-d2-img-fit: contain;
    --nt-d2-img-zoom-scale: 1.08;
    --nt-d2-img-transition-duration: 0.35s;
    --nt-d2-img-content-gap: 14px;

    /* Quick View button */
    --nt-d2-quickview-bg: #202938;
    --nt-d2-quickview-text-color: #ffffff;
    --nt-d2-quickview-radius: 9999px;

    /* Content Typography & Spacing */
    --nt-d2-title-color: #111827;
    --nt-d2-title-margin: 8px;
    --nt-d2-price-color: #111827;
    --nt-d2-del-color: #9ca3af;
    --nt-d2-price-margin: 12px;
    --nt-d2-var-margin: 12px;
    --nt-d2-desc-color: #6b7280;
    --nt-d2-desc-margin: 10px;
    --nt-d2-rating-gap: 8px;

    /* Variants */
    --nt-d2-var-bg: #ffffff;
    --nt-d2-var-border: #e2e8f0;
    --nt-d2-var-text: #475569;
    --nt-d2-var-active-bg: #ffffff;
    --nt-d2-var-active-border: var(--theme-primary-color, #e11d48);
    --nt-d2-var-active-text: var(--theme-primary-color, #e11d48);

    /* Social Proof */
    --nt-d2-social-proof-bg: #fefce8;
    --nt-d2-social-proof-border: #fef08a;
    --nt-d2-social-proof-text-color: #854d0e;
    --nt-d2-social-proof-icon-color: #a16207;
    --nt-d2-social-proof-margin: 12px;

    /* Add to Cart button */
    --nt-d2-btn-bg: var(--theme-primary-color, #e11d48);
    --nt-d2-btn-text-color: #ffffff;
    --nt-d2-btn-radius: 8px;
    --nt-d2-btn-height: 42px;
    --nt-d2-btn-width: 100%;
    --nt-d2-btn-cart-margin: 0px;

    /* Badges & Icons */
    --nt-d2-badge-bg: var(--theme-primary-color, #e11d48);
    --nt-d2-badge-text-color: #ffffff;
    --nt-d2-wishlist-color: #64748b;
    --nt-d2-wishlist-active-color: var(--theme-primary-color, #e11d48);

    /* Element Ordering Defaults */
    --nt-d2-order-title: 1;
    --nt-d2-order-price: 2;
    --nt-d2-order-variant: 3;
    --nt-d2-order-social_proof: 4;
    --nt-d2-order-add_to_cart: 5;
    --nt-d2-order-description: 6;
    --nt-d2-order-rating: 7;

    /* Element Visibility Defaults */
    --nt-d2-show-badge: inline-block;
    --nt-d2-show-wishlist: inline-flex;
    --nt-d2-show-image: flex;
    --nt-d2-show-quickview: inline-flex;
    --nt-d2-show-title: block;
    --nt-d2-show-price: flex;
    --nt-d2-show-regular_price: inline;
    --nt-d2-show-variations: flex;
    --nt-d2-show-social_proof: flex;
    --nt-d2-show-add_to_cart: block;
    --nt-d2-show-description: none;
    --nt-d2-show-rating: none;
}

/* ==================== CARD CONTAINER ==================== */
.nt-card-d2,
.productItem.nt-card-d2 {
    position: relative;
    background: var(--nt-d2-bg-color, #ffffff);
    border: 1px solid var(--nt-d2-border-color, #f1f3f5);
    border-radius: var(--nt-d2-card-radius, 14px);
    padding: var(--nt-d2-card-padding, 12px 14px 16px 14px);
    padding-bottom: var(--nt-d2-card-bottom-padding, 16px);
    display: flex;
    flex-direction: column;
    height: var(--nt-d2-card-height, auto);
    min-height: var(--nt-d2-card-min-height, 0);
    max-height: var(--nt-d2-card-max-height, none);
    box-sizing: border-box;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: visible;
}

.nt-card-d2:hover {
    transform: translateY(-3px);
    box-shadow: var(--nt-d2-hover-shadow, 0 10px 25px rgba(0, 0, 0, 0.08));
    border-color: var(--nt-d2-hover-border-color, #e2e8f0);
}

/* Flex Column Containers (for uniform height in grids) */
.row > [class*="col-"]:has(> .nt-card-d2),
.nt-bestsellers-section .row > [class*="col-"]:has(> .nt-card-d2) {
    display: flex;
    flex-direction: column;
}

[class*="col-"] > .nt-card-d2,
.nt-carousel-item > .nt-card-d2 {
    flex: var(--nt-d2-card-flex, 1 1 auto);
}

/* ==================== TOP BAR (DISCOUNT BADGE & WISHLIST) ==================== */
.nt-d2-top-bar {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 5;
}

/* Discount Badge (-5%) */
.nt-d2-badge {
    display: var(--nt-d2-show-badge, inline-block);
    pointer-events: auto;
    background: var(--nt-d2-badge-bg, var(--theme-primary-color, #e11d48));
    color: var(--nt-d2-badge-text-color, #ffffff);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    padding: 3px 8px;
    border-radius: 9999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* Wishlist Button */
.nt-d2-wishlist-btn {
    display: var(--nt-d2-show-wishlist, inline-flex);
    pointer-events: auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: var(--nt-d2-wishlist-color, #64748b);
    font-size: 16px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nt-d2-wishlist-btn:hover {
    color: var(--theme-primary-color, #e11d48);
    border-color: var(--theme-primary-color, #e11d48);
    transform: scale(1.08);
}

.nt-d2-wishlist-btn.active-wishlist {
    color: var(--nt-d2-wishlist-active-color, var(--theme-primary-color, #e11d48));
    border-color: var(--theme-primary-color, #e11d48);
    background: #ffffff;
}

/* ==================== PRODUCT IMAGE AREA & ZOOM ==================== */
.nt-d2-thumb-wrap {
    position: relative;
    width: 100%;
    height: var(--nt-d2-img-height, 220px);
    background: var(--nt-d2-img-bg, #ffffff);
    border-radius: var(--nt-d2-img-radius, 10px);
    padding: var(--nt-d2-img-padding, 10px);
    overflow: hidden;
    display: var(--nt-d2-show-image, flex);
    align-items: center;
    justify-content: center;
    margin-bottom: var(--nt-d2-img-content-gap, 14px);
    box-sizing: border-box;
}

.nt-d2-thumb-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
    overflow: hidden;
}

.nt-d2-thumb-img {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: var(--nt-d2-img-fit, contain);
    object-position: center;
    transition: transform var(--nt-d2-img-transition-duration, 0.35s) cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
}

/* Hover Zoom on Product Image */
.nt-card-d2:hover .nt-d2-thumb-img {
    transform: scale(var(--nt-d2-img-zoom-scale, 1.08));
}

/* ==================== QUICK VIEW BUTTON ON HOVER ==================== */
.nt-d2-quickview-btn {
    display: var(--nt-d2-show-quickview, inline-flex);
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translate(-50%, 8px);
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--nt-d2-quickview-bg, #202938);
    color: var(--nt-d2-quickview-text-color, #ffffff) !important;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 18px;
    border-radius: var(--nt-d2-quickview-radius, 9999px);
    border: none;
    cursor: pointer;
    text-decoration: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    z-index: 4;
    white-space: nowrap;
}

.nt-d2-quickview-btn i {
    font-size: 15px;
    line-height: 1;
}

.nt-card-d2:hover .nt-d2-quickview-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.nt-d2-quickview-btn:hover {
    background: color-mix(in srgb, var(--nt-d2-quickview-bg, #202938) 85%, #000000);
    color: #ffffff !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* ==================== PRODUCT BODY ==================== */
.nt-d2-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    box-sizing: border-box;
}

/* Title */
.nt-d2-title {
    display: var(--nt-d2-show-title, block);
    order: var(--nt-d2-order-title, 1);
    font-size: 15px;
    font-weight: 700;
    color: var(--nt-d2-title-color, #111827);
    line-height: 1.35;
    margin: 0 0 var(--nt-d2-title-margin, 8px) 0;
    letter-spacing: 0.01em;
}

.nt-d2-title a {
    color: inherit;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.nt-d2-title a:hover {
    color: var(--theme-primary-color, #e11d48);
}

/* Price Wrap */
.nt-d2-price-wrap {
    display: var(--nt-d2-show-price, flex);
    order: var(--nt-d2-order-price, 2);
    align-items: baseline;
    gap: 8px;
    margin-bottom: var(--nt-d2-price-margin, 12px);
}

.nt-d2-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--nt-d2-price-color, #111827);
    line-height: 1.2;
}

.nt-d2-price-del {
    display: var(--nt-d2-show-regular_price, inline);
    font-size: 13px;
    font-weight: 500;
    color: var(--nt-d2-del-color, #9ca3af);
    text-decoration: line-through;
}

/* Product Variations (Pills: 100g, 200g, etc.) */
.nt-d2-variations {
    display: var(--nt-d2-show-variations, flex);
    order: var(--nt-d2-order-variant, 3);
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--nt-d2-var-margin, 12px);
}

.nt-d2-size-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    min-width: 48px;
    border-radius: 6px;
    background: var(--nt-d2-var-bg, #ffffff);
    border: 1px solid var(--nt-d2-var-border, #e2e8f0);
    color: var(--nt-d2-var-text, #475569);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

.nt-d2-size-box:not(.active):hover,
.nt-d2-size-box:not(.active):focus-visible {
    border-color: var(--theme-primary-color, #e11d48);
    color: var(--theme-primary-color, #e11d48);
    background-color: #fff1f2;
    outline: none;
}

/* Selected Variant State: Matches Reference 1 (Bold primary border + primary text) */
.nt-card-d2 .nt-d2-size-box.active {
    background: var(--nt-d2-var-active-bg, #ffffff) !important;
    background-color: var(--nt-d2-var-active-bg, #ffffff) !important;
    border: 2px solid var(--nt-d2-var-active-border, var(--theme-primary-color, #e11d48)) !important;
    border-color: var(--nt-d2-var-active-border, var(--theme-primary-color, #e11d48)) !important;
    color: var(--nt-d2-var-active-text, var(--theme-primary-color, #e11d48)) !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 4px rgba(225, 29, 72, 0.15) !important;
}

/* Short Description (Optional) */
.nt-d2-desc {
    display: var(--nt-d2-show-description, none);
    order: var(--nt-d2-order-description, 4);
    font-size: 13px;
    line-height: 1.45;
    color: var(--nt-d2-desc-color, #6b7280);
    margin: 0 0 var(--nt-d2-desc-margin, 10px) 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Rating Stars (Optional) */
.nt-d2-rating {
    display: var(--nt-d2-show-rating, none);
    order: var(--nt-d2-order-rating, 5);
    align-items: center;
    gap: 3px;
    margin-bottom: var(--nt-d2-rating-gap, 8px);
    color: #9ca3af;
    font-size: 13px;
}

.nt-d2-rating.is-rated,
.nt-d2-rating .ri-star-fill {
    color: #f59e0b;
}

/* Bottom Section Container: Anchors Divider, Social Proof, and Add to Cart Button to Bottom */
.nt-card-d2 .nt-d2-body .nt-d2-bottom-wrap,
.productItem.nt-card-d2 .nt-d2-body .nt-d2-bottom-wrap,
.nt-d2-bottom-wrap {
    order: var(--nt-d2-order-bottom_wrap, 99) !important;
    margin-top: auto !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
}

/* Horizontal Divider above Social Proof */
.nt-d2-bottom-wrap .nt-d2-divider,
.nt-d2-divider {
    order: 1 !important;
    width: 100%;
    border: none;
    border-top: 1px solid #eef2f6;
    margin: 12px 0 10px 0;
    box-sizing: border-box;
}

/* Social Proof / Purchase Indicator */
.nt-d2-bottom-wrap .nt-d2-social-proof,
.nt-d2-social-proof {
    display: var(--nt-d2-show-social_proof, flex);
    order: var(--nt-d2-order-social_proof, 2) !important;
    align-items: center;
    gap: 8px;
    background: var(--nt-d2-social-proof-bg, #fefce8);
    border: 1px solid var(--nt-d2-social-proof-border, #fef08a);
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: var(--nt-d2-social-proof-margin, 10px);
    font-size: 12px;
    font-weight: 600;
    color: var(--nt-d2-social-proof-text-color, #854d0e);
    box-sizing: border-box;
    width: 100%;
}

.nt-d2-social-proof i {
    font-size: 15px;
    color: var(--nt-d2-social-proof-icon-color, #a16207);
    flex-shrink: 0;
}

.nt-d2-social-proof-text {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Add to Cart Button Container & Button */
.nt-d2-bottom-wrap .nt-d2-btn-cart-wrap,
.nt-d2-btn-cart-wrap {
    display: var(--nt-d2-show-add_to_cart, block);
    order: var(--nt-d2-order-add_to_cart, 3) !important;
    margin-top: 0;
    margin-bottom: var(--nt-d2-btn-cart-margin, 0px);
    width: 100%;
}

.nt-d2-btn-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: var(--nt-d2-btn-width, 100%);
    height: var(--nt-d2-btn-height, 42px);
    background: var(--nt-d2-btn-bg, var(--theme-primary-color, #e11d48));
    color: var(--nt-d2-btn-text-color, #ffffff) !important;
    border: none;
    border-radius: var(--nt-d2-btn-radius, 8px);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.nt-d2-btn-cart i {
    font-size: 16px;
    line-height: 1;
}

.nt-d2-btn-cart:hover:not(.is-loading):not(.is-stock-out) {
    background: color-mix(in srgb, var(--nt-d2-btn-bg, var(--theme-primary-color, #e11d48)) 88%, #000000);
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.3);
}

.nt-d2-btn-cart:active:not(.is-loading):not(.is-stock-out) {
    transform: translateY(0);
}

.nt-d2-btn-cart.is-stock-out {
    background: #94a3b8 !important;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
}

/* Loading State for Add to Cart */
.nt-d2-btn-cart.is-loading,
.nt-d1-btn-cart.is-loading {
    opacity: 0.85 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    transform: none !important;
    box-shadow: none !important;
}

@keyframes nt-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.ri-loader-4-line.ri-spin,
.ri-spin,
.nt-spin {
    display: inline-block;
    animation: nt-spin 0.85s linear infinite !important;
}

/* ==================== RESPONSIVE BEHAVIOR ==================== */
/* Tablet */
@media (max-width: 991px) and (min-width: 577px) {
    .nt-card-d2,
    .productItem.nt-card-d2 {
        height: var(--nt-d2-card-height-tablet, var(--nt-d2-card-height, auto));
    }
    .nt-d2-thumb-wrap {
        height: 190px;
    }
}

/* Mobile & Touch (<768px): Quick View accessible on touch, clean tap targets */
@media (max-width: 768px) {
    .nt-card-d2,
    .productItem.nt-card-d2 {
        height: var(--nt-d2-card-height-mobile, var(--nt-d2-card-height, auto));
        padding: 10px 10px 14px 10px;
    }
    .nt-d2-thumb-wrap {
        height: 175px;
        margin-bottom: 10px;
    }
    .nt-d2-quickview-btn {
        /* Always show on mobile without relying on mouse hover */
        opacity: 0.95;
        pointer-events: auto;
        transform: translate(-50%, 0);
        padding: 5px 12px;
        font-size: 11.5px;
        bottom: 8px;
    }
    .nt-d2-title {
        font-size: 14px;
        margin-bottom: 6px;
    }
    .nt-d2-price {
        font-size: 16px;
    }
    .nt-d2-size-box {
        padding: 3px 8px;
        min-width: 40px;
        font-size: 11.5px;
    }
    .nt-d2-social-proof {
        padding: 5px 8px;
        font-size: 11px;
    }
    .nt-d2-btn-cart {
        height: 38px;
        font-size: 12.5px;
    }
}
