/* ==========================================================
   HV Product Card – Elementor widget (dùng trong Loop Item)
   ========================================================== */
.hv-pcard {
    --hv-accent: var(--e-global-color-primary, #6F5E4B);
    --hv-price: var(--hv-red, #c62828);
    --hv-card-bg: #fff;
    --hv-media-bg: #f4f3f0;
    --hv-text: #1d2733;
    --hv-muted: #7a8490;
    --hv-radius: 16px;
    --hv-ratio: 1 / 1;
    --hv-fit: cover;
    --hv-title-lines: 2;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--hv-card-bg);
    border-radius: var(--hv-radius);
    overflow: hidden;
    font-family: var(--e-global-typography-primary-font-family, "Roboto Flex"), sans-serif;
    transition: box-shadow .35s ease, transform .35s ease;
}

.hv-pcard:hover {
    box-shadow: 0 14px 36px rgba(16, 24, 40, .09);
}

.hv-pcard a {
    text-decoration: none;
}

/* ---------- Ảnh ---------- */
.hv-pcard__media {
    position: relative;
    width: 100%;
    min-width: 0;
    aspect-ratio: var(--hv-ratio);
    background: var(--hv-media-bg);
    border-radius: var(--hv-radius);
    overflow: hidden;
    isolation: isolate;
}

.hv-pcard__image-link {
    position: absolute;
    inset: 0;
    display: block;
}

.hv-pcard__img {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: var(--hv-fit);
    transition: opacity .5s ease, transform .7s cubic-bezier(.2, .7, .2, 1);
}

.hv-pcard__img--hover {
    opacity: 0;
}

.hv-pcard:hover .hv-pcard__img--main {
    transform: scale(1.05);
}

.hv-pcard.has-hover-image:hover .hv-pcard__img--main {
    opacity: 0;
}

.hv-pcard.has-hover-image:hover .hv-pcard__img--hover {
    opacity: 1;
    transform: scale(1.03);
}

.hv-pcard.is-out-of-stock .hv-pcard__img--main {
    filter: grayscale(.35);
    opacity: .8;
}

/* Nhãn */
.hv-pcard__badges {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    pointer-events: none;
}

.hv-pcard__badge {
    padding: 5px 10px;
    border-radius: 999px;
    background: #fff;
    color: var(--hv-text);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .04em;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.hv-pcard__badge.is-sale {
    background: var(--hv-price);
    color: #fff;
}

.hv-pcard__badge.is-new {
    background: var(--hv-accent);
    color: #fff;
}

.hv-pcard__badge.is-out {
    background: rgba(29, 39, 51, .78);
    color: #fff;
}

/* Nút giỏ nhỏ */
.hv-pcard__cart {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    color: var(--hv-text) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .1);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s ease, transform .25s ease, background .2s ease, color .2s ease;
}

.hv-pcard:hover .hv-pcard__cart,
.hv-pcard__cart:focus-visible {
    opacity: 1;
    transform: none;
}

.hv-pcard__cart:hover {
    background: var(--hv-accent);
    color: #fff !important;
}

.hv-pcard__cart.loading {
    opacity: .6;
}

.hv-pcard__cart.added::after,
.hv-pcard .added_to_cart {
    display: none !important;
}

/* ---------- Thông tin ---------- */
.hv-pcard__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    padding: 16px 6px 10px;
}

.hv-pcard__cat {
    position: relative;
    z-index: 2;
    align-self: flex-start;
    color: var(--hv-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .08em;
    line-height: 1.3;
    text-transform: uppercase;
    transition: color .2s ease;
}

.hv-pcard__cat:hover {
    color: var(--hv-accent);
}

.hv-pcard__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--hv-text);
}

.hv-pcard__title a {
    display: -webkit-box;
    -webkit-line-clamp: var(--hv-title-lines);
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: inherit;
    transition: color .2s ease;
}

/* Cả thẻ bấm được (qua link tiêu đề) */
.hv-pcard__title a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.hv-pcard:hover .hv-pcard__title a {
    color: var(--hv-accent);
}

/* Thông số ngắn */
.hv-pcard__specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hv-pcard__specs li {
    margin: 0;
    padding: 0 9px;
    border: 1px solid #e6e8eb;
    border-radius: 6px;
    color: #4a5560;
    font-size: 12px;
    /* Không padding dọc để cắt đúng 1 dòng */
    line-height: 24px;
    max-height: 26px;
    max-width: 100%;
    min-width: 0;
    /* 1 dòng + "…" nhưng vẫn co được, không kéo giãn cột lưới */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

/* Sao */
.hv-pcard__rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--hv-muted);
}

