/* Chat interno integrado ao painel — usa os tokens do ticket-system.css. */

/* ── Barra lateral (dark, no mesmo estilo dos nav-item) ── */
.chat-section { padding: 0 12px 4px; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px; }
.chat-head > .chat-head-title { font-size: 10px; font-weight: 600; letter-spacing: 1px; color: rgba(255,255,255,.3); text-transform: uppercase; }
.chat-head-actions { display: flex; gap: 2px; }
.chat-mini-btn { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: rgba(255,255,255,.5); background: none; border: none; cursor: pointer; }
.chat-mini-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.chat-mini-btn svg { width: 15px; height: 15px; }
.chat-sub { font-size: 10px; font-weight: 600; letter-spacing: .5px; color: rgba(255,255,255,.22); text-transform: uppercase; padding: 8px 12px 3px; }
.chat-list { display: flex; flex-direction: column; gap: 1px; }
.chat-row {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; position: relative;
  color: rgba(255,255,255,.6); font-size: 13.5px; font-family: inherit; background: none; border: none;
}
.chat-row:hover { background: rgba(255,255,255,.07); color: #fff; }
.chat-row.active { background: rgba(92,181,249,.22); color: #fff; }
.chat-row.active::before { content:''; position:absolute; left:0; top:50%; transform:translateY(-50%); width:3px; height:60%; background:var(--brand); border-radius:0 3px 3px 0; }
.chat-row .c-glyph { color: rgba(255,255,255,.4); font-weight: 600; width: 16px; text-align: center; flex: none; }
.chat-row.active .c-glyph { color: var(--brand); }
.chat-row .c-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.unread { color: #fff; font-weight: 650; }
.chat-row .c-count { background: var(--pink); color: #4A0F2E; font-size: 10px; font-weight: 700; border-radius: 20px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; flex: none; }
.chat-row .c-lock { color: rgba(255,255,255,.3); flex: none; display: inline-flex; }
.chat-row .c-lock svg { width: 12px; height: 12px; }
.chat-av { width: 22px; height: 22px; border-radius: 6px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 10px; position: relative; overflow: visible; background-size: cover; background-position: center; }
.chat-av .c-pres { position: absolute; bottom: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid #000; background: var(--muted); }
.chat-av .c-pres.on { background: var(--lime); }
.chat-empty-note { color: rgba(255,255,255,.3); font-size: 12px; padding: 4px 12px 8px; }
/* "Todos os colaboradores" (atalho para o diretório) */
.chat-row-dir { margin: 2px 0 4px; }
.chat-row-dir .c-glyph-dir { display: inline-flex; }
.chat-row-dir .c-glyph-dir svg { width: 15px; height: 15px; }
.app.nav-collapsed .chat-row-dir .c-name { display: none; }

/* Tickets (recolhível) */
.ticket-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 6px; cursor: pointer; user-select: none; }
.ticket-head .chat-head-title { font-size: 10px; font-weight: 600; letter-spacing: 1px; color: rgba(255,255,255,.3); text-transform: uppercase; }
.ticket-chev { color: rgba(255,255,255,.35); display: inline-flex; transition: transform .15s; }
.ticket-chev svg { width: 14px; height: 14px; }
.ticket-section.collapsed .ticket-chev { transform: rotate(-90deg); }
.ticket-group.collapsed { display: none; }

/* Foto de perfil no rodapé + avatares */
.avatar { overflow: hidden; }
.avatar img, .avatar-img { width: 100%; height: 100%; object-fit: cover; }

/* Modo recolhido da sidebar */
.app.nav-collapsed .chat-head-title, .app.nav-collapsed .chat-head-actions,
.app.nav-collapsed .chat-sub, .app.nav-collapsed .chat-row .c-name,
.app.nav-collapsed .chat-row .c-count, .app.nav-collapsed .chat-row .c-lock,
.app.nav-collapsed .ticket-head .chat-head-title, .app.nav-collapsed .ticket-chev,
.app.nav-collapsed .chat-empty-note { display: none; }
.app.nav-collapsed .chat-row, .app.nav-collapsed .ticket-head { justify-content: center; }

/* ── View do chat (área principal, theme-aware) ── */
#chatView { display: none; }
.main.chat-active > .topbar, .main.chat-active > .content { display: none !important; }
.main.chat-active #chatView { display: flex; }
#chatView { flex: 1; flex-direction: column; height: 100vh; background: var(--white); min-width: 0; }

.chat-topbar { height: var(--header-h); background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 20px; flex-shrink: 0; }
.chat-topbar .chat-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); display: flex; align-items: center; gap: 7px; min-width: 0; }
.chat-topbar .chat-glyph { color: var(--muted); }
.chat-topbar .chat-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-topic { color: var(--muted); font-size: 12.5px; border-left: 1px solid var(--border); padding-left: 12px; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.chat-top-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 11px; border-radius: 8px; color: var(--muted); background: none; border: 1px solid transparent; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.chat-top-btn:hover { background: var(--surface); color: var(--text); }
.chat-top-btn svg { width: 17px; height: 17px; }

.chat-stream { flex: 1; overflow-y: auto; padding: 16px 0 8px; background: var(--white); }
.chat-divider { display: flex; align-items: center; gap: 12px; margin: 10px 22px; color: var(--muted); font-size: 12px; font-weight: 600; }
.chat-divider::before, .chat-divider::after { content: ''; height: 1px; background: var(--border); flex: 1; }
.chat-view-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); text-align: center; padding: 24px; }
.chat-view-empty svg { width: 46px; height: 46px; opacity: .5; }
.chat-view-empty h3 { font-family: 'Sora', sans-serif; color: var(--text); font-size: 16px; }

.cmsg { display: flex; gap: 12px; padding: 5px 22px; position: relative; }
.cmsg:hover { background: var(--surface); }
.cmsg .c-avcol { width: 38px; flex: none; padding-top: 2px; }
.cmsg .c-avatar { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 14px; overflow: hidden; background-size: cover; background-position: center; }
.cmsg.cont { padding-top: 1px; padding-bottom: 1px; }
.cmsg.cont .c-avcol { visibility: hidden; }
.c-body { min-width: 0; flex: 1; }
.c-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.c-who { font-weight: 700; font-size: 14px; color: var(--ink); }
.c-role { font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface); padding: 1px 5px; border-radius: 4px; transform: translateY(-1px); }
.c-when { color: var(--muted); font-size: 11.5px; }
.c-text { font-size: 14.5px; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.c-actions { position: absolute; top: 2px; right: 18px; display: flex; gap: 4px; opacity: 0; }
.cmsg:hover .c-actions { opacity: 1; }
.c-mini { font-size: 11px; color: var(--muted); background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; cursor: pointer; font-weight: 600; }
.c-mini:hover { border-color: var(--brand); color: var(--blue); }

/* Anexos */
.c-att-img { margin-top: 6px; max-width: 320px; max-height: 280px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; display: block; background: var(--surface); }
.c-att-audio { margin-top: 6px; max-width: 340px; display: block; height: 40px; }
.c-att-file { margin-top: 6px; display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); cursor: pointer; max-width: 340px; }
.c-att-file .fi { width: 34px; height: 34px; border-radius: 8px; background: var(--blue-lite); color: var(--blue); display: grid; place-items: center; flex: none; }
.c-att-file .fn { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Composer */
.chat-composer-wrap { padding: 6px 20px 16px; flex: none; background: var(--white); }
.chat-attach-preview { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 12.5px; color: var(--text); }
.chat-attach-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.chat-attach-preview .ap-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attach-preview .ap-x { margin-left: auto; cursor: pointer; color: var(--muted); background: none; border: none; font-size: 18px; }
.chat-composer { border: 1.5px solid var(--border); border-radius: 12px; background: var(--white); transition: border-color .15s; }
.chat-composer:focus-within { border-color: var(--brand); }
.chat-composer textarea { width: 100%; border: none; outline: none; resize: none; background: none; color: var(--text); font-family: inherit; font-size: 14.5px; line-height: 1.5; padding: 12px 14px 4px; max-height: 160px; }
.chat-composer textarea::placeholder { color: var(--muted); }
.chat-composer-foot { display: flex; align-items: center; gap: 4px; padding: 6px 8px 8px; }
.chat-icon-btn { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: none; border: none; cursor: pointer; }
.chat-icon-btn:hover { background: var(--surface); color: var(--text); }
.chat-icon-btn.recording { color: var(--red); background: var(--red-bg); }
.chat-icon-btn svg { width: 18px; height: 18px; }
.chat-rec { display: none; align-items: center; gap: 6px; color: var(--red); font-size: 12.5px; font-weight: 600; }
.chat-rec.on { display: inline-flex; }
.chat-rec .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: chatpulse 1s infinite; }
@keyframes chatpulse { 50% { opacity: .3; } }
.chat-send { margin-left: auto; width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; border: none; cursor: pointer; transition: background .15s; }
.chat-send:hover { background: #3FA0EE; }
.chat-send:disabled { background: var(--border); color: var(--muted); cursor: default; }
.chat-send svg { width: 18px; height: 18px; }

/* ── Modais do chat ── */
.chat-modal-overlay { position: fixed; inset: 0; background: rgba(6,15,28,.55); display: none; align-items: center; justify-content: center; z-index: 2200; padding: 20px; }
.chat-modal-overlay.open { display: flex; }
.chat-modal { width: 440px; max-width: 94vw; max-height: 82vh; background: var(--white); border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,.35); }
.chat-modal-head { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.chat-modal-head h3 { font-family: 'Sora', sans-serif; font-size: 16px; color: var(--ink); font-weight: 700; }
.chat-modal-head .x { margin-left: auto; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: none; border: none; cursor: pointer; }
.chat-modal-head .x:hover { background: var(--surface); color: var(--text); }
.chat-modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.chat-field label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.chat-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; font-family: inherit; background: var(--white); color: var(--text); outline: none; }
.chat-input:focus { border-color: var(--brand); }
.chat-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.chat-modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.chat-btn { padding: 9px 16px; border-radius: 9px; font-size: 13px; font-weight: 700; border: none; cursor: pointer; }
.chat-btn-primary { background: var(--brand); color: var(--brand-ink); }
.chat-btn-primary:hover { background: #3FA0EE; }
.chat-btn-ghost { background: var(--white); border: 1px solid var(--border); color: var(--text); }
.chat-picker-list { display: flex; flex-direction: column; gap: 2px; max-height: 44vh; overflow-y: auto; }
.chat-picker-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; background: none; border: none; width: 100%; text-align: left; font-family: inherit; color: var(--text); }
.chat-picker-item:hover { background: var(--surface); }
.chat-picker-item .pi-name { font-weight: 600; font-size: 14px; }
.chat-picker-item .pi-role { margin-left: auto; font-size: 11px; color: var(--muted); }
.chat-pick-av { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 11px; overflow: hidden; background-size: cover; background-position: center; flex: none; }
.chat-member-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.chat-member-row .mr-name { font-size: 13.5px; color: var(--text); }
.chat-member-remove { margin-left: auto; font-size: 11px; color: var(--red); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.chat-member-remove:hover { border-color: var(--red); }
.chat-modal-subhead { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 4px 0 2px; }

/* Foto de perfil no modal "Meu perfil" */
.prof-avatar-wrap { display: flex; align-items: center; gap: 14px; }
.prof-avatar { width: 64px; height: 64px; border-radius: 16px; background: var(--blue); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 22px; overflow: hidden; background-size: cover; background-position: center; flex: none; }
.prof-avatar-actions { display: flex; flex-direction: column; gap: 6px; }

/* Lightbox de imagem */
.chat-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 3000; cursor: zoom-out; }
.chat-lightbox.open { display: flex; }
.chat-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* ═══════════ Layout WhatsApp, PALETA Grupo Evo / TicketFlow ═══════════
   Os tokens --wa-* são só nomes de papel (fundo, painel, balão de entrada/saída,
   acento…). Os VALORES vêm da identidade do ticketflow: superfícies, bordas e
   texto usam os mesmos tokens do painel (--surface/--white/--border/--text/--muted/
   --ink) e o acento é o AZUL da marca (--brand #5CB5F9 / --blue #104E8B), no lugar
   do verde do WhatsApp. O tema escuro herda automaticamente pelos tokens. */
#chatView {
  --wa-bg: var(--surface);                 /* fundo da conversa           */
  --wa-panel: var(--white);                /* barra do topo / composer     */
  --wa-input: var(--surface);              /* pílula de digitar            */
  --wa-in: var(--white);                   /* balão dos outros             */
  --wa-out: var(--blue-lite);              /* balão MEU (azul-claro marca) */
  --wa-text: var(--ink);
  --wa-time: var(--muted);
  --wa-icon: var(--muted);
  --wa-hover: rgba(16,78,139,.08);         /* --blue com transparência     */
  --wa-accent: var(--blue);                /* enviar / online / destaques  */
  --wa-date: var(--white);
  --wa-date-text: var(--muted);
  --wa-line: var(--border);
  background: var(--wa-bg);
}
:root[data-theme="dark"] #chatView {
  --wa-input: #1F242D;
  --wa-out: #12283F;                       /* --blue-lite do tema escuro   */
  --wa-hover: rgba(92,181,249,.10);
  --wa-accent: var(--brand);               /* azul claro lê melhor no dark */
}

