/* ============================================================
   WC Linked Variations v3 – Frontend Swatches
   Style: Card (thumbnail + tên + giá) – giống ảnh mẫu
   ============================================================ */

/* ── Wrapper ─────────────────────────────────────────────────────────── */
.wc-lv-swatches,
.wc-lv-variation-swatches { margin: 12px 0 18px; font-family: inherit; }
.wc-lv-var-group { margin-bottom: 14px; }

/* ── Attribute label ─────────────────────────────────────────────────── */
.wc-lv-attr-label { font-size: 13px; margin-bottom: 8px; line-height: 1.4; display: flex; align-items: baseline; gap: 5px; }
.wc-lv-attr-name  { color: #555; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.wc-lv-active-label { color: #111; font-weight: 700; font-size: 13px; }

/* ── List ────────────────────────────────────────────────────────────── */
.wc-lv-list { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 4px; }

/* ════════════════════════════════════════════════════════════════════════
   CARD SWATCH – kiểu ảnh 1 (thumbnail + tên + giá nằm trong ô)
   Áp dụng cho tất cả linked product swatch
   ════════════════════════════════════════════════════════════════════════ */
.wc-lv-type-card .wc-lv-item,
.wc-lv-type-label .wc-lv-item,
.wc-lv-type-image .wc-lv-item,
.wc-lv-type-color .wc-lv-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    text-decoration: none !important;
    cursor: pointer;
    box-sizing: border-box;
    background: #fff;
    overflow: hidden;          /* gạch chéo OOS bị clip trong ô */
    transition: border-color .18s, box-shadow .18s;
    outline: none;
    -webkit-user-select: none; user-select: none;
}

