/* Giỏ hàng và thanh toán của web cho khách (luồng 9). Nạp sau web.css của luồng 8 và dùng lại biến --bhw-*, nút, ô nhập,
   khung .bhw-panel, .bhw-sum, .bhw-lines của file đó; ở đây chỉ có phần riêng của giỏ. Lớp .bhw-*, mobile-first. */

/* ---------- Liên kết giỏ ở thanh trên, nút trên thẻ hàng ---------- */

.bhw a.bhw-cartlink {
  display: inline-flex;
  align-items: center;
  gap: var(--bhw-s2);
  min-height: 40px;
  padding: 0 var(--bhw-s3);
  border: 1px solid var(--bhw-line);
  border-radius: 999px;
  background: var(--bhw-bg);
  color: var(--bhw-ink);
  font-size: var(--vc-step--1, 14px);
  font-weight: 600;
  text-decoration: none;
}

.bhw a.bhw-cartlink:hover {
  border-color: var(--bhw-c);
  color: var(--bhw-c);
}

.bhw-cartlink-n {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bhw-a);
  color: var(--bhw-on-a);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.bhw-cartlink-n[hidden] {
  display: none;
}

.bhw-addcart {
  min-height: 40px;
  border-color: var(--bhw-c);
  color: var(--bhw-c);
  font-size: var(--vc-step--1, 14px);
}

.bhw-addcart:hover {
  background: var(--bhw-soft);
}

.bhw-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Thẻ hết hàng / giá liên hệ: luồng 9 không in nút, khối bọc của luồng 8 không chiếm chỗ. */
.bhw-card-actions:not(:has(*)) {
  display: none;
}

/* ---------- Ô số lượng ---------- */

.bhw-qty {
  display: inline-flex;
  align-items: stretch;
  flex: none;
  border: 1px solid var(--bhw-line);
  border-radius: var(--bhw-r);
  background: var(--bhw-bg);
  overflow: hidden;
}

.bhw-qty-btn {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--bhw-ink);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.bhw-qty-btn:hover {
  background: var(--bhw-soft);
}