.chat-topbar { background: var(--wa-panel); border-bottom: 1px solid var(--wa-line); gap: 12px; }
.chat-head-av { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; overflow: hidden; background-size: cover; background-position: center; background: var(--blue); }
.chat-head-info { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.chat-topbar .chat-title { color: var(--wa-text); font-size: 16px; line-height: 1.2; }
.chat-topbar .chat-glyph { color: var(--wa-time); }
.chat-head-info .chat-topic { border: none; padding: 0; margin: 0; max-width: none; color: var(--wa-time); font-size: 12.5px; }
.chat-top-btn { color: var(--wa-icon); }
.chat-top-btn:hover { background: var(--wa-hover); color: var(--wa-text); }

.chat-stream {
  background-color: var(--wa-bg); padding: 12px 0 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='44' cy='28' r='2'/%3E%3Ccircle cx='26' cy='52' r='2'/%3E%3C/g%3E%3C/svg%3E");
}
:root[data-theme="dark"] .chat-stream {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='44' cy='28' r='2'/%3E%3Ccircle cx='26' cy='52' r='2'/%3E%3C/g%3E%3C/svg%3E");
}
.chat-view-empty { color: var(--wa-time); }
.chat-view-empty h3 { color: var(--wa-text); }

.chat-divider { justify-content: center; margin: 12px 0; }
.chat-divider::before, .chat-divider::after { display: none; }
.chat-divider span { background: var(--wa-date); color: var(--wa-date-text); padding: 5px 12px; border-radius: 8px; font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; box-shadow: 0 1px .5px rgba(11,20,26,.13); }

.cmsg { display: flex; padding: 1px 7%; }
.cmsg:hover { background: transparent; }
.cmsg.own { justify-content: flex-end; }
.cmsg:not(.cont) { margin-top: 10px; }
.c-bubble { position: relative; max-width: min(65%, 460px); display: flex; flex-direction: column; background: var(--wa-in); color: var(--wa-text); border-radius: 8px; padding: 6px 9px 5px; box-shadow: 0 1px .5px rgba(11,20,26,.13); }
.cmsg.own .c-bubble { background: var(--wa-out); }
.cmsg:not(.own):not(.cont) .c-bubble { border-top-left-radius: 0; }
.cmsg:not(.own):not(.cont) .c-bubble::before { content: ''; position: absolute; top: 0; left: -8px; width: 8px; height: 13px; background: var(--wa-in); clip-path: polygon(100% 0, 0 0, 100% 100%); }
.cmsg.own:not(.cont) .c-bubble { border-top-right-radius: 0; }
.cmsg.own:not(.cont) .c-bubble::before { content: ''; position: absolute; top: 0; right: -8px; width: 8px; height: 13px; background: var(--wa-out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.c-sender { font-size: 12.5px; font-weight: 600; margin-bottom: 1px; }
.c-text { font-size: 14.2px; line-height: 1.35; color: var(--wa-text); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.c-time { align-self: flex-end; font-size: 11px; color: var(--wa-time); margin-top: 2px; line-height: 1; display: flex; align-items: center; gap: 3px; }
.cmsg.own .c-time .chk { color: var(--wa-time); }
.c-actions { position: absolute; top: 50%; transform: translateY(-50%); }
.cmsg:not(.own) .c-actions { right: -102px; }
.cmsg.own .c-actions { left: -102px; }

.c-att-img { max-width: 100%; width: 260px; max-height: 300px; object-fit: cover; border-radius: 6px; margin-bottom: 3px; border: none; background: rgba(0,0,0,.06); }
.c-att-audio { width: 250px; margin: 2px 0 3px; }
.c-att-file { background: rgba(0,0,0,.05); border-color: var(--wa-line); margin-bottom: 3px; }

.chat-composer-wrap { background: var(--wa-panel); padding: 8px 14px; }
.chat-composer { display: flex; align-items: center; gap: 4px; background: none; border: none; border-radius: 0; }
.chat-composer:focus-within { border: none; }
.wa-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--wa-icon); background: none; border: none; cursor: pointer; flex: none; }
.wa-icon:hover { background: var(--wa-hover); color: var(--wa-text); }
.wa-icon svg { width: 22px; height: 22px; }
.wa-mic.recording { color: var(--red); background: var(--red-bg); }
.wa-pill { flex: 1; background: var(--wa-input); border-radius: 22px; padding: 9px 14px; display: flex; min-width: 0; }
.wa-pill textarea { width: 100%; border: none; outline: none; resize: none; background: none; color: var(--wa-text); font-family: inherit; font-size: 15px; line-height: 1.35; max-height: 120px; padding: 0; }
.wa-pill textarea::placeholder { color: var(--wa-time); }
.wa-send { width: 44px; height: 44px; border-radius: 50%; background: var(--wa-accent); color: #fff; display: grid; place-items: center; border: none; cursor: pointer; flex: none; }
.wa-send svg { width: 20px; height: 20px; }
.wa-send:disabled { opacity: .5; cursor: default; }

/* Barra de gravação de áudio (substitui o composer enquanto grava) */
.chat-recbar { display: flex; align-items: center; gap: 6px; }
.chat-recbar .rec-cancel { color: var(--red); }
.chat-recbar .rec-cancel:hover { background: var(--red-bg); color: var(--red); }
.chat-recbar .rec-live { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--wa-text); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chat-recbar .rec-live .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: chatpulse 1s infinite; }
.chat-recbar.paused .rec-live .dot { animation: none; opacity: .45; }
.chat-recbar .rec-state { color: var(--wa-time); font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.chat-recbar .rec-pause { color: var(--wa-icon); }

/* Campo de digitar fixo no rodapé: trava a altura da view e faz só o fluxo de
   mensagens rolar (min-height:0 resolve o flex que empurrava o composer). */
/* A .main não é esticada pelo .app (align-items:flex-start), então precisa de
   altura de viewport própria no modo chat — sem isso o #chatView colapsa para o
   tamanho do conteúdo e o composer sobe. */
.main.chat-active { height: 100vh; height: 100dvh; overflow: hidden; }
#chatView { height: 100vh; height: 100dvh; max-height: 100dvh; overflow: hidden; }
.chat-stream { min-height: 0; }
.chat-composer-wrap { flex: 0 0 auto; }

/* ═══════════ Diretório de colaboradores (home do chat) ═══════════ */
.chat-convo { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#chatView.dir-mode .chat-convo { display: none; }
.chat-directory { display: none; }
#chatView.dir-mode .chat-directory { display: flex; flex: 1; min-height: 0; flex-direction: column; background: var(--wa-bg); }

/* botão "voltar aos colaboradores" no cabeçalho da conversa */
.chat-back { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--wa-icon); background: none; border: none; cursor: pointer; flex: none; }
.chat-back:hover { background: var(--wa-hover); color: var(--wa-text); }
.chat-back svg { width: 20px; height: 20px; }

.dir-head { background: var(--wa-panel); border-bottom: 1px solid var(--wa-line); padding: 18px 24px 16px; display: flex; flex-direction: column; gap: 14px; flex: none; }
.dir-top { display: flex; align-items: flex-start; gap: 14px; }
.dir-title { font-family: "Sora", "Segoe UI", sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--wa-text); }
.dir-sub { font-size: 13px; color: var(--wa-time); margin-top: 3px; }
.dir-toggle { margin-left: auto; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--wa-icon); border: 1px solid var(--wa-line); background: none; cursor: pointer; }
.dir-toggle:hover { color: var(--wa-text); background: var(--wa-hover); }
.dir-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; }
.dir-search { display: flex; align-items: center; gap: 10px; background: var(--wa-input); border: 1px solid var(--wa-line); border-radius: 10px; padding: 10px 14px; color: var(--wa-time); }
.dir-search input { border: none; background: none; outline: none; color: var(--wa-text); font-family: inherit; font-size: 14px; width: 100%; }
.dir-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 24px 28px; }
.dir-group { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--wa-time); margin: 6px 2px 12px; display: flex; align-items: center; gap: 8px; }
.dir-group .dir-count { background: var(--wa-input); border: 1px solid var(--wa-line); border-radius: 20px; padding: 1px 8px; font-size: 11px; color: var(--wa-text); }
.dir-group.online .dir-count { color: var(--wa-accent); }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 24px; }
.chat-person-card { display: flex; align-items: center; gap: 13px; padding: 13px 15px; border-radius: 14px; background: var(--wa-in); border: 1px solid var(--wa-line); cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s; text-align: left; width: 100%; font-family: inherit; }
.chat-person-card:hover { transform: translateY(-2px); border-color: var(--wa-accent); box-shadow: 0 8px 22px rgba(0,0,0,.14); }
.pc-av { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px; flex: none; position: relative; background-size: cover; background-position: center; }
.pc-pres { position: absolute; bottom: 1px; right: 1px; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--wa-in); background: var(--muted); }
.pc-pres.on { background: var(--wa-accent); }
.pc-info { min-width: 0; flex: 1; }
.pc-name { font-size: 15px; font-weight: 650; color: var(--wa-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-role { font-size: 12px; color: var(--wa-time); margin-top: 1px; }
.pc-status { font-size: 11.5px; margin-top: 3px; color: var(--wa-time); display: flex; align-items: center; gap: 5px; }
.pc-status.on { color: var(--wa-accent); }
.pc-status.on::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dir-empty { color: var(--wa-time); padding: 12px 2px; }

/* ═══════════ Mobile / celular ═══════════ */
@media (max-width: 820px) {
  /* Balões mais largos, como no WhatsApp do celular */
  .c-bubble { max-width: 84%; }
  .cmsg { padding: 1px 4%; }

  /* Cabeçalho da conversa mais compacto; o tópico some pra sobrar espaço */
  .chat-topbar { padding: 0 6px; gap: 8px; }
  .chat-topbar .chat-title { font-size: 15.5px; }
  .chat-head-info .chat-topic { display: none; }
  .chat-top-btn { height: 40px; padding: 0 9px; }

  /* Diretório de colaboradores: menos margem e cards em uma coluna */
  .dir-head { padding: 14px 16px; gap: 12px; }
  .dir-top { align-items: center; }
  .dir-title { font-size: 19px; }
  .dir-sub { font-size: 12px; }
  .dir-body { padding: 14px 16px 24px; }
  .dir-grid { grid-template-columns: 1fr; gap: 10px; }

  /* Campo de digitar com folga pro polegar (e área segura do iPhone) */
  .chat-composer-wrap { padding: 8px 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }

  /* Modais ocupam quase toda a largura */
  .chat-modal { width: 100%; max-width: 100%; }
}

/* Teclado móvel: --vvh é a altura VISÍVEL (setada via visualViewport no JS).
   Com o teclado aberto o app encolhe — cabeçalho fica, composer gruda no teclado. */
@media (max-width: 820px) {
  .main.chat-active { height: var(--vvh, 100dvh); }
  #chatView { height: var(--vvh, 100dvh); max-height: var(--vvh, 100dvh); }
}

/* PWA instalado (standalone): área segura do topo (notch) na barra da conversa e
   no header do diretório, para não ficarem sob a status bar do iPhone. */
@media (display-mode: standalone) {
  .chat-topbar {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-h) + env(safe-area-inset-top));
  }
  .dir-head { padding-top: calc(18px + env(safe-area-inset-top)); }
}

