/* ============================================================================
   ts-shop-giohang.css — CSS RIÊNG CHO NHÓM "GIỎ HÀNG / ĐẶT HÀNG / ĐƠN HÀNG"
   File này CHỈ do nhóm Giỏ hàng sửa (Views/GioHang/Index.cshtml,
   Views/DatHang/Index.cshtml, Views/DatHang/ThanhCong.cshtml,
   Views/DonHang/Index.cshtml, Views/DonHang/ChiTiet.cshtml).

   ⚠️ `ts-shop.css` KHÔNG có class cho BẢNG → đây là nơi khai báo bảng biểu, form
   nhập liệu, dòng tổng tiền… Mọi lớp thêm mới đặt tiền tố `gh-` để không đụng
   trang khác. Chỉ dùng biến CSS có sẵn ở `:root` của ts-shop.css.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1) KHUNG TRANG + THẺ (card)
   `.section` của ts-shop.css đã lo padding dọc; ở đây chỉ thêm chút khoảng thở.
   --------------------------------------------------------------------------- */
.gh-page { padding-block: clamp(1.75rem, 1.2rem + 2vw, 3rem) clamp(2.5rem, 2rem + 2vw, 4rem); }
.gh-page .section-head { max-width: 52rem; }

.gh-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.1rem, .9rem + 1vw, 1.75rem);
}
.gh-card + .gh-card { margin-top: clamp(1.1rem, .9rem + 1vw, 1.75rem); }

.gh-card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.1rem; padding-bottom: .85rem;
  border-bottom: 1px solid var(--line);
}
.gh-card-title { margin: 0; font-size: var(--t-h3); color: var(--ink); }
.gh-count {
  display: inline-flex; align-items: center;
  font-size: .82rem; font-weight: 700; color: var(--blue);
  background: rgba(11, 92, 171, .09);
  border: 1px solid rgba(11, 92, 171, .22);
  border-radius: 999px; padding: .25rem .7rem; white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   2) BẢNG (giỏ hàng / danh sách đơn / chi tiết đơn)
   `.gh-table-wrap` cuộn ngang được → bảng rộng vẫn dùng tốt trên mobile.
   --------------------------------------------------------------------------- */
.gh-table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--white);
}
.gh-table-wrap:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.gh-table {
  width: 100%; min-width: 40rem;
  border-collapse: collapse;
  font-size: .95rem; color: var(--ink);
}
.gh-table th {
  text-align: left; white-space: nowrap;
  font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); background: var(--paper);
  padding: .8rem 1rem; border-bottom: 1px solid var(--line);
}
.gh-table td {
  padding: .9rem 1rem; vertical-align: middle;
  border-bottom: 1px solid var(--line); color: var(--ink-2);
}
.gh-table tbody tr:last-child td { border-bottom: 0; }
.gh-table tbody tr { transition: background .2s ease; }
.gh-table tbody tr:hover { background: rgba(11, 92, 171, .04); }
.gh-table th.is-num, .gh-table td.is-num { text-align: right; white-space: nowrap; }
.gh-table tfoot th, .gh-table tfoot td {
  background: var(--paper); font-weight: 800; color: var(--ink);
  border-top: 1px solid var(--line); border-bottom: 0;
}
.gh-table .gh-cell-act { text-align: right; white-space: nowrap; }

/* Ô "Sản phẩm": ảnh + tên + giá */
.gh-prod { display: flex; align-items: center; gap: .85rem; min-width: 15rem; }
.gh-prod-media {
  flex: 0 0 64px; width: 64px; height: 64px;
  display: grid; place-items: center; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-box);
}
.gh-prod-media img { width: 100%; height: 100%; object-fit: contain; }
.gh-prod-text { display: grid; gap: .15rem; min-width: 0; }
.gh-prod-name { font-weight: 700; color: var(--ink); }
.gh-prod-meta { font-size: .82rem; color: var(--ink-3); }

/* Số tiền */
.gh-money { font-weight: 800; color: var(--ink); white-space: nowrap; }
.gh-money.is-total { color: #d0021b; }

/* Ô số lượng + form cập nhật */
.gh-qty { display: inline-flex; align-items: center; gap: .45rem; }
.gh-qty input {
  width: 5rem; text-align: center;
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-box); padding: .45rem .5rem;
}
.gh-qty input:focus {
  outline: none; background: var(--white);
  border-color: var(--blue); box-shadow: 0 0 0 4px var(--glow);
}

/* Nút nhỏ trong bảng */
.gh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 700; font-size: .85rem;
  padding: .5rem .9rem; border-radius: var(--r-box);
  border: 1px solid transparent; background: var(--white); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.gh-btn:hover { transform: translateY(-1px); }
