/*
 * Buying flow: favourites, product page extras, cart, and the
 * buyer–seller chat with payment links. Uses the tokens from site.css.
 */

/* ============ SHARED ============ */
.btn-sm { padding: 7px 14px; font-size: 13px; }
.verified-text { display: inline-flex; align-items: center; gap: 3px; color: #146c3a; font-weight: 700; }

.nav-badge,
.menu-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--heart);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.menu-badge { margin-left: auto; }
.hero-badge-alerts { left: 73.2%; }

/* Favourite heart on product cards sits above the card-wide link. */
.fav-form { position: absolute; top: 12px; right: 12px; z-index: 3; margin: 0; }
.fav-form .fav-btn { position: static; text-decoration: none; }
.fav-btn[aria-pressed="true"] { color: var(--heart); }
.fav-btn[aria-pressed="true"] svg { animation: fav-pop .3s ease; }
@keyframes fav-pop { 50% { transform: scale(1.3); } }

.fav-toggle[aria-pressed="true"] { border-color: #f6c4c6; background: #fff3f3; color: var(--heart); }
.fav-toggle[aria-pressed="true"] .icon { fill: currentColor; }

/* ============ PRODUCT PAGE ============ */
.detail-eyebrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.detail-eyebrow .detail-company { margin: 0; text-decoration: none; }
.detail-eyebrow .detail-company:hover { text-decoration: underline; }
.detail-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: -6px 0 18px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}
.detail-facts li { display: inline-flex; align-items: center; gap: 5px; }

.buy-box-top { display: grid; gap: 6px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.buy-box .detail-price small { font-size: 13px; }
.buy-box-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.buy-box-actions form { margin: 0; }
.buy-box-edit { justify-self: start; }

.trust-list { display: grid; gap: 12px; margin: 4px 0 0; padding: 16px 0 0; border-top: 1px dashed var(--line); list-style: none; }
.trust-list li { display: flex; align-items: flex-start; gap: 12px; }
.trust-list .icon { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 2px; color: var(--blue); }
.trust-list strong { display: block; color: var(--ink); font-size: 14px; }
.trust-list span { color: var(--muted); font-size: 13px; }

.detail-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 44px;
  align-items: start;
  margin-top: 36px;
}
.detail-lower-side { position: sticky; top: 20px; display: grid; gap: 20px; }
.detail-lower-side .detail-card { margin: 0; }
.detail-lower .detail-card h2 { font-size: 18px; }

.spec-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.spec-table th,
.spec-table td { padding: 11px 14px; border-bottom: 1px solid #edf0f5; text-align: left; }
.spec-table tr:nth-child(odd) th,
.spec-table tr:nth-child(odd) td { background: #f8fafd; }
.spec-table th { width: 42%; color: var(--muted); font-weight: 600; }
.spec-table td { color: var(--ink); font-weight: 600; }
.detail-card h3.detail-subhead { margin: 20px 0 10px; color: var(--ink); font-size: 15px; font-weight: 800; }

.inquiry-card form { display: grid; gap: 12px; margin-bottom: 10px; }
.inquiry-card textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}
.inquiry-card textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(0, 119, 255, .15); }
.inquiry-card .btn-primary { justify-self: start; }

.detail-more { margin-top: 48px; }
.detail-more .catalog-head h2 { margin: 0; color: var(--ink); font-size: 22px; font-weight: 800; }
.detail-more .catalog-head .text-link { display: inline-flex; align-items: center; gap: 4px; }

/* ============ CART ============ */
.cart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}
.cart-main { display: grid; gap: 20px; }
.cart-group { border: 1px solid var(--line); border-radius: 16px; background: #fff; overflow: hidden; }
.cart-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #edf0f5;
  background: #fafbfd;
}
.cart-group-head form { margin: 0 0 0 auto; }
.cart-seller-logo { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 11px; object-fit: cover; font-size: 18px; }
.cart-seller-info { display: grid; gap: 2px; min-width: 0; }
.cart-seller-info strong { color: var(--ink); font-size: 15px; }
.cart-seller-info > span { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }

