/* E-commerce tab, WhatsApp part (public/ecom/wa.js): chats list and thread side by side on a computer, one at a time on a
   phone (the open chat full screen with a back arrow), the connection card with the QR code, settings and quick replies.
   Colours from style.css (tokens), so the part follows the app's theme; the QR code is always black on white. */
.wa { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.wa-tabs { display: flex; align-items: center; gap: 4px; padding: 6px 12px 0; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.wa-tabs::-webkit-scrollbar { display: none; }
.wa-tabs a { flex: none; padding: 8px 12px 9px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.wa-tabs a:hover { color: var(--ink); }
.wa-tabs a.on { color: var(--brand); border-bottom-color: #1fa855; }
.wa-tabstate { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 6px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.wa-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #b9c3be; flex: none; }
.wa-dot.ok { background: #1fa855; }
.wa-dot.wait { background: #e0a020; }
.wa-dot.off { background: #c9534b; }
.wa-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wa-banner { flex: none; margin: 0; padding: 8px 14px; background: #fdf0d9; color: #7a4a00; font-size: .88rem; border-bottom: 1px solid #f0d9a8; }
.wa-banner[hidden] { display: none; }
.wa-banner a { color: inherit; font-weight: 600; }
.wa svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wa-empty { margin: 0; padding: 24px 16px; color: var(--muted); text-align: center; }
.wa-empty.bad, .wa .bad { color: var(--bad); }

/* ---------- chats: list and thread */
.wa-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.wa-list { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border-right: 1px solid var(--line); }
.wa-list-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px 6px; }
.wa-search { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.wa-search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.wa-search input { padding-left: 32px; min-height: 36px; height: 36px; background: var(--bg); }
.wa-chips { display: flex; gap: 6px; padding: 2px 12px 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.wa-chips::-webkit-scrollbar { display: none; }
.wa-chip { flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 16px; padding: 4px 11px; font-size: .82rem; cursor: pointer; }
.wa-chip.on { background: #e3f6ea; border-color: #9fd4b1; color: #12663a; font-weight: 600; }
.wa-rows { flex: 1; min-height: 0; overflow-y: auto; }
.wa-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.wa-row:hover { background: var(--soft); }
.wa-row.on { background: var(--soft); box-shadow: inset 3px 0 0 #1fa855; }
.wa-av { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #d7ece2; color: #14433f; font-weight: 600; font-size: .85rem; }
.wa-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wa-row-top, .wa-row-bot { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.wa-row-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-row-top time { flex: none; font-size: .72rem; color: var(--muted); }
.wa-last { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; color: var(--muted); }
.wa-unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #1fa855; color: #fff; font: 600 .72rem/20px "Segoe UI", system-ui, sans-serif; text-align: center; }
.wa-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.wa-tags .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-more { display: block; margin: 10px auto 16px; }

.wa-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #efeae2; }
.wa-none { margin: auto; max-width: 360px; padding: 24px; text-align: center; color: var(--muted); }
.wa-none svg { width: 48px; height: 48px; color: #1fa855; }
.wa-th-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.wa-th-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wa-th-who b, .wa-th-who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-th-who > span { font-size: .8rem; color: var(--muted); }
.wa-ib { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; text-decoration: none; }
.wa-ib:hover { background: var(--soft); color: var(--ink); }
.wa-ib:disabled { opacity: .4; cursor: not-allowed; }
.wa-ib svg { width: 21px; height: 21px; }
.wa-back { display: none; }
.wa-who { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; background: #f7faf8; border-bottom: 1px solid var(--line); }
.wa-who[hidden] { display: none; }
.wa-ord { display: inline-flex; gap: 4px; align-items: baseline; padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--brand); font-size: .8rem; text-decoration: none; }
.wa-ord small { color: var(--muted); }

.wa-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.wa-older { align-self: center; margin-bottom: 6px; }
.wa-day { align-self: center; margin: 8px 0 4px; }
.wa-day span { display: inline-block; padding: 3px 10px; border-radius: 8px; background: #fff; color: var(--muted); font-size: .75rem; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); }
.wa-msg { display: flex; }
.wa-msg.out { justify-content: flex-end; }
.wa-bub { position: relative; max-width: min(78%, 520px); min-width: 70px; padding: 6px 8px 4px; border-radius: 8px; background: #fff; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); overflow-wrap: anywhere; }
.wa-msg.out .wa-bub { background: #d9fdd3; }
.wa-msg.failed .wa-bub { background: #fde8e6; }
.wa-text { white-space: pre-wrap; font-size: .93rem; }
.wa-text a { color: #0b6bcb; }
.wa-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; font-size: .7rem; color: #667781; }
.wa-by { margin-right: auto; padding-right: 8px; }
.wa-tk { display: inline-flex; }
.wa-tk svg { width: 16px; height: 16px; }
.wa-tk.read { color: #34b7f1; }
.wa-tk.bad { color: var(--bad); }
.wa-tk.wait svg { width: 13px; height: 13px; }
.wa-err { margin: 4px 0 0; color: var(--bad); font-size: .8rem; }
.wa-err[hidden] { display: none; }
.wa-cancel { margin-top: 4px; padding: 2px 8px; border: 1px solid #e0b4b0; border-radius: 6px; background: #fff; color: var(--bad); font-size: .78rem; cursor: pointer; }
.wa-img { display: block; padding: 0; margin: 0 0 4px; border: 0; background: none; cursor: zoom-in; }
.wa-img img { display: block; max-width: 100%; width: 260px; max-height: 320px; object-fit: cover; border-radius: 6px; background: #eee; }
.wa-img.st img { width: 120px; height: 120px; object-fit: contain; background: none; }
.wa-bub audio { display: block; width: 260px; max-width: 100%; height: 40px; }
.wa-aud { margin-bottom: 4px; }
.wa-audl { display: inline-block; margin-top: 2px; font-size: 12px; }
.wa-nofile { margin: 0 0 4px; font-size: .8rem; color: var(--muted); font-style: italic; }
.wa-doc { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; padding: 8px; border-radius: 6px; background: rgba(0, 0, 0, .05); color: inherit; text-decoration: none; }
.wa-doc svg { width: 26px; height: 26px; color: var(--brand-2); }
.wa-doc span { display: flex; flex-direction: column; min-width: 0; }
.wa-doc b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.wa-doc small { color: var(--muted); }
.wa-big { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 6px; }

/* ---------- the composer, the chosen products and the '/' dropdown */
.wa-comp { position: relative; flex: none; padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); background: #f0f2f5; border-top: 1px solid var(--line); }
.wa-comp-row { display: flex; align-items: flex-end; gap: 6px; }
.wa-comp textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 150px; resize: none; border-radius: 20px; padding: 9px 14px; line-height: 1.35; border-color: var(--line); }
.wa-comp textarea:disabled { background: #e9ecea; }
.wa-sendb { background: #1fa855; color: #fff; width: 42px; height: 42px; }
.wa-sendb:hover { background: #178f47; color: #fff; }
.wa-cnote { margin: 0 0 6px; padding: 6px 10px; border-radius: 6px; font-size: .82rem; background: var(--panel); color: var(--muted); }
.wa-cnote[hidden] { display: none; }
.wa-cnote.warn { background: #fdf0d9; color: #7a4a00; }
.wa-cnote.bad { background: #fbe6e4; color: var(--bad); }
.wa-cnote.ok { background: #e3f6ea; color: #12663a; }
.wa-cnote a { color: inherit; font-weight: 600; }
.wa-sel { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.wa-sel[hidden] { display: none; }
.wa-chip2 { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 4px 3px 4px; border: 1px solid #9fd4b1; border-radius: 16px; background: #fff; font-size: .82rem; }
.wa-chip2 > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-chip2 img, .wa-chip2 > svg { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; }
.wa-chip2 select { width: auto; min-height: 26px; padding: 1px 4px; font-size: .8rem; }
.wa-chip2 button { flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--soft); color: var(--muted); cursor: pointer; line-height: 1; }
.wa-chip2.cat { border-color: #b9c3be; }
.wa-selnote { flex: 1 1 100%; margin: 0; }
.wa-selnote.bad { color: var(--bad, #b42318); }
.wa-sc { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 4px); z-index: 30; max-height: min(52vh, 420px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 -6px 24px rgba(0, 0, 0, .16); }
.wa-sc[hidden] { display: none; }
.wa-sc-top { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.wa-sc-top span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-sc-g { margin: 0; padding: 8px 12px 2px; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.wa-sc-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 12px; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.wa-sc-row:hover, .wa-sc-row.on { background: var(--soft); }
.wa-sc-row.chosen { box-shadow: inset 3px 0 0 #1fa855; }
.wa-sc-ph { flex: none; width: 40px; height: 40px; border-radius: 6px; background: #eef1ef; overflow: hidden; }
.wa-sc-ph:empty { display: none; }
.wa-sc-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wa-sc-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wa-sc-t b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-sc-t small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-sc-ck { flex: none; width: 20px; color: #1fa855; }
.wa-sc-ck svg { width: 18px; height: 18px; }
.wa-sc-none { margin: 0; padding: 10px 12px; color: var(--muted); font-size: .85rem; }

/* ---------- pages: connection, settings, quick replies */
.wa-page { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 14px; max-width: 900px; }
.wa-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.wa-card h2 { font-size: 1.05rem; }
.wa-card p { margin: 0; }
.wa-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wa-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1rem; }
.wa-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wa-warn { padding: 10px 12px; border-radius: 8px; background: #fdf0d9; color: #7a4a00; font-size: .88rem; }
.wa-warn a { color: inherit; font-weight: 600; }
.wa-risk { padding: 10px 12px; border-radius: 8px; background: #f4f6f5; color: var(--muted); font-size: .85rem; }
.wa-okline { color: var(--ok); font-weight: 600; }
.wa-qrbox { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
/* Always black on white with its quiet zone, whatever the theme, so the phone reads it */
.wa-qr { flex: none; width: 280px; max-width: 100%; aspect-ratio: 1; padding: 0; background: #fff; border: 1px solid #dde2de; border-radius: 8px; overflow: hidden; }
.wa-qr svg { display: block; width: 100%; height: 100%; fill: initial; stroke: none; }
.wa-qr svg path { fill: #000; stroke: none; }
.wa-qr svg rect { fill: #fff; stroke: none; }
.wa-steps { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.wa-steps ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.wa-radios { display: flex; flex-direction: column; gap: 8px; }
.wa-radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.wa-radio input { width: 18px; height: 18px; min-height: 0; margin-top: 2px; flex: none; accent-color: #1fa855; }
.wa-radio span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wa-radio small { color: var(--muted); }
.wa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: start; }
.wa-grid .wa-btns { grid-column: 1 / -1; }
.wa-usage { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px; font-size: .88rem; }
.wa-usage li { padding: 8px 10px; border-radius: 6px; background: #f4f6f5; }
.wa-copyrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; }
.wa-copyrow > span { color: var(--muted); }
.wa-copyrow code { flex: 1 1 200px; min-width: 0; padding: 6px 8px; border-radius: 6px; background: #f4f6f5; overflow-wrap: anywhere; font-size: .8rem; }
.wa-replies { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.wa-replies li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.wa-replies li > div { flex: 1 1 260px; min-width: 0; }
.wa-replies p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: .88rem; }

/* ---------- the "Send on linked WhatsApp" dialog and the Queued toast */
.wa-sug { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: -6px; }
.wa-sug[hidden] { display: none; }
.wa-sug button { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line); background: var(--panel); text-align: left; cursor: pointer; font: inherit; }
.wa-sug button:last-child { border-bottom: 0; }
.wa-sug button:hover { background: var(--soft); }
.wa-sug span { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.wa-chk { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.wa-chk input { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: #1fa855; }
.wa-dtitle { margin: 0; }
.btn.wa-green { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.wa-green:hover { background: #178f47; }
.wa-toast { display: flex; align-items: center; gap: 10px; }
.wa-toast span { flex: 1; }
.wa-toast-btn { flex: none; padding: 4px 10px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 6px; background: none; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }

@media (max-width: 1000px) {
  .wa-panes { grid-template-columns: 280px minmax(0, 1fr); }
}
/* Phone: the list, or the open chat full screen with a back arrow; pages scroll with the screen. */
@media (max-width: 767px) {
  .wa { height: auto; }
  .wa-tabs { position: sticky; top: 104px; z-index: 12; padding: 4px 8px 0; }
  .wa-tabstate { display: none; }
  .wa-view { display: block; }
  .wa-panes { display: block; }
  .wa-list { border-right: 0; min-height: calc(100dvh - 200px); }
  .wa-rows { overflow: visible; }
  .wa-list-head, .wa-chips { padding-left: 16px; padding-right: 16px; }
  .wa-row { padding: 10px 16px; }
  .wa-thread { display: none; }
  .wa-panes.has-chat .wa-list { display: none; }
  .wa-panes.has-chat .wa-thread { display: flex; position: fixed; inset: 0; z-index: 40; height: 100vh; height: 100dvh; }
  .wa-back { display: inline-grid; }
  .wa-th-head { padding: 6px 8px; gap: 6px; }
  .wa-th-head .wa-av { display: none; }
  .wa-msgs { padding: 10px 12px; }
  .wa-bub { max-width: 86%; }
  .wa-img img { width: 220px; }
  .wa-comp { padding-left: 8px; padding-right: 8px; }
  .wa-sc { left: 0; right: 0; bottom: 100%; border-radius: 14px 14px 0 0; max-height: 55vh; }
  .wa-page { padding: 12px 16px 30px; }
  .wa-card { padding: 14px; }
  .wa-qr { width: 100%; max-width: 320px; margin: 0 auto; }
  .wa-grid { grid-template-columns: minmax(0, 1fr); }
}
