/* web.bro.tips — WhatsApp Web, ours.
 *
 * The look is copied, not invented. Familiarity IS the requirement: an agent who knows WhatsApp
 * should need no training, and a near-miss reads as broken software. Measurements below come from
 * the real client — 65px header, 72px rows, 7.5px bubble radius, the tail notch, the doodle wall.
 * System fonts only; nothing is fetched from outside this origin.
 */
:root{
  --bg:#0b141a;
  --panel:#111b21;
  --panel-2:#202c33;
  --hdr:#202c33;
  --hover:#202c33;
  --active:#2a3942;
  --line:rgba(134,150,160,.15);
  --txt:#e9edef;
  --dim:#8696a0;
  --dim-2:#667781;
  --green:#00a884;
  --green-2:#25d366;
  --out:#005c4b;
  --blue:#53bdeb;
  --danger:#f15c6d;
}
*{ box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
/* The browser's own `[hidden]{display:none}` is a plain attribute selector and LOSES to any class
   rule that sets `display` — so `.intro{display:grid}` kept the intro pane painted over the open
   conversation even though `hidden` was correctly set. Every toggle in this app relies on `hidden`,
   so it is made to win once, here, instead of being worked around per element. */
[hidden]{ display:none !important; }
html,body{ height:100%; }
body{
  background:#0c1317; color:var(--txt);
  font:400 15px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  overflow:hidden; -webkit-font-smoothing:antialiased;
}
svg{ width:24px; height:24px; fill:currentColor; display:block; }
::-webkit-scrollbar{ width:6px; height:6px; }
::-webkit-scrollbar-thumb{ background:rgba(134,150,160,.3); border-radius:3px; }
::-webkit-scrollbar-track{ background:transparent; }

/* ── boot ───────────────────────────────────────────────────────────────── */
.boot{ position:fixed; inset:0; display:grid; place-content:center; justify-items:center;
  gap:16px; background:var(--panel); text-align:center; padding:24px; z-index:50; }
.boot-mark{ width:60px; height:60px; border-radius:50%; background:var(--green-2);
  -webkit-mask:center/36px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 0 0-8.6 15L2 22l5.2-1.4A10 10 0 1 0 12 2z'/%3E%3C/svg%3E");
  mask:center/36px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 0 0-8.6 15L2 22l5.2-1.4A10 10 0 1 0 12 2z'/%3E%3C/svg%3E"); }
.boot-bar{ width:min(320px,70vw); height:3px; border-radius:3px; background:#2a3942; overflow:hidden; }
.boot-bar span{ display:block; height:100%; width:38%; background:var(--green-2);
  animation:slide 1.15s cubic-bezier(.4,0,.2,1) infinite; }
@keyframes slide{ 0%{transform:translateX(-110%)} 100%{transform:translateX(330%)} }
#boot-msg{ font-size:20px; font-weight:300; letter-spacing:.4px; }
.boot-sub{ font-size:13px; color:var(--dim); }
.boot-back{ color:var(--green-2); font-size:14px; text-decoration:none; border:1px solid #2a3942;
  padding:9px 20px; border-radius:22px; margin-top:8px; transition:background .15s; }
.boot-back:hover{ background:var(--panel-2); }

/* ── layout ─────────────────────────────────────────────────────────────── */
.app{ display:grid; grid-template-columns:clamp(300px,30%,460px) 1fr; height:100dvh;
  background:var(--panel); }
.pane-left{ display:flex; flex-direction:column; min-width:0;
  border-right:1px solid var(--line); background:var(--panel); }
.pane-right{ position:relative; min-width:0; background:var(--bg); }

.hdr{ display:flex; align-items:center; gap:10px; height:65px; padding:0 16px;
  background:var(--hdr); flex:0 0 65px; }
.hdr-actions{ margin-left:auto; display:flex; align-items:center; gap:2px; }
.ic{ display:grid; place-content:center; width:40px; height:40px; border:0; border-radius:50%;
  background:transparent; color:var(--dim); cursor:pointer; transition:background .12s,color .12s; }
.ic:hover:not(:disabled){ background:rgba(134,150,160,.16); color:var(--txt); }
.ic:active:not(:disabled){ background:rgba(134,150,160,.24); }
.ic:disabled{ opacity:.32; cursor:default; }
.ic.on{ color:var(--green-2); }

.avatar{ width:49px; height:49px; border-radius:50%; flex:0 0 49px; display:grid; place-content:center;
  color:#fff; font-size:15px; font-weight:500; letter-spacing:.3px; user-select:none; }
.avatar.sm{ width:40px; height:40px; flex-basis:40px; font-size:13px; }
.avatar.me{ background:var(--green); }

/* ── search ─────────────────────────────────────────────────────────────── */
.search-wrap{ padding:8px 12px; display:flex; gap:8px; align-items:center; }
.search{ flex:1; display:flex; align-items:center; gap:0; background:var(--panel-2);
  border-radius:8px; padding:0 12px 0 14px; height:35px; transition:box-shadow .15s; }
.search:focus-within{ box-shadow:0 0 0 1px var(--green); }
.search-ic{ width:20px; height:20px; color:var(--dim); flex:0 0 20px; margin-right:12px; }
.search input{ flex:1; min-width:0; background:none; border:0; outline:0; color:var(--txt); font-size:14px; }
.search input::placeholder{ color:var(--dim); }

/* ── admin scope bar ────────────────────────────────────────────────────── */
.scope{ padding:0 12px 8px; display:none; flex-direction:column; gap:7px; }
.scope.on{ display:flex; }
.scope-row{ display:flex; gap:7px; }
.scope select{ flex:1; min-width:0; background:var(--panel-2); color:var(--txt); border:0;
  border-radius:8px; height:33px; padding:0 9px; font-size:13px; outline:0; cursor:pointer; }
.scope select:focus{ box-shadow:0 0 0 1px var(--green); }
.scope-tag{ display:flex; align-items:center; gap:6px; align-self:flex-start; font-size:11px;
  color:var(--green-2); background:rgba(0,168,132,.12); padding:4px 10px; border-radius:12px; }
.scope-tag svg{ width:13px; height:13px; }

.tabs{ display:flex; gap:8px; padding:0 12px 8px; }
.tab{ border:0; background:var(--panel-2); color:var(--dim); font-size:13px; padding:6px 13px;
  border-radius:16px; cursor:pointer; transition:.12s; }
.tab:hover{ background:var(--active); }
.tab.on{ background:rgba(0,168,132,.18); color:var(--green-2); }

/* ── chat list ──────────────────────────────────────────────────────────── */
.chats{ flex:1; overflow-y:auto; overscroll-behavior:contain; }
.empty-list{ padding:40px 24px; text-align:center; color:var(--dim); font-size:14px; line-height:1.6; }
.row{ display:flex; align-items:center; gap:15px; padding:0 0 0 13px; height:72px; cursor:pointer;
  transition:background .1s; }
.row:hover{ background:var(--hover); }
.row.on{ background:var(--active); }
.row-main{ flex:1; min-width:0; height:100%; display:flex; flex-direction:column;
  justify-content:center; gap:2px; border-bottom:1px solid var(--line); padding-right:15px; }
.row:last-child .row-main{ border-bottom:0; }
.row-top{ display:flex; align-items:baseline; gap:8px; }
.row-name{ flex:1; min-width:0; font-size:17px; font-weight:400;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.row-time{ font-size:12px; color:var(--dim); flex:0 0 auto; }
.row.unread .row-time{ color:var(--green-2); }
.row-bot{ display:flex; align-items:center; gap:8px; }
.row-prev{ flex:1; min-width:0; font-size:14px; color:var(--dim);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:flex; align-items:center; gap:4px; }
.row-prev .tick{ width:16px; height:16px; flex:0 0 16px; }
.badge{ min-width:20px; height:20px; padding:0 6px; border-radius:10px; background:var(--green-2);
  color:#111b21; font-size:12px; font-weight:600; display:grid; place-content:center; flex:0 0 auto; }
.row-who{ font-size:11px; color:var(--dim-2); }

/* ── intro ──────────────────────────────────────────────────────────────── */
.intro{ height:100%; display:grid; place-content:center; justify-items:center; gap:0;
  text-align:center; padding:40px; border-bottom:6px solid var(--green); background:var(--panel); }
.intro-art{ width:250px; height:250px; border-radius:50%; margin-bottom:28px; background:
  radial-gradient(closest-side, rgba(134,150,160,.10), rgba(134,150,160,.03) 70%, transparent);
  display:grid; place-content:center; }
.intro-art svg{ width:120px; height:120px; color:rgba(134,150,160,.35); }
.intro h1{ font-size:32px; font-weight:300; color:#e9edef; margin-bottom:14px; }
.intro p{ color:var(--dim); font-size:14px; max-width:520px; line-height:1.6; }
.intro-lock{ display:flex; align-items:center; gap:7px; margin-top:34px; font-size:13px; color:var(--dim-2); }
.intro-lock svg{ width:13px; height:13px; }

/* ── conversation ───────────────────────────────────────────────────────── */
.chat{ height:100%; display:flex; flex-direction:column; }
.chat-hdr .back{ display:none; }
.chat-who{ min-width:0; flex:1; cursor:default; }
.chat-name{ font-size:16px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-sub{ font-size:13px; color:var(--dim); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* The doodle wall: two offset dot grids at very low alpha, drawn in CSS so nothing is downloaded. */
.msgs{ flex:1; overflow-y:auto; overscroll-behavior:contain; padding:14px 6% 10px;
  background-color:var(--bg);
  background-image:
    radial-gradient(rgba(255,255,255,.030) 1.2px, transparent 1.2px),
    radial-gradient(rgba(255,255,255,.022) 1.2px, transparent 1.2px);
  background-size:36px 36px, 36px 36px;
  background-position:0 0, 18px 18px; }

.day{ display:flex; justify-content:center; margin:12px 0 14px; }
.day span{ background:#182229; color:#8696a0; font-size:12.5px; font-weight:500;
  padding:6px 13px; border-radius:8px; box-shadow:0 1px .5px rgba(11,20,26,.13);
  text-transform:uppercase; letter-spacing:.3px; }

/* A bubble HUGS its text. Without width:fit-content a block-level div fills the whole column and
   every short message becomes a wide slab — the single biggest visual tell that this is not the
   real client. max-width still caps long messages at a readable measure. */
.b{ position:relative; width:fit-content; max-width:min(65%,520px); margin-bottom:2px;
  padding:6px 7px 8px 9px; border-radius:7.5px; box-shadow:0 1px .5px rgba(11,20,26,.13); }
.b.in{ background:var(--panel-2); margin-right:auto; }
.b.out{ background:var(--out); margin-left:auto; }
/* First bubble of a run gets the tail notch, exactly like the real client. */
.b.in.first{ border-top-left-radius:0; }
.b.out.first{ border-top-right-radius:0; }
.b.in.first::before,.b.out.first::before{ content:''; position:absolute; top:0; width:8px; height:13px; }
.b.in.first::before{ left:-8px;
  background:radial-gradient(circle at 0 100%, transparent 8px, var(--panel-2) 8px); }
.b.out.first::before{ right:-8px;
  background:radial-gradient(circle at 100% 100%, transparent 8px, var(--out) 8px); }
.b + .b{ margin-top:2px; }
.b.first{ margin-top:12px; }
.msgs-inner > .b:first-child{ margin-top:0; }

.b-txt{ font-size:14.2px; line-height:19px; white-space:pre-wrap; word-break:break-word; }
/* Floated INSIDE the text: the browser reserves the space and wraps the last line around it, so a
   one-word message and a five-line one both end with the clock tucked neatly on the right. */
.b-meta{ float:right; display:inline-flex; align-items:center; gap:3px; height:15px;
  margin:6px -2px -4px 12px; font-size:11px; color:rgba(233,237,239,.6); white-space:nowrap; }
.b-meta .tick{ width:16px; height:16px; }
.b-meta .tick.read{ color:var(--blue); }
.b-meta .tick.failed{ color:var(--danger); }
.b img,.b video{ max-width:100%; border-radius:6px; display:block; margin:-2px -3px 4px; }
.b audio{ width:262px; max-width:100%; display:block; margin-bottom:4px; }
.b .doc{ display:flex; align-items:center; gap:10px; background:rgba(0,0,0,.18); border-radius:6px;
  padding:11px 12px; margin:-1px -4px 4px; color:var(--txt); text-decoration:none; }
.b .doc:hover{ background:rgba(0,0,0,.26); }
.b .doc svg{ width:22px; height:22px; color:var(--dim); flex:0 0 22px; }
.b .doc span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13.5px; }

/* Read-only banner when an admin is looking at someone else's inbox. */
.readonly{ display:flex; align-items:center; justify-content:center; gap:8px; padding:11px;
  background:#182229; color:var(--dim); font-size:13px; }
.readonly svg{ width:15px; height:15px; }

/* ── composer ───────────────────────────────────────────────────────────── */
.composer{ display:flex; align-items:flex-end; gap:4px; padding:5px 16px 7px; background:var(--hdr); }
.input-wrap{ flex:1; min-width:0; background:#2a3942; border-radius:8px; padding:9px 12px;
  margin:0 4px; }
.composer textarea{ width:100%; max-height:110px; resize:none; border:0; outline:0; background:none;
  color:var(--txt); font:inherit; font-size:15px; line-height:20px; display:block; }
.composer textarea::placeholder{ color:var(--dim); }

/* ── toast ──────────────────────────────────────────────────────────────── */
.toast{ position:fixed; left:50%; bottom:28px; transform:translate(-50%,26px); opacity:0;
  background:#182229; color:var(--txt); font-size:14px; padding:12px 22px; border-radius:8px;
  box-shadow:0 4px 20px rgba(0,0,0,.55); pointer-events:none; transition:.2s; z-index:60; max-width:88vw; }
.toast.show{ opacity:1; transform:translate(-50%,0); }
.toast.err{ background:#3b1f22; color:#ffb4bb; }

/* ── mobile: one pane at a time, like the real client ───────────────────── */
@media (max-width:820px){
  .app{ grid-template-columns:1fr; }
  .pane-right{ position:fixed; inset:0; z-index:20; transform:translateX(100%);
    transition:transform .18s ease-out; }
  .app.open .pane-right{ transform:translateX(0); }
  .intro{ display:none; }
  .chat-hdr .back{ display:grid; margin-left:-6px; }
  .msgs{ padding-left:4%; padding-right:4%; }
  .b{ max-width:84%; }
  .composer{ padding-left:8px; padding-right:8px; }
}

/* ── fidelity pass ──────────────────────────────────────────────────────────
   Details copied from the real client because their absence is what reads as "almost". */

/* Left header: the profile avatar sits at 40px with the icon cluster hard right. */
.pane-left > .hdr{ padding:0 16px 0 16px; }

/* The search row in WhatsApp Web is one 49px band, not a floating pill. */
.search-wrap{ padding:7px 12px 7px; background:var(--panel);
  border-bottom:1px solid var(--line); }
.search{ height:35px; border-radius:8px; }

/* Chat rows: the divider starts AFTER the avatar, and the whole row is one hit target. */
.row{ position:relative; }
.row-main{ padding-right:15px; }

/* Unread rows carry a heavier name, like the real list. */
.row.unread .row-name{ font-weight:500; }

/* Selected row loses its hover tint so the two states cannot stack into a third colour. */
.row.on:hover{ background:var(--active); }

/* Conversation header sits on the same 65px band and gains a left hairline. */
.chat-hdr{ border-left:1px solid var(--line); padding:0 16px; }

/* Message column: WhatsApp caps the reading width rather than letting bubbles span a wide screen. */
.msgs-inner{ max-width:1100px; margin:0 auto; }

/* Bubble text and the meta line share a baseline; without the float trick the timestamp wraps. */
.b-txt:empty{ display:none; }
.b.media-only .b-txt{ padding-right:0; }
.b.media-only .b-meta{ position:absolute; right:10px; bottom:8px; margin:0;
  background:rgba(11,20,26,.45); border-radius:8px; padding:2px 6px; color:#fff; }

/* Composer: emoji on the left of the paperclip, mic swapping to send — the real layout. */
.composer .ic{ width:42px; height:42px; }
.composer .ic svg{ width:26px; height:26px; }

/* Scroll-to-bottom pill, appears when the agent has scrolled up. */
.jump{ position:absolute; right:22px; bottom:78px; width:42px; height:42px; border-radius:50%;
  background:var(--panel-2); color:var(--dim); border:0; display:grid; place-content:center;
  cursor:pointer; box-shadow:0 1px 3px rgba(11,20,26,.5); opacity:0; pointer-events:none;
  transform:translateY(8px); transition:.15s; }
.jump.on{ opacity:1; pointer-events:auto; transform:translateY(0); }
.jump:hover{ color:var(--txt); }
.jump .badge{ position:absolute; top:-4px; right:-2px; }

/* Menu (avatar click): back to CRM, sign out. Real actions only — no decorative buttons. */
.menu{ position:absolute; top:58px; left:12px; min-width:210px; background:var(--panel-2);
  border-radius:3px; box-shadow:0 2px 10px rgba(11,20,26,.6); padding:6px 0; z-index:30; display:none; }
.menu.on{ display:block; }
.menu button, .menu a{ display:block; width:100%; text-align:left; background:none; border:0;
  color:var(--txt); font:inherit; font-size:14.5px; padding:12px 24px; cursor:pointer;
  text-decoration:none; }
.menu button:hover, .menu a:hover{ background:var(--active); }
.pane-left{ position:relative; }

/* Typing/sending affordance on the send button, matching the client's mic->send swap. */
.ic.send svg{ transition:transform .12s; }
.ic.send.on svg{ transform:scale(1.04); }
