/* ==========================================================================
   WhatsApp inbox — lead panel tabs, chat thread, AI reply, composer.
   Uses the tokens from style.css.
   ========================================================================== */

/* ── WhatsApp icon next to the name in the leads table ───────────────────── */
.name-cell { display: flex; align-items: flex-start; gap: 6px; }
.name-cell .cell-name { min-width: 0; }
.wa-flag {
  flex: none; display: inline-flex; align-items: center; gap: 3px; height: 22px; min-width: 22px; padding: 0 5px;
  margin-top: -1px; border-radius: 11px; border: 1px solid #b9e0c9; background: #eef8f2; color: #1f8f5f;
  font: 700 11px var(--font); cursor: pointer; justify-content: center;
}
.wa-flag:hover { border-color: #1f8f5f; }
.wa-flag:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wa-flag.is-unread { background: #1f8f5f; border-color: #1f8f5f; color: #fff; padding: 0 7px 0 6px; animation: wa-ping 2s ease-out infinite; }
@keyframes wa-ping { 0% { box-shadow: 0 0 0 0 rgba(31, 143, 95, .45); } 70%, 100% { box-shadow: 0 0 0 7px rgba(31, 143, 95, 0); } }
@media (prefers-reduced-motion: reduce) { .wa-flag.is-unread { animation: none; } }

/* ── Lead panel tabs ─────────────────────────────────────────────────────── */
.lead-tabs { display: flex; gap: 4px; margin: 12px -24px 18px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.lead-tab {
  background: none; border: 0; padding: 10px 12px 12px; font: 600 14px var(--font); color: var(--muted); cursor: pointer;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 7px;
}
.lead-tab:hover { color: var(--text); }
.lead-tab.is-active { color: var(--graphite); border-bottom-color: var(--champagne); font-weight: 700; }
.lead-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 6px; }
.lead-tab__badge { min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: #1f8f5f; color: #fff; font-size: 11px; display: grid; place-items: center; }

/* ── Pane ────────────────────────────────────────────────────────────────── */
.wa { display: flex; flex-direction: column; gap: 12px; }
.wa-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wa-head__icon { width: 38px; height: 38px; border-radius: 50%; background: #1f8f5f; color: #fff; display: grid; place-items: center; flex: none; }
.wa-head__who { flex: 1; min-width: 0; }
.wa-head__who b { display: block; font-size: 14.5px; }
.wa-head__who small { font-size: 12.5px; color: var(--muted); }
.wa-window { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; }
.wa-window.is-open { color: #17734a; background: #e3f3ea; }
.wa-window.is-ending { color: #8a4c06; background: #fff5e8; }
.wa-window.is-closed { color: #5d6672; background: #eef0f2; }
.wa-notice { font-size: 13px; line-height: 1.5; color: #8a4c06; background: #fff5e8; border: 1px solid #f6d5a8; border-radius: 10px; padding: 10px 12px; }
.wa-notice code { font-size: 12px; background: rgba(0, 0, 0, .05); padding: 1px 4px; border-radius: 4px; }

/* ── Thread ──────────────────────────────────────────────────────────────── */
.wa-thread {
  height: min(440px, 52vh); overflow-y: auto; background: #f2f3f5; border-radius: 14px; border: 1px solid var(--border);
  padding: 16px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth;
}
.wa-thread::-webkit-scrollbar { width: 8px; }
.wa-thread::-webkit-scrollbar-thumb { background: #cdd2d8; border-radius: 8px; }
.wa-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13.5px; padding: 20px; }
.wa-day { align-self: center; font-size: 11.5px; font-weight: 600; color: #5d6670; background: #e3e6ea; padding: 4px 10px; border-radius: 999px; margin: 6px 0; }
.wa-msg { max-width: 80%; padding: 8px 11px 5px; font-size: 14px; line-height: 1.45; border-radius: 14px; animation: wa-in .3s cubic-bezier(.2, .8, .2, 1) both; }
.wa-msg--in { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-top-left-radius: 4px; }
.wa-msg--out { align-self: flex-end; background: #dff2e7; border: 1px solid #c3e5d1; border-top-right-radius: 4px; }
.wa-msg.is-failed { background: #fdeeee; border-color: #f2c4c4; }
.wa-text { white-space: pre-wrap; word-break: break-word; }
.wa-text a { color: #0a66c2; }
.wa-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: #5d6670; margin-top: 2px; }
.wa-msg--out .wa-meta { color: #4f6b5c; }
.wa-tick { color: #8a959f; }
.wa-tick--read { color: #2a78d6; }
.wa-failed { color: #b42323; font-weight: 700; cursor: help; }
.wa-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6e5428; margin-bottom: 3px; }
.wa-img img { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin-bottom: 5px; }
.wa-msg audio, .wa-msg video { max-width: 100%; margin-bottom: 4px; }
.wa-msg video { border-radius: 10px; max-height: 260px; }
.wa-file { display: flex; align-items: center; gap: 9px; background: rgba(255, 255, 255, .8); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; margin-bottom: 5px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 13px; }
a.wa-file:hover { border-color: var(--graphite); }
@keyframes wa-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .wa-msg { animation: none; } .wa-thread { scroll-behavior: auto; } }

/* ── AI suggested reply ──────────────────────────────────────────────────── */
.wa-ai { border: 1px solid #e6d3ad; background: #fbf8f2; border-radius: 14px; padding: 13px 15px; }
.wa-ai--idle { border-style: dashed; background: transparent; padding: 8px 10px; }
.wa-ai__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--champagne-600); }
.wa-ai__title {
  font-weight: 800; font-size: 13px; letter-spacing: .02em;
  background: linear-gradient(90deg, #9a7f4d 0%, #c9ad78 50%, #9a7f4d 100%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: wa-sheen 4s linear infinite;
}
@keyframes wa-sheen { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .wa-ai__title { animation: none; } }
.wa-ai__spacer { flex: 1; }
.wa-ai__intent { font-size: 11.5px; font-weight: 600; color: #6e5428; background: #f3ead8; padding: 3px 8px; border-radius: 6px; }
.wa-ai__text { margin: 9px 0 0; font-size: 14px; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.wa-ai__why { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.wa-ai__loading { margin: 8px 0 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.wa-ai__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.wa-use { font: 700 13px var(--font); padding: 9px 16px; border-radius: 999px; border: 0; background: var(--graphite); color: #fff; cursor: pointer; min-height: 36px; }
.wa-use:hover:not([disabled]) { background: var(--gunmetal); }
.wa-use[disabled] { opacity: .5; }
.wa-chip {
  font: 600 12.5px var(--font); padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); cursor: pointer; min-height: 34px; display: inline-flex; align-items: center; gap: 6px;
}
.wa-chip:hover:not([disabled]) { border-color: var(--graphite); }
.wa-chip[disabled] { opacity: .55; cursor: default; }
.wa-chip--ghost { border-color: transparent; background: transparent; color: var(--muted); }

/* ── Templates + attachment ──────────────────────────────────────────────── */
.wa-tpl { border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px; background: var(--surface-2); display: grid; gap: 10px; }
.wa-tpl__row { display: flex; align-items: flex-end; gap: 10px; }
.wa-tpl__row label { flex: 1; display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.wa-tpl__preview { margin: 0; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.wa-tpl__param { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.wa-attach { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; font-weight: 600; background: var(--champagne-50); border: 1px solid #e6d3ad; border-radius: 10px; padding: 8px 10px; }
.wa-attach small { font-weight: 400; color: var(--muted); flex: 1; }

/* ── Composer ────────────────────────────────────────────────────────────── */
.wa-compose { display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--border-strong); border-radius: 14px; background: #fff; padding: 6px 6px 6px 8px; }
.wa-compose:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }
.wa-compose textarea { flex: 1; min-width: 0; border: 0; outline: none; resize: none; font: 14px/1.5 var(--font); color: var(--text); padding: 8px 2px; background: transparent; max-height: 160px; }
.wa-compose textarea:disabled { color: var(--muted); }
.wa-iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; display: grid; place-items: center; flex: none; }
.wa-iconbtn:hover:not([disabled]) { background: var(--bg); }
.wa-iconbtn[disabled] { opacity: .4; cursor: not-allowed; }
.wa-textbtn { font: 600 12.5px var(--font); height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; flex: none; }
.wa-textbtn.is-hot { background: var(--graphite); color: #fff; border-color: var(--graphite); }
.wa-send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #1f8f5f; color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; transition: transform .15s; }
.wa-send:hover:not([disabled]) { background: #18774e; transform: scale(1.04); }
.wa-send[disabled] { opacity: .45; cursor: not-allowed; }
.wa-send.is-busy { opacity: .6; }
.wa-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.wa-quick:empty { display: none; }
.wa-foot { margin: 0; font-size: 11.5px; color: var(--muted); }