.cart-items { margin: 0; padding: 0; list-style: none; }
.cart-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto 110px;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
}
.cart-item + .cart-item { border-top: 1px solid #edf0f5; }
.cart-item-img {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 12px;
  background: #eef2f8;
  color: #8a93a6;
  overflow: hidden;
}
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info { display: grid; gap: 4px; min-width: 0; }
.cart-item-name { color: var(--ink); font-size: 15px; font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.cart-item-name:hover { color: var(--blue); }
.cart-item-unit { margin: 0; color: var(--ink); font-weight: 700; }
.cart-item-unit span { color: var(--muted); font-size: 13px; font-weight: 500; }
.cart-item-stock { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 13px; }
.cart-item-links { display: flex; gap: 16px; margin-top: 4px; }
.cart-item-links form { margin: 0; }
.cart-item-links .text-button { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.cart-item-total { margin: 0; color: var(--ink); font-size: 17px; font-weight: 800; text-align: right; }

.qty-stepper {
  display: inline-flex;
  align-items: center;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}
.qty-stepper button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.qty-stepper button:hover:not(:disabled) { background: #f1f5fb; color: var(--blue); }
.qty-stepper button:disabled { color: #c3cad6; cursor: not-allowed; }
.qty-stepper .icon { width: 15px; height: 15px; }
.qty-stepper input {
  width: 48px;
  border: 0;
  font: inherit;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cart-group-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-top: 1px solid #edf0f5;
  background: #fafbfd;
}
.cart-group-foot > div { display: grid; gap: 2px; }
.cart-group-foot strong { color: var(--ink); font-size: 18px; }
.cart-group-foot form { margin: 0; }

.cart-side { position: sticky; top: 20px; display: grid; gap: 20px; }
.cart-side .card + .card { margin-top: 0; }
.cart-summary h2,
.how-card h2 { margin-bottom: 14px; }
.cart-summary dl { display: grid; gap: 10px; margin: 0; }
.cart-summary dl > div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.cart-summary dt { color: var(--muted); }
.cart-summary dd { margin: 0; color: var(--ink); font-weight: 600; }
.cart-summary-total { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.cart-summary-total dt { color: var(--ink) !important; font-weight: 800; }
.cart-summary-total dd { font-size: 22px; font-weight: 800 !important; }
.cart-summary-total small { color: var(--muted); font-size: 12px; }

.how-steps { display: grid; gap: 14px; margin: 0 0 14px; padding: 0; list-style: none; }
.how-steps li { display: flex; gap: 12px; }
.how-steps li > span {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8f1ff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}
.how-steps strong { color: var(--ink); font-size: 14px; }
.how-steps p { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.how-note { display: flex; align-items: center; gap: 6px; margin: 0; padding: 10px 12px; border-radius: 10px; background: #edf9f1; color: #155c32; font-size: 13px; font-weight: 600; }

/* ============ CHAT ============ */
.chat-app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: min(760px, calc(100vh - 140px));
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.chat-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid #edf0f5; }
.chat-list-head h2 { margin: 0; color: var(--ink); font-size: 16px; font-weight: 800; }
.chat-list-body { flex: 1; min-height: 0; overflow-y: auto; }
.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #f1f3f7;
  color: var(--ink);
  text-decoration: none;
}
.chat-row:hover { background: #f7f9fc; }
.chat-row.is-active { background: #eaf3ff; box-shadow: inset 3px 0 0 var(--blue); }
.chat-avatar {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #eef2f8;
}
.chat-avatar-initial {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff;
  font-weight: 800;
}
.chat-row-body { flex: 1; display: grid; gap: 3px; min-width: 0; }
.chat-row-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-row-top strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.chat-row-top time { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.chat-row-preview { overflow: hidden; color: var(--muted); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.chat-row.is-unread .chat-row-preview { color: var(--ink); font-weight: 600; }
.chat-unread {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.chat-list-empty { display: grid; justify-items: center; gap: 12px; padding: 40px 24px; color: var(--muted); font-size: 14px; text-align: center; }

.chat-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #f6f8fc; }
.chat-thread-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-thread-title { flex: 1; display: grid; gap: 2px; min-width: 0; }
.chat-thread-title strong { color: var(--ink); font-size: 15px; }
.chat-thread-title > span { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.chat-back { display: none; color: var(--ink); }
.chat-back .icon { transform: rotate(180deg); }

.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 20px; overflow-y: auto; }
.chat-start { align-self: center; max-width: 440px; margin-bottom: 6px; text-align: center; color: var(--muted); font-size: 13px; }
.chat-start span { display: inline-block; padding: 4px 12px; border-radius: 999px; background: #e9eef6; font-weight: 700; }
.chat-start p { margin: 8px 0 0; }

.msg { display: grid; justify-items: start; gap: 4px; max-width: min(560px, 80%); }
.msg.is-mine { align-self: flex-end; justify-items: end; }
.msg-bubble {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  box-shadow: 0 1px 2px rgba(6, 25, 76, .05);
}
.msg.is-mine .msg-bubble { border-color: transparent; border-radius: 16px 4px 16px 16px; background: linear-gradient(135deg, #086eff, #0a8dff); color: #fff; }
.msg-text { margin: 0; overflow-wrap: anywhere; }
.msg.is-mine .msg-text a { color: #fff; }
.msg-time { color: var(--muted); font-size: 11px; }

.msg-product {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 12px;
  background: #f4f7fb;
  color: var(--ink);
  text-decoration: none;
}
.msg.is-mine .msg-product { background: rgba(255, 255, 255, .95); }
.msg-product img,
.msg-product-img { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 9px; object-fit: cover; background: #e2e8f2; }
.msg-product-img { display: grid; place-items: center; color: #8a93a6; }
.msg-product-info { display: grid; gap: 1px; min-width: 0; font-size: 12px; color: var(--muted); }
.msg-product-info strong { overflow: hidden; color: var(--ink); font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.msg-product-label { color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

.msg-system { display: grid; justify-items: center; gap: 2px; align-self: center; max-width: 520px; text-align: center; }
.msg-system span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #e6f6ec;
  color: #146c3a;
  font-size: 13px;
  font-weight: 600;
}
.msg-system time { color: var(--muted); font-size: 11px; }

.pay-card {
  display: grid;
  gap: 10px;
  width: min(360px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.pay-card.is-paid { border-color: #b6e3c6; background: #f3fbf6; }
.pay-card.is-cancelled { opacity: .7; }
.pay-card-head { display: flex; align-items: center; gap: 10px; }
.pay-card-icon { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; background: #e8f1ff; color: var(--blue); }
.pay-card-head div { display: grid; gap: 1px; min-width: 0; }
.pay-card-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pay-card-head strong { font-size: 14px; overflow-wrap: anywhere; }
.pay-card-amount { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.pay-card-amount small { color: var(--muted); font-size: 12px; font-weight: 600; }
.pay-card-desc { margin: 0; color: #3b4357; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.pay-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid #edf0f5; }
.pay-card-foot form { margin: 0; }
.pay-card-note { margin: 0; color: var(--muted); font-size: 12px; }
.pay-status { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pay-status.is-pending { background: #fff4d6; color: #7a5500; }
.pay-status.is-paid { background: #dff5e7; color: #146c3a; }
.pay-status.is-cancelled { background: #eef1f6; color: var(--muted); }

.pay-composer { border-top: 1px solid var(--line); background: #fff; }
.pay-composer summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.pay-composer summary::-webkit-details-marker { display: none; }
.pay-composer summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.pay-composer[open] summary::after { content: "▴"; }
.pay-composer-form { padding: 0 20px 18px; }
.pay-composer-form .button-row { margin-top: 14px; }
.pay-composer-hint { justify-content: flex-end; }

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0;
  padding: 14px 20px 6px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.chat-composer textarea {
  flex: 1;
  max-height: 160px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: none;
}
.chat-composer textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(0, 119, 255, .15); }
.chat-send {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #086eff, #00a8ff);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 119, 255, .3);
}
.chat-send:disabled { opacity: .6; }
.chat-hint { margin: 0; padding: 0 20px 12px; background: #fff; color: var(--muted); font-size: 11px; }
.chat-placeholder { display: grid; place-content: center; justify-items: center; gap: 6px; height: 100%; padding: 30px; color: var(--muted); text-align: center; }
.chat-placeholder h3 { margin: 8px 0 0; color: var(--ink); }
.chat-placeholder p { margin: 0; font-size: 14px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .cart-layout,
  .detail-lower { grid-template-columns: 1fr; }
  .cart-side,
  .detail-lower-side { position: static; }
}

@media (max-width: 760px) {
  .chat-app { grid-template-columns: 1fr; height: calc(100vh - 120px); }
  .chat-app.has-active .chat-list { display: none; }
  .chat-app:not(.has-active) .chat-thread { display: none; }
  .chat-back { display: grid; }
  .msg { max-width: 92%; }
  .cart-item { grid-template-columns: 72px minmax(0, 1fr); }
  .cart-item-img { width: 72px; height: 72px; }
  .qty-stepper { grid-column: 2; justify-self: start; }
  .cart-item-total { grid-column: 2; text-align: left; }
  .cart-group-head { flex-wrap: wrap; }
  .cart-group-head form { margin-left: 0; }
}

/* A payment request on its own is shown as a card, not inside a bubble. */
.msg-bubble.is-card,
.msg.is-mine .msg-bubble.is-card { padding: 0; border: 0; background: none; box-shadow: none; }
.msg-bubble.is-card .pay-card { box-shadow: 0 8px 24px rgba(6, 25, 76, .10); }
.msg.is-mine .msg-bubble.is-card .pay-card { border-color: #bcd6ff; }

/* Live unread badges are always in the page; hidden when the count is 0. */
.nav-badge[hidden],
.menu-badge[hidden],
.hero-badge[hidden] { display: none; }
.account-menu .nav-badge { margin-left: 4px; vertical-align: 1px; }
.badge-bump { animation: badge-bump .5s ease; }
@keyframes badge-bump { 30% { transform: scale(1.35); } }

/* New message pop-up */
.msg-alert {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 18px 44px rgba(6, 25, 76, .22);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.msg-alert.show { transform: none; opacity: 1; pointer-events: auto; }
.msg-alert-icon { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #086eff, #00a8ff); color: #fff; }
.msg-alert-body { display: grid; gap: 2px; min-width: 0; }
.msg-alert-body strong { font-size: 14px; }
.msg-alert-body span { overflow: hidden; color: var(--muted); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.msg-alert-close { margin-left: auto; padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }

.msg-system-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 4px 12px;
  border: 1px solid #b6e3c6;
  border-radius: 999px;
  background: #fff;
  color: #146c3a;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.msg-system-link:hover { background: #f1fbf5; border-color: #1a9b54; }