.bhw-qty-input {
  width: 56px;
  min-height: 44px;
  border: 0;
  border-inline: 1px solid var(--bhw-line);
  background: transparent;
  color: var(--bhw-ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.bhw-qty-input::-webkit-outer-spin-button,
.bhw-qty-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.bhw-qty-btn:focus-visible,
.bhw-qty-input:focus-visible,
.bhw-cart-remove:focus-visible {
  outline: 2px solid var(--bhw-focus, color-mix(in srgb, var(--bhw-c) 50%, transparent));
  outline-offset: -2px;
}

.bhw-buy .bhw-qty {
  align-self: center;
}

/* ---------- Thông báo nổi ---------- */

.bhw-toast {
  position: fixed;
  left: 50%;
  bottom: var(--bhw-s5);
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: var(--bhw-s3);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: var(--bhw-s3) var(--bhw-s4);
  border-radius: var(--bhw-r);
  background: var(--bhw-ink);
  color: #fff;
  font-size: var(--vc-step--1, 14px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.bhw-toast.is-on {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.bhw-toast.is-error {
  background: var(--bhw-warn);
}

.bhw .bhw-toast a {
  flex: none;
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
}

/* ---------- Trang giỏ hàng ---------- */

.bhw-cart.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.bhw-cart-grid {
  display: grid;
  gap: var(--bhw-s5);
  align-items: start;
}

.bhw-cart-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--bhw-line);
}

.bhw-cart-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  grid-template-areas:
    "img info info"
    "img qty total"
    "img del del";
  gap: var(--bhw-s2) var(--bhw-s3);
  align-items: center;
  padding: var(--bhw-s4) 0;
  border-bottom: 1px solid var(--bhw-line);
}

.bhw-cart-img {
  grid-area: img;
  align-self: start;
}

.bhw-cart-img img {
  display: block;
}

.bhw-cart-img .bhw-noimg {
  display: grid;
  place-items: center;
}

.bhw-cart-img img,
.bhw-cart-img .bhw-noimg {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--bhw-r-sm);
}

.bhw-cart-info {
  grid-area: info;
  display: grid;
  gap: var(--bhw-s1);
  min-width: 0;
}

.bhw a.bhw-cart-name {
  color: var(--bhw-ink);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.bhw a.bhw-cart-name:hover {
  color: var(--bhw-c);
}

.bhw-cart-price {
  color: var(--bhw-muted);
  font-size: var(--vc-step--1, 14px);
}

.bhw-cart-out {
  justify-self: start;
  padding: 2px var(--bhw-s2);
  border-radius: var(--bhw-r-sm);
  background: var(--bhw-warn-l, #fdecec);
  color: var(--bhw-warn);
  font-size: 12px;
  font-weight: 600;
}

.bhw-cart-line.is-out .bhw-cart-img {
  opacity: 0.5;
}

.bhw-cart-line .bhw-qty {
  grid-area: qty;
  justify-self: start;
}

.bhw-cart-total {
  grid-area: total;
  justify-self: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bhw-cart-remove {
  display: inline-flex;
  align-items: center;
  gap: var(--bhw-s1);
  grid-area: del;
  justify-self: start;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bhw-muted);
  font: inherit;
  font-size: var(--vc-step--1, 14px);
  text-decoration: underline;
  cursor: pointer;
}

.bhw-cart-remove:hover {
  color: var(--bhw-warn);
}

.bhw-cart-remove .bhw-i {
  width: 16px;
  height: 16px;
}

.bhw-cart-side {
  display: grid;
  gap: var(--bhw-s4);
}

.bhw-cart-side .bhw-h2,
.bhw-cart-side .bhw-msg {
  margin: 0;
}

.bhw a.bhw-cart-back {
  justify-self: center;
  color: var(--bhw-muted);
  font-size: var(--vc-step--1, 14px);
}

/* ---------- Mã giảm giá ---------- */

.bhw-coupon {
  display: grid;
  gap: var(--bhw-s2);
}

.bhw-coupon-form {
  display: flex;
  gap: var(--bhw-s2);
}

.bhw-coupon-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--bhw-s3);
  border: 1px solid var(--bhw-line);
  border-radius: var(--bhw-r);
  background: var(--bhw-bg);
  color: var(--bhw-ink);
  font: inherit;
  text-transform: uppercase;
}

/* Ô mã giảm giá có icon coupon nằm trong ô. */
.bhw-coupon-field {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}

.bhw-coupon-field > .bhw-i {
  position: absolute;
  left: var(--bhw-s3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--bhw-muted);
  pointer-events: none;
}

.bhw-coupon-field input {
  width: 100%;
  padding-left: calc(var(--bhw-s3) + 28px);
}

.bhw-coupon-form input:focus {
  border-color: var(--bhw-c);
  outline: 2px solid color-mix(in srgb, var(--bhw-c) 25%, transparent);
}

.bhw-coupon-on,
.bhw-coupon-err {
  margin: 0;
  font-size: var(--vc-step--1, 14px);
}

.bhw-coupon-on {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--bhw-s1);
  color: var(--bhw-ok);
}

.bhw-coupon-on > .bhw-i {
  margin-right: var(--bhw-s1);
}

.bhw-coupon-err {
  color: var(--bhw-warn);
}

.bhw-coupon .bhw-cart-remove {
  min-height: 0;
}

/* ---------- Trang thanh toán ---------- */

.bhw-checkout {
  display: grid;
  gap: var(--bhw-s5);
  align-items: start;
}

.bhw-checkout-h {
  margin-top: var(--bhw-s5);
}

.bhw-field textarea {
  width: 100%;
  min-height: 88px;
  padding: var(--bhw-s2) var(--bhw-s3);
  border: 1px solid var(--bhw-line);
  border-radius: var(--bhw-r);
  background: var(--bhw-bg);
  color: var(--bhw-ink);
  font: inherit;
  resize: vertical;
}

.bhw-field textarea:focus {
  border-color: var(--bhw-c);
  outline: 2px solid color-mix(in srgb, var(--bhw-c) 25%, transparent);
  outline-offset: 0;
}

