/* Salespirit Sales — chat in the "Focus" layout (team chat in the app, and the chat in the client portal).
   Same soft look as the app: one grey, depth from a light and a dark shadow, your own messages in ink.
   On a computer the list is a slim rail with faces (click the arrow to show names); the conversation sits in the middle. */
:root {
  --c-bg: var(--bg, #e8e8e8); --c-fg: var(--fg, #222224); --c-dim: var(--dim, #7a7a7f); --c-soft: var(--soft, #e0e0e0);
  --c-out: var(--sh-out-sm, var(--out-sm, 4px 4px 10px #c4c4c4, -4px -4px 10px #fff));
  --c-in: var(--sh-in-sm, var(--in-sm, inset 2px 2px 5px #c4c4c4, inset -2px -2px 5px #fff));
  --c-in-lg: var(--sh-in, inset 4px 4px 9px var(--lo, #c4c4c4), inset -4px -4px 9px var(--hi, #fff));
  --wa-green: var(--c-fg); --wa-meta: var(--c-dim); --wa-text: var(--c-fg); --wa-badge: #2bb673; --wa-blue: #3b82f6;
}

.wa { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 20px; height: calc(100vh - 140px); min-height: 520px; color: var(--c-fg); }
.wa.wide { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }

/* ---- List: a rail of faces, or the full list ---- */
.wa-list { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-radius: var(--r, 22px); background: var(--c-bg); box-shadow: var(--sh-out, var(--out)); padding: 14px 10px; }
.wa-list-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px 10px; }
.wa-list-h h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.wa-ib { width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--c-bg); color: var(--c-fg); box-shadow: var(--c-out); cursor: pointer; flex: none; }
.wa-ib:hover { box-shadow: var(--c-in); }
.wa-ib .ti { font-size: 19px; vertical-align: 0; }
.wa-search { margin: 0 4px 10px; display: flex; align-items: center; gap: 9px; padding: 0 14px; height: 40px; border-radius: 99px; box-shadow: var(--c-in); color: var(--c-dim); }
.wa-search input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; color: var(--c-fg); font-size: 14px; outline: none; }
.wa-filters { display: flex; gap: 4px; padding: 4px; margin: 0 4px 10px; border-radius: 99px; box-shadow: var(--c-in); overflow-x: auto; scrollbar-width: none; }
.wa-filters button { border: 0; border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 12.5px; font-weight: 700; background: transparent; color: var(--c-dim); cursor: pointer; white-space: nowrap; }
.wa-filters button.on { background: var(--c-bg); color: var(--c-fg); box-shadow: var(--c-out); }
.wa-items { flex: 1; overflow-y: auto; scrollbar-width: none; display: grid; align-content: start; gap: 4px; padding: 2px; }
.wa-sec { padding: 12px 10px 4px; font-size: 11px; font-weight: 800; color: var(--c-dim); text-transform: uppercase; letter-spacing: .08em; }
.wa-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 16px; background: transparent; color: inherit; text-align: left; cursor: pointer; font: inherit; position: relative; }
.wa-item:hover { background: color-mix(in srgb, var(--c-fg) 4%, transparent); }
.wa-item.on { box-shadow: var(--c-in); background: transparent; }
.wa-item-b { flex: 1; min-width: 0; }
.wa-item-r1, .wa-item-r2 { display: flex; align-items: center; gap: 8px; }
.wa-item-r1 b { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item-r1 time { font-size: 11px; color: var(--c-dim); flex: none; }
.wa-item.unread .wa-item-r1 time { color: var(--c-fg); font-weight: 700; }
.wa-item-r2 span { flex: 1; min-width: 0; font-size: 12.5px; color: var(--c-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-item-r2 span.typing, .wa-status.typing { color: var(--c-fg); font-weight: 700; }
.wa-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--c-fg); color: var(--c-bg); font-size: 11px; font-weight: 800; display: grid; place-items: center; flex: none; }
.wa-empty { padding: 26px 10px; text-align: center; color: var(--c-dim); font-size: 13px; }
/* rail (default on a computer): only the faces, the unread number on the face */
.wa:not(.wide) .wa-list { padding: 14px 0; align-items: center; }
.wa:not(.wide) .wa-list-h { flex-direction: column; padding: 0 0 8px; gap: 10px; }
.wa:not(.wide) .wa-list-h h2, .wa:not(.wide) .wa-search, .wa:not(.wide) .wa-filters, .wa:not(.wide) .wa-sec, .wa:not(.wide) .wa-item-r1, .wa:not(.wide) .wa-item-r2 span { display: none; }
.wa:not(.wide) .wa-items { width: 100%; justify-items: center; padding: 4px 0; }
.wa:not(.wide) .wa-item { width: 64px; height: 64px; padding: 0; justify-content: center; border-radius: 50%; }
.wa:not(.wide) .wa-item-b { position: absolute; top: 2px; right: 2px; flex: none; }
.wa:not(.wide) .wa-item-r2 { margin: 0; }
.wa-wide-btn .ti { transition: transform .2s; }
.wa.wide .wa-wide-btn .ti { transform: rotate(180deg); }

/* Avatars with a green dot when online */
.wa-av { position: relative; width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; 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: 14px; }
.wa-av.hash { background: var(--c-bg); color: var(--c-dim); font-size: 20px; box-shadow: var(--c-out); }
.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(--c-bg); }

/* ---- Conversation, in the middle ---- */
.wa-win { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; border-radius: var(--r, 22px); background: var(--c-bg); box-shadow: var(--sh-out, var(--out)); overflow: hidden; }
.wa-head { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 64px 14px; text-align: center; flex: none; z-index: 2; position: relative; }
.wa-head .wa-av, .wa-head .wa-av.sm { width: 58px; height: 58px; font-size: 19px; }
.wa-head-t { min-width: 0; max-width: 100%; line-height: 1.3; }
.wa-head-t b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-status { display: block; font-size: 12.5px; color: var(--c-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-acts { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.wa-back { display: none; position: absolute; top: 16px; left: 16px; }
.wa-log { flex: 1; overflow-y: auto; padding: 8px max(20px, calc((100% - 760px) / 2)) 14px; display: flex; flex-direction: column; gap: 3px; scrollbar-width: thin; overscroll-behavior: contain; }
.wa-day { align-self: center; margin: 12px 0 8px; padding: 3px 12px; border-radius: 99px; background: var(--c-bg); box-shadow: var(--c-in); color: var(--c-dim); font-size: 11.5px; font-weight: 700; position: sticky; top: 4px; z-index: 1; }
.wa-note { align-self: center; margin: 4px 0 10px; padding: 6px 14px; border-radius: 99px; box-shadow: var(--c-in); color: var(--c-dim); font-size: 12px; 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: 10px; }
.wa-b { position: relative; max-width: min(68%, 560px); padding: 9px 13px 8px; border-radius: 18px; background: var(--c-bg); color: var(--c-fg); box-shadow: var(--c-out); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.wa-row.wa-them.first .wa-b { border-bottom-left-radius: 6px; }
.wa-row.wa-me .wa-b { background: var(--c-fg); color: var(--c-bg); box-shadow: 3px 3px 8px var(--lo, rgba(0,0,0,.15)); }
.wa-row.wa-me.first .wa-b { border-bottom-right-radius: 6px; }
.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: 12px; font-weight: 800; margin-bottom: 2px; white-space: normal; }
.wa-row.wa-me .wa-name { color: inherit !important; opacity: .7; }
.wa-b a { color: inherit; text-decoration: underline; }
.wa-meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 7px 0 -4px 12px; font-size: 10.5px; color: var(--c-dim); white-space: nowrap; line-height: 1; position: relative; top: 2px; }
.wa-row.wa-me .wa-meta { color: currentColor; opacity: .65; }
.wa-tick { width: 16px; height: 11px; color: currentColor; flex: none; }
.wa-tick.read { color: var(--wa-blue); opacity: 1; }
.wa-row.wa-me .wa-tick.read { color: #7fb5ff; }
.wa-typing { display: inline-flex; gap: 3px; padding: 4px 2px; }
.wa-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--c-dim); 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); } }

/* Quick replies and the composer */
.wa-quick { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 max(20px, calc((100% - 760px) / 2)) 10px; flex: none; }
.wa-quick button { border: 0; border-radius: 99px; padding: 7px 13px; font: inherit; font-size: 12.5px; font-weight: 700; background: var(--c-bg); color: var(--c-fg); box-shadow: var(--c-out); cursor: pointer; }
.wa-quick button:hover { box-shadow: var(--c-in); }
.wa-compose { display: flex; align-items: flex-end; gap: 10px; margin: 0 max(16px, calc((100% - 776px) / 2)) 16px; padding: 8px 8px 8px 10px; border-radius: 22px; background: var(--c-bg); box-shadow: var(--c-in-lg); flex: none; }
.wa-compose textarea {
  flex: 1; min-height: 42px !important; max-height: 140px; height: 42px; resize: none; border: 0 !important; border-radius: 14px !important;
  padding: 11px 8px !important; background: transparent !important; color: var(--c-fg) !important; box-shadow: none !important; font: inherit; font-size: 14.5px; line-height: 1.35; outline: none;
}
.wa-send { width: 42px; height: 42px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--c-fg); color: var(--c-bg); flex: none; cursor: pointer; transition: transform .12s; box-shadow: 3px 3px 8px var(--lo, rgba(0,0,0,.15)); }
.wa-send:active { transform: scale(.92); }
.wa-send .ti { font-size: 19px; vertical-align: 0; }
.wa-blank { flex: 1; display: grid; place-items: center; text-align: center; color: var(--c-dim); padding: 30px; }
.wa-blank b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--c-fg); margin: 14px 0 8px; }
.wa-blank .ti { font-size: 56px; color: var(--c-dim); opacity: .5; }

