/* ==========================================================================
   MercadoLibre-Style Product Card System
   Inspired by https://www.mercadolibre.cl/
   ========================================================================== */

/* ── Card Container ─────────────────────────────────────────── */
.ml-product-card {
    position: relative;
    background: #fff;
    border: 1px solid #ededed;
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow .25s ease, transform .2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    cursor: pointer;
}

.ml-product-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, .1);
    transform: translateY(-2px);
    z-index: 2;
}

/* ── Image Area ─────────────────────────────────────────────── */
.ml-card-img {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
    background: #fff;
}

.ml-card-img a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.ml-card-img img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform .35s ease;
    border-radius: 0 !important;
    border: none !important;
}

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

/* ── Discount Badge (top-left green pill) ───────────────────── */
.ml-discount-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    background: #00a650;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.4;
    white-space: nowrap;
}

[dir="rtl"] .ml-discount-badge {
    left: auto;
    right: 8px;
}

/* ── Card Body (text content) ───────────────────────────────── */
.ml-card-body {
    padding: 10px 12px 6px;
    display: flex;
    flex-direction: column;
    flex: 1;
    text-align: left;
}

[dir="rtl"] .ml-card-body {
    text-align: right;
}

/* ── Product Title ──────────────────────────────────────────── */
.ml-card-title {
    font-size: 14px;
    font-weight: 400;
    color: #333;
    line-height: 1.35;
    margin: 0 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0;
}

.ml-card-title a {
    color: inherit;
    text-decoration: none;
    display: inline !important;
    -webkit-line-clamp: unset;
}

.ml-card-title a:hover {
    color: #1259c3;
}

/* ── Original (struck-through) Price ────────────────────────── */
.ml-price-original {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
    margin: 0 0 1px;
    line-height: 1.3;
    font-weight: 400;
    letter-spacing: 0;
}

/* ── Discounted Price Row ───────────────────────────────────── */
.ml-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0 0 2px;
}

.ml-price-current {
    font-size: 22px;
    font-weight: 400;
    color: #333;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.ml-price-off {
    font-size: 13px;
    font-weight: 400;
    color: #00a650;
    white-space: nowrap;
}

/* ── Installments Line ──────────────────────────────────────── */
.ml-installments {
    font-size: 12px;
    color: #00a650;
    margin: 2px 0 0;
    line-height: 1.35;
    font-weight: 400;
}

/* ── Free Shipping Badge ────────────────────────────────────── */
.ml-shipping {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: #00a650;
    margin: 4px 0 0;
    font-weight: 600;
    line-height: 1.35;
}

.ml-shipping-bolt {
    display: inline-flex;
    align-items: center;
    font-style: normal;
    color: #00a650;
}

.ml-shipping-full {
    font-weight: 700;
    font-style: italic;
    color: #00a650;
}

/* ── Star Rating ────────────────────────────────────────────── */
.ml-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 5px 0 0;
    font-size: 12px;
}

.ml-rating i {
    font-size: 12px;
}

.ml-rating-count {
    color: #999;
    font-size: 11px;
    font-weight: 400;
}

/* ── Card Footer (Add-to-cart area) ─────────────────────────── */
.ml-card-footer {
    padding: 4px 12px 10px;
    margin-top: auto;
}

/* ── Quick View Overlay (subtle) ────────────────────────────── */
.ml-card-quick-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background .25s ease;
    z-index: 2;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
}

.ml-product-card:hover .ml-card-quick-view {
    background: rgba(0, 0, 0, .04);
}

.ml-card-quick-view .btn-circle {
    opacity: 0;
    transform: scale(0.6);
    transition: all .25s ease;
}

.ml-product-card:hover .ml-card-quick-view .btn-circle {
    opacity: 1;
    transform: scale(1);
}

/* ── Out of Stock Badge ─────────────────────────────────────── */
.ml-out-of-stock {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 3;
}


/* ==========================================================================
   Horizontal Product Card (ML Style) — for flash deals, featured deals,
   new arrivals carousels
   ========================================================================== */

.ml-hcard {
    position: relative;
    background: #fff;
    border: 1px solid #ededed;
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow .25s ease;
    cursor: pointer;
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ml-hcard:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

.ml-hcard-inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex: 1;
}

/* ── Horizontal Card Image ──────────────────────────────────── */
.ml-hcard-img {
    flex-shrink: 0;
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 4px;
    position: relative;
}

.ml-hcard-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform .3s ease;
    border: none !important;
    border-radius: 0 !important;
}

