/*
 * Phần dùng chung của giỏ hàng, thanh toán, tài khoản, đơn hàng (plan 11).
 * Đặc tả: docs/plans/11-dac-ta-wireframe.md mục 1.
 * Phụ thuộc: tokens.css, base.css, components.css, layout.css
 */

/* =========================================================
   Khung trang: mobile nền kem, khối là thẻ trắng cách lề 8px; desktop khung 1240px
   ========================================================= */
.tg-shop {
  background: var(--color-bg);
}

.tg-shop__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
}

/* Thẻ trắng của các màn này (mobile bo 10px, desktop bo 12px viền ấm) */
.tg-shop-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3-5);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.tg-shop-card__title {
  color: var(--color-text);
  font-size: var(--text-15);
  font-weight: var(--weight-bold);
}

.tg-shop-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* Hàng có mũi tên phải (Lời nhắn, Hỗ trợ…): cả hàng là nút/link */
.tg-shop-row {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  width: 100%;
  min-height: var(--tap-min);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text);
  font-size: var(--text-14);
  text-align: left;
  cursor: pointer;
  --icon-size: 18px;
}

.tg-shop-row__value {
  margin-left: auto;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-meta);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-shop-row > .tg-icon:last-child {
  flex: none;
  color: var(--color-text-muted);
  --icon-size: 16px;
}

.tg-shop-row > .tg-icon:first-child {
  color: var(--color-brand);
}

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

/* Chữ mờ, số tiền */
.tg-muted {
  color: var(--color-text-muted);
}

.tg-money {
  color: var(--color-red);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tg-money--minus {
  color: var(--color-brand-strong);
}

/* Tiêu đề khối gợi ý giữa trang, gạch hai bên ("Có thể bạn cũng thích") */
.tg-shop-divider-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-block: var(--space-2);
  color: var(--color-text);
  font-size: var(--text-15);
  font-weight: var(--weight-bold);
  text-align: center;
}

.tg-shop-divider-title::before,
.tg-shop-divider-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border-strong);
}

/* Lưới thẻ sản phẩm gợi ý: 2 cột mobile, 3 cột 768–1023px, 6 cột desktop */
.tg-shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

/* Thẻ cùng hàng cao bằng nhau (thẻ có giá gạch cao hơn) */
.tg-shop-grid > li {
  display: flex;
}

.tg-shop-grid > li > .tg-product-card {
  flex: 1;
}

@media (min-width: 768px) {
  .tg-shop-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .tg-shop {
    padding-block: var(--space-6);
  }

  .tg-shop__inner {
    gap: var(--section-gap);
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding: 0 var(--gutter);
  }

  .tg-shop-card {
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6);
    border: 1px solid var(--color-border-warm);
    border-radius: var(--radius-xl);
  }

  .tg-shop-card__title {
    font-size: var(--text-17);
  }

  .tg-shop-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-3);
  }
}

/* =========================================================
   Header rút gọn (desktop): logo | gạch đứng | tên màn | phần phải
   ========================================================= */
.tg-header--compact .tg-header__divider {
  width: 1.5px;
  height: 32px;
  background: var(--color-brand);
}

.tg-header--compact .tg-header__page-title {
  color: var(--color-brand);
  font-size: var(--text-20);
  font-weight: var(--weight-regular);
}

.tg-header__compact-search {
  display: flex;
  width: 520px;
  max-width: 45%;
  height: 42px;
  margin-left: auto;
  overflow: hidden;
  border: 2px solid var(--color-brand);
  border-radius: var(--radius-md);
}

.tg-header__compact-search input {
  flex: 1;
  min-width: 0;
  padding: 0 var(--space-3);
  border: 0;
  font-size: var(--text-14);
  outline: none;
}

.tg-header__compact-search button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  border: 0;
  background: var(--color-brand);
  color: var(--color-text-on-dark);
  --icon-size: 18px;
}

.tg-header__compact-search:focus-within {
  box-shadow: var(--ring-input-focus);
}

.tg-header__support {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: var(--text-14);
}

.tg-header__support a {
  color: var(--color-text-muted);
  text-decoration: underline;
}

.tg-header__help {
  margin-left: auto;
  color: var(--color-brand);
  font-size: var(--text-14);
}

/* Đăng nhập, đăng ký (D10, D10b): tên màn 22px màu chữ chính */
.tg-header--compact-help .tg-header__page-title {
  color: var(--color-text);
  font-size: var(--text-22);
}

/* =========================================================
   Appbar: số mờ sau tiêu đề, nút chữ "Sửa"
   ========================================================= */
.tg-appbar__count {
  color: var(--color-text-muted);
  font-size: var(--text-14);
  font-weight: var(--weight-regular);
}

.tg-appbar--center .tg-appbar__title {
  text-align: center;
}

.tg-appbar__action {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0 var(--space-2);
  border: 0;
  background: none;
  color: var(--color-brand);
  font-size: var(--text-14);
}

