/* =========================================================================
 * PRODUCT CARD – component dùng chung cho mọi nơi render woocommerce/content-product.php:
 * trang chủ (rail Nam/Nữ/Phụ kiện, Rolex, Longines), danh mục, thương hiệu, tìm kiếm/lọc,
 * sản phẩm liên quan, landing page dùng shortcode WooCommerce.
 *
 * Quy tắc: CHỈ sửa giao diện card tại file này. Các file trang (catalog-page, home-*,
 * responsive, product-page) chỉ được quyết định số cột / khoảng cách của lưới chứa card.
 * File được nạp cuối cùng (setup.php, priority 100) nên luôn thắng các sheet trang.
 *
 * Cấu trúc (thiết kế chuẩn): Ảnh → Tên (căn giữa) → Đường kẻ → Giá (căn giữa) → Footer xác thực.
 * Ảnh: khung vuông 1:1 tràn hết chiều rộng card, object-fit: contain → không méo, không crop;
 * ảnh sản phẩm TopWatch đa số đã vuông nên lấp đầy khung, ảnh lệch tỉ lệ được căn giữa.
 * ========================================================================= */
.tw-product-card {
  /* Chữ: lấy từ typography-scale.css (token --tw-type-card-*, đã có thang Desktop/Tablet/Mobile). */
  --tw-card-title-size: var(--tw-type-card-title, 14px);
  --tw-card-title-weight: var(--tw-type-card-title-weight, 500);
  --tw-card-title-line: var(--tw-type-card-title-line, 1.45);
  --tw-card-title-lines: 3;
  --tw-card-price-size: var(--tw-type-card-price, 18px);
  --tw-card-price-weight: var(--tw-type-card-price-weight, 700);
  --tw-card-footer-size: var(--tw-type-card-footer, 12px);
  --tw-card-badge-size: var(--tw-type-card-badge, 11px);
  /* Khoảng cách & kích thước vùng (theo breakpoint bên dưới). */
  --tw-card-pad: 20px;
  --tw-card-gap: 14px;
  --tw-card-footer-h: 54px;
  --tw-card-footer-pad: 14px;
  --tw-card-icon: 17px;

  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  margin: 0;
  list-style: none;
  background: var(--white);
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  box-shadow: 0 3px 12px rgb(0 0 0 / .07);
  overflow: hidden;
  scroll-snap-align: start;
  transition: transform .25s ease, box-shadow .25s ease;
}
.tw-product-card:hover { box-shadow: 0 6px 18px rgb(0 0 0 / .11); transform: translateY(-2px); }
.tw-product-card > .woocommerce-LoopProduct-link {
  display: flex; flex-direction: column; flex: 1 1 auto;
  min-width: 0; min-height: 0; height: auto; overflow: visible; color: inherit;
}

/* Ảnh: tràn hết chiều rộng card, khung vuông cố định, không padding trắng. */
.tw-product-card .tw-product-media {
  position: relative;
  flex: none;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.tw-product-card .tw-product-media img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
  margin: 0 !important;
}
.tw-product-card .onsale {
  position: absolute; z-index: 2; top: 10px; right: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--teal-800); color: var(--white);
  font: 700 11px/1 var(--font-sans);
}

/* Thân card: tên cố định N dòng → đường kẻ, giá và footer thẳng hàng giữa các card. */
.tw-product-card .tw-product-card-body {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  flex: 1 1 auto; gap: var(--tw-card-gap);
  min-height: 0; overflow: visible;
  padding: calc(var(--tw-card-pad) * 1.4) var(--tw-card-pad) var(--tw-card-pad);
  text-align: center;
  border-top: 1px solid #f0f0f0;
}
/* Hộp tên cao cố định N dòng; chữ căn giữa cả ngang lẫn dọc → tên 1, 2 hay 3 dòng
   đều cách đường kẻ như nhau và đường kẻ/giá không xê dịch giữa các card. */
