/* Atendimento — consome só tokens semânticos da Central (light/dark). */
:root {
  --a-raised: var(--redes-surface-raised, var(--redes-surface-alt));
  --a-emph: var(--redes-surface-emphasis, var(--redes-primary-light));
  --a-hover: var(--redes-surface-hover, var(--redes-surface-alt));
  --a-text2: var(--redes-text-secondary, var(--redes-text));
  --a-ctl: var(--redes-control-border, var(--redes-line));
  --a-ok: #3fb68b; --a-warn: #e0a84c; --a-bad: #e4686a; --a-wa: #4cc38a; --a-ig: #d980b5; --a-cm: #8fa8f0;
  --a-out: var(--redes-primary-surface, var(--redes-primary));
}
:root[data-theme=light] { --a-out: var(--redes-primary); }
* { box-sizing: border-box; }
html, body { height: 100%; }
body.redes-theme { margin: 0; display: flex; flex-direction: column; height: 100dvh; font-family: var(--redes-font-main); background: var(--redes-bg); color: var(--redes-text); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--redes-primary); outline-offset: 2px; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--redes-surface); border-bottom: 1px solid var(--redes-line); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 auto; }
.logo-dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--a-emph); font-size: 18px; flex: none; }
.brand-name { margin: 0; font: 700 18px/1.1 var(--redes-font-display); }
.who { margin-left: auto; text-align: right; min-width: 0; }
.who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.who span { font-size: 12px; color: var(--redes-muted); }

.strip { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 8px 16px; background: var(--redes-surface-alt); border-bottom: 1px solid var(--redes-line); font-size: 13px; flex: none; }
.strip[hidden] { display: none; }
.strip .st { display: inline-flex; align-items: center; gap: 6px; color: var(--a-text2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--redes-muted); display: inline-block; }
.dot.ok { background: var(--a-ok); } .dot.bad { background: var(--a-bad); } .dot.warn { background: var(--a-warn); }
.strip a { color: var(--redes-primary); font-weight: 600; margin-left: auto; text-decoration: none; }
.strip a:hover { text-decoration: underline; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); }
.pane-list { min-width: 0; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--redes-line); background: var(--redes-surface); }
.pane-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--redes-bg); }

