/*
 * Thanh toán (M5/D5): phương thức nhận hàng, phương thức thanh toán, chi tiết thanh toán, ô đồng ý, thanh đặt hàng.
 * Đặc tả: docs/plans/11-dac-ta-wireframe.md 2.3.
 * Phụ thuộc: shop.css, checkout.css
 */

.tg-checkout-ship__list,
.tg-pay-methods,
.tg-checkout-lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* =========================================================
   Phương thức nhận hàng: ô dạng thẻ, ô chọn có tam giác xanh góc trên trái
   ========================================================= */
.tg-checkout-ship__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tg-checkout-ship__list input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tg-checkout-ship__option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: var(--tap-min);
  padding: var(--space-2-5) var(--space-3);
  overflow: hidden;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.tg-checkout-ship__top {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-14);
  font-weight: var(--weight-semibold);
}

.tg-checkout-ship__cost {
  white-space: nowrap;
}

.tg-checkout-ship__sub {
  color: var(--color-text-muted);
  font-size: var(--text-meta);
}

.tg-checkout-ship__list input:checked + .tg-checkout-ship__option {
  border-color: var(--color-brand);
  background: var(--color-brand-tint);
}

.tg-checkout-ship__list input:checked + .tg-checkout-ship__option::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  background: var(--color-brand);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.tg-checkout-ship__list input:focus-visible + .tg-checkout-ship__option {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.tg-checkout-ship__hint {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-meta);
  --icon-size: 14px;
}

.tg-checkout-ship__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-14);
}

/* =========================================================
   Phương thức thanh toán: mobile hàng có chỉ báo chọn bên phải
   ========================================================= */
.tg-checkout-pay {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tg-pay-methods {
  display: flex;
  flex-direction: column;
}

.tg-pay-method {
  position: relative;
}

.tg-pay-method + .tg-pay-method {
  border-top: 1px solid var(--color-divider);
}

.tg-pay-method > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tg-pay-method__label {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  min-height: 48px;
  font-size: var(--text-14);
  cursor: pointer;
}

.tg-pay-method__icon {
  color: var(--color-brand);
  --icon-size: 20px;
}

.tg-pay-method__name {
  flex: 1;
}

.tg-pay-method__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--color-border-input);
  border-radius: var(--radius-round);
  color: transparent;
  --icon-size: 12px;
  --icon-stroke: 3;
}

.tg-pay-method > input:checked + .tg-pay-method__label .tg-pay-method__dot {
  border-color: var(--color-brand);
  background: var(--color-brand);
  color: var(--color-text-on-dark);
}

.tg-pay-method > input:focus-visible + .tg-pay-method__label {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.tg-pay-method .payment_box {
  padding: 0 0 var(--space-3) calc(20px + var(--space-2-5));
  color: var(--color-text-muted);
  font-size: var(--text-meta);
}

/* Chi tiết thanh toán */
.tg-checkout-totals__table {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-body-sm);
}

.tg-checkout-totals__table > div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.tg-checkout-totals__table dt {
  color: var(--color-text-muted);
}

.tg-checkout-totals__table dd {
  font-variant-numeric: tabular-nums;
}

.tg-checkout-totals__grand {
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-14);
}

.tg-checkout-totals__grand dt {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

/* Mobile: hai số tổng trong thẻ màu chữ chính (wireframe M5); desktop đỏ (D5) */
.tg-checkout-totals__grand .tg-money,
.tg-checkout-ship__total .tg-money {
  color: var(--color-text);
}

/* =========================================================
   Đồng ý + thanh đặt hàng (mobile dính đáy)
   ========================================================= */
.tg-checkout-consent {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-1-5);
  font-size: var(--text-meta);
}

.tg-checkout-consent .tg-check {
  font-size: var(--text-meta);
}

.tg-checkout-consent__terms {
  color: var(--color-text-muted);
}

.tg-checkout-consent__terms a {
  color: var(--color-brand);
  text-decoration: underline;
}

.tg-checkout-bar {
  justify-content: flex-end;
}

.tg-checkout-bar__sum {
  min-width: 0;
  text-align: right;
}

.tg-checkout-bar__total {
  font-size: var(--text-body-sm);
}

.tg-checkout-bar__total .tg-money {
  font-size: var(--text-17);
}

