/* ==========================================================================
   Cart / Quote / Product modal / Floating dock / Mobile bar
   ========================================================================== */

/* ---- Product card actions ---- */
.product-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
/* flex-basis auto + nowrap: buttons keep their natural width and the row
   wraps as a whole when the card is too narrow — previously flex:1 with
   basis 0 squeezed both buttons onto one row and stacked their text. */
.product-card-actions .btn { flex: 1 1 auto; padding: 9px 12px; font-size: 13px; white-space: nowrap; }

/* ---- In-card cart control (add / qty stepper / remove) ---- */
/* flex-basis auto + a floor min-width: the control keeps its natural width
   and WRAPS to the next row when the card is too narrow. The old flex:1
   (basis 0, min-width 0) collapsed it to zero width and the nowrap button
   text spilled outside the card. */
.cart-ctrl { flex: 1 1 auto; min-width: 112px; }
.cart-ctrl .cart-add { width: 100%; }
.cart-stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cart-stepper-qty { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 3px; }
.cart-step { width: 28px; height: 28px; border-radius: 6px; font-size: 16px; font-weight: 700; color: var(--ink-strong); }
.cart-step:hover { background: var(--bg-soft); }
.cart-qty { min-width: 20px; text-align: center; font-weight: 700; font-size: 14px; }
.cart-remove { color: #d33; font-size: 13px; font-weight: 600; white-space: nowrap; }
.cart-remove:hover { text-decoration: underline; }

/* ---- Toast ---- */
#hxgd-toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px);
  background: var(--ink-strong); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 500; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px);
}
#hxgd-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Quote drawer ---- */
.quote-drawer { position: fixed; inset: 0; z-index: 160; visibility: hidden; }
.quote-drawer.open { visibility: visible; }
.qd-backdrop { position: absolute; inset: 0; background: rgba(7,20,38,.55); opacity: 0; transition: opacity var(--t-med) var(--ease); }
.quote-drawer.open .qd-backdrop { opacity: 1; }
.qd-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 100%; max-width: 460px;
  background: #fff; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform var(--t-med) var(--ease);
}
.quote-drawer.open .qd-panel { transform: translateX(0); }
.qd-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.qd-head h3 { font-size: 20px; }
.qd-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.qd-close { font-size: 26px; line-height: 1; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.qd-close:hover { background: var(--bg-soft); color: var(--ink-strong); }
.qd-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.qd-empty { text-align: center; color: var(--muted); padding: 40px 12px; font-size: 15px; }
.qd-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.qd-item img { width: 52px; height: 52px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; flex: none; }
.qd-item-info { flex: 1; min-width: 0; }
.qd-model { font-size: 12px; font-weight: 700; color: var(--brand); }
.qd-name { font-size: 14px; font-weight: 600; color: var(--ink-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-qty { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.qd-qty button { width: 26px; height: 26px; font-size: 16px; border-radius: 6px; color: var(--ink); }
.qd-qty button:hover { background: var(--bg-soft); }
.qd-qty span { min-width: 18px; text-align: center; font-weight: 600; }
.qd-remove { color: var(--muted); font-size: 18px; padding: 4px; }
.qd-remove:hover { color: #d33; }
.qd-form { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.qd-form h4 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.qd-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qd-form input, .qd-form textarea {
  padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 14px;
  background: #fff; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.qd-form input:focus, .qd-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.qd-form textarea { resize: vertical; min-height: 64px; }
.qd-download { background: none; color: var(--brand); font-size: 13px; font-weight: 600; padding: 4px; }
.qd-download:hover { text-decoration: underline; }
.qd-status { font-size: 13px; }
.qd-status.ok { color: #1a9e5a; }
.qd-status.err { color: #d33; }

/* ---- Product modal ---- */
.pmodal { position: fixed; inset: 0; z-index: 170; display: flex; align-items: center; justify-content: center; padding: 16px; visibility: hidden; }
.pmodal.open { visibility: visible; }
.pm-backdrop { position: absolute; inset: 0; background: rgba(7,20,38,.6); opacity: 0; transition: opacity var(--t-med) var(--ease); }
.pmodal.open .pm-backdrop { opacity: 1; }
.pm-panel {
  position: relative; width: 100%; max-width: 1080px; max-height: 90vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.98); opacity: 0; transition: transform var(--t-med) var(--ease), opacity var(--t-med) var(--ease);
}
.pmodal.open .pm-panel { transform: none; opacity: 1; }
.pm-head { padding: 20px 24px 14px; border-bottom: 1px solid var(--line); position: relative; flex: 0 0 auto; height: 88px; overflow: hidden; }
.pm-head h3 { font-size: 21px; margin-top: 6px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pm-head .qd-close { position: absolute; top: 14px; right: 16px; }
.pm-model { font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 3px 10px; border-radius: 999px; }
.pm-cat { font-size: 12px; color: var(--muted); margin-left: 8px; }
.pm-tabs { display: flex; gap: 2px; padding: 8px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; min-height: 60px; align-items: stretch; }
.pm-tab { flex: 1 1 0; min-width: 0; padding: 9px 6px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; text-align: center; line-height: 1.25; }
.pm-tab:hover { color: var(--ink-strong); }
.pm-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.pm-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 24px; }
.pm-desc { color: var(--ink); font-size: 15px; line-height: 1.7; }
.pm-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.pm-list li { padding: 10px 14px; background: var(--bg-soft); border-radius: 9px; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.pm-list li svg { flex: 0 0 auto; width: 18px; height: 18px; color: var(--brand); }
.pm-list li span { flex: 1; }
.pm-specs { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pm-spec { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.8fr); gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; align-items: center; }
.pm-spec:last-child { border-bottom: none; }
.pm-spec-k { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 500; }
.pm-spec-v { color: var(--ink-strong); font-weight: 600; }
.pm-spec:nth-child(odd) { background: var(--bg-soft); }
.pm-spec-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; background: var(--brand-soft); color: var(--brand); flex: 0 0 auto; }
.pm-spec-icon svg { width: 16px; height: 16px; display: block; }
.pm-spec-icon--pending { background: var(--bg-softer); animation: pmSpecIconPulse 1.1s ease-in-out infinite; }
@keyframes pmSpecIconPulse {
  0%,100% { opacity: 0.5; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}
/* Legacy 2-column layout (when no icon is rendered — .pm-spec-k is the
   first child, .pm-spec-v the second; no .pm-spec-icon inside) */
.pm-spec:not(:has(.pm-spec-icon)) { grid-template-columns: 1fr 1.6fr; }
.pm-spec:not(:has(.pm-spec-icon)) > .pm-spec-k { color: var(--muted); font-weight: 500; }
.pm-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pm-gallery img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
/* 图片加载失败 → 展示 alt（SEO 图片描述）文字兜底 */
.pm-gallery img.img-fallback { display: grid; place-items: center; min-height: 160px; background: #f6f9fc; border: 1px dashed #d7e0ea; color: #5a6b7d; font-size: 13px; line-height: 1.6; padding: 14px; text-align: center; }
.pm-empty { color: var(--muted); padding: 30px 0; text-align: center; }
.pm-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; flex: 0 0 auto; min-height: 68px; }
.pm-foot-note { margin-right: auto; font-size: 12.5px; color: var(--muted); }
.pm-contact { display: inline-flex; align-items: center; gap: 5px; padding: 8px 11px; font-size: 13px; font-weight: 600; }
.pm-foot > .btn { padding: 8px 16px; font-size: 13px; }
.pm-contact svg { flex: none; }

/* ---- Knowledge entry (pm-foot-note doubles as the knowledge button) ---- */
.pm-foot-knowledge {
  min-width: 150px; max-width: 46%; margin-right: auto; text-decoration: none;
  color: #000;
}
.pm-foot-knowledge svg { flex: none; }
.pm-foot-knowledge-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; opacity: .85; }
.pm-foot-knowledge-title { font-size: 12.5px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Lead Time & After-Sales tab ---- */
.pm-leadtime { display: grid; gap: 10px; }
.pm-leadtime-item {
  display: grid; grid-template-columns: 170px 1fr; gap: 14px; padding: 12px 16px;
  background: var(--bg-soft); border-radius: 10px; font-size: 13.5px; line-height: 1.55;
}
.pm-leadtime-k { color: var(--muted); font-weight: 600; }
.pm-leadtime-v { color: var(--ink-strong); }
/* 固定的 Lead Time & After-Sales 内容样式 */
.pm-leadtime--fixed { gap: 14px; }
.pm-leadtime-p { color: var(--ink); font-size: 14px; line-height: 1.65; margin: 0; }
.pm-leadtime-p a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.pm-leadtime-terms { margin-top: 0; }
.pm-leadtime-terms li {
  padding: 10px 14px;
  background: var(--bg-soft); border-radius: 9px;
  font-size: 13.5px; line-height: 1.55;
}
.pm-leadtime-terms li strong { color: var(--ink-strong); }
.pm-leadtime-contact {
  margin-top: 4px;
  padding: 14px 16px;
  background: var(--brand-soft);
  border-radius: 10px;
  border-left: 3px solid var(--brand);
}
.pm-leadtime-contact p { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--ink); }
.pm-leadtime-contact p + p { margin-top: 4px; }
.pm-leadtime-contact strong { color: var(--brand); }
.pm-leadtime-knowledge { margin-top: 14px; padding: 16px; border: 1px solid var(--brand-soft); background: var(--brand-soft); border-radius: 12px; }
.pm-leadtime-knowledge strong { display: block; color: var(--brand); font-size: 14px; margin-bottom: 6px; }
.pm-leadtime-knowledge p { color: var(--ink); font-size: 13.5px; line-height: 1.6; margin-bottom: 10px; }

/* ---- Floating contact dock ---- */
.contact-dock { position: fixed; right: 22px; bottom: 22px; z-index: 85; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 12px; }
/* Function-name pill under the dock button (matches the AI FAB label) */
.dock-label {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  color: #1E293B;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(13, 36, 56, 0.12);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(13, 36, 56, 0.14);
  white-space: nowrap;
}
.dock-btn {
  width: 54px; height: 54px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 24px var(--brand-ring);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast);
}
.dock-btn:hover { background: var(--brand-dark); transform: scale(1.06); }
.dock-btn svg { width: 24px; height: 24px; }
/* Contact dock shows the raw Lottie animation (no circular background) —
   the animation carries its own artwork (black + steel-blue phone). */
.dock-main {
  background: transparent; box-shadow: none; border-radius: 12px;
  width: 64px; height: 68px;
}
.dock-main:hover { background: transparent; transform: scale(1.08); }
.dock-icon { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; transform: scale(1.45); }
.dock-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  background: #f59e0b; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px;
  display: none; align-items: center; justify-content: center; border: 2px solid #fff;
}
/* Menu floats free of the dock layout (absolute) so opening it never moves
   the button; direction classes (set by cart.js) keep it fully on screen. */
.dock-menu {
  position: absolute; z-index: 6;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 250px; overflow: hidden; display: none; flex-direction: column;
}
.dock-menu.menu-up { bottom: calc(100% + 10px); top: auto; }
.dock-menu.menu-down { top: calc(100% + 10px); bottom: auto; }
.dock-menu.menu-right { right: 0; left: auto; }
.dock-menu.menu-left { left: 0; right: auto; }
.dock-menu.open { display: flex; }
.dock-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 12px 16px; font-size: 14px; font-weight: 600; color: var(--ink-strong); border-bottom: 1px solid var(--line); text-align: left; }
.dock-item:last-child { border-bottom: none; }
.dock-item:hover { background: var(--bg-soft); }
.dock-item small { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---- Mobile bottom bar ---- */
.mobile-bar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); transform: translateZ(0); }
.mobile-bar a, .mobile-bar button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; height: 58px; font-size: 12px; font-weight: 600; color: var(--ink); position: relative; }
.mobile-bar a.active, .mobile-bar button.active { color: var(--brand); }
.mb-badge {
  position: absolute; top: 8px; right: calc(50% - 24px); min-width: 16px; height: 16px; padding: 0 4px;
  background: #f59e0b; color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px;
  display: none; align-items: center; justify-content: center;
}

/* ---- Mobile occlusion fixes ---- */
@media (max-width: 768px) {
  .mobile-bar { display: flex; }
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .contact-dock { right: 16px; bottom: calc(74px + env(safe-area-inset-bottom)); }
  #hxgd-toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
  .pm-panel { max-height: 86vh; }
  .pm-spec { grid-template-columns: 1fr; gap: 4px; }
  .pm-gallery { grid-template-columns: 1fr; }
  .pm-leadtime-item { grid-template-columns: 1fr; gap: 4px; }
  .pm-foot-knowledge { max-width: 70%; }
  .qd-row { grid-template-columns: 1fr; }
  .product-card-actions { flex-direction: column; }
}

/* ---- Draggable contact dock ---------------------------------------------
   Drag anywhere on the dock (handle = dock element itself); tap still
   opens the menu. Position persists via localStorage (main.js GYPDrag). */
.contact-dock { touch-action: none; cursor: grab; }
.contact-dock.is-dragging { cursor: grabbing; }
.contact-dock.is-dragging * { cursor: grabbing !important; }
.contact-dock.is-dragging,
.contact-dock.is-dragging .dock-btn { transition: none; }

/* Keep text/image selection from competing with dock dragging. */
.contact-dock, .contact-dock * { -webkit-user-select: none; user-select: none; }
.contact-dock img, .contact-dock svg { -webkit-user-drag: none; }

/* Closed quote drawer must not extend the document scroll width on phones. */
.quote-drawer:not(.open) { display: none; }
.quote-drawer.open .qd-panel { animation: qd-slide-in var(--t-med) var(--ease); }
@keyframes qd-slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