.tw-product-card h2.woocommerce-loop-product__title {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 100%;
  margin: 0; padding: 0;
  font: var(--tw-card-title-weight, 600) var(--tw-card-title-size)/var(--tw-card-title-line) var(--font-sans);
  color: var(--text-heading, var(--text-strong));
  text-align: center;
  height: calc(var(--tw-card-title-lines) * var(--tw-card-title-line) * 1em);
  overflow: hidden;
}
.tw-product-card h2.woocommerce-loop-product__title > span {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--tw-card-title-lines);
  overflow: hidden;
  overflow-wrap: anywhere;
}
.tw-product-card .tw-product-divider {
  display: block; flex: none;
  width: 34px; height: 2px;
  background: var(--teal-700);
}
.tw-product-card .tw-stock,
.tw-product-card .star-rating { display: none; }
.tw-product-card .price {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 2px 6px;
  margin: 0; padding: 0;
  font: var(--tw-card-price-weight, 700) var(--tw-card-price-size)/1.3 var(--font-sans);
  color: var(--teal-800);
  text-align: center;
}
.tw-product-card .price ins { text-decoration: none; }
.tw-product-card .price del { order: 2; font-size: calc(.7em - 0.3px); font-weight: 400; color: var(--text-muted); margin: 0; }
.tw-product-card .tw-contact-price { font-size: inherit; font-weight: inherit; }

/* Footer xác thực: chiều cao cố định, luôn nằm đáy card. */
.tw-product-card .tw-product-assurance {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap;
  flex: none; gap: 8px;
  height: var(--tw-card-footer-h); min-height: var(--tw-card-footer-h);
  margin-top: auto;
  padding: 0 var(--tw-card-footer-pad) !important;
  border-top: 1px solid #e2e2e2;
  font: 600 var(--tw-card-footer-size)/1.25 var(--font-sans);
  color: var(--text-strong);
}
/* "100% Verified Authentic" luôn trên một hàng; card quá hẹp thì rút gọn bằng "…" thay vì xuống dòng. */
.tw-product-card .tw-assurance-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.tw-product-card .tw-assurance-icons { display: flex; gap: 6px; margin-left: auto; color: var(--green-700); }
.tw-product-card .tw-assurance-icons svg { display: block; width: var(--tw-card-icon); height: var(--tw-card-icon); }
.tw-product-card .tw-assurance-icons svg:last-child { color: var(--alert-600); }
.tw-product-card .tw-condition {
  flex: none; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 8px; border: 1.5px solid #5db82e; border-radius: 4px;
  color: #3fa31f; text-transform: uppercase;
  font: 700 var(--tw-card-badge-size)/1.3 var(--font-sans) !important;
}

/* Rolex trang chủ: lưới đồng nhất như mọi lưới sản phẩm khác (bỏ bento ô to/ô nhỏ). */
#om-rolex-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; grid-template-rows: none !important; grid-auto-rows: auto !important; gap: 18px; margin: 0; padding: 0; }
#om-rolex-grid > .tw-product-card:first-child { grid-row: auto; grid-column: auto; }

/* Lưới chứa card: hàng co theo card cao nhất, mọi card cùng chiều cao. */
:is(.tw-product-grid, .tw-product-rail, #dm-grid, #om-rolex-grid, #om-longines-grid) { align-items: stretch; }

/* Card hẹp (rail 5 cột, lưới Longines 5 cột, laptop): thu gọn khoảng cách, giữ nguyên cấu trúc. */
@media (max-width: 1439px) {
  .tw-product-card {
    --tw-card-pad: 16px;
    --tw-card-gap: 12px;
    --tw-card-footer-h: 50px;
    --tw-card-footer-pad: 12px;
    --tw-card-icon: 16px;
  }
}

/* Tablet ≤1023px */
@media (max-width: 1023px) {
  .tw-product-card {
    --tw-card-pad: 14px;
    --tw-card-gap: 10px;
    --tw-card-footer-h: 46px;
    --tw-card-footer-pad: 10px;
    --tw-card-icon: 15px;
  }
  #om-rolex-grid { gap: 14px; }
}

/* Mobile ≤767px: 2 cột; ẩn icon phụ để nhãn tình trạng không bị cắt. */
@media (max-width: 767px) {
  .tw-product-card {
    --tw-card-pad: 10px;
    --tw-card-gap: 8px;
    --tw-card-footer-h: 40px;
    --tw-card-footer-pad: 8px;
  }
  .tw-product-card .tw-product-divider { width: 28px; }
  .tw-product-card .tw-assurance-icons { display: none; }
  .tw-product-card .tw-condition { padding: 2px 6px; border-width: 1px; }
  .tw-product-card .onsale { width: 36px; height: 36px; font-size: 10px; top: 6px; right: 6px; }
  #om-rolex-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px; }
}