.tg-checkout-bar__saving {
  font-size: var(--text-meta);
}

.tg-checkout-bar__saving strong {
  color: var(--color-brand-strong);
}

.tg-checkout-bar__submit {
  flex: none;
  min-width: 132px;
  min-height: 46px;
}

/* Desktop D5 */
@media (min-width: 1024px) {
  .tg-checkout-ship {
    display: contents;
  }

  .tg-checkout-ship__title,
  .tg-checkout-ship__list,
  .tg-checkout-ship__empty {
    grid-area: ship;
  }

  .tg-checkout-ship__title {
    align-self: start;
    font-size: var(--text-15);
    font-weight: var(--weight-regular);
  }

  .tg-checkout-ship__list {
    flex-direction: row;
    flex-wrap: wrap;
    align-self: start;
    margin-top: var(--space-8);
  }

  .tg-checkout-ship__option {
    min-width: 220px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
  }

  .tg-checkout-ship__list input:checked + .tg-checkout-ship__option::before {
    display: none;
  }

  .tg-checkout-ship__top {
    font-size: var(--text-14);
  }

  .tg-checkout-ship__total {
    grid-area: total;
    justify-content: flex-end;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border-warm);
    font-size: var(--text-15);
  }

  .tg-checkout-ship__total .tg-money {
    color: var(--color-red);
    font-size: var(--text-18);
    font-weight: var(--weight-medium);
  }

  /* Thanh toán: hàng phương thức + dải bảng tiền + hàng cuối (đồng ý, nút) trong một thẻ */
  .tg-checkout-pay {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--color-border-warm);
    border-bottom: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    background: var(--color-surface);
  }

  .tg-checkout-pay__methods {
    flex-direction: row;
    align-items: center;
    gap: var(--space-6);
    border: 0;
    border-radius: 0;
  }

  .tg-checkout-pay__methods .tg-shop-card__title {
    font-weight: var(--weight-regular);
  }

  /* Chip phương thức thanh toán desktop chỉ có chữ (wireframe D5) */
  .tg-pay-method__icon {
    display: none;
  }

  .tg-pay-methods {
    flex-direction: row;
    gap: var(--space-3);
  }

  .tg-pay-method + .tg-pay-method {
    border-top: 0;
  }

  .tg-pay-method__label {
    min-height: 44px;
    padding: 0 var(--space-4);
    border: 1px solid var(--color-border-input);
    border-radius: var(--radius-md);
  }

  .tg-pay-method__dot {
    display: none;
  }

  .tg-pay-method > input:checked + .tg-pay-method__label {
    border-color: var(--color-brand);
    background: var(--color-brand-soft-alt);
    color: var(--color-brand-strong);
    font-weight: var(--weight-semibold);
  }

  .tg-pay-method .payment_box {
    padding: var(--space-2) 0 0;
  }

  .tg-checkout-totals {
    border: 0;
    border-top: 1px dashed var(--color-border-warm);
    border-radius: 0;
    background: var(--color-bg);
  }

  .tg-checkout-totals__table {
    align-self: flex-end;
    gap: var(--space-3);
    font-size: var(--text-14);
  }

  .tg-checkout-totals__table > div {
    display: grid;
    grid-template-columns: 200px 160px;
    justify-items: end;
  }

  .tg-checkout-totals__table dt {
    justify-self: start;
  }

  .tg-checkout-totals__grand {
    align-items: center;
    padding-top: 0;
    border-top: 0;
  }

  .tg-checkout-totals__grand .tg-money {
    color: var(--color-red);
    font-size: var(--text-26);
    font-weight: var(--weight-medium);
  }

  .tg-checkout-totals__grand dt {
    color: inherit;
    font-weight: var(--weight-regular);
  }

  .tg-checkout-finish {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    margin-top: calc(var(--section-gap) * -1);
    padding: var(--space-5) var(--space-6);
    border: 1px solid var(--color-border-warm);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    background: var(--color-surface);
  }

  .tg-checkout-consent {
    padding: 0;
    font-size: var(--text-14);
  }

  .tg-checkout-bar {
    position: static;
    padding: 0;
    border: 0;
  }

  .tg-checkout-bar__submit {
    width: 210px;
    min-height: 48px;
  }
}
