/* Identidade visual conforme o Manual de Aplicação da Marca Unimed (MS.139).
   Fonte Unimed Sans: usada se estiver instalada no computador ou se os arquivos .woff2 forem
   colocados em /public/fonts (veja public/fonts/LEIA-ME.txt). Sem ela, cai para a fonte do sistema. */
@font-face { font-family: 'Unimed Sans'; font-weight: 400; font-display: swap;
  src: local('Unimed Sans 2020 Regular'), local('UnimedSans-2020-Regular'), url('/fonts/UnimedSans-2020-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Unimed Sans'; font-weight: 600; font-display: swap;
  src: local('Unimed Sans 2020 SemiBold'), local('UnimedSans-2020-SemiBold'), url('/fonts/UnimedSans-2020-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Unimed Sans'; font-weight: 700; font-display: swap;
  src: local('Unimed Sans 2020 Bold'), local('UnimedSans-2020-Bold'), url('/fonts/UnimedSans-2020-Bold.woff2') format('woff2'); }

:root {
  /* paleta primária do manual */
  --verde: #00995D;          /* Verde Unimed, Pantone 348c */
  --verde-escuro: #004E4C;
  --citrico: #B1D34B;
  --laranja: #F47920;        /* só em detalhes: o manual pede que o verde seja o protagonista */
  /* cores de apoio do manual */
  --apoio-amarelo: #FFE196;
  --apoio-verde: #CFE3BC;
  --apoio-azul: #A6DADE;
  --apoio-bege: #EBE3DA;
  --apoio-rosa: #F0CECE;
  --apoio-terracota: #D1A394;

  --ink: #14302E;
  --muted: #4D6462;
  --ground: #F4F7F6;
  --surface: #FFFFFF;
  --line: #D8E2E0;
  --brand: var(--verde);
  --brand-dark: var(--verde-escuro);
  --bubble-mine: var(--verde-escuro);
  --mine-time: #CFE3BC;
  --accent: var(--laranja);
  --focus: var(--verde-escuro);
  --danger: #C2362F;
  /* "box" da marca: três cantos arredondados e o inferior direito reto */
  --box: 14px 14px 0 14px;
  --box-sm: 10px 10px 0 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E6F0EE;
    --muted: #A2B9B6;
    --ground: #0A1D1C;
    --surface: #102A28;
    --line: #1F403D;
    --bubble-mine: #00664A;
    --focus: var(--citrico);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --ink: #E6F0EE;
    --muted: #A2B9B6;
    --ground: #0A1D1C;
    --surface: #102A28;
    --line: #1F403D;
    --bubble-mine: #00664A;
    --focus: var(--citrico);
    color-scheme: dark;
  }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Unimed Sans', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--ground);
}
h1, h2, h3, strong { font-weight: 700; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.logo { display: block; height: auto; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--verde-escuro); color: #fff; font-weight: 700;
}
.btn {
  height: 48px; padding: 0 22px; border-radius: var(--box-sm); border: none;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 17px;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: none; border: 1.5px solid var(--line); color: var(--ink); font-size: 15px; }
.btn-ghost:hover { background: var(--ground); border-color: var(--brand); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none; flex-shrink: 0;
  background: none; display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.icon-btn:hover { color: var(--brand); }
.icon-btn.primary { background: var(--brand); color: #fff; width: 48px; height: 48px; }
.icon-btn.primary:hover { background: var(--brand-dark); }
.icon-btn.recording, .icon-btn.recording:hover { background: var(--danger); color: #fff; }

/* mensagens */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.msg.system { justify-content: center; }
.bubble {
  max-width: 80%; padding: 10px 12px; border-radius: 16px; line-height: 1.4;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
/* a mensagem enviada usa o desenho do box da marca (canto inferior direito reto) */
.msg.mine .bubble { background: var(--bubble-mine); color: #fff; border-color: var(--bubble-mine);
  border-radius: 16px 16px 0 16px; }
.msg.system .bubble { background: none; border: none; color: var(--muted); font-size: 13px; text-align: center; }
.msg.system-card .bubble { text-align: left; background: var(--surface); border: 1px dashed var(--line); color: var(--ink);
  font-size: 14px; border-radius: 12px 12px 0 12px; max-width: min(460px, 90%); }
.bubble .time { font-size: 12px; color: var(--muted); align-self: flex-end; }
.msg.mine .bubble .time { color: var(--mine-time); }
.bubble .via { font-size: 12px; color: var(--muted); font-weight: 600; }
.msg.mine .bubble .via { color: var(--mine-time); }
.msg.mine .bubble a { color: #fff; }
/* foto na conversa: miniatura; o clique abre ampliada */
.img-thumb { display: block; padding: 0; border: none; background: none; border-radius: 10px; overflow: hidden; cursor: zoom-in; }
.bubble img { display: block; width: auto; height: auto; max-width: min(240px, 100%); max-height: 240px; object-fit: cover; border-radius: 10px; }
.img-thumb:hover img { opacity: .9; }
.msg-video { display: block; max-width: min(280px, 100%); max-height: 320px; border-radius: 10px; background: #000; margin-bottom: 4px; }
.lightbox { border: none; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.lightbox[open] { display: flex; }
.lightbox::backdrop { background: rgba(0, 20, 19, .88); }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100vh - 90px); object-fit: contain; border-radius: 8px; cursor: default; }
.lightbox-bar { width: min(100vw - 32px, 1200px); display: flex; justify-content: space-between; align-items: center; }
.lightbox-bar a { color: #fff; font-size: 15px; }
.lightbox-close { width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,.14); color: #fff; font-size: 20px; }
.lightbox-close:hover { background: rgba(255,255,255,.26); }
.bubble audio { width: 260px; max-width: 100%; }

/* responder, editar e apagar (como no WhatsApp) */
.msg { align-items: center; gap: 6px; }
.msg-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: .75; } }
.msg-action { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.msg-action:hover, .msg-action:focus-visible { color: var(--ink); border-color: var(--brand); }
.bubble .quote { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; font: inherit; font-size: 13px; color: inherit;
  border: none; border-left: 3px solid var(--brand); background: rgba(0, 78, 76, .07); padding: 6px 8px; border-radius: 8px; cursor: pointer; white-space: normal; }
.bubble .quote strong { font-size: 12.5px; color: var(--brand-dark); }
.bubble .quote span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; opacity: .85; }
.msg.mine .bubble .quote { background: rgba(255, 255, 255, .14); border-left-color: var(--citrico); }
.msg.mine .bubble .quote strong { color: var(--citrico); }
.bubble .caption { white-space: pre-wrap; }
.bubble.deleted .deleted-text { font-style: italic; opacity: .8; }
.msg.flash .bubble { animation: msg-flash 1.4s ease-out; }
@keyframes msg-flash { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 25% { box-shadow: 0 0 0 4px var(--citrico); } }

/* faixa acima da caixa de texto: respondendo, anexo esperando legenda, editando */
.composer-tray { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 0; background: var(--surface); border-top: 1px solid var(--line); }
.composer-tray:has(+ .composer.hidden) { display: none; }
.tray-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-left: 3px solid var(--brand); background: var(--ground); border-radius: 8px; }
.tray-item.edit { border-left-color: var(--accent); }
.tray-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 13.5px; }
.tray-text strong { color: var(--brand-dark); }
.tray-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.tray-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.tray-file { width: 44px; height: 44px; border-radius: 6px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tray-close { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.tray-close:hover { color: var(--ink); border-color: var(--brand); }
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) .bubble .quote { background: rgba(255, 255, 255, .06); }
  :where(:root:not([data-theme="light"])) .bubble .quote strong, :where(:root:not([data-theme="light"])) .tray-text strong { color: var(--citrico); }
}
:where(:root[data-theme="dark"]) .bubble .quote { background: rgba(255, 255, 255, .06); }
:where(:root[data-theme="dark"]) .bubble .quote strong, :where(:root[data-theme="dark"]) .tray-text strong { color: var(--citrico); }

.composer { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--line); }
.composer input[type=text], .composer textarea {
  flex: 1; min-width: 0; height: 44px; border-radius: 22px; border: 1px solid var(--line);
  padding: 0 16px; background: var(--ground);
}
.composer textarea { resize: none; padding: 11px 16px; line-height: 1.4; max-height: 160px; font: inherit; color: inherit; }
.composer input[type=text]:focus, .composer textarea:focus { border-color: var(--brand); }
.file-label { position: relative; }
.file-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.rec-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.notice { padding: 10px 16px; font-size: 14px; color: var(--danger); background: var(--surface); }

/* botão de sol e lua (tema claro/escuro); fica sempre sobre o verde-escuro da marca */
.tema-btn { width: 40px; height: 40px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; }
.tema-btn:hover { background: rgba(255, 255, 255, .18); }
.tema-btn:focus-visible { outline: 2px solid var(--citrico); outline-offset: 2px; }

/* "certos" da mensagem do atendente no painel: um = enviada, dois = o beneficiário viu */
.ticks { display: inline-flex; vertical-align: -1px; margin-left: 4px; opacity: .75; }
.ticks.lida { color: #7DD3FC; opacity: 1; }

/* reações às mensagens */
.reacoes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.reacao { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; line-height: 1.5; cursor: default; }
button.reacao { cursor: pointer; }
.reacao.minha { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, var(--surface)); }
.reacao-n { font-size: 12px; color: var(--muted); }
.reacao-pop { position: fixed; z-index: 1000; display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.reacao-opcao { width: 40px; height: 40px; border: none; border-radius: 50%; background: none; font-size: 24px; line-height: 1; cursor: pointer;
  transition: transform .12s; }
.reacao-opcao:hover, .reacao-opcao:focus-visible { transform: scale(1.2); background: var(--line); outline: none; }
.reacao-opcao.ativa { background: color-mix(in srgb, var(--brand) 22%, transparent); }

/* seletor de emojis do chat */
.emoji-painel { position: fixed; z-index: 1000; display: flex; flex-direction: column; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); overflow: hidden; }
.emoji-topo { display: flex; gap: 6px; padding: 8px 8px 4px; }
.emoji-busca { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg, var(--surface));
  color: inherit; font: inherit; font-size: 14px; }
.emoji-busca:focus { outline: none; border-color: var(--brand); }
.emoji-tom { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: none; font-size: 18px; cursor: pointer; }
.emoji-abas { display: flex; justify-content: space-between; padding: 0 6px 4px; border-bottom: 1px solid var(--line); }
.emoji-aba { flex: 1; height: 32px; border: none; background: none; font-size: 18px; border-radius: 8px; cursor: pointer; filter: grayscale(.4); }
.emoji-aba:hover, .emoji-aba:focus-visible { background: var(--line); filter: none; outline: none; }
.emoji-lista { flex: 1; overflow-y: auto; padding: 0 6px 8px; overscroll-behavior: contain; }
.emoji-titulo { position: sticky; top: 0; margin: 0; padding: 8px 4px 4px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); }
.emoji-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.emoji-item { height: 38px; border: none; background: none; border-radius: 8px; font-size: 24px; line-height: 1; cursor: pointer; padding: 0; }
.emoji-item:hover, .emoji-item:focus-visible { background: var(--line); outline: none; }
.emoji-vazio { padding: 16px; text-align: center; color: var(--muted); font-size: 14px; }