.ml-hcard:hover .ml-hcard-img img {
    transform: scale(1.08);
}

/* ── Horizontal Card Body ───────────────────────────────────── */
.ml-hcard-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ml-hcard-title {
    font-size: 13px;
    font-weight: 400;
    color: #333;
    line-height: 1.3;
    margin: 0 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ml-hcard-title a {
    color: inherit;
    text-decoration: none;
    display: inline !important;
}

.ml-hcard-title a:hover {
    color: #1259c3;
}

.ml-hcard .ml-price-original {
    font-size: 11px;
    margin: 0 0 1px;
}

.ml-hcard .ml-price-row {
    gap: 5px;
    margin: 0 0 2px;
}

.ml-hcard .ml-price-current {
    font-size: 18px;
}

.ml-hcard .ml-price-off {
    font-size: 12px;
}

.ml-hcard .ml-installments {
    font-size: 11px;
}

.ml-hcard .ml-shipping {
    font-size: 11px;
    margin: 3px 0 0;
}

.ml-hcard .ml-rating {
    margin: 4px 0 0;
}

.ml-hcard-footer {
    padding: 8px 0 0;
    margin-top: auto;
}

/* Discount badge for horizontal card */
.ml-hcard .ml-discount-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 11px;
    padding: 1px 6px;
}

[dir="rtl"] .ml-hcard .ml-discount-badge {
    left: auto;
    right: 6px;
}


/* ==========================================================================
   ML Add-to-Cart Button Overrides
   ========================================================================== */

.ml-product-card .atc-btn-wrapper,
.ml-hcard .atc-btn-wrapper {
    padding: 6px 0 0;
}

.ml-product-card .atc-add-btn,
.ml-hcard .atc-add-btn {
    height: 32px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    background: #3483fa;
    letter-spacing: 0;
}

.ml-product-card .atc-add-btn:hover,
.ml-hcard .atc-add-btn:hover {
    background: #2968c8;
    filter: none;
}

.ml-product-card .atc-qty-delete,
.ml-product-card .atc-qty-plus,
.ml-hcard .atc-qty-delete,
.ml-hcard .atc-qty-plus {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 6px;
    background: #3483fa;
}

.ml-product-card .atc-qty-display,
.ml-hcard .atc-qty-display {
    height: 32px;
    border-radius: 6px;
    font-size: 12px;
}


/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 575px) {
    .ml-card-img {
        padding: 8px;
    }

    .ml-card-body {
        padding: 8px 10px 4px;
    }

    .ml-card-footer {
        padding: 2px 10px 8px;
    }

    .ml-card-title {
        font-size: 13px;
        margin-bottom: 4px;
    }

    .ml-price-current {
        font-size: 18px;
    }

    .ml-price-off {
        font-size: 12px;
    }

    .ml-installments,
    .ml-shipping {
        font-size: 11px;
    }

    /* Horizontal cards stack on very small screens */
    .ml-hcard-img {
        width: 90px;
        height: 90px;
    }

    .ml-hcard .ml-price-current {
        font-size: 16px;
    }
}

@media (min-width: 576px) and (max-width: 767px) {
    .ml-price-current {
        font-size: 20px;
    }
}

/* Fix owl-carousel item spacing for ML cards */
.owl-carousel .ml-product-card {
    margin: 0 4px;
}

/* ── Equal-height cards in Owl Carousel ─────────────────────── */
.owl-carousel .owl-stage {
    display: flex !important;
}

.owl-carousel .owl-item {
    display: flex;
    flex: 1 0 auto;
}

.owl-carousel .owl-item > * {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.owl-carousel .ml-product-card,
.owl-carousel .ml-hcard {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.owl-carousel .ml-product-card .ml-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.owl-carousel .ml-hcard .ml-hcard-inner {
    flex: 1;
}

.owl-carousel .ml-product-card .ml-card-footer,
.owl-carousel .ml-hcard .ml-hcard-footer {
    margin-top: auto;
}

/* Ensure cards in grid have equal height */
.row .ml-product-card,
.hero-center-product-card .ml-product-card {
    height: 100%;
}

/* ── No price scenario (when no discount) ───────────────────── */
.ml-price-single {
    font-size: 22px;
    font-weight: 400;
    color: #333;
    line-height: 1.2;
    letter-spacing: -0.3px;
    margin: 0 0 2px;
}

@media (max-width: 575px) {
    .ml-price-single {
        font-size: 18px;
    }
}
