/* Salespirit Sales — chat in a WhatsApp layout (team chat in the app, and the chat in the client portal).
   Light and dark follow the theme (html.is-dark is set by public/theme.js). */
:root {
  --wa-wall: #efeae2; --wa-in: #ffffff; --wa-out: #d9fdd3; --wa-text: #111b21; --wa-meta: #667781;
  --wa-head: #f0f2f5; --wa-panel: #ffffff; --wa-line: #e9edef; --wa-hover: #f5f6f6; --wa-active: #f0f2f5;
  --wa-green: #00a884; --wa-badge: #25d366; --wa-blue: #53bdeb; --wa-chip: #ffffff; --wa-input: #ffffff;
  --wa-doodle: rgba(17, 27, 33, .045);
}
html.is-dark {
  --wa-wall: #0b141a; --wa-in: #202c33; --wa-out: #005c4b; --wa-text: #e9edef; --wa-meta: #8696a0;
  --wa-head: #202c33; --wa-panel: #111b21; --wa-line: #222d34; --wa-hover: #202c33; --wa-active: #2a3942;
  --wa-chip: #182229; --wa-input: #2a3942; --wa-doodle: rgba(233, 237, 239, .035);
}

.wa { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); height: calc(100vh - 140px); min-height: 520px; border-radius: var(--r, 22px); overflow: hidden; background: var(--wa-panel); color: var(--wa-text); box-shadow: var(--sh-out, 0 10px 30px rgba(0,0,0,.12)); }