/* Zona de perigo (apagar canal) no modal de membros */
.chat-danger { margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; }
.chat-danger .chat-modal-subhead { color: var(--red); }
.chat-danger-text { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.chat-btn-danger { align-self: flex-start; background: var(--white); color: var(--red); border: 1px solid var(--red); }
.chat-btn-danger:hover { background: var(--red-bg); }
.chat-btn-danger:disabled { opacity: .6; cursor: default; }
.chat-danger-input { border-color: var(--red) !important; }

/* ── Item 6: check duplo, digitando, não lidas, busca ── */
.c-time .chk.read { color: var(--brand); font-weight: 700; }
:root:not([data-theme="dark"]) .c-time .chk.read { color: #1E88E5; }
.chat-typing { padding: 2px 16px 4px; font-size: 12.5px; color: var(--wa-time); font-style: italic; background: var(--wa-panel); }
.chat-unread-divider { display: flex; justify-content: center; margin: 12px 0; }
.chat-unread-divider span { background: var(--blue-lite); color: var(--blue); padding: 5px 14px; border-radius: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
:root[data-theme="dark"] .chat-unread-divider span { background: #12283F; color: var(--brand); }
.chat-search-bar { position: relative; background: var(--wa-panel); border-bottom: 1px solid var(--wa-line); padding: 8px 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: none; }
.chat-search-bar input { flex: 1; min-width: 160px; background: var(--wa-input); color: var(--wa-text); border: 1px solid var(--wa-line); border-radius: 20px; padding: 9px 14px; font-family: inherit; font-size: 14px; outline: none; }
.chat-search-bar input:focus { border-color: var(--brand); }
.chat-search-results { flex-basis: 100%; max-height: 40vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.chat-search-item { text-align: left; background: var(--wa-in); border: 1px solid var(--wa-line); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-family: inherit; color: var(--wa-text); }
.chat-search-item:hover { border-color: var(--brand); }
.chat-search-item .si-who { font-weight: 700; font-size: 12.5px; margin-right: 8px; }
.chat-search-item .si-when { font-size: 11px; color: var(--wa-time); }
.chat-search-item .si-text { font-size: 13px; margin-top: 2px; }
.chat-search-item mark { background: rgba(92,181,249,.35); color: inherit; border-radius: 3px; padding: 0 2px; }
.cmsg.c-hit .c-bubble { box-shadow: 0 0 0 3px rgba(92,181,249,.55); transition: box-shadow .3s; }

/* ═══════════ @MENÇÕES ═══════════ */
/* "@Nome" dentro do balão */
.c-mention { color: var(--wa-accent); font-weight: 600; }
.cmsg.own .c-mention { color: var(--blue); }
:root[data-theme="dark"] .cmsg.own .c-mention { color: var(--brand); }
/* Balão em que EU fui mencionado: filete + leve tom de destaque */
/* (laranja "warning" da paleta Grupo Evo: --orange / --amber-bg; o dark herda pelos tokens) */
.cmsg.mentioned .c-bubble { background: var(--amber-bg); box-shadow: inset 3px 0 0 var(--orange), 0 1px .5px rgba(11,20,26,.13); }
.cmsg.mentioned:not(.cont) .c-bubble::before { background: var(--amber-bg); }
/* Badge "@" na barra lateral (fica até abrir a conversa) */
.chat-row .c-at { background: var(--orange); color: #3A2208; font-size: 11px; font-weight: 800; border-radius: 20px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; flex: none; line-height: 1; }
.chat-row.mentioned .c-name { font-weight: 700; }
.app.nav-collapsed .chat-row .c-at { display: none; }
/* Popup de autocomplete acima do composer */
.chat-composer-wrap { position: relative; }
.chat-mention-pop { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 2px); max-width: 360px; max-height: 290px; overflow-y: auto; background: var(--wa-panel); border: 1px solid var(--wa-line); border-radius: 12px; box-shadow: 0 8px 24px rgba(11,20,26,.18); padding: 6px; z-index: 30; }
.mention-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: none; border-radius: 8px; background: none; color: var(--wa-text); cursor: pointer; text-align: left; font: inherit; }
.mention-item.active, .mention-item:hover { background: var(--wa-hover); }
.mention-item .mi-av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; overflow: hidden; background-size: cover; background-position: center; }
.mention-item .mi-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-item .mi-role { margin-left: auto; font-size: 10.5px; color: var(--wa-time); text-transform: uppercase; letter-spacing: .04em; flex: none; }
@media (max-width: 820px) {
  .chat-mention-pop { left: 8px; right: 8px; max-width: none; }
}

/* ═══════════ Áudio: velocidade 1× / 1,5× / 2× ═══════════ */
.c-audio { display: flex; align-items: center; gap: 6px; margin: 2px 0 3px; max-width: 100%; }
.c-audio .c-att-audio { margin: 0; width: 250px; max-width: calc(100% - 46px); flex: 1 1 auto; min-width: 0; }
.c-audio-rate { flex: none; min-width: 40px; height: 26px; padding: 0 8px; border-radius: 13px; border: 1px solid var(--wa-line); background: var(--wa-panel); color: var(--wa-text); font-size: 12px; font-weight: 700; cursor: pointer; line-height: 1; font-variant-numeric: tabular-nums; }
.c-audio-rate:hover { background: var(--wa-hover); }
.c-audio-rate.on { background: var(--wa-accent); border-color: var(--wa-accent); color: #fff; }
:root[data-theme="dark"] .c-audio-rate.on { color: #0B1220; }