/* ── CARD: thumbnail + tên + giá ─────────────────────────────────────── */
/* Đây là layout chính cho linked variations */
.wc-lv-type-card .wc-lv-item {
    flex-direction: row;
    gap: 8px;
    padding: 8px 12px 8px 8px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    min-width: 140px;
    max-width: 200px;
}
.wc-lv-type-card .wc-lv-item:hover { border-color: #bbb; }
.wc-lv-type-card .wc-lv-item.is-active {
    border-color: var(--lv-active, #e84c3d) !important;
    box-shadow: 0 0 0 1px var(--lv-active, #e84c3d);
}

/* Thumbnail bên trái */
.wc-lv-card-thumb {
    width: 44px; height: 44px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
    pointer-events: none;
    background: #f5f5f5;
}
.wc-lv-card-thumb.no-img {
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; background: #f0f0f0; border-radius: 4px;
}

/* Nội dung bên phải */
.wc-lv-card-info {
    display: flex; flex-direction: column;
    gap: 2px; flex: 1; min-width: 0;
    pointer-events: none;
}
.wc-lv-card-name {
    font-size: 13px; font-weight: 600; color: #1d2327;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1.3;
}
.wc-lv-card-price {
    font-size: 13px; font-weight: 600; color: #333; line-height: 1.2;
}
.wc-lv-card-price.has-sale { color: var(--lv-active, #e84c3d); }
.wc-lv-card-price del { font-size: 11px; color: #999; font-weight: 400; text-decoration: line-through; margin-left: 3px; }

/* Checkmark góc phải khi active */
.wc-lv-card-check {
    position: absolute; top: 6px; right: 6px;
    width: 18px; height: 18px;
    background: var(--lv-active, #e84c3d);
    border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; line-height: 1;
    pointer-events: none;
}
.wc-lv-item.is-active .wc-lv-card-check { display: flex; }

/* ── COLOR: tròn màu ─────────────────────────────────────────────────── */
.wc-lv-type-color .wc-lv-item {
    width: var(--lv-size, 36px);
    height: var(--lv-size, 36px);
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    padding: 3px;
    justify-content: center;
}
.wc-lv-dot {
    width: 100%; height: 100%;
    border-radius: 50%;
    display: block;
    pointer-events: none;
}
.wc-lv-type-color .wc-lv-item:hover { border-color: #888; }
.wc-lv-type-color .wc-lv-item.is-active {
    border-color: var(--lv-active, #e84c3d) !important;
    box-shadow: 0 0 0 1px var(--lv-active, #e84c3d);
    padding: 4px;
}

/* ── LABEL: chữ ─────────────────────────────────────────────────────── */
.wc-lv-type-label .wc-lv-item {
    min-width: 72px;
    height: auto;
    min-height: var(--lv-size, 36px);
    padding: 7px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #f5f5f5;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: normal;        /* ← bỏ nowrap để children xuống dòng được */
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}
.wc-lv-type-label .wc-lv-item:hover { border-color: #aaa; background: #eee; }
.wc-lv-type-label .wc-lv-item.is-active {
    border-color: var(--lv-active, #e84c3d) !important;
    box-shadow: 0 0 0 1px var(--lv-active, #e84c3d);
    background: #fff;
    color: var(--lv-active, #e84c3d);
}
.wc-lv-type-label .wc-lv-item .wc-lv-label-stack {
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    min-width: 0;
    pointer-events: none;
    line-height: 1.2;
}
.wc-lv-type-label .wc-lv-item .wc-lv-text {
    pointer-events: none;
    font-size: inherit;
    font-weight: inherit;
    display: block !important;  /* Keep price on a separate row. */
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Giá nhỏ bên dưới tên trong label swatch */
.wc-lv-type-label .wc-lv-item .wc-lv-label-price {
    display: block !important;  /* Keep price below the attribute name. */
    width: 100%;
    font-size: 12px;
    font-weight: 700;
    color: var(--lv-active, #e84c3d);
    pointer-events: none;
    white-space: nowrap;
    line-height: 1.2;
}
.wc-lv-type-label .wc-lv-item.is-active .wc-lv-label-price { color: var(--lv-active, #e84c3d); }

/* ── IMAGE ────────────────────────────────────────────────────────────── */
.wc-lv-type-image .wc-lv-item {
    width: calc(var(--lv-size,36px) + 16px);
    height: calc(var(--lv-size,36px) + 16px);
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 2px;
    justify-content: center;
}
.wc-lv-type-image .wc-lv-item img {
    width: 100%; height: 100%;
    object-fit: cover; border-radius: 3px;
    display: block; pointer-events: none;
}
.wc-lv-type-image .wc-lv-item:hover { border-color: #aaa; }
.wc-lv-type-image .wc-lv-item.is-active {
    border-color: var(--lv-active, #e84c3d) !important;
    box-shadow: 0 0 0 1px var(--lv-active, #e84c3d);
}

/* ════════════════════════════════════════════════════════════════════════
   HẾT HÀNG (OOS) – gạch chéo hoàn toàn trong ô (overflow:hidden xử lý)
   ════════════════════════════════════════════════════════════════════════ */

/* OOS cho phép click nhưng cursor khác */
.wc-lv-item.is-oos { cursor: pointer; }
.wc-lv-item.is-oos:hover { border-color: #ccc !important; box-shadow: none !important; }

/* Mờ dần */
body.wc-lv-oos-dim  .wc-lv-item.is-oos,
body.wc-lv-oos-both .wc-lv-item.is-oos { opacity: .4; }

/* Gạch chéo – dùng pseudo element, clip bởi overflow:hidden của item */
.wc-lv-oos-slash {
    display: none;
    position: absolute;
    /* fill toàn bộ diện tích ô, đường chéo sẽ bị clip vừa ô */
    inset: 0;
    pointer-events: none;
    z-index: 3;
}
.wc-lv-oos-slash::before {
    content: '';
    position: absolute;
    /* đường chéo từ góc dưới-trái đến góc trên-phải */
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(
        to top right,
        transparent calc(50% - 1px),
        rgba(170,30,30,.65) calc(50% - 1px),
        rgba(170,30,30,.65) calc(50% + 1px),
        transparent calc(50% + 1px)
    );
}
body.wc-lv-oos-strikethrough .wc-lv-item.is-oos .wc-lv-oos-slash,
body.wc-lv-oos-both          .wc-lv-item.is-oos .wc-lv-oos-slash { display: block; }

/* Badge "Hết hàng" – hiện khi hover, nằm trong ô */
.wc-lv-oos-badge {
    position: absolute;
    bottom: 4px; left: 50%; transform: translateX(-50%);
    background: rgba(180,30,30,.9); color: #fff;
    font-size: 9px; font-weight: 700;
    white-space: nowrap; padding: 2px 6px; border-radius: 3px;
    pointer-events: none; opacity: 0; transition: opacity .15s;
    z-index: 10;
}
.wc-lv-item.is-oos:hover .wc-lv-oos-badge { opacity: 1; }

/* Tooltip khi hover OOS */
.wc-lv-item.is-oos::after {
    content: attr(title);
    position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
    background: #222; color: #fff; font-size: 11px;
    white-space: nowrap; padding: 4px 8px; border-radius: 4px;
    pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 9999;
    overflow: visible;
}
.wc-lv-item.is-oos:hover::after { opacity: 1; }

/* ── SALE BADGE ──────────────────────────────────────────────────────── */
.wc-lv-sale-badge {
    position: absolute; top: 4px; right: 4px;
    background: var(--lv-active, #e84c3d); color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 2px 5px; border-radius: 8px;
    white-space: nowrap; pointer-events: none; line-height: 1.3; z-index: 5;
}
/* Card: sale badge nhỏ hơn vì giá đã hiện trong card */
.wc-lv-type-card .wc-lv-sale-badge { font-size: 9px; padding: 1px 4px; top: 3px; right: 3px; }

/* ── PRICE DISPLAY (khi click linked) ────────────────────────────────── */
.wc-lv-price-display {
    margin-top: 8px;
    font-size: 20px; font-weight: 700; color: var(--lv-active, #e84c3d);
    min-height: 0; transition: opacity .2s;
}
.wc-lv-price-display:empty { display: none; }
.wc-lv-price-display ins { text-decoration: none; }
.wc-lv-price-display del { font-size: 14px; color: #999; font-weight: 400; margin-left: 8px; }

/* Variation price display */
.wc-lv-var-price-display {
    margin-top: 8px;
    font-size: 20px; font-weight: 700; color: var(--lv-active, #e84c3d); min-height: 0;
}
.wc-lv-var-price-display:empty { display: none; }
.wc-lv-var-price-display ins { text-decoration: none; }
.wc-lv-var-price-display del { font-size: 14px; color: #999; font-weight: 400; margin-left: 8px; }

/* ── HOVER INFO ───────────────────────────────────────────────────────── */
.wc-lv-hover-info { font-size: 12px; color: #888; min-height: 14px; margin-top: 4px; }

/* ── Ẩn select WC mặc định ──────────────────────────────────────────── */
.wc-lv-replaced { opacity: 0 !important; height: 0 !important; padding: 0 !important;
    border: 0 !important; pointer-events: none !important; position: absolute !important; }
.single_variation_wrap.wc-lv-controlled .woocommerce-variation-price { display: none !important; }

/* ── LOOP (thu nhỏ) ─────────────────────────────────────────────────── */
.wc-lv-ctx-loop .wc-lv-list { gap: 5px; }
.wc-lv-ctx-loop .wc-lv-type-card .wc-lv-item { min-width: 100px; max-width: 140px; padding: 5px 8px 5px 5px; gap: 5px; border-radius: 6px; }
.wc-lv-ctx-loop .wc-lv-card-thumb { width: 30px; height: 30px; }
.wc-lv-ctx-loop .wc-lv-card-name  { font-size: 11px; }
.wc-lv-ctx-loop .wc-lv-card-price { font-size: 11px; }
.wc-lv-ctx-loop .wc-lv-card-check { width: 14px; height: 14px; font-size: 9px; top: 4px; right: 4px; }
.wc-lv-ctx-loop .wc-lv-type-color .wc-lv-item { width: 22px; height: 22px; }
.wc-lv-ctx-loop .wc-lv-type-label .wc-lv-item { min-width: 28px; height: 28px; padding: 0 7px; font-size: 11px; }
.wc-lv-ctx-loop .wc-lv-sale-badge { font-size: 8px; padding: 1px 3px; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .wc-lv-type-card .wc-lv-item { min-width: 120px; max-width: 160px; }
    .wc-lv-list { gap: 6px; }
}
