/* Painel de chat — usado em index.html e chat.html (as variáveis de cor vêm da página) */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius, 16px);
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.chat-head strong { color: var(--text); font-size: 14px; }
.chat-head .spacer { flex: 1; }
.chat-online { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.chat-online .dot { width: 7px; height: 7px; border-radius: 50%; background: #3ecf8e; }
.chat-online.off .dot { background: #6b5d69; }
.chat-iconbtn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  cursor: pointer;
}
.chat-iconbtn:hover { border-color: var(--line); color: var(--text); }
.chat-iconbtn[aria-pressed="true"] { color: var(--accent); }
.chat-iconbtn svg { width: 16px; height: 16px; }
/* modo foco ligado: botão em destaque */
.chat-focusbtn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px #ff5c8a33;
}
.chat-focusbtn[aria-pressed="true"]:hover { color: #fff; border-color: var(--accent); }

.chat-who {
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.chat-who[hidden] { display: none; }

.chat-list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
}
.chat-empty { margin: auto; color: var(--muted); font-size: 13px; text-align: center; }

.chat-msg { font-size: 14px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.chat-msg .meta { display: flex; align-items: baseline; gap: 6px; }
.chat-msg .name { font-weight: 650; }
.chat-msg .badge {
  font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  padding: 1px 5px; border-radius: 4px; background: var(--accent); color: #fff;
}
.chat-msg .time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chat-msg .text { white-space: pre-wrap; color: var(--text); }
.chat-msg.cont .meta { display: none; }
.chat-msg.cont { margin-top: -6px; }
.chat-msg.mine .text { color: #ffd9e4; }

.chat-newbtn {
  position: sticky; bottom: 0; align-self: center;
  padding: 5px 12px; border-radius: 999px; border: 0;
  background: var(--accent); color: #fff; font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; box-shadow: 0 6px 18px -6px #000a;
}
.chat-newbtn[hidden] { display: none; }

.chat-form {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.chat-form textarea, .chat-form input {
  flex: 1;
  min-width: 0;
  resize: none;
  overflow-y: hidden;
  max-height: 120px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
}
.chat-form textarea:focus, .chat-form input:focus { border-color: var(--accent); }
.chat-form button {
  flex: none;
  padding: 9px 14px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chat-form button:disabled { opacity: .5; cursor: default; }
.chat-error { padding: 0 12px 8px; font-size: 12px; color: #ff7a8a; min-height: 0; }
.chat-error:empty { display: none; }

.chat-name {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 20px 16px;
  text-align: center;
}
.chat-name[hidden] { display: none; }
.chat-name form { width: 100%; max-width: 280px; }
/* Celular/tablet: fonte >= 16px nos campos (menos que isso o Safari do iPhone dá zoom ao focar) */
@media (max-width: 999px) {
  .chat-form textarea, .chat-form input { font-size: 16px; }
}

/* Celular/tablet: a página vira um "app" do tamanho da parte visível da tela.
   --app-h vem do visualViewport (chat-ui.js): quando o teclado abre, o layout encolhe junto
   e a página volta pro topo, em vez de o Safari empurrar o vídeo pra fora da tela. */
@media (max-width: 999px) {
  html:has(body.app) { height: 100%; overflow: hidden; }
  body.app {
    height: var(--app-h, 100dvh);
    min-height: 0;
    overflow: hidden;
  }
}

.chat-name h2 { margin: 0 0 4px; font-size: 17px; }
.chat-name p { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.chat-name .chat-form { padding: 0; border: 0; }

/* ---------- Chat de voz (voice.js) ---------- */
/* na voz: botão em destaque (igual ao modo foco) */
.chat-voicebtn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px #ff5c8a33;
}
.chat-voicebtn[aria-pressed="true"]:hover { color: #fff; border-color: var(--accent); }
.chat-voicebtn.busy svg { animation: voice-pulse 1s ease-in-out infinite; }
@keyframes voice-pulse { 50% { opacity: .35; } }
.chat-mutebtn[hidden] { display: none; }
/* mudo: vermelho */
.chat-mutebtn[aria-pressed="true"] {
  background: #ff3b4e;
  border-color: #ff3b4e;
  color: #fff;
  box-shadow: 0 0 0 3px #ff3b4e33;
}
.chat-mutebtn[aria-pressed="true"]:hover { color: #fff; border-color: #ff3b4e; }

.voice-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.voice-bar[hidden] { display: none; }
.voice-bar > svg { flex: none; width: 14px; height: 14px; color: var(--accent); }
.voice-label { flex: none; white-space: nowrap; }
.voice-chips {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 3px 2px; /* espaço pro brilho de quem fala não ser cortado */
}
.voice-chips::-webkit-scrollbar { display: none; }
.voice-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 150px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 600;
  line-height: 1.5;
  transition: border-color .12s, box-shadow .12s;
}
.voice-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-chip .you { flex: none; color: var(--muted); font-weight: 400; }
.voice-chip svg { flex: none; width: 12px; height: 12px; color: #ff7a8a; }
.voice-chip.pending { opacity: .6; }
/* falando */
.voice-chip.speaking { border-color: var(--accent); box-shadow: 0 0 0 2px #ff5c8a40, 0 0 10px #ff5c8a80; }
.voice-action {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.voice-action:hover, .voice-action.solid { background: var(--accent); color: #fff; }
.voice-action[hidden] { display: none; }
/* "Ativar áudio da voz" aparecendo: tira o contador pra sobrar espaço */
.voice-bar:has(.voice-action.solid:not([hidden])) .voice-label { display: none; }
/* <audio> da voz: fora da tela, mas não display:none (o iPhone não toca elemento escondido assim) */
.voice-audio {
  position: fixed; left: 0; bottom: 0;
  width: 1px; height: 1px;
  overflow: hidden; opacity: 0; pointer-events: none;
  clip-path: inset(50%);
}
@media (max-width: 999px) {
  body.keyboard .voice-bar { display: none; }
}
/* celular estreito: cabeçalho do chat mais apertado pra caber os botões da voz */
@media (max-width: 420px) {
  .chat-head { gap: 4px; }
  .voice-label { display: none; }
  .voice-chip { max-width: 110px; }
}
