/* QG UX — so sánh sản phẩm, thanh mua cố định, sửa bảng hướng dẫn mua hàng. Claude 01/10/2026 */
html.qg-ux { --qg-green: var(--gh-primary, #178653); --qg-green-dark: var(--gh-primary-dark, #10663F); --qg-soft: var(--gh-primary-soft, #EAF7F0); --qg-ink: var(--gh-dark-surface, #102B22); --qg-muted: var(--gh-muted, #66756F); --qg-line: var(--gh-border, #DCE8E2); --qg-orange: var(--gh-promotion, #F97316); --qg-dock-h: 0px; --qg-bar-h: 0px; }

/* ---- 4. Bảng "Hướng dẫn mua hàng" trong mô tả: không vỡ chữ trên điện thoại ---- */
html.qg-ux .gh247-pdp__richtext table { width: 100% !important; border-collapse: collapse; table-layout: auto; }
html.qg-ux .gh247-pdp__richtext table td { padding: 10px 12px; vertical-align: top; word-break: normal; overflow-wrap: anywhere; text-align: left !important; }
html.qg-ux .gh247-pdp__richtext table td:first-child:not(:only-child) { width: 1%; white-space: nowrap; font-weight: 700; color: var(--qg-ink); background: var(--qg-soft); }
@media (max-width: 599px) {
  html.qg-ux .gh247-pdp__richtext table, html.qg-ux .gh247-pdp__richtext table tbody, html.qg-ux .gh247-pdp__richtext table tr, html.qg-ux .gh247-pdp__richtext table td { display: block; width: 100% !important; }
  html.qg-ux .gh247-pdp__richtext table { border: 1px solid var(--qg-line) !important; border-radius: 12px; overflow: hidden; }
  html.qg-ux .gh247-pdp__richtext table td { border: 0 !important; }
  html.qg-ux .gh247-pdp__richtext table td:first-child:not(:only-child) { white-space: normal; padding: 8px 12px; border-top: 1px solid var(--qg-line) !important; }
  html.qg-ux .gh247-pdp__richtext table tr:first-child td:first-child { border-top: 0 !important; }
}

/* ---- Nút "So sánh" trên thẻ sản phẩm ---- */
html.qg-ux .gh247-product-card__media { position: relative; }
.qg-cmp-toggle { display: inline-flex; align-items: center; gap: 6px; font: 700 12px/1 var(--gh-font, system-ui, sans-serif); color: var(--qg-ink); background: rgba(255,255,255,.94); border: 1px solid var(--qg-line); border-radius: 999px; padding: 6px 10px 6px 7px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; -webkit-tap-highlight-color: transparent; }
.gh247-product-card__media > .qg-cmp-toggle { position: absolute; top: 8px; right: 8px; z-index: 3; box-shadow: 0 2px 8px rgba(16,43,34,.10); }
.qg-cmp-box { width: 15px; height: 15px; border: 2px solid #94A3B8; border-radius: 4px; background: #fff; display: inline-grid; place-items: center; flex: none; }
.qg-cmp-toggle.is-on { background: var(--qg-green); border-color: var(--qg-green); color: #fff; }
.qg-cmp-toggle.is-on .qg-cmp-box { border-color: #fff; background: #fff; }
.qg-cmp-toggle.is-on .qg-cmp-box::after { content: ""; width: 7px; height: 4px; border: solid var(--qg-green); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.qg-cmp-toggle:focus-visible { outline: 3px solid var(--gh-focus-ring, rgba(34,197,94,.38)); outline-offset: 2px; }
.qg-cmp-pdp { margin: 12px 0 4px; padding: 9px 14px 9px 10px; font-size: 14px; }
@media (max-width: 599px) { .gh247-product-card__media > .qg-cmp-toggle { top: 6px; right: 6px; padding: 5px 8px 5px 6px; font-size: 11px; } }

/* ---- Thanh so sánh ở cuối màn hình ---- */
#qg-cmp-dock { position: fixed; left: 0; right: 0; bottom: calc(var(--qg-bar-h) + env(safe-area-inset-bottom)); z-index: 60; pointer-events: none; }
html.qg-has-dock { --qg-dock-h: 76px; }
.qg-dock-inner { pointer-events: auto; max-width: 980px; margin: 0 auto 10px; background: #fff; border: 1px solid var(--qg-line); border-radius: 16px; box-shadow: 0 16px 42px rgba(16,43,34,.18); display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
.qg-dock-items { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; flex: 1; min-width: 0; }
.qg-dock-item { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; height: 52px; padding: 4px 22px 4px 4px; border: 1px solid var(--qg-line); border-radius: 12px; font: 600 12px/1.25 var(--gh-font, system-ui, sans-serif); color: var(--qg-ink); }
.qg-dock-item img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.qg-dock-item span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qg-dock-item button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: #F1F5F9; color: #334155; font-size: 15px; line-height: 1; cursor: pointer; }
.qg-dock-empty { justify-content: center; border-style: dashed; color: var(--qg-muted); font-weight: 500; padding-right: 4px; }
.qg-dock-actions { display: flex; flex-direction: column; align-items: stretch; gap: 2px; flex: none; }
.qg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: 800 14px/1.1 var(--gh-font, system-ui, sans-serif); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.qg-btn--primary { background: var(--qg-green); color: #fff !important; }
.qg-btn--primary:hover { background: var(--qg-green-dark); }
.qg-btn--primary[disabled] { background: #CBD5E1; cursor: not-allowed; }
.qg-btn--ghost { background: #fff; color: var(--qg-green-dark) !important; border-color: var(--qg-line); }
.qg-btn--link { background: none; color: var(--qg-muted); min-height: 26px; font-weight: 600; font-size: 12px; text-decoration: underline !important; }
@media (max-width: 699px) {
  html.qg-has-dock { --qg-dock-h: 66px; }
  .qg-dock-inner { margin: 0 8px 8px; padding: 6px; gap: 6px; border-radius: 14px; }
  .qg-dock-items { gap: 4px; }
  .qg-dock-item { height: 48px; padding: 3px; justify-content: center; }
  .qg-dock-item span { display: none; }
  .qg-dock-empty span { display: block; font-size: 10px; text-align: center; }
  .qg-dock-item img { width: 40px; height: 40px; }
  .qg-dock-item button { top: -6px; right: -6px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
  .qg-btn { padding: 0 12px; font-size: 13px; }
}

/* ---- Bảng so sánh ---- */
#qg-cmp-modal { position: fixed; inset: 0; z-index: 2147483000; display: none; background: rgba(15,23,42,.55); padding: 24px; }
#qg-cmp-modal.is-open { display: flex; align-items: center; justify-content: center; }
html.qg-lock, html.qg-lock body { overflow: hidden !important; }
.qg-cmp-sheet { background: #fff; width: min(1080px, 100%); max-height: 100%; border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 70px rgba(16,43,34,.3); font-family: var(--gh-font, system-ui, sans-serif); color: var(--qg-ink); }
.qg-cmp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--qg-line); }
.qg-cmp-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.qg-x { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #F1F5F9; font-size: 24px; line-height: 1; cursor: pointer; color: #334155; }
.qg-cmp-body { overflow: auto; -webkit-overflow-scrolling: touch; padding: 0 0 12px; }
.qg-loading { padding: 40px 20px; text-align: center; color: var(--qg-muted); }
.qg-note { margin: 12px 18px 0; padding: 10px 12px; background: #FFF7ED; border-radius: 10px; font-size: 13px; color: #9A3412; }
.qg-table-wrap { overflow-x: auto; }
.qg-cmp-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.qg-cmp-table th, .qg-cmp-table td { padding: 10px 14px; border-bottom: 1px solid #EEF2F0; text-align: left; vertical-align: top; }
.qg-cmp-table th { position: sticky; left: 0; z-index: 1; width: 170px; min-width: 120px; background: #F8FAF9; color: var(--qg-muted); font-weight: 700; font-size: 13px; }
.qg-cmp-table td { min-width: 150px; }
.qg-cmp-table.qg-cols-2 td { width: 40%; }
.qg-cmp-table.qg-cols-3 td { width: 27%; }
.qg-row-prod td, .qg-row-prod th { position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--qg-line); }
.qg-row-prod th { z-index: 3; background: #fff; vertical-align: bottom; }
.qg-cmp-prod { display: flex; flex-direction: column; gap: 8px; color: var(--qg-ink) !important; text-decoration: none !important; font-weight: 700; font-size: 14px; line-height: 1.3; }
.qg-cmp-prod img { width: 100%; max-width: 150px; aspect-ratio: 1; object-fit: contain; border-radius: 12px; background: #fff; border: 1px solid #EEF2F0; }
.qg-cmp-prod span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.qg-mini { margin-top: 6px; padding: 0; border: 0; background: none; color: var(--qg-muted); font-size: 12px; text-decoration: underline; cursor: pointer; }
.qg-price { display: block; color: var(--qg-green-dark); font-size: 17px; font-weight: 800; }
.qg-row-price del { color: #94A3B8; font-size: 13px; }
.qg-ok { color: var(--qg-green-dark); font-weight: 700; }
.qg-out { color: #B45309; font-weight: 700; }
.qg-na { color: #CBD5E1; }
.qg-cmp-table tr:not(.qg-same):not(.qg-row-prod):not(.qg-row-buy) td { background: #FCFFFD; }
.qg-only-diff .qg-cmp-table tr.qg-same { display: none; }
.qg-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.qg-cmp-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--qg-line); font-size: 13px; color: var(--qg-muted); background: #fff; }
.qg-diff { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; font-weight: 600; color: var(--qg-ink); cursor: pointer; line-height: 1.3; }
.qg-diff input { width: 18px; height: 18px; accent-color: var(--qg-green); flex: none; margin: 0; }
.qg-row-buy td { border-bottom: 0; }
.qg-row-buy .qg-btn { width: 100%; margin-bottom: 6px; }
.qg-cmp-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 8px 18px 0; padding-top: 12px; border-top: 1px solid var(--qg-line); font-size: 13px; color: var(--qg-muted); }
.qg-cmp-foot p { margin: 0; flex: 1 1 280px; }
.qg-cmp-foot a { color: var(--qg-green-dark); font-weight: 700; }
@media (max-width: 699px) {
  #qg-cmp-modal { padding: 0; }
  #qg-cmp-modal.is-open { align-items: stretch; }
  .qg-cmp-sheet { border-radius: 0; height: 100%; }
  .qg-cmp-head { padding: 10px 12px; }
  .qg-cmp-head h2 { font-size: 18px; }
  .qg-cmp-table { font-size: 13px; }
  .qg-cmp-table th { width: 92px; min-width: 92px; max-width: 92px; padding: 8px; font-size: 12px; }
  .qg-cmp-table td { min-width: 128px; padding: 8px; }
  .qg-cmp-prod { font-size: 13px; }
  .qg-cmp-prod img { max-width: 112px; }
  .qg-price { font-size: 15px; }
  .qg-cmp-foot { margin: 8px 12px 0; }
  .qg-cmp-tools { padding: 8px 12px; }
  /* Trên trang sản phẩm khi thanh mua hiện: thu gọn thanh so sánh thành 1 nút */
  html.qg-buybar-on.qg-has-dock { --qg-dock-h: 52px; }
  html.qg-buybar-on .qg-dock-items, html.qg-buybar-on [data-qg-clear] { display: none; }
  html.qg-buybar-on .qg-dock-inner { width: max-content; margin: 0 10px 8px auto; padding: 4px; border-radius: 12px; }
  .qg-row-buy .qg-btn { padding: 0 8px; font-size: 12px; }
}

/* ---- 3. Thanh mua hàng cố định trên trang sản phẩm (điện thoại) ---- */
#qg-buybar { display: none; }
@media (max-width: 899px) {
  #qg-buybar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; display: flex; align-items: center; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--qg-line); box-shadow: 0 -8px 24px rgba(16,43,34,.10); transform: translateY(110%); transition: transform .22s var(--gh-ease-standard, ease); font-family: var(--gh-font, system-ui, sans-serif); }
  html.qg-buybar-on #qg-buybar { transform: none; }
  html.qg-buybar-on { --qg-bar-h: 64px; }
  .qg-buybar-price { flex: 1; min-width: 0; line-height: 1.1; }
  .qg-buybar-price small { display: block; font-size: 11px; color: var(--qg-muted); }
  .qg-buybar-price strong { display: block; font-size: 17px; font-weight: 800; color: var(--qg-orange); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qg-buybar-call { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--qg-line); color: var(--qg-green-dark); flex: none; }
  .qg-buybar-call svg { width: 20px; height: 20px; fill: currentColor; }
  #qg-buybar button { height: 44px; padding: 0 12px; border-radius: 12px; border: 0; font: 800 14px/1 var(--gh-font, system-ui, sans-serif); cursor: pointer; flex: none; }
  .qg-buybar-add { background: var(--qg-green); color: #fff; }
  .qg-buybar-buy { background: var(--qg-orange); color: #fff; }
  #qg-buybar button[disabled] { background: #CBD5E1; }
  /* 1. Nút Zalo/Facebook/Gọi và Subiz không đè lên thanh mua, thanh so sánh */
  html.qg-ux #ndt-contact { bottom: calc(16px + var(--qg-bar-h) + var(--qg-dock-h) + env(safe-area-inset-bottom)) !important; transition: bottom .22s ease; }
  html.qg-ux #ndt-contact-toggle { width: 46px !important; height: 46px !important; }
  html.qg-ux #ndt-contact-toggle img { width: 46px; height: 46px; }
  html.qg-buybar-on, html.qg-has-dock { --gh247-subiz-bottom: calc(18px + var(--qg-bar-h) + var(--qg-dock-h) + env(safe-area-inset-bottom)); }
}
@media (min-width: 900px) {
  html.qg-has-dock #ndt-contact { bottom: calc(24px + var(--qg-dock-h)) !important; }
  html.qg-has-dock { --gh247-subiz-bottom: calc(24px + var(--qg-dock-h)); }
}
/* Trang sản phẩm điện thoại: ẩn tạm nút liên hệ khi nó sắp che khối giá */
html.qg-hide-contact #ndt-contact { opacity: 0 !important; pointer-events: none !important; transition: opacity .15s; }
@media (max-width: 899px) {
  html.qg-ux body.template-product .gh247-pdp__price-panel { position: relative; z-index: 1; }
}

#qg-toast { position: fixed; left: 50%; bottom: calc(20px + var(--qg-bar-h) + var(--qg-dock-h) + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 2147483001; max-width: min(92vw, 460px); padding: 10px 16px; border-radius: 12px; background: #0F172A; color: #fff; font: 600 13px/1.4 var(--gh-font, system-ui, sans-serif); text-align: center; transition: opacity .2s, transform .2s; }
#qg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #qg-buybar, #qg-toast, html.qg-ux #ndt-contact { transition: none !important; } }

/* 02/10/2026: thông số chỉ 1 sản phẩm có -> gom vào mục "Xem thêm" */
.qg-cmp-table tr.qg-row-extra { display: none; }
#qg-cmp-modal.qg-show-extra .qg-cmp-table tr.qg-row-extra { display: table-row; }
#qg-cmp-modal.qg-show-extra .qg-cmp-table tr.qg-row-more { display: none; }
.qg-cmp-table tr.qg-row-more td { padding: 6px 8px 10px; }
.qg-cmp-table .qg-more-btn { margin: 0; color: var(--qg-green-dark, #166534); font-weight: 700; font-size: 13px; text-align: left; }
.qg-row-price small { font-size: 12px; color: var(--qg-muted); }
