/* =====================================================================
   Woo Tùy Biến v3 - tự chứa đầy đủ (không phụ thuộc CSS/font của theme)
   Màu chủ đạo + tỉ lệ ảnh thẻ được đặt ở Cài đặt > Woo Tùy Biến
   (biến --mwc-accent, --mwc-card-ratio được nạp inline ngay sau file này).
   ===================================================================== */
:root {
    --mwc-accent: #d6569a;
    --mwc-accent-contrast: #fff;
    --mwc-border: #e2e2e2;
    --mwc-radius: 6px;
    --mwc-card-ratio: 4 / 5;
}

.mwc-hidden { display: none !important; }
.mwc-icon { width: 1.1em; height: 1.1em; flex: 0 0 auto; vertical-align: -.15em; }
html.mwc-qv-open { overflow: hidden; }

/* ---------- Nút dùng trong thẻ sản phẩm & Quick View ---------- */
.mwc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 11px 16px;
    border: 0;
    border-radius: var(--mwc-radius);
    background: var(--mwc-accent);
    color: var(--mwc-accent-contrast);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .02em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: filter .15s;
}
.mwc-btn:hover { filter: brightness(.92); color: var(--mwc-accent-contrast); }

/* ======================================================================
   LƯỚI SẢN PHẨM
   ====================================================================== */
.mwc-archive { max-width: 1200px; margin: 0 auto; padding: 20px; }

.mwc-products {
    display: grid;
    grid-template-columns: repeat(var(--mwc-cols, 3), minmax(0, 1fr)); /* minmax(0,1fr): ảnh to không làm vỡ cột */
    gap: 24px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.mwc-products > li { margin: 0; padding: 0; width: auto; float: none; list-style: none; }

.related.products,
.up-sells.products,
.upsells.products,
.cross-sells {
    clear: both;
    width: 100%;
    margin: 48px 0 0;
}
.related.products > h2,
.up-sells.products > h2,
.upsells.products > h2,
.cross-sells > h2 { margin: 0 0 20px; font-size: 24px; font-weight: 700; }

@media (max-width: 1024px) { .mwc-products { grid-template-columns: repeat(min(var(--mwc-cols, 3), 3), minmax(0, 1fr)); } }
@media (max-width: 768px)  { .mwc-products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } }

/* ---------- Thẻ sản phẩm ---------- */
.mwc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.mwc-card__image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: var(--mwc-card-ratio, 4 / 5);
    overflow: hidden;
    background: #fff;
}
.mwc-card__image-wrapper > .mwc-card__link { display: block; width: 100%; height: 100%; }
.mwc-card__image-wrapper img,
.mwc-card__image-wrapper .mwc-card__img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain; /* hiện trọn áo, không bị cắt */
    margin: 0;
}

