/* weinshop-agent · chat widget (小德 / Ludo)
 * Mount: <link rel="stylesheet" href="/api/agent/web/agent-widget.css">
 *        <script src="/api/agent/web/agent-widget.js" defer></script>
 * after /js/cart.js. Language comes from <body data-lang="zh|de|en">. */
.wa-root {
  --wa-ink: #1A1612;
  --wa-ink-70: rgba(26, 22, 18, 0.72);
  --wa-ink-50: #5E564C;
  --wa-line: rgba(26, 22, 18, 0.14);
  --wa-gold: #C9A961;
  --wa-gold-deep: #8C6F2E;
  --wa-cream: #faf7f1;
  --wa-paper: #ffffff;
  --wa-serif: "Charter", "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", Georgia, serif;
  --wa-sans: "Inter", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  font: 400 14px/1.55 var(--wa-sans);
  color: var(--wa-ink);
}
.wa-root *, .wa-root *::before, .wa-root *::after { box-sizing: border-box; }

.wa-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483000;
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 20px 0 16px;
  background: var(--wa-ink); color: var(--wa-cream);
  border: 1px solid var(--wa-gold); border-radius: 24px;
  font: 500 14px/1 var(--wa-sans); letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(26, 22, 18, 0.24);
  cursor: pointer;
}
.wa-launcher:hover { background: #2a241e; }
.wa-launcher:focus-visible, .wa-root button:focus-visible, .wa-root a:focus-visible, .wa-root textarea:focus-visible {
  outline: 2px solid var(--wa-gold); outline-offset: 2px;
}
.wa-launcher .wa-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wa-gold); }
.wa-launcher[aria-expanded="true"] { display: none; }

.wa-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483001;
  width: 384px; height: min(640px, calc(100vh - 48px));
  display: flex; flex-direction: column;
  background: var(--wa-cream); border: 1px solid var(--wa-line); border-radius: 8px;
  box-shadow: 0 16px 48px rgba(26, 22, 18, 0.28);
  overflow: hidden;
}
.wa-panel[hidden] { display: none; }

.wa-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px 20px; background: var(--wa-ink); color: var(--wa-cream);
  border-bottom: 2px solid var(--wa-gold);
}
.wa-head h2 { margin: 0; font: 400 18px/1.2 var(--wa-serif); letter-spacing: 0.04em; }
.wa-head .wa-sub { margin: 2px 0 0; font: 400 12px/1.3 var(--wa-sans); color: rgba(250, 247, 241, 0.72); }
.wa-head .wa-titles { flex: 1; min-width: 0; }
.wa-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: 4px;
  background: transparent; color: var(--wa-cream); font-size: 20px; line-height: 1; cursor: pointer;
}
.wa-icon-btn:hover { background: rgba(250, 247, 241, 0.1); }

