/* Live chat window (batch 16, inc/chat-ui.php). Tokens from sgh-tokens.css; buttons are the
   design system .btn. One launcher bottom right: a pill on wide screens, a round button on phones,
   lifted above the page's bottom bar (--chat-lift, measured in sgh-chat.js). Never orange: the page
   keeps the only primary action at the bottom. */
.x-chat { --chat-lift: 0px; --chat-gap: 24px; font: 400 var(--fs-body)/var(--lh-body) var(--sans); color: var(--ink); }
.x-chat-launch { position: fixed; right: var(--chat-gap); bottom: calc(var(--chat-gap) + var(--chat-lift)); z-index: var(--z-bottom-bar); display: inline-flex; align-items: center; gap: 10px; min-height: var(--btn-lg); padding: 0 20px 0 16px; border: 0; border-radius: var(--radius-pill); background: var(--ink); color: var(--paper); font: 600 var(--fs-body)/1 var(--sans); box-shadow: var(--shadow-2); cursor: pointer; transition: bottom .15s ease, background-color .15s ease; }
.x-chat-launch:hover { background: var(--charcoal); }
.x-chat-launch:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.x-chat-ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.x-chat-badge { position: absolute; top: -2px; right: -2px; width: 14px; height: 14px; border: 2px solid var(--paper); border-radius: 50%; background: var(--orange); }
.x-chat.is-open .x-chat-launch { display: none; }
.x-chat [hidden] { display: none !important; }

.x-chat-panel { position: fixed; right: var(--chat-gap); bottom: calc(var(--chat-gap) + var(--chat-lift)); z-index: var(--z-drawer); display: flex; flex-direction: column; width: min(400px, calc(100vw - 2 * var(--chat-gap))); height: min(640px, calc(100vh - 2 * var(--chat-gap) - var(--chat-lift))); height: min(640px, calc(100dvh - 2 * var(--chat-gap) - var(--chat-lift))); background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius-2); box-shadow: var(--shadow-2); overflow: hidden; }
.x-chat-panel[hidden] { display: none; }
.x-chat-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 12px 12px 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.x-chat-ht { flex: 1; min-width: 0; }
.x-chat-head h2 { margin: 0; font: 700 var(--fs-h4)/1.3 var(--display, var(--sans)); letter-spacing: 0; }
.x-chat-sub { margin: 2px 0 0; color: var(--slate); font-size: var(--fs-small); line-height: 1.4; }
.x-chat[data-state="live"] .x-chat-sub::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--mark-ok); vertical-align: 1px; }
.x-chat[data-state="waiting"] .x-chat-sub::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--mark-warn); vertical-align: 1px; }
.x-chat-x { display: inline-grid; place-items: center; width: 40px; height: 40px; margin: -6px 0 0; border: 0; border-radius: var(--radius-2); background: transparent; color: var(--charcoal); cursor: pointer; }
.x-chat-x:hover { background: var(--ground); }
.x-chat-x .icon { width: 20px; height: 20px; }

.x-chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; background: var(--ground); font-size: var(--fs-small); line-height: 1.5; }
.x-chat-log:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.x-chat-m { max-width: 90%; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-2); background: var(--paper); overflow-wrap: anywhere; }
.x-chat-m p { margin: 0 0 6px; }
.x-chat-m p:last-child { margin-bottom: 0; }
.x-chat-m.is-me { margin-left: auto; width: fit-content; border-color: var(--panel); background: var(--panel); color: var(--panel-ink); white-space: pre-wrap; }
.x-chat-m.is-pending { opacity: .6; }
.x-chat-sending { display: block; margin-top: 4px; font-size: var(--fs-micro); color: var(--ink-muted, inherit); }
.x-chat-m:not(.is-pending) .x-chat-sending { display: none; }
/* A line that did not send: kept, light with an error edge, "Not sent" and Retry under it. */
.x-chat-m.is-failed { border-color: var(--error-line); background: var(--paper); color: var(--ink); }
.x-chat-fail { margin: 6px 0 0 !important; color: var(--error); font-size: var(--fs-micro); white-space: normal; }
.x-chat-fail .x-chat-link { font-size: inherit; }
.x-chat-loaderr .x-chat-link { margin-left: 4px; }
.x-chat-keep .x-chat-btns { margin-top: 8px; }
.x-assist-suggest button { cursor: pointer; }
.x-chat-m.is-staff { border-color: var(--orange-line); background: var(--orange-tint); white-space: pre-wrap; }
.x-chat-m.is-bot { max-width: 100%; }
.x-chat-who { display: block; margin: 0 0 4px; color: var(--charcoal); font: 700 var(--fs-micro)/1.3 var(--sans); white-space: normal; }
.x-chat-seen { display: block; margin-top: 4px; color: var(--panel-mute); font-size: var(--fs-micro); text-align: right; }
.x-chat-sys { margin: 4px 8px 12px; color: var(--slate); font-size: var(--fs-micro); line-height: 1.45; text-align: center; }
.x-chat-err { margin: 0 0 12px; padding: 8px 10px; border: 1px solid var(--error-line); border-radius: var(--radius-2); background: var(--error-bg); color: var(--error); font-size: var(--fs-small); }
.x-chat-intro.is-past .x-chat-chips { display: none; }
.x-chat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.x-chat-chip { min-height: 36px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-1); background: var(--paper); color: var(--ink); font: 500 var(--fs-small)/1.3 var(--sans); text-align: left; cursor: pointer; }
.x-chat-chip:hover { border-color: var(--ink); }