/* Badge Sale / Sold out */
.mwc-badges { position: absolute; top: 10px; left: 10px; z-index: 3; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.mwc-badge { padding: 4px 9px; border-radius: 3px; background: var(--mwc-accent); color: #fff; font-size: 12px; font-weight: 700; line-height: 1.2; text-transform: uppercase; }
.mwc-badge--soldout { background: #444; }

/* Quick View: ẩn bằng visibility => không bấm nhầm khi đang vô hình */
.mwc-card__overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s, visibility .2s;
}
.mwc-card:hover .mwc-card__overlay,
.mwc-card:focus-within .mwc-card__overlay { opacity: 1; visibility: visible; transform: none; }

/* Wishlist */
.mwc-card .mwc-wishlist {
    display: inline-flex; align-items: center; justify-content: center;
    box-sizing: border-box; border: 0; cursor: pointer;
    position: absolute;
    top: 10px; right: 10px;
    z-index: 3;
    width: 38px; height: 38px;
    padding: 0;
    border-radius: 50%;
    background: #111;
    color: #fff;
}
.mwc-wishlist .mwc-icon { width: 20px; height: 20px; fill: none; }
.mwc-wishlist.is-active { background: var(--mwc-accent); }
.mwc-wishlist.is-active .mwc-icon { fill: currentColor; }

/* Thông tin */
.mwc-card__info { display: flex; flex-direction: column; flex: 1 1 auto; gap: 10px; padding: 12px 4px 4px; }
.mwc-card__details { display: flex; flex-direction: column; gap: 6px; }
.mwc-card__title {
    margin: 0;
    font-size: 16px;
    line-height: 1.35;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mwc-card__title a { color: inherit; text-decoration: none; }
.mwc-card__rating:empty { display: none; }
.mwc-card__price { display: block; font-size: 15px; line-height: 1.4; }
.mwc-card__price del { margin-right: 6px; opacity: .6; }
.mwc-card__price ins { text-decoration: none; font-weight: 700; }

/* Sao đánh giá (không phụ thuộc font của WooCommerce) */
.mwc-card .star-rating,
.mwc-qv .star-rating { position: relative; display: inline-block; width: 5.6em; height: 1.2em; font-size: 15px; line-height: 1.2; overflow: hidden; color: #d3d3d3; }
.mwc-card .star-rating::before,
.mwc-qv .star-rating::before { content: "★★★★★"; position: absolute; left: 0; top: 0; letter-spacing: .06em; }
.mwc-card .star-rating > span,
.mwc-qv .star-rating > span { position: absolute; left: 0; top: 0; height: 100%; overflow: hidden; white-space: nowrap; text-indent: -9999px; color: #f5a623; }
.mwc-card .star-rating > span::before,
.mwc-qv .star-rating > span::before { content: "★★★★★"; position: absolute; left: 0; top: 0; text-indent: 0; letter-spacing: .06em; }

/* Nút ở đáy thẻ: gồm cả nút của WooCommerce (.button) cho simple/grouped/external/hết hàng */
.mwc-card__actions { margin-top: auto; padding-top: 4px; }
.mwc-card__actions .button,
.mwc-card__actions .mwc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    border: 0;
    border-radius: var(--mwc-radius);
    background: var(--mwc-accent);
    color: var(--mwc-accent-contrast);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
}
.mwc-card__actions .added_to_cart { display: block; margin-top: 6px; font-size: 13px; text-align: center; }

@media (max-width: 768px) {
    .mwc-card__title { font-size: 14px; }
    .mwc-card__actions .button,
    .mwc-card__actions .mwc-btn { padding: 10px 8px; font-size: 12px; }
}
@media (hover: none) { .mwc-card__overlay { display: none; } }

/* ======================================================================
   GALLERY TRANG SẢN PHẨM
   ====================================================================== */
.mwc-gallery { display: flex; gap: 12px; align-items: flex-start; width: 100%; }

.mwc-thumbs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 64px;
    width: 64px;
    max-height: 540px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}
.mwc-thumb { display: block; padding: 0; margin: 0; border: 0; background: none; cursor: pointer; line-height: 0; }
.mwc-thumb__img {
    width: 56px; height: 56px;
    object-fit: cover;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    opacity: .75;
    transition: opacity .15s, border-color .15s;
}
.mwc-thumb:hover .mwc-thumb__img,
.mwc-thumb:focus-visible .mwc-thumb__img,
.mwc-thumb.active .mwc-thumb__img { opacity: 1; border-color: #000; }
.mwc-thumb:focus-visible { outline: 2px solid var(--mwc-accent); outline-offset: 2px; }

.mwc-main { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.mwc-main-img { display: block; width: 100%; height: auto; max-width: 100%; }

/* Kính lúp zoom */
.mwc-lens {
    display: none;
    position: absolute;
    width: 180px; height: 180px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 14px rgba(0, 0, 0, .35);
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 3;
}

@media (max-width: 768px) {
    .mwc-gallery { flex-direction: column-reverse; }
    .mwc-thumbs { flex-direction: row; flex: 0 0 auto; width: 100%; max-height: none; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
    .mwc-thumb { flex: 0 0 auto; }
    .mwc-thumb__img { width: 52px; height: 52px; }
    .mwc-lens { display: none !important; }
}

/* ======================================================================
   SWATCH MÀU / SIZE
   ====================================================================== */
.mwc-variations { display: flex; flex-wrap: wrap; gap: 14px 40px; align-items: flex-start; margin-bottom: 14px; }
.mwc-swatch-group { flex: 1 1 100%; min-width: 0; }
.mwc-swatch-group.mwc-single-option { flex: 0 0 auto; }          /* nhóm chỉ có 1 lựa chọn: xếp ngang cho gọn */
.mwc-swatch-group.mwc-fallback select { display: block; min-width: 180px; }

.mwc-swatch-title { margin-bottom: 8px; font-size: 14px; text-transform: uppercase; }
.mwc-swatch-title strong { margin-right: 4px; font-weight: 700; }
.mwc-swatch-title .mwc-swatch-selection { text-transform: none; font-weight: 400; }

.mwc-swatches { display: flex; flex-wrap: wrap; gap: 8px; }

.mwc-swatch {
    position: relative;
    flex: 0 0 auto;
    margin: 0;
    cursor: pointer;
    font: inherit;
    transition: box-shadow .15s, background-color .15s, color .15s, border-color .15s;
}
.mwc-swatch:focus-visible { outline: 2px solid var(--mwc-accent); outline-offset: 3px; }

.mwc-swatch--text {
    min-width: 44px;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--mwc-border);
    border-radius: 4px;
    background: #fff;
    color: #111;
    font-size: 15px;
    line-height: 1;
}
.mwc-swatch--text:hover { border-color: #111; }
.mwc-swatch--text.selected { background: var(--mwc-accent); border-color: var(--mwc-accent); color: var(--mwc-accent-contrast); box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }

.mwc-swatch--color {
    width: 32px; height: 32px; min-width: 32px;
    padding: 0;
    border: 1px solid #cfcfcf;
    border-radius: 50%;
    background-color: #eee;
    background-size: cover;
    background-position: center;
}
.mwc-swatch--color.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000; }

/* Hết hàng / không có tổ hợp: mờ + gạch chéo, vẫn bấm được (bấm vào sẽ tự bỏ chọn nhóm xung đột) */
.mwc-swatch.is-disabled { opacity: .45; }
.mwc-swatch.is-disabled::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(to top right, transparent calc(50% - 1px), #888 50%, transparent calc(50% + 1px));
    pointer-events: none;
}

.mwc-reset { flex: 1 1 100%; font-size: 13px; text-decoration: underline; }

/* ======================================================================
   ADD TO CART + SỐ LƯỢNG
   ====================================================================== */
.single_variation_wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.single_variation_wrap .woocommerce-variation { flex: 1 1 auto; }
.single_variation_wrap .woocommerce-variation-add-to-cart { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.single_variation_wrap .woocommerce-variation-price .price { font-size: 22px; font-weight: 700; color: var(--mwc-accent); }

.mwc-qty { display: inline-flex; align-items: stretch; border: 1px solid var(--mwc-border); border-radius: var(--mwc-radius); background: #fff; overflow: hidden; }
.mwc-qty .qty {
    width: 56px;
    margin: 0;
    padding: 0 4px;
    border: 0;
    border-left: 1px solid var(--mwc-border);
    border-right: 1px solid var(--mwc-border);
    border-radius: 0;
    background: transparent;
    text-align: center;
    font-size: 16px;
    -moz-appearance: textfield;
    appearance: textfield;
}
.mwc-qty .qty::-webkit-outer-spin-button,
.mwc-qty .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mwc-qty .mwc-qty__btn {
    width: 38px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #444;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.mwc-qty .mwc-qty__btn:hover { background: #f4f4f4; }
.mwc-qty .mwc-qty__btn:focus-visible { outline: 2px solid var(--mwc-accent); outline-offset: -2px; }

/* :where() => độ ưu tiên 0, theme có style nút riêng thì theme thắng */
:where(.single_add_to_cart_button) {
    padding: 13px 22px;
    border: 0;
    border-radius: var(--mwc-radius);
    background: var(--mwc-accent);
    color: var(--mwc-accent-contrast);
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}
.single_add_to_cart_button.disabled,
.single_add_to_cart_button:disabled { opacity: .5; cursor: not-allowed; }

/* ======================================================================
   KHỐI CHÍNH SÁCH GIAO HÀNG
   ====================================================================== */
.mwc-policy { margin-top: 16px; }
.mwc-policy__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: #dedede;
}
.mwc-policy__bar h3 { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.3; }
.mwc-policy__bar img { height: 32px; width: auto; }
.mwc-policy__list { margin: 8px 0 0; padding: 0; list-style: none; }
.mwc-policy__list li { margin: 4px 0; font-size: 15px; line-height: 1.5; }
.mwc-policy__icon { display: inline-block; width: 26px; }
.mwc-policy__note { margin: 10px 0 0; font-size: 12px; color: #666; }

/* ======================================================================
   QUICK VIEW
   ====================================================================== */
.mwc-qv { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 16px; }
.mwc-qv[hidden] { display: none; }
.mwc-qv__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.mwc-qv__dialog {
    position: relative;
    width: 100%;
    max-width: 920px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
    outline: 0;
}
.mwc-qv__close {
    position: absolute; top: 10px; right: 12px; z-index: 2;
    width: 36px; height: 36px;
    border: 0; border-radius: 50%;
    background: #f1f1f1; color: #111;
    font-size: 24px; line-height: 1; cursor: pointer;
}
.mwc-qv__close:hover { background: #e2e2e2; }
.mwc-qv__state { margin: 0; padding: 48px 24px; text-align: center; }
.mwc-qv__state.is-error { color: #b32d2e; }

.mwc-qv__inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; padding: 28px; }
.mwc-qv__media.mwc-gallery { display: block; }
.mwc-qv__title { margin: 0 40px 8px 0; font-size: 22px; line-height: 1.3; }
.mwc-qv__price { margin: 0 0 12px; font-size: 18px; }
.mwc-qv__excerpt { margin: 0 0 14px; font-size: 14px; line-height: 1.6; color: #444; }
.mwc-qv__more { display: inline-block; margin-top: 14px; font-size: 14px; text-decoration: underline; }

.mwc-qv__notice { margin: 0 0 12px; padding: 10px 12px; border-radius: 4px; font-size: 14px; }
.mwc-qv__notice[hidden] { display: none; }
.mwc-qv__notice.is-success { background: #edf7ee; color: #1d5f2a; }
.mwc-qv__notice.is-error { background: #fbeaea; color: #b32d2e; }
.mwc-qv__notice a { margin-left: 8px; font-weight: 600; text-decoration: underline; }

.mwc-qv form.cart.mwc-busy { opacity: .6; pointer-events: none; }
.mwc-qv .single_variation_wrap { margin-top: 8px; }

@media (max-width: 768px) {
    .mwc-qv { padding: 0; align-items: flex-end; }
    .mwc-qv__dialog { max-width: none; max-height: 92vh; border-radius: 12px 12px 0 0; }
    .mwc-qv__inner { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
    .mwc-qv__media .mwc-main-img { max-height: 40vh; width: auto; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .mwc-card__overlay, .mwc-swatch, .mwc-thumb__img { transition: none; }
}

/* ======================================================================
   v3.1 - BỐ CỤC TRANG SẢN PHẨM (tự chứa, không dựa vào class của theme)
   Chỉ áp dụng trong .mwc-single (template trang sản phẩm của plugin).
   ====================================================================== */
.mwc-single { box-sizing: border-box; max-width: 1366px; margin: 0 auto; padding: 0 20px; }
.mwc-single .product { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 24px 30px; }
.mwc-single .product > .mwc-gallery { flex: 0 0 45%; width: 45%; max-width: 45%; }
.mwc-single .product > .summary { flex: 1 1 0; min-width: 0; width: 50%; }
.mwc-single .product > .woocommerce-tabs,
.mwc-single .product > .related,
.mwc-single .product > .upsells,
.mwc-single .product > .up-sells { flex: 0 0 100%; width: 100%; max-width: 100%; }
.mwc-single .single_variation_wrap > div,
.mwc-qv .single_variation_wrap > div { width: auto; }

@media (max-width: 992px) {
    .mwc-single { padding: 0 15px; }
    .mwc-single .product { flex-direction: column; align-items: stretch; }
    .mwc-single .product > .mwc-gallery,
    .mwc-single .product > .summary { flex: 0 0 auto; width: 100%; max-width: 100%; }
}

/* Gallery trong Quick View: ảnh nằm trên, không có cột thumbnail */
.mwc-gallery--qv { display: block; }

/* Ảnh trong thẻ / gallery luôn theo kích thước của plugin, không bị rule img toàn cục của theme kéo giãn */
.mwc-card .mwc-card__img { height: 100%; width: 100%; object-fit: contain; }
.mwc-main .mwc-main-img { height: auto; width: 100%; object-fit: initial; }

/* Breadcrumb dự phòng khi theme không có cat_breadcrumbs() */
.mwc-breadcrumb { max-width: 1366px; margin: 0 auto; padding: 14px 20px; font-size: 14px; }