.wa-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
/* Items keep their natural height so the log scrolls; without this a product card row shrinks and gets clipped. */
.wa-log > * { flex-shrink: 0; }
.wa-msg { max-width: 88%; padding: 8px 12px; border-radius: 8px; white-space: pre-wrap; word-wrap: break-word; }
.wa-msg.wa-user { align-self: flex-end; background: var(--wa-ink); color: var(--wa-cream); border-bottom-right-radius: 2px; }
.wa-msg.wa-bot { align-self: flex-start; background: var(--wa-paper); border: 1px solid var(--wa-line); border-bottom-left-radius: 2px; }
.wa-msg.wa-error { align-self: stretch; background: #fff4f2; border: 1px solid #d9a79d; color: #6E1F2A; font-size: 13px; }
.wa-typing { align-self: flex-start; color: var(--wa-ink-50); font-size: 13px; font-style: italic; }

.wa-carousel { position: relative; }
.wa-cards { display: flex; gap: 12px; overflow-x: auto; padding: 4px 0 10px; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: thin; scrollbar-color: rgba(26, 22, 18, 0.28) transparent; }
.wa-cards::-webkit-scrollbar { height: 6px; }
.wa-cards::-webkit-scrollbar-thumb { background: rgba(26, 22, 18, 0.28); border-radius: 3px; }
.wa-cards:focus-visible { outline: 2px solid var(--wa-gold); outline-offset: 2px; }
.wa-arrow {
  position: absolute; top: 60px; z-index: 1;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--wa-paper); color: var(--wa-ink); border: 1px solid var(--wa-line);
  box-shadow: 0 2px 8px rgba(26, 22, 18, 0.18);
  font: 400 24px/1 var(--wa-serif); cursor: pointer;
}
.wa-arrow:hover { background: var(--wa-cream); border-color: var(--wa-gold); }
.wa-arrow[hidden] { display: none; }
.wa-prev { left: 4px; }
.wa-next { right: 4px; }
.wa-cards.wa-single { overflow: visible; }
.wa-card {
  flex: 0 0 216px; scroll-snap-align: start;
  display: flex; flex-direction: column;
  background: var(--wa-paper); border: 1px solid var(--wa-line); border-radius: 8px; overflow: hidden;
}
.wa-cards.wa-single .wa-card { flex-basis: 100%; flex-direction: row; }
.wa-card .wa-img { background: #f1ebe0; display: flex; align-items: center; justify-content: center; height: 144px; text-decoration: none; }
.wa-card .wa-more { align-self: flex-start; display: inline-flex; align-items: center; min-height: 24px; margin-top: 4px; font-size: 13px; color: var(--wa-gold-deep); text-decoration: underline; text-underline-offset: 3px; }
.wa-cards.wa-single .wa-img { width: 96px; height: auto; min-height: 144px; flex: 0 0 96px; }
.wa-card img { max-height: 132px; max-width: 100%; object-fit: contain; }
.wa-card .wa-body { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.wa-card .wa-name { font: 400 15px/1.35 var(--wa-serif); margin: 0; color: var(--wa-ink); text-decoration: none; }
.wa-card a.wa-name:hover { text-decoration: underline; text-decoration-color: var(--wa-gold); }
.wa-card .wa-meta { font-size: 12px; color: var(--wa-ink-50); }
.wa-card .wa-reason { font-size: 13px; color: var(--wa-ink-70); }
.wa-card .wa-price { font: 500 15px/1.2 var(--wa-sans); margin-top: 4px; }
.wa-card .wa-price small { font-weight: 400; color: var(--wa-ink-50); font-size: 12px; margin-left: 4px; }
.wa-card .wa-oos { font-size: 12px; color: #6E1F2A; }
.wa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; margin-top: 8px;
  background: var(--wa-ink); color: var(--wa-cream);
  border: 1px solid var(--wa-ink); border-radius: 4px;
  font: 500 13px/1 var(--wa-sans); letter-spacing: 0.04em; cursor: pointer; text-decoration: none;
}
.wa-btn:hover { background: #2a241e; }
.wa-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.wa-btn.wa-gold { background: var(--wa-gold); border-color: var(--wa-gold); color: var(--wa-ink); }
.wa-btn.wa-gold:hover { background: #d6ba78; }
.wa-gate p { margin: 0 0 12px; }
.wa-gate-btn { display: inline-block; text-decoration: none; text-align: center; min-height: 44px; line-height: 28px; }

.wa-checkout { align-self: stretch; background: var(--wa-paper); border: 1px solid var(--wa-gold); border-radius: 8px; padding: 12px 16px; }
.wa-checkout h3 { margin: 0 0 8px; font: 400 16px/1.3 var(--wa-serif); }
.wa-checkout ul { margin: 0 0 8px; padding: 0; list-style: none; font-size: 13px; }
.wa-checkout li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--wa-line); }
.wa-checkout .wa-total { display: flex; justify-content: space-between; font-weight: 500; }
.wa-checkout .wa-note { font-size: 12px; color: var(--wa-ink-50); margin: 8px 0 0; }
.wa-checkout .wa-btn { width: 100%; }

.wa-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.wa-chip {
  min-height: 32px; padding: 4px 12px; border: 1px solid var(--wa-gold); border-radius: 16px;
  background: transparent; color: var(--wa-ink); font: 400 13px/1.3 var(--wa-sans); cursor: pointer; text-align: left;
}
.wa-chip:hover { background: rgba(201, 169, 97, 0.14); }

.wa-guide { background: var(--wa-paper); border: 1px solid var(--wa-line); border-radius: 8px; padding: 12px 16px; }
.wa-guide h3 { margin: 0 0 8px; font: 400 16px/1.3 var(--wa-serif); }
.wa-guide h4 { margin: 8px 0 4px; font: 500 13px/1.3 var(--wa-sans); }
.wa-guide p { margin: 0; font-size: 13px; }

.wa-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--wa-line); background: var(--wa-cream); }
.wa-form textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: 12px;
  border: 1px solid var(--wa-line); border-radius: 4px; background: var(--wa-paper);
  font: 400 16px/1.35 var(--wa-sans); color: var(--wa-ink);
}
.wa-form .wa-btn { margin-top: 0; min-height: 44px; }
.wa-foot { padding: 0 12px 12px; font-size: 11px; line-height: 1.4; color: var(--wa-ink-50); text-align: center; background: var(--wa-cream); }
.wa-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 520px) {
  .wa-launcher { right: 16px; bottom: 16px; }
  .wa-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .wa-card { flex-basis: 184px; }
}
@media (prefers-reduced-motion: no-preference) {
  .wa-panel { animation: wa-in 0.18s ease-out; }
  @keyframes wa-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