/* Phone: list first, conversation full screen */
@media (max-width: 820px) {
  .wa, .wa.wide { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 150px); gap: 0; }
  .wa .wa-list { padding: 14px 10px; align-items: stretch; }
  .wa .wa-list-h { flex-direction: row; padding: 2px 4px 10px; }
  .wa .wa-list-h h2, .wa .wa-search, .wa .wa-filters { display: flex; }
  .wa .wa-list-h h2 { display: block; }
  .wa .wa-sec { display: block; }
  .wa .wa-item-r1, .wa .wa-item-r2 { display: flex; }
  .wa .wa-item-r2 span { display: block; }
  .wa .wa-items { justify-items: stretch; }
  .wa .wa-item { width: 100%; height: auto; padding: 9px 10px; border-radius: 16px; justify-content: flex-start; }
  .wa .wa-item-b { position: static; flex: 1; }
  .wa-wide-btn { display: none; }
  .wa.open .wa-list { display: none; }
  .wa:not(.open) .wa-win { display: none; }
  .wa-back { display: grid; }
  .wa-head { padding: 16px 56px 10px; }
  .wa-log { padding: 8px 12px 12px; }
  .wa-b { max-width: 84%; }
  .wa-quick { padding: 0 12px 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .wa-quick button { flex: none; }
  .wa-compose { margin: 0 10px 10px; }
}
@media (prefers-reduced-motion: reduce) { .wa-row.new .wa-b, .wa-typing i { animation: none; } }