/* ---- List ---- */
.wa-list { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--wa-line); background: var(--wa-panel); }
.wa-list-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.wa-list-h h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.wa-ib { width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--wa-meta); cursor: pointer; flex: none; }
.wa-ib:hover { background: var(--wa-hover); color: var(--wa-text); }
.wa-ib .ti { font-size: 20px; vertical-align: 0; }
.wa-search { margin: 4px 12px 8px; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 38px; border-radius: 10px; background: var(--wa-head); color: var(--wa-meta); }
.wa-search input { flex: 1; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; color: var(--wa-text); font-size: 14px; outline: none; }
.wa-filters { display: flex; gap: 8px; padding: 0 12px 8px; flex-wrap: wrap; }
.wa-filters button { border: 0; border-radius: 99px; padding: 6px 13px; font-size: 13px; font-weight: 600; background: var(--wa-head); color: var(--wa-meta); cursor: pointer; }
.wa-filters button.on { background: color-mix(in srgb, var(--wa-green) 18%, transparent); color: var(--wa-green); }
.wa-items { flex: 1; overflow-y: auto; scrollbar-width: thin; }
.wa-sec { padding: 14px 16px 6px; font-size: 12px; font-weight: 700; color: var(--wa-green); text-transform: uppercase; letter-spacing: .06em; }
.wa-item { display: flex; align-items: center; gap: 13px; width: 100%; padding: 0 0 0 13px; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.wa-item:hover { background: var(--wa-hover); }
.wa-item.on { background: var(--wa-active); }
.wa-item-b { flex: 1; min-width: 0; padding: 12px 15px 12px 0; border-bottom: 1px solid var(--wa-line); }
.wa-item-r1, .wa-item-r2 { display: flex; align-items: center; gap: 8px; }
.wa-item-r1 b { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item-r1 time { font-size: 12px; color: var(--wa-meta); flex: none; }
.wa-item.unread .wa-item-r1 time { color: var(--wa-badge); font-weight: 600; }
.wa-item-r2 { margin-top: 2px; }
.wa-item-r2 span { flex: 1; min-width: 0; font-size: 14px; color: var(--wa-meta); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item-r2 span.typing, .wa-status.typing { color: var(--wa-green); font-weight: 600; }
.wa-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--wa-badge); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
html.is-dark .wa-badge { color: #111b21; }
.wa-empty { padding: 30px 20px; text-align: center; color: var(--wa-meta); font-size: 14px; }

/* Avatars with a green dot when online */
.wa-av { position: relative; width: 49px; height: 49px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 17px; color: #fff; background: #6a7175; overflow: visible; }
.wa-av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.wa-av.sm { width: 40px; height: 40px; font-size: 15px; }
.wa-av.hash { background: var(--wa-head); color: var(--wa-meta); font-size: 22px; }
.wa-av.on::after { content: ""; position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--wa-badge); box-shadow: 0 0 0 2.5px var(--wa-panel); }
.wa-head .wa-av.on::after { box-shadow: 0 0 0 2.5px var(--wa-head); }

/* ---- Conversation ---- */
.wa-win { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--wa-wall); position: relative; }
.wa-head { display: flex; align-items: center; gap: 13px; height: 62px; padding: 0 12px 0 14px; background: var(--wa-head); flex: none; z-index: 2; }
.wa-head-t { flex: 1; min-width: 0; line-height: 1.25; }
.wa-head-t b { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-status { display: block; font-size: 13px; color: var(--wa-meta); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-back { display: none; }
.wa-log {
  flex: 1; overflow-y: auto; padding: 14px 6% 10px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; overscroll-behavior: contain;
  background-color: var(--wa-wall);
  background-image:
    radial-gradient(circle at 20% 20%, var(--wa-doodle) 0 3px, transparent 4px),
    radial-gradient(circle at 70% 60%, var(--wa-doodle) 0 2px, transparent 3px),
    radial-gradient(circle at 40% 85%, transparent 0 5px, var(--wa-doodle) 6px 7px, transparent 8px),
    radial-gradient(circle at 85% 15%, transparent 0 4px, var(--wa-doodle) 5px 6px, transparent 7px);
  background-size: 120px 120px, 90px 90px, 150px 150px, 110px 110px;
}
.wa-day { align-self: center; margin: 10px 0 8px; padding: 5px 12px; border-radius: 8px; background: var(--wa-chip); color: var(--wa-meta); font-size: 12.5px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); position: sticky; top: 4px; z-index: 1; }
.wa-note { align-self: center; margin: 6px 0 10px; padding: 6px 12px; border-radius: 8px; background: color-mix(in srgb, #ffd279 30%, var(--wa-chip)); color: var(--wa-text); font-size: 12.5px; text-align: center; max-width: 90%; }
.wa-row { display: flex; padding: 0; }
.wa-row.wa-me { justify-content: flex-end; }
.wa-row.first { margin-top: 8px; }
.wa-b {
  position: relative; max-width: min(65%, 560px); padding: 6px 8px 8px 9px; border-radius: 8px;
  background: var(--wa-in); color: var(--wa-text); font-size: 14.2px; line-height: 1.38;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13); overflow-wrap: anywhere; white-space: pre-wrap;
}
.wa-row.wa-me .wa-b { background: var(--wa-out); }
.wa-row.first.wa-them .wa-b { border-top-left-radius: 0; }
.wa-row.first.wa-me .wa-b { border-top-right-radius: 0; }
.wa-row.first.wa-them .wa-b::before, .wa-row.first.wa-me .wa-b::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; background: inherit; }
.wa-row.first.wa-them .wa-b::before { left: -8px; clip-path: polygon(100% 0, 0 0, 100% 100%); }
.wa-row.first.wa-me .wa-b::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.wa-row.new .wa-b { animation: waIn .25s ease-out; }
@keyframes waIn { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.wa-name { display: block; font-size: 12.8px; font-weight: 600; margin-bottom: 2px; white-space: normal; }
.wa-b a { color: #027eb5; }
html.is-dark .wa-b a { color: #53bdeb; }
.wa-meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -5px 10px; font-size: 11px; color: var(--wa-meta); white-space: nowrap; line-height: 1; position: relative; top: 2px; }
html.is-dark .wa-row.wa-me .wa-meta { color: rgba(233, 237, 239, .6); }
.wa-tick { width: 16px; height: 11px; color: var(--wa-meta); flex: none; }
.wa-tick.read { color: var(--wa-blue); }
.wa-typing { display: inline-flex; gap: 3px; padding: 4px 2px; }
.wa-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--wa-meta); animation: waDot 1.2s infinite; }
.wa-typing i:nth-child(2) { animation-delay: .15s; } .wa-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes waDot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* Composer */
.wa-compose { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; background: var(--wa-head); flex: none; }
.wa-compose textarea {
  flex: 1; min-height: 42px !important; max-height: 140px; height: 42px; resize: none; border: 0 !important; border-radius: 10px !important;
  padding: 11px 14px !important; background: var(--wa-input) !important; color: var(--wa-text) !important; box-shadow: none !important; font: inherit; font-size: 15px; line-height: 1.35; outline: none;
}
.wa-send { width: 42px; height: 42px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--wa-green); color: #fff; flex: none; cursor: pointer; transition: transform .12s; }
.wa-send:active { transform: scale(.92); }
.wa-send .ti { font-size: 20px; vertical-align: 0; }
.wa-blank { flex: 1; display: grid; place-items: center; text-align: center; color: var(--wa-meta); padding: 30px; background: var(--wa-head); }
.wa-blank b { display: block; font-size: 26px; font-weight: 300; color: var(--wa-text); margin: 14px 0 8px; }
.wa-blank .ti { font-size: 64px; color: var(--wa-meta); opacity: .5; }

/* Phone: list first, conversation full screen */
@media (max-width: 820px) {
  .wa { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 150px); border-radius: 18px; }
  .wa.open .wa-list { display: none; }
  .wa:not(.open) .wa-win { display: none; }
  .wa-back { display: grid; }
  .wa-log { padding: 12px 10px 8px; }
  .wa-b { max-width: 82%; }
}
@media (prefers-reduced-motion: reduce) { .wa-row.new .wa-b, .wa-typing i { animation: none; } }
