/* ===================================================
   WC Linked Variations – Frontend Swatches CSS
   dienmaytructuyen.vn
   =================================================== */

/* ── Container ────────────────────────────────────────────────────────── */
.wc-lv-swatches {
    margin: 12px 0 16px;
    font-family: inherit;
}

/* ── Label thuộc tính ─────────────────────────────────────────────────── */
.wc-lv-label {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.wc-lv-current-label {
    color: #111;
    font-weight: 700;
}

/* ── Danh sách Swatch ─────────────────────────────────────────────────── */
.wc-lv-swatch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* ── Item chung ───────────────────────────────────────────────────────── */
.wc-lv-swatch-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, opacity .2s;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid transparent;
    box-sizing: border-box;
}
.wc-lv-swatch-item:hover {
    border-color: #999;
    text-decoration: none;
}
.wc-lv-swatch-item.active {
    border-color: var(--wc-lv-active, #e84c3d) !important;
    box-shadow: 0 0 0 1px var(--wc-lv-active, #e84c3d);
}

/* ── Label (Text) ─────────────────────────────────────────────────────── */
.wc-lv-type-label .wc-lv-swatch-item {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}
.wc-lv-type-label .wc-lv-swatch-item:hover {
    background: #eee;
    border-color: #aaa;
}
.wc-lv-type-label .wc-lv-swatch-item.active {
    background: #fff;
    color: var(--wc-lv-active, #e84c3d);
}

/* ── Color (Màu sắc) ──────────────────────────────────────────────────── */
.wc-lv-type-color .wc-lv-swatch-item {
    width: 36px;
    height: 36px;
    padding: 2px;
    border-radius: 50%;
    border: 2px solid #ddd;
}
.wc-lv-color-dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}
.wc-lv-type-color .wc-lv-swatch-item:hover {
    border-color: #888;
}
.wc-lv-type-color .wc-lv-swatch-item.active {
    border-color: var(--wc-lv-active, #e84c3d);
    padding: 3px;
}

/* ── Image ────────────────────────────────────────────────────────────── */
.wc-lv-type-image .wc-lv-swatch-item {
    width: 48px;
    height: 48px;
    padding: 2px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: #fff;
}
.wc-lv-type-image .wc-lv-swatch-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
    display: block;
}

/* ── HẾT HÀNG – Styles ────────────────────────────────────────────────── */
.wc-lv-swatch-item.out-of-stock {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Gạch chéo */
.wc-lv-oos-line {
    position: absolute;
    top: 50%;
    left: -2px;
    right: -2px;
    height: 2px;
    background: rgba(200,50,50,.75);
    transform: rotate(-45deg);
    transform-origin: center;
    pointer-events: none;
    display: none;
}

/* Badge nhỏ "Hết hàng" - chỉ hiện khi hover trên loop */
.wc-lv-oos-badge {
    display: none; /* bật trong JS khi hover */
}

/* Hiển thị theo cài đặt */
body.wc-lv-oos-strikethrough .wc-lv-swatch-item.out-of-stock .wc-lv-oos-line,
body.wc-lv-oos-both .wc-lv-swatch-item.out-of-stock .wc-lv-oos-line {
    display: block;
}
body.wc-lv-oos-dim .wc-lv-swatch-item.out-of-stock,
body.wc-lv-oos-both .wc-lv-swatch-item.out-of-stock {
    opacity: .3;
}

/* Tooltip hết hàng khi hover */
.wc-lv-swatch-item.out-of-stock::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.8);
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
    padding: 3px 7px;
    border-radius: 3px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 9999;
}
.wc-lv-swatch-item.out-of-stock {
    pointer-events: auto; /* re-enable để tooltip hoạt động */
}
.wc-lv-swatch-item.out-of-stock:hover::after {
    opacity: 1;
}

/* ── Hover Info (trang single) ────────────────────────────────────────── */
.wc-lv-hover-info {
    font-size: 12px;
    color: #777;
    margin-top: 6px;
    min-height: 18px;
    transition: color .15s;
}

/* ── Product Loop – thu gọn ───────────────────────────────────────────── */
.wc-lv-context-loop .wc-lv-swatch-list {
    gap: 4px;
}
.wc-lv-context-loop .wc-lv-type-label .wc-lv-swatch-item {
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    font-size: 11px;
}
.wc-lv-context-loop .wc-lv-type-color .wc-lv-swatch-item {
    width: 24px;
    height: 24px;
}
.wc-lv-context-loop .wc-lv-type-image .wc-lv-swatch-item {
    width: 32px;
    height: 32px;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .wc-lv-swatch-list { gap: 5px; }
    .wc-lv-type-label .wc-lv-swatch-item { min-width: 34px; height: 34px; }
}