.gh-btn:active { transform: none; }
.gh-btn-ghost { background: var(--white); border-color: var(--line); color: var(--ink); }
.gh-btn-ghost:hover { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 3px var(--glow); }
.gh-btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.gh-btn-blue:hover { background: #0d69c4; color: #fff; box-shadow: 0 8px 20px rgba(11, 92, 171, .35); }
.gh-btn-danger { background: var(--white); border-color: rgba(208, 2, 27, .35); color: #d0021b; }
.gh-btn-danger:hover { background: #d0021b; border-color: #d0021b; color: #fff; }

/* ---------------------------------------------------------------------------
   3) DÒNG TỔNG TIỀN
   --------------------------------------------------------------------------- */
.gh-totals {
  display: grid; gap: .6rem;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1rem 1.15rem;
  width: min(24rem, 100%);
}
.gh-totals--flat { border: 0; padding: 0; width: 100%; background: transparent; }
.gh-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  font-size: .95rem; color: var(--ink-3);
}
.gh-row b { color: var(--ink); font-weight: 700; }
.gh-row.is-total {
  margin-top: .2rem; padding-top: .7rem;
  border-top: 1px solid var(--line);
  font-size: 1rem; font-weight: 700; color: var(--ink);
}
.gh-row.is-total b { font-size: 1.35rem; font-weight: 800; color: #d0021b; }
.gh-totals .btn { width: 100%; margin-top: .25rem; }
.gh-note { margin: 0; font-size: .85rem; color: var(--ink-3); }

/* Khối tổng tiền đặt cạnh bảng (giỏ hàng) */
.gh-foot {
  display: flex; flex-wrap: wrap; gap: 1rem 1.5rem;
  align-items: flex-start; justify-content: space-between;
  margin-top: clamp(1.1rem, .9rem + 1vw, 1.75rem);
}
.gh-foot-note { flex: 1 1 18rem; margin: 0; font-size: .92rem; color: var(--ink-3); }
.gh-foot-note b { color: var(--ink); }

/* ---------------------------------------------------------------------------
   4) BẢNG RỖNG (trạng thái không có dữ liệu — không để bảng trống trơ)
   --------------------------------------------------------------------------- */
.gh-empty {
  display: grid; gap: .7rem; justify-items: center; text-align: center;
  background: var(--white); border: 1px dashed var(--line); border-radius: var(--r-lg);
  padding: clamp(2rem, 1.4rem + 3vw, 3.25rem) 1.25rem;
}
.gh-empty-icon {
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.85rem;
  background: var(--paper); border: 1px solid var(--line);
}
.gh-empty h3 { margin: 0; font-size: var(--t-h3); color: var(--ink); }
.gh-empty p { margin: 0; max-width: 34rem; color: var(--ink-3); }
.gh-empty .btn { margin-top: .35rem; }

/* ---------------------------------------------------------------------------
   5) NHÃN TRẠNG THÁI ĐƠN (chờ xác nhận / đang giao / hoàn thành / đã huỷ)
   --------------------------------------------------------------------------- */
.gh-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 800; letter-spacing: .02em;
  padding: .3rem .7rem; border-radius: 999px; border: 1px solid;
  white-space: nowrap;
}
.gh-badge::before {
  content: ""; flex: 0 0 auto;
  width: .45rem; height: .45rem; border-radius: 50%; background: currentColor;
}
.gh-badge.is-new { color: #0b5cab; background: rgba(11, 92, 171, .1); border-color: rgba(11, 92, 171, .28); }
.gh-badge.is-ship { color: #9a5b00; background: rgba(255, 166, 0, .16); border-color: rgba(255, 166, 0, .4); }
.gh-badge.is-done { color: #1a7f37; background: rgba(26, 127, 55, .12); border-color: rgba(26, 127, 55, .3); }
.gh-badge.is-cancel { color: #b00020; background: rgba(208, 2, 27, .1); border-color: rgba(208, 2, 27, .3); }

/* ---------------------------------------------------------------------------
   6) FORM NHẬP LIỆU (họ tên / SĐT / địa chỉ / ghi chú)
   Dùng cùng ngôn ngữ thị giác với `.field` của #tu-van trong ts-shop.css.
   --------------------------------------------------------------------------- */
.gh-form { display: grid; gap: 1rem; }
.gh-field { display: grid; gap: .4rem; }
.gh-field label { font-weight: 600; font-size: .95rem; color: var(--ink); }
.gh-field .req { color: #d0021b; }
.gh-field input, .gh-field textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-box); padding: .7rem .85rem;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.gh-field textarea { resize: vertical; min-height: 4.5rem; }
.gh-field input:focus, .gh-field textarea:focus {
  outline: none; background: var(--white);
  border-color: var(--blue); box-shadow: 0 0 0 4px var(--glow);
}
/* Ô chọn (radio/checkbox) nếu form có thêm về sau — ăn theo màu thương hiệu */
.gh-field input[type="radio"], .gh-field input[type="checkbox"] {
  width: 1.1rem; height: 1.1rem; accent-color: var(--blue);
}
/* Thông báo lỗi từ asp-validation-for (tag helper tự thêm field-validation-*) */
.gh-err { font-size: .85rem; color: #b00020; min-height: 1.1em; }
.gh-err:empty { display: none; }
.gh-field .field-validation-error { color: #b00020; }
.gh-field .field-validation-valid:empty { display: none; }
.gh-field .input-validation-error {
  border-color: #d0021b; background: var(--white);
  box-shadow: 0 0 0 3px rgba(208, 2, 27, .14);
}
/* asp-validation-summary: khối cảnh báo chung của form */
.gh-alert {
  border: 1px solid rgba(208, 2, 27, .35); background: rgba(208, 2, 27, .06);
  color: #b00020; border-radius: var(--r-lg);
  padding: .85rem 1.1rem; font-size: .92rem; font-weight: 600;
}
.gh-alert ul { margin: .35rem 0 0; padding-left: 1.15rem; font-weight: 400; }
.gh-alert.validation-summary-valid { display: none; }
.gh-alert .validation-summary-valid { display: none; }
.gh-submit { width: 100%; margin-top: .25rem; }

/* ---------------------------------------------------------------------------
   7) BỐ CỤC 2 CỘT TRANG ĐẶT HÀNG (form + tóm tắt đơn)
   --------------------------------------------------------------------------- */
.gh-checkout {
  display: grid; grid-template-columns: 1.15fr .85fr;
  gap: clamp(1.1rem, .8rem + 2vw, 2.25rem); align-items: start;
}
.gh-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.gh-mini-item {
  display: flex; align-items: center; gap: .75rem;
  padding-bottom: .75rem; border-bottom: 1px dashed var(--line);
}
.gh-mini-item:last-child { padding-bottom: 0; border-bottom: 0; }
.gh-mini-name { flex: 1 1 auto; min-width: 0; color: var(--ink); font-weight: 600; font-size: .93rem; }
.gh-mini-qty { flex: 0 0 auto; font-size: .82rem; color: var(--ink-3); white-space: nowrap; }
.gh-mini .gh-money { font-size: .93rem; }
.gh-side-totals { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.gh-side-block { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.gh-side-block .gh-card-title { font-size: 1rem; margin-bottom: .7rem; }

/* Danh sách phương thức thanh toán (thông tin, không phải trường form) */
.gh-pay { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.gh-pay li { display: flex; gap: .55rem; align-items: flex-start; font-size: .9rem; color: var(--ink-2); }
.gh-pay li::before { content: "✓"; flex: 0 0 auto; font-weight: 800; color: #1a7f37; }
.gh-pay-note { margin: .6rem 0 0; font-size: .82rem; color: var(--ink-3); }

/* ---------------------------------------------------------------------------
   8) TRANG ĐẶT HÀNG THÀNH CÔNG
   --------------------------------------------------------------------------- */
.gh-done {
  display: grid; gap: .75rem; justify-items: center; text-align: center;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: clamp(1.5rem, 1.1rem + 2vw, 2.5rem);
}
.gh-done-icon {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; font-size: 2.25rem; color: #fff; line-height: 1;
  background: linear-gradient(140deg, #1a7f37, #39c46b);
  box-shadow: 0 12px 28px rgba(26, 127, 55, .28);
}
.gh-done-code { margin: 0; font-size: clamp(1.35rem, 1.1rem + 1.2vw, 2rem); font-weight: 800; color: var(--ink); }
.gh-done p { margin: 0; color: var(--ink-3); max-width: 40rem; }
.gh-done p b { color: var(--ink); }

/* ---------------------------------------------------------------------------
   9) DANH SÁCH THÔNG TIN ĐƠN (người nhận, địa chỉ, ngày đặt…)
   --------------------------------------------------------------------------- */
.gh-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem 1.5rem; margin: 0;
}
.gh-fact { min-width: 0; }
.gh-fact dt {
  font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
}
.gh-fact dd { margin: .25rem 0 0; font-weight: 600; color: var(--ink); overflow-wrap: break-word; }
.gh-fact dd .gh-note { font-weight: 400; }

/* ---------------------------------------------------------------------------
   10) HÀNG NÚT HÀNH ĐỘNG
   --------------------------------------------------------------------------- */
.gh-actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; margin-top: 1.25rem; }
.gh-actions--start { justify-content: flex-start; }

/* ---------------------------------------------------------------------------
   11) RESPONSIVE + GIẢM HIỆU ỨNG
   --------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .gh-checkout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .gh-table { min-width: 34rem; font-size: .9rem; }
  .gh-table th, .gh-table td { padding: .7rem .75rem; }
  .gh-prod-media { flex-basis: 52px; width: 52px; height: 52px; }
  .gh-totals { width: 100%; }
  .gh-foot { display: grid; }
  .gh-actions .btn { width: 100%; }
}

html.reduce-fx .gh-btn,
html.reduce-fx .gh-table tbody tr { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .gh-btn, .gh-table tbody tr { transition: none !important; }
  .gh-btn:hover { transform: none; }
}