.bhw-pay {
  display: grid;
  gap: var(--bhw-s2);
  margin: 0 0 var(--bhw-s4);
  padding: 0;
  border: 0;
  min-width: 0;
}

.bhw-pay-opt {
  display: flex;
  align-items: flex-start;
  gap: var(--bhw-s3);
  padding: var(--bhw-s3) var(--bhw-s4);
  border: 1px solid var(--bhw-line);
  border-radius: var(--bhw-r);
  cursor: pointer;
}

.bhw-pay-opt:has(input:checked) {
  border-color: var(--bhw-c);
  background: var(--bhw-soft);
}

.bhw-pay-opt input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--bhw-c);
}

.bhw-pay-i {
  color: var(--bhw-c);
}

.bhw-pay-opt span {
  display: grid;
  gap: 2px;
}

.bhw-pay-opt small {
  color: var(--bhw-muted);
  font-size: var(--vc-step--1, 14px);
}

.bhw-checkout-sum .bhw-lines {
  margin-bottom: var(--bhw-s4);
}

/* ---------- Trang đặt hàng thành công ---------- */

.bhw-done {
  text-align: center;
  margin-bottom: var(--bhw-s5);
}

.bhw-done p {
  margin: 0 0 var(--bhw-s2);
}

.bhw-done-mark {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto var(--bhw-s3);
  color: var(--bhw-ok);
}

.bhw-done-note {
  color: var(--bhw-muted);
}

.bhw-bank-grid {
  display: grid;
  gap: var(--bhw-s4);
  align-items: center;
}

.bhw-bank-qr {
  justify-self: center;
  width: min(100%, 240px);
  aspect-ratio: 1;
  border: 1px solid var(--bhw-line);
  border-radius: var(--bhw-r);
  background: #fff;
  overflow: hidden;
}

.bhw-bank-qr[hidden] {
  display: none;
}

.bhw-qr {
  display: block;
  width: 100%;
  height: 100%;
}

.bhw-bank .bhw-sum dd {
  overflow-wrap: anywhere;
}

.bhw-done-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--bhw-s3);
  margin: var(--bhw-s5) 0 0;
}

/* ---------- Màn rộng ---------- */

@media (min-width: 600px) {
  .bhw-cart-line {
    grid-template-columns: 72px minmax(0, 1fr) auto 120px auto;
    grid-template-areas: "img info qty total del";
    gap: var(--bhw-s4);
  }

  .bhw-cart-img {
    align-self: center;
  }

  .bhw-cart-remove {
    justify-self: end;
  }

  .bhw-bank-grid {
    grid-template-columns: 240px minmax(0, 1fr);
  }
}

@media (min-width: 1024px) {
  .bhw-cart-grid {
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: var(--bhw-s6);
  }

  .bhw-checkout {
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: var(--bhw-s6);
  }

  .bhw-cart-side,
  .bhw-checkout-sum {
    position: sticky;
    top: var(--bhw-s5);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bhw-toast {
    transition: none;
  }
}

/* W2: nhắc mức miễn phí giao */
.bhw-freeship { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--bhw-accent, #ffab2e) 18%, transparent); font-size: 14px; }

/* Khối phí và thời gian giao (templates/pages/ship.php): trang Chính sách giao hàng và giỏ hàng. */
.bhw-ship {
  margin: 20px 0 0;
  padding: 16px;
  border: 1px solid var(--vc-line, #dfe4e1);
  border-radius: var(--vc-r, 12px);
  background: var(--vc-bg, #fff);
}

.bhw-ship-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 17px;
}

.bhw-ship--compact .bhw-ship-title {
  font-size: 15px;
}

.bhw-ship-list {
  margin: 0;
}

.bhw-ship-times {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 14px;
}

.bhw-ship-times th,
.bhw-ship-times td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--vc-line, #dfe4e1);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.bhw-ship-times th {
  font-weight: 600;
  background: color-mix(in srgb, var(--bhw-c, #1d5fbf) 6%, #fff);
}
