/* Theme fix 2026-10: product-card action button, countdown fit, mobile P0 fixes.
   Loaded right after codex-polish.scss.css (layout/theme.liquid). Header/footer untouched. */

/* ---------- Product card: whole card opens the product; action button always visible ---------- */
.product-container .product-meta h4.product-name > a:first-child::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}
.product-container .swatch { position: relative; z-index: 2; }
.product-container:has(.product-name > a:focus-visible) {
  outline: 3px solid var(--anker-blue-deep, #007fae);
  outline-offset: 2px;
}

.product-container .product-card-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}
.product-container .product-card-foot .sale-cycle-countdown { margin: 0; }

/* Reset the legacy hover overlay (timber + codex-polish) for the foot button only. */
.product-card-foot .product-actions {
  position: relative;
  z-index: 2;
  inset: auto;
  top: auto !important;
  width: 100%;
  max-width: none;
  margin: 0;
  opacity: 1;
  transform: none;
  transition: none;
}
.product-card-foot .product-card-buy { width: 100%; margin: 0; }

.product-card-foot .product-actions .product-action {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  color: #fff;
  background: var(--anker-blue-deep, #007fae);
  border: 1.5px solid var(--anker-blue-deep, #007fae);
  border-radius: 12px;
  box-shadow: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.product-card-foot .product-actions .product-action:hover,
.product-card-foot .product-actions .product-action:focus-visible {
  color: #fff;
  background: #006a92;
  border-color: #006a92;
  box-shadow: none;
  transform: none;
}
.product-card-foot .product-actions .product-action:focus-visible {
  outline: 3px solid #7dddff;
  outline-offset: 2px;
}
.product-card-foot .product-action__icon { flex: 0 0 auto; }

.product-card-foot .product-actions .product-action--ghost {
  color: var(--anker-blue-deep, #007fae);
  background: #fff;
}
.product-card-foot .product-actions .product-action--ghost:hover,
.product-card-foot .product-actions .product-action--ghost:focus-visible {
  color: #005f83;
  background: #eef8fc;
  border-color: #005f83;
}
.product-card-foot .product-actions .product-action--off,
.product-card-foot .product-actions .product-action--off:hover,
.product-card-foot .product-actions .product-action--off:focus-visible {
  color: #4f5b65;
  background: #eef2f4;
  border-color: #eef2f4;
}

/* "Đề cử" badge: discount above 50%. Top-right of the image; Liquid skips it when promo tag 1 ("New") holds that corner. */
.product-container .product-badge-pick {
  position: absolute;
  z-index: 7;
  top: 12px;
  right: 12px;
  padding: 5px 8px;
  color: #fff;
  background: #0b1118;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
  pointer-events: none;
}

/* Countdown in cards: never clip (backlog 1). "Còn" wraps above the timer only when the card is too narrow. */
.product-container .sale-cycle-countdown {
  flex-wrap: wrap;
  row-gap: 1px;
  column-gap: 3px;
}

/* Đợt 8 product v3: chip đặc tính trên card mobile hiện đủ chữ (trước đây 1 dòng, cắt "Mag…", "Ove…").
   codex-polish ≤640px ép rail 1 dòng cao 38px, chip nowrap + ellipsis, chip đầu max 45%. Ở đây: tối đa 2 chip (giữ luật codex),
   chip xuống dòng khi hẹp, không cắt chữ. Trang chủ v3 (.hv2) có rule riêng mạnh hơn nên không đổi. */
@media (max-width: 640px) {
  .product-container .product-tags {
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    height: auto;
    row-gap: 4px;
    overflow: visible;
  }
  .product-container .product-tags > .product-promo-tag,
  .product-container .product-tags > .product-gift {
    height: auto;
    min-height: 24px;
    max-width: 100%;
    padding: 4px 7px;
    line-height: 16px;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .product-container .product-tags > :first-child,
  .product-container .product-tags > :nth-child(2) { flex: 0 1 auto; max-width: 100%; }
}

/* Hover: light feedback only (border/shadow + back image from codex-polish); nothing covers the image. */
@media (hover: none) {
  .product-container:hover { box-shadow: none; }
}

@media (max-width: 768px) {
  .product-container .product-card-foot { gap: 8px; padding-top: 8px; }
  .product-card-foot .product-actions .product-action {
    min-height: 44px; /* đợt 8 product v3: 40 → 44px (chuẩn chạm của dự án) */
    gap: 6px;
    padding: 8px 6px;
    border-radius: 10px;
    font-size: 13px;
  }
  .product-card-foot .product-action__icon { width: 16px; height: 16px; }

  /* Countdown: fit 2-column cards. */
  .product-container .sale-cycle-countdown {
    padding: 4px 3px;
    font-size: clamp(10px, 2.9vw, 11px);
  }
  .product-container .sale-cycle-countdown__timer { gap: 2px; }
  .product-container .sale-cycle-countdown__separator { margin: 0; }

  html[data-mobile-theme="dark"] .product-card-foot .product-actions .product-action--ghost {
    color: #7dd3f5;
    background: transparent;
    border-color: #3a6f88;
  }
  html[data-mobile-theme="dark"] .product-card-foot .product-actions .product-action--off {
    color: #9baab4;
    background: #1a2731;
    border-color: #1a2731;
  }
}

@media (max-width: 359px) {
  .product-container .sale-cycle-countdown { padding: 4px 1px; }
  .product-container .sale-cycle-countdown__timer { gap: 0; }
  .product-container [data-sale-cycle-days] + span { margin: 0 2px 0 1px; }
  .akr-hw .product-container [data-sale-cycle-days] + span { margin: 0; } /* landing keeps its own timer gap */
  .product-card-foot .product-action__icon { display: none; }
  .product-card-foot .product-actions .product-action { padding: 8px 4px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .product-card-foot .product-actions .product-action { transition: none; }
}

/* ---------- P0: pagination on collection/search (44px targets, visible in mobile dark) ---------- */
.template-collection .pagination > span,
.template-search .pagination > span {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  vertical-align: middle;
}
.template-collection .pagination > span > a,
.template-search .pagination > span > a {
  display: flex;
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}
@media (max-width: 768px) {
  html[data-mobile-theme="dark"] .template-collection .pagination,
  html[data-mobile-theme="dark"] .template-search .pagination { border-color: #2c3a45; }
  html[data-mobile-theme="dark"] .template-collection .pagination > span,
  html[data-mobile-theme="dark"] .template-collection .pagination a,
  html[data-mobile-theme="dark"] .template-search .pagination > span,
  html[data-mobile-theme="dark"] .template-search .pagination a { color: #f1f6f8; }
  html[data-mobile-theme="dark"] .template-collection .pagination .page.current,
  html[data-mobile-theme="dark"] .template-search .pagination .page.current { color: #fff; background: #007fae; }
}

/* ---------- P0: search suggestions readable in mobile dark ---------- */
@media (max-width: 768px) {
  html[data-mobile-theme="dark"] .anker-search-suggestion__title { color: var(--anker-ink); }
  html[data-mobile-theme="dark"] .anker-search-suggestion__status { color: #f1f6f8; background: #2c3a45; }
}

/* ---------- P1: mobile dark leftovers (sort select, sold-out badge outside home) ---------- */
@media (max-width: 768px) {
  html[data-mobile-theme="dark"] .collection__sort #SortBy {
    color: var(--anker-ink);
    background-color: var(--anker-surface);
    border-color: var(--anker-border);
  }
  html[data-mobile-theme="dark"] .product-container .label.sold-out {
    color: #f1f6f8;
    background: #2c3a45;
  }
}

/* ---------- Cart drawer open: hide the chat bubble so it never covers "Thanh toán" ---------- */
html.js-drawer-open-right #anker-live-chat { display: none !important; }

/* ---------- P0: chat bubble sits above the sticky "Mua ngay" bar on product pages ---------- */
@media (max-width: 768px) {
  .template-product #anker-live-chat { bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ======================================================================
   Đợt 1 giỏ hàng v3 (theme-cart-v3, Claude-A). Chỉ CSS, không đổi DOM.
   Màu nút thanh toán ở ngăn giỏ và /cart do khối này giữ (Claude-C không viết lại).
   Biến --cart-sticky-h: chiều cao thanh dính đáy /cart mobile (mặc định 66px = nút 46 + lề 10 + khe 10).
   Trang /cart v3 (Codex) có thanh cao hơn thì đặt biến này trên .template-cart, chat và lề đáy tự theo.
   ====================================================================== */

/* ---------- Chat: desktop/tablet chỉ còn avatar khi đang thu gọn (pill 180×60 che nút card cột cuối) ----------
   #anker-live-chat là khung ngoài, nội dung nằm trong shadow DOM của center.anker.vn nên chỉ cắt vùng hiển thị.
   clip-path cắt luôn vùng nhận click, nên phần bị cắt không chặn nút bên dưới.
   Cắt chỉ khi khung hẹp hơn 250px và thấp hơn 120px (pill thu gọn). Khi mở (400×680) mọi giá trị về âm/0:
   không cắt, giữ bóng đổ. Bong bóng tròn 52px ở mobile: phần phải bị cắt <0 nên cũng không đổi.
   Rê chuột hoặc focus vào avatar thì hiện lại đủ "Cần tư vấn?" (pill phủ cả chỗ avatar nên không nháy). */
#anker-live-chat:not(:hover):not(:focus-within) {
  clip-path: inset(
    max(-60px, min(0px, calc((120px - 100%) * 100)))
    max(-60px, min(calc(100% - 64px), calc((250px - 100%) * 100)))
    max(-60px, min(0px, calc((120px - 100%) * 100)))
    max(-60px, min(0px, calc((250px - 100%) * 100)))
    round max(0px, min(30px, calc((250px - 100%) * 100)))
  );
  /* avatar nằm mép trái pill: dời khung sang phải để avatar về đúng góc phải (cách mép 20px như cũ),
     không lấn vào cột card. Khi mở/hover giá trị về 0, panel giữ vị trí gốc. */
  transform: translateX(max(0px, min(calc(100% - 64px), calc((250px - 100%) * 100))));
}

/* ---------- Ngăn giỏ: nút Thanh toán đạt AA (trắng trên #007FAE = 4,52:1) ---------- */
#CartDrawer .cart__checkout {
  color: #fff;
  background: #007fae;
  border-color: #007fae;
}
#CartDrawer .cart__checkout:hover,
#CartDrawer .cart__checkout:focus {
  color: #fff;
  background: #006a92;
  border-color: #006a92;
}
#CartDrawer .cart__checkout:focus-visible {
  outline: 3px solid #7dddff;
  outline-offset: 2px;
}

/* ---------- Ngăn giỏ: nút đóng và nút ± đủ 44px (codex-polish ép 36px ≤640, ± 35×36) ---------- */
#CartDrawer .drawer__close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
}
#CartDrawer .drawer__close button {
  width: 44px;
  height: 44px;
}
#CartDrawer .ajaxcart__qty { /* khung 116×38 overflow:hidden → 3×44 + viền 1px */
  width: 134px;
  min-width: 134px;
  max-width: 134px;
  height: 46px;
}
#CartDrawer .ajaxcart__qty-num,
#CartDrawer .ajaxcart__qty-adjust {
  height: 44px;
}
#CartDrawer .ajaxcart__qty-num { line-height: 44px; }
#CartDrawer .ajaxcart__qty-adjust { width: 44px; }

/* ---------- /cart: nút Thanh toán đạt AA (input hoặc button name="checkout") ---------- */
body.template-cart [name="checkout"] {
  color: #fff;
  background: #007fae;
  border-color: #007fae;
}
body.template-cart [name="checkout"]:hover,
body.template-cart [name="checkout"]:focus {
  color: #fff;
  background: #006a92;
  border-color: #006a92;
}
body.template-cart [name="checkout"]:focus-visible {
  outline: 3px solid #7dddff;
  outline-offset: 2px;
}

/* ---------- /cart mobile: nút Thanh toán dính đáy (≤640) — chat nằm trên nút, trang chừa đáy ---------- */
@media (max-width: 640px) {
  .template-cart #anker-live-chat {
    bottom: calc(var(--cart-sticky-h, 66px) + 10px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .template-cart .main-content {
    padding-bottom: max(112px, calc(var(--cart-sticky-h, 66px) + 46px + env(safe-area-inset-bottom, 0px)));
  }
  /* cuối trang: dòng bản quyền không nằm dưới nút và chat (cùng cách trang sản phẩm 136px ở codex-polish) */
  .template-cart .site-footer__copyright .wrapper {
    padding-bottom: calc(var(--cart-sticky-h, 66px) + 74px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- /cart giỏ trống: nút 44px; dark mobile đọc được (H1 #F1F6F8 trên khung #FFF = 1,09:1) ---------- */
.template-cart .cart-empty__continue {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  color: #fff;
  background: #007fae;
  line-height: 20px;
}
.template-cart .cart-empty__continue:hover,
.template-cart .cart-empty__continue:focus {
  color: #fff;
  background: #006a92;
}
.template-cart .cart-empty__continue:focus-visible {
  outline: 3px solid #7dddff;
  outline-offset: 2px;
}
@media (max-width: 768px) {
  html[data-mobile-theme="dark"] .template-cart .cart-empty {
    color: #9baab4;
    background: #121c25;
    border-color: #2c3a45;
    box-shadow: none;
  }
  html[data-mobile-theme="dark"] .template-cart .cart-empty h1 { color: #f1f6f8; }
  html[data-mobile-theme="dark"] .template-cart .cart-empty p { color: #c6d1d8; }
}

/* Sản phẩm "Đề cử" (giảm trên 50%) nổi hơn các thẻ khác MỘT CHÚT (Tùng 22/10: sản phẩm khác vẫn cần bán).
   Thẻ: vạch nhấn xanh 3px trên đỉnh, viền xanh mảnh, bóng 2 lớp, phần chữ ánh xanh rất nhạt. Nhãn: nhạt, cùng dáng viên thuốc với nhãn -%, không icon (Tùng 23/10).
   !important để thắng rule thẻ riêng của trang chủ v3 (.hv2) và giao diện tối mobile; không đổi kích thước hay bố cục. */
.product-container:has(.product-badge-pick) {
  border-color: #a6d9ee !important;
  box-shadow: 0 1px 2px rgba(0, 63, 90, .06), 0 14px 28px -20px rgba(0, 127, 174, .5) !important;
}
.product-container:has(.product-badge-pick):hover { border-color: #6cc3e4 !important; box-shadow: 0 1px 2px rgba(0, 63, 90, .08), 0 16px 32px -18px rgba(0, 127, 174, .55) !important; }
.product-container:has(.product-badge-pick)::before {
  content: "";
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #00a7e1, #007fae 60%, #00a7e1);
  pointer-events: none;
}
.product-container:has(.product-badge-pick) .product-meta {
  background: linear-gradient(180deg, rgba(234, 247, 253, 0) 0, #f3fafd 100%) !important;
  box-shadow: inset 0 1px 0 #e3f2f9;
}
.product-container .product-badge-pick {
  color: #006b93;
  background: #eaf7fc;
  box-shadow: inset 0 0 0 1px rgba(0, 127, 174, .2);
  border-radius: 999px !important;
  letter-spacing: .04em;
}
html[data-mobile-theme="dark"] .product-container:has(.product-badge-pick) {
  border-color: #2a6f8f !important;
  box-shadow: 0 14px 28px -20px rgba(63, 182, 227, .4) !important;
}
html[data-mobile-theme="dark"] .product-container:has(.product-badge-pick) .product-meta {
  background: linear-gradient(180deg, rgba(63, 182, 227, 0) 0, rgba(63, 182, 227, .08) 100%) !important;
  box-shadow: inset 0 1px 0 rgba(63, 182, 227, .18);
}

/* Sửa tràn ngang (Tùng 30/10): dải nền breadcrumb cũ dùng padding 200% làm trang rộng 3720px trên máy tính
   (đăng nhập, đăng ký, tìm kiếm, trang nội dung); nền html xanh #00a4e0 lộ ra khi cuộn nảy. */
html { background-color: #fff; }
.bgFull:before { left: 50%; width: 100vw; padding: 0; margin-left: -50vw; }