.chan-tabs { display: flex; gap: 2px; padding: 10px 12px 0; overflow-x: auto; scrollbar-width: none; }
.chan-tabs button { flex: 1 0 auto; padding: 8px 7px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--redes-muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.chan-tabs button[aria-selected=true] { color: var(--redes-text); border-bottom-color: var(--redes-primary); }
.chan-tabs .n { margin-left: 4px; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--redes-primary-surface, var(--redes-primary)); color: #fff; }
.search-row { padding: 10px 12px 6px; }
.search-row input { width: 100%; }
.chips { display: flex; gap: 6px; padding: 4px 12px 10px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--redes-line); }
.chip { flex: none; padding: 5px 11px; border: 1px solid var(--a-ctl); border-radius: 99px; background: var(--a-raised); color: var(--a-text2); font-size: 12.5px; font-weight: 600; }
.chip[aria-pressed=true] { background: var(--a-out); border-color: var(--a-out); color: #fff; }

.list { flex: 1; overflow-y: auto; }
.row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; padding: 12px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--redes-line); }
.row:hover { background: var(--a-hover); }
.row[aria-current=true] { background: var(--a-raised); box-shadow: inset 3px 0 0 var(--redes-primary); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--a-emph); color: var(--redes-text); position: relative; }
.avatar .ch { position: absolute; right: -2px; bottom: -2px; width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--redes-surface); font-size: 0; }
.ch.whatsapp { background: var(--a-wa); } .ch.instagram_direct { background: var(--a-ig); } .ch.instagram_comment { background: var(--a-cm); }
.row .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .pv { font-size: 13px; color: var(--redes-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row.unread .nm, .row.unread .pv { color: var(--redes-text); }
.row .meta { text-align: right; font-size: 11.5px; color: var(--redes-muted); display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.badge-n { min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--a-out); color: #fff; font-weight: 700; font-size: 11.5px; text-align: center; }
.lbls { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.lbl { font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--a-ctl); color: var(--a-text2); background: var(--a-raised); }
.lbl i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.empty { padding: 28px 20px; text-align: center; color: var(--redes-muted); font-size: 14px; }
.empty b { display: block; color: var(--redes-text); font: 700 16px var(--redes-font-display); margin-bottom: 6px; }
.empty .redes-btn { margin-top: 12px; }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--redes-surface); border-bottom: 1px solid var(--redes-line); flex-wrap: wrap; }
.chat-head .t { min-width: 0; flex: 1 1 180px; }
.chat-head .t b { display: block; font: 700 16px var(--redes-font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .t span { font-size: 12.5px; color: var(--redes-muted); }
.chat-head .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.mini { padding: 6px 11px; font-size: 12.5px; }
.back-list { display: none; }
.win { font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--a-ctl); background: var(--a-raised); color: var(--a-text2); white-space: nowrap; }
.win.warn { border-color: var(--a-warn); color: var(--a-warn); } .win.bad { border-color: var(--a-bad); color: var(--a-bad); }
.post-ref { margin: 10px 14px 0; padding: 8px 12px; border: 1px solid var(--redes-line); border-radius: 10px; background: var(--redes-surface); font-size: 12.5px; color: var(--redes-muted); }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: 11.5px; color: var(--redes-muted); margin: 8px 0 2px; }
.msg { max-width: min(78%, 620px); padding: 8px 12px; border-radius: 14px; background: var(--redes-surface); border: 1px solid var(--redes-line); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.4; }
.msg.out { align-self: flex-end; background: var(--a-out); border-color: var(--a-out); color: #fff; }
.msg .kind { display: block; font-size: 11px; font-weight: 700; opacity: .8; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .03em; }
.msg .tm { display: block; font-size: 11px; opacity: .7; margin-top: 3px; text-align: right; }
.msg.purged { font-style: italic; color: var(--redes-muted); background: transparent; border-style: dashed; }
.msg.bad { border-color: var(--a-bad); }
.msg .err { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; background: var(--redes-surface); color: var(--a-bad); padding: 4px 8px; border-radius: 8px; }
.msg .err button { margin-top: 4px; margin-right: 6px; }

.composer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--redes-surface); border-top: 1px solid var(--redes-line); }
.composer .modes { display: flex; gap: 6px; margin-bottom: 8px; }
.composer .row2 { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; }
.composer .hint { font-size: 12px; color: var(--redes-muted); margin-top: 6px; }
.composer .hint.warn { color: var(--a-warn); }
.noopen { padding: 14px; text-align: center; font-size: 13px; color: var(--a-warn); background: var(--redes-surface-alt); border-top: 1px solid var(--redes-line); }
.placeholder { margin: auto; text-align: center; color: var(--redes-muted); padding: 20px; }

.menu { position: absolute; z-index: 30; min-width: 220px; padding: 6px; background: var(--redes-surface); border: 1px solid var(--a-ctl); border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.35); }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 8px; font-size: 13.5px; }
.menu button:hover { background: var(--a-hover); }
.menu hr { border: 0; border-top: 1px solid var(--redes-line); margin: 4px 0; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--a-emph); border: 1px solid var(--a-ctl); font-size: 13.5px; box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.toast.bad { border-color: var(--a-bad); }
.skeleton { height: 62px; margin: 8px 12px; border-radius: 10px; background: linear-gradient(90deg, var(--a-raised), var(--a-hover), var(--a-raised)); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

@media (max-width: 820px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout[data-pane=list] .pane-chat, .layout[data-pane=chat] .pane-list { display: none; }
  .back-list { display: inline-flex; }
  .back-label { display: none; }
  .who { flex: 1 1 0; }
  .who b { max-width: 100%; font-size: 13px; }
  .who span { display: none; }
  .brand-name { font-size: 16px; }
  .brand .redes-eyebrow { display: none; }
  .msg { max-width: 88%; }
}

/* Cabeçalho padrão (§19.2): marca à esquerda; usuário, ⊞ Central de Ferramentas e Sair à direita. */
.topbar .brand { margin-right: auto; min-width: 0; }
.topbar .who { margin-left: 0; }
.topbar .redes-back-btn { flex: none; white-space: nowrap; }