.tg-appbar__action[aria-pressed="true"] {
  color: var(--color-brand);
  font-weight: var(--weight-semibold);
}

/* =========================================================
   Thông báo của Woo (woocommerce-error / -message / -info) theo kiểu tg-alert
   ========================================================= */
.tg-shop .woocommerce-notices-wrapper:empty {
  display: none;
}

.tg-shop .woocommerce-error,
.tg-shop .woocommerce-message,
.tg-shop .woocommerce-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: var(--space-3) var(--space-3-5);
  border-radius: var(--radius-lg);
  background: var(--color-brand-tint);
  color: var(--color-text);
  font-size: var(--text-14);
  list-style: none;
}

.tg-shop .woocommerce-error {
  border: 1px solid var(--color-red-soft);
  background: var(--color-red-soft);
  color: var(--color-red-strong);
}

.tg-shop .woocommerce-error a {
  color: inherit;
  text-decoration: underline;
}

.tg-shop .woocommerce-message .button,
.tg-shop .woocommerce-info .button {
  margin-left: var(--space-2);
  color: var(--color-brand);
  font-weight: var(--weight-semibold);
}

/* =========================================================
   Bảng trượt: mobile từ đáy (components.css), desktop thành hộp thoại giữa màn
   ========================================================= */
.tg-shop-dialog .tg-sheet__head h2 {
  flex: 1;
  min-width: 0;
  font-size: inherit;
  font-weight: inherit;
}

.tg-shop-dialog .tg-sheet__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.tg-shop-dialog .tg-sheet__foot {
  display: flex;
  gap: var(--space-2);
}

.tg-shop-dialog .tg-sheet__foot .tg-btn {
  flex: 1;
}

@media (min-width: 1024px) {
  .tg-sheet.tg-shop-dialog {
    inset: 50% auto auto 50%;
    width: min(var(--dialog-width, 560px), calc(100vw - 48px));
    max-height: 80vh;
    border-radius: var(--radius-3xl);
    opacity: 0;
    transform: translate(-50%, -46%);
    transition: transform var(--duration-base) var(--ease-out), opacity var(--duration-base), visibility 0s linear var(--duration-base);
  }

  .tg-sheet.tg-shop-dialog.is-open {
    opacity: 1;
    transform: translate(-50%, -50%);
  }

  .tg-shop-dialog .tg-sheet__foot {
    justify-content: flex-end;
  }

  .tg-shop-dialog .tg-sheet__foot .tg-btn {
    flex: none;
    min-width: 140px;
  }
}

/* Tra cứu đơn cho khách vãng lai (page-templates/order-lookup.php) */
.tg-lookup .tg-shop-card {
  margin-bottom: 8px;
}
.tg-lookup__form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.tg-lookup__total {
  margin-top: 8px;
  text-align: right;
}
.tg-lookup__orders {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.tg-lookup__order {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tg-lookup__order:hover,
.tg-lookup__order[aria-current="true"] {
  border-color: var(--color-brand);
}
.tg-lookup__order[aria-current="true"] {
  box-shadow: inset 0 0 0 1px var(--color-brand);
}

/* =========================================================
   Khối gợi ý (giỏ, thanh toán): mobile dải cuộn ngang thẻ 112px, desktop lưới 6 cột
   ========================================================= */
/* Wireframe M4/M4e: tiêu đề khối gợi ý 14px (desktop 15px), nhỏ hơn tiêu đề thẻ chung */
.tg-cart-suggest .tg-shop-card__title {
  font-size: var(--text-14);
}

.tg-cart-suggest__list {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.tg-cart-suggest__list::-webkit-scrollbar {
  display: none;
}

.tg-cart-suggest__item {
  display: flex;
  flex: 0 0 112px;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  scroll-snap-align: start;
  --price-size: var(--text-14);
}

.tg-cart-suggest__media {
  display: block;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--color-surface-alt);
}

.tg-cart-suggest__item > :not(.tg-cart-suggest__media) {
  padding-inline: var(--space-1-5);
}

.tg-cart-suggest__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tg-cart-suggest__name {
  overflow: hidden;
  font-size: var(--text-meta);
  font-weight: var(--weight-regular);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-cart-suggest__name a {
  color: var(--color-text);
}

.tg-cart-suggest__add {
  display: inline-flex;
  align-items: center;
  gap: var(--space-0-5);
  min-height: var(--tap-min);
  color: var(--color-brand);
  font-size: var(--text-meta);
  font-weight: var(--weight-semibold);
  --icon-size: 14px;
}

@media (min-width: 1024px) {
  .tg-cart-suggest .tg-shop-card__title {
    font-size: var(--text-15);
  }

  .tg-cart-suggest__list {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-3);
    overflow: visible;
  }

  .tg-cart-suggest__name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: var(--text-14);
    white-space: normal;
  }
}