/* Assistant answers inside a bubble: the panel components, one column. */
.x-chat-answer.x-assist-body { border-top: 0; padding-top: 0; }
.x-chat-answer .x-assist-card { grid-template-columns: minmax(0, 1fr); background: var(--ground); }
.x-chat-answer .x-assist-card .price, .x-chat-answer .x-assist-card .stock { grid-column: 1; grid-row: auto; text-align: left; }
.x-chat-answer .x-assist-facts { grid-template-columns: minmax(0, 1fr); }
.x-chat ul.x-assist-list, .x-chat ul.x-assist-docs { list-style: none; margin: 0 0 10px; padding: 0; }
.x-chat-answer .x-assist-person { margin-top: 10px; }
.x-chat-answer .x-assist-person [data-chat-person] { margin: 0 8px 6px 0; }

.x-chat-typing { margin: 0; padding: 6px 16px; border-top: 1px solid var(--line); background: var(--ground); color: var(--slate); font-size: var(--fs-micro); }
.x-chat-typing::after { content: "…"; }

.x-chat-foot { padding: 10px 12px 10px; border-top: 1px solid var(--line); background: var(--paper); }
.x-chat-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 8px; }
.x-chat-row:not(:has(> :not([hidden]))) { display: none; }
.x-chat-link { min-height: 36px; padding: 0 4px; border: 0; background: none; color: var(--charcoal); font: 600 var(--fs-small)/1 var(--sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.x-chat-form { display: flex; align-items: flex-end; gap: 8px; }
.x-chat-form[hidden] { display: none; }
.x-chat-form textarea { flex: 1; min-width: 0; min-height: var(--field-h); max-height: 140px; padding: 10px 12px; border: var(--field-border) solid var(--line-strong); border-radius: var(--radius-2); background: var(--paper); color: var(--ink); font: 16px/1.4 var(--sans); resize: none; }
.x-chat-form textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.x-chat-send { min-height: var(--field-h); }
.x-chat.is-busy .x-chat-send, .x-chat-panel.is-busy .x-chat-send { opacity: .6; }
.x-chat-privacy { margin: 8px 0 0; color: var(--slate); font-size: var(--fs-micro); line-height: 1.4; }
.x-chat-privacy a { color: inherit; text-underline-offset: 2px; }

/* Handover card */
.x-chat-card { margin: 0 0 12px; padding: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-2); background: var(--paper); }
.x-chat-card h3 { margin: 0 0 4px; font: 700 var(--fs-body)/1.3 var(--display, var(--sans)); }
.x-chat-avail { margin: 0 0 10px; color: var(--charcoal); }
.x-chat-f { margin: 0 0 10px; }
.x-chat-f label { display: block; margin: 0 0 4px; font-weight: 600; font-size: var(--fs-small); }
.x-chat-f .opt { font-weight: 400; color: var(--slate); }
.x-chat-f input, .x-chat-f textarea { width: 100%; min-height: var(--field-h); padding: 8px 12px; border: var(--field-border) solid var(--line-strong); border-radius: var(--radius-2); background: var(--paper); color: var(--ink); font: 16px/1.4 var(--sans); }
.x-chat-f input:focus, .x-chat-f textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.x-chat-either { margin: 0 0 4px; padding: 0; border: 0; }
.x-chat-either legend { padding: 0; margin: 0 0 6px; font-size: var(--fs-small); color: var(--slate); }
.x-chat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.x-chat-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.x-chat-alt { margin: 10px 0 0; font-size: var(--fs-small); color: var(--slate); }
.x-chat-alt a { color: var(--ink); font-weight: 600; }

@media (max-width: 760px) {
  .x-chat { --chat-gap: 16px; }
  .x-chat-launch { width: 52px; height: 52px; min-height: 0; padding: 0; justify-content: center; }
  .x-chat-launch .x-chat-lt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .x-chat-ic { width: 24px; height: 24px; }
  .x-chat-panel { inset: 0; width: auto; height: 100%; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; z-index: var(--z-modal); }
  .x-chat-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .x-chat-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  html.x-chat-on, html.x-chat-on body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .x-chat-launch { transition: none; } }
@media print { .x-chat { display: none !important; } }