.hv-pcard__stars {
    position: relative;
    display: inline-block;
    font-size: 13px;
    line-height: 1;
    letter-spacing: 2px;
    color: #dcdfe3;
}

.hv-pcard__stars::before {
    content: "★★★★★";
}

.hv-pcard__stars::after {
    content: "★★★★★";
    position: absolute;
    top: 0;
    left: 0;
    width: var(--hv-rating);
    overflow: hidden;
    color: #f5a623;
}

/* Giá + xem chi tiết */
.hv-pcard__footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 6px;
}

.hv-pcard__price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
}

.hv-pcard__price-now {
    white-space: nowrap; /* không ngắt dòng giữa số tiền */
    color: var(--hv-price);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: .01em;
}

.hv-pcard__from {
    font-size: 13px;
    font-weight: 500;
    color: var(--hv-muted);
}

.hv-pcard__price-old {
    color: #a0a8b1;
    font-size: 13.5px;
    line-height: 1.2;
}

.hv-pcard__more {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--hv-accent);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity .25s ease, transform .25s ease;
}

.hv-pcard:hover .hv-pcard__more {
    opacity: 1;
    transform: none;
}

.hv-pcard__more svg {
    transition: transform .25s ease;
}

.hv-pcard__more:hover svg {
    transform: translateX(3px);
}

/* Thiết bị cảm ứng: luôn hiện */
@media (hover: none) {
    .hv-pcard__more {
        opacity: 1;
        transform: none;
    }

    .hv-pcard__more span {
        display: none;
    }

    .hv-pcard__cart {
        opacity: 1;
        transform: none;
    }
}

/* ==========================================================
   Kiểu Lifestyle: chữ phủ trên ảnh
   ========================================================== */
.hv-pcard--overlay {
    --hv-ratio: 3 / 4;
    background: transparent;
}

.hv-pcard--overlay .hv-pcard__media {
    width: 100%;
    height: auto;
    min-height: 100%;
}

.hv-pcard--overlay .hv-pcard__media::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(10, 20, 35, 0) 30%, rgba(10, 20, 35, .55) 60%, rgba(10, 20, 35, .9) 100%);
    pointer-events: none;
    transition: opacity .4s ease;
}

.hv-pcard--overlay .hv-pcard__body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 24px;
    color: #fff;
}

.hv-pcard--overlay .hv-pcard__cat,
.hv-pcard--overlay .hv-pcard__price-old,
.hv-pcard--overlay .hv-pcard__from {
    color: rgba(255, 255, 255, .75);
}

.hv-pcard--overlay .hv-pcard__title {
    font-size: 20px;
    color: #fff;
}

.hv-pcard--overlay:hover .hv-pcard__title a {
    color: #fff;
}

.hv-pcard--overlay .hv-pcard__specs li {
    border-color: rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .12);
    color: #fff;
    backdrop-filter: blur(4px);
}

.hv-pcard--overlay .hv-pcard__price-now {
    color: #fff;
}

.hv-pcard--overlay .hv-pcard__more {
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff;
    color: var(--hv-text);
    opacity: 1;
    transform: none;
}

.hv-pcard--overlay .hv-pcard__cart {
    top: 12px;
    bottom: auto;
}

@media (max-width: 767px) {
    .hv-pcard__body {
        padding: 12px 4px 8px;
        gap: 6px;
    }

    .hv-pcard__title {
        font-size: 14.5px;
    }

    .hv-pcard__price-now {
        font-size: 16px;
    }

    .hv-pcard__specs li:nth-child(n+2) {
        display: none;
    }

    .hv-pcard--overlay .hv-pcard__body {
        padding: 16px;
    }

    .hv-pcard--overlay .hv-pcard__title {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hv-pcard,
    .hv-pcard * {
        transition: none !important;
    }
}

/* ==========================================================
   Trong Loop Grid: thẻ luôn cao bằng ô lưới (các thẻ cùng hàng bằng nhau)
   Chuỗi khung Elementor: .e-loop-item > .e-con-inner > widget > widget-container > .hv-pcard
   ========================================================== */
.e-loop-item .elementor-widget-hv_product_card {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.e-loop-item .elementor-widget-hv_product_card > .elementor-widget-container {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
}

.e-loop-item .elementor-widget-hv_product_card .hv-pcard {
    flex: 1 1 auto;
}

/* ==========================================================
   Thanh nút khi rê chuột: Thêm vào giỏ | Xem nhanh
   ========================================================== */
/* Vùng ảnh nằm trên lớp phủ link của tiêu đề (::after z-index 1) để bấm được nút */
.hv-pcard__media:has(.hv-pcard__actions) {
    z-index: 2;
}

.hv-pcard__actions {
    position: absolute;
    left: 50%;
    bottom: 14px;
    z-index: 4;
    display: flex;
    align-items: stretch;
    padding: 4px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(16, 24, 40, .16);
    opacity: 0;
    transform: translate(-50%, 14px);
    transition: opacity .3s ease, transform .4s cubic-bezier(.2, .7, .2, 1);
}

.hv-pcard:hover .hv-pcard__actions,
.hv-pcard:focus-within .hv-pcard__actions {
    opacity: 1;
    transform: translate(-50%, 0);
}

.hv-pcard .hv-pcard__act {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--hv-text, #1d2733) !important;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

/* Vạch chia giữa 2 nút */
.hv-pcard .hv-pcard__act + .hv-pcard__act::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 10px;
    bottom: 10px;
    width: 1px;
    background: #e3e6ea;
    transition: opacity .2s ease;
}

.hv-pcard .hv-pcard__act:focus {
    outline: none;
}

.hv-pcard .hv-pcard__act:focus-visible {
    outline: 2px solid var(--hv-ink, #1f1f1f);
    outline-offset: 2px;
}

@media (hover: hover) {
    .hv-pcard .hv-pcard__act:hover {
        background: var(--hv-ink, #1f1f1f);
        color: #fff !important;
    }
}

.hv-pcard .hv-pcard__act:focus-visible {
    background: var(--hv-ink, #1f1f1f);
    color: #fff !important;
}

.hv-pcard .hv-pcard__act:hover::before,
.hv-pcard .hv-pcard__act:hover + .hv-pcard__act::before {
    opacity: 0;
}

/* Nhãn nhỏ phía trên nút */
.hv-pcard .hv-pcard__act::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    padding: 5px 9px;
    border-radius: 6px;
    background: #1d2733;
    color: #fff;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity .2s ease, transform .2s ease;
}

.hv-pcard .hv-pcard__act:hover::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Trạng thái thêm giỏ (WooCommerce gắn class loading / added) */
.hv-pcard__act-check {
    display: none;
}

.hv-pcard .hv-pcard__act.loading {
    pointer-events: none;
}

.hv-pcard .hv-pcard__act.loading svg {
    animation: hv-pcard-pulse .8s ease-in-out infinite;
}

.hv-pcard .hv-pcard__act.added {
    background: #2e7d32;
    color: #fff !important;
}

.hv-pcard .hv-pcard__act.added svg:not(.hv-pcard__act-check) {
    display: none;
}

.hv-pcard .hv-pcard__act.added .hv-pcard__act-check {
    display: block;
}

.hv-pcard .hv-pcard__act.loading::after,
.hv-pcard .hv-pcard__act.added::after {
    display: none;
}

@keyframes hv-pcard-pulse {
    50% {
        transform: scale(.82);
        opacity: .5;
    }
}

/* Thẻ dạng hàng ngang (NEXUS PRIME) ảnh nhỏ: không hiện thanh nút */
.hv-pcard--row .hv-pcard__actions {
    display: none;
}

/* Điện thoại / máy không có chuột: chạm vào ảnh mới hiện (JS gắn .is-actions-open), gọn hơn */
@media (hover: none) {
    .hv-pcard__actions {
        bottom: 8px;
        padding: 3px;
        border-radius: 12px;
        pointer-events: none;
    }

    .hv-pcard:focus-within .hv-pcard__actions {
        opacity: 0;
        transform: translate(-50%, 14px);
    }

    .hv-pcard.is-actions-open .hv-pcard__actions {
        opacity: 1;
        pointer-events: auto;
        transform: translate(-50%, 0);
    }

    .hv-pcard .hv-pcard__act {
        width: 40px;
        height: 36px;
    }

    .hv-pcard .hv-pcard__act::after {
        display: none;
    }
}
