/* ===================== Botoes do cabecalho (tema, instalar, push) ===================== */
.app-header-icon-btn {
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.app-header-icon-btn[hidden] { display: none; }

.app-tema-ico { display: none; }
.app-tema-btn[data-tema="claro"] .app-tema-ico--claro,
.app-tema-btn[data-tema="escuro"] .app-tema-ico--escuro,
.app-tema-btn[data-tema="auto"] .app-tema-ico--auto,
.app-tema-btn:not([data-tema]) .app-tema-ico--auto { display: inline; }

.app-nav-link { position: relative; }
.app-nav-badge {
  position: static;
  margin-left: 0.15rem;
}

/* ===================== Chat: cores ===================== */
:root {
  --hd-chat-fundo: #ffffff;
  --hd-chat-area: #f3f6fb;
  --hd-chat-borda: #dbe3ee;
  --hd-chat-texto: #1e293b;
  --hd-chat-suave: #64748b;
  --hd-chat-minha: #2b6fbb;
  --hd-chat-minha-texto: #ffffff;
  --hd-chat-outro: #ffffff;
  --hd-chat-sistema: #e8eef7;
  --hd-chat-ativo: #e7f0fb;
}

[data-bs-theme="dark"] {
  --hd-chat-fundo: #172231;
  --hd-chat-area: #0f1620;
  --hd-chat-borda: #2a3a4f;
  --hd-chat-texto: #e3e9f2;
  --hd-chat-suave: #9fb0c6;
  --hd-chat-minha: #2f6fb5;
  --hd-chat-minha-texto: #ffffff;
  --hd-chat-outro: #1d2a3b;
  --hd-chat-sistema: #1d2a3b;
  --hd-chat-ativo: #1f3550;
}

/* ===================== Chat: conversa (balao e pagina) ===================== */
.hd-chat-cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, #2b6fbb, #123a6f);
  color: #fff;
}

.hd-chat-cabecalho strong { display: block; font-size: 0.95rem; }
.hd-chat-sub { display: block; font-size: 0.75rem; opacity: 0.8; }

.hd-chat-fechar {
  background: none;
  border: 0;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}
.hd-chat-fechar:hover { opacity: 1; }

.hd-chat-mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  background: var(--hd-chat-area);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.hd-chat-vazio {
  margin: auto 0;
  text-align: center;
  color: var(--hd-chat-suave);
  font-size: 0.86rem;
  line-height: 1.5;
  padding: 1rem;
}

.hd-chat-data {
  align-self: center;
  font-size: 0.7rem;
  color: var(--hd-chat-suave);
  margin: 0.4rem 0 0.1rem;
}

.hd-chat-sistema {
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 0.76rem;
  color: var(--hd-chat-suave);
  background: var(--hd-chat-sistema);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
}

.hd-chat-msg {
  max-width: 82%;
  padding: 0.5rem 0.75rem 0.35rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.hd-chat-msg--minha {
  align-self: flex-end;
  background: var(--hd-chat-minha);
  color: var(--hd-chat-minha-texto);
  border-bottom-right-radius: 4px;
}

.hd-chat-msg--outro {
  align-self: flex-start;
  background: var(--hd-chat-outro);
  color: var(--hd-chat-texto);
  border: 1px solid var(--hd-chat-borda);
  border-bottom-left-radius: 4px;
}

.hd-chat-texto { white-space: pre-wrap; }
.hd-chat-autor { font-size: 0.72rem; font-weight: 600; color: #2b6fbb; margin-bottom: 0.1rem; }
[data-bs-theme="dark"] .hd-chat-autor { color: #7fb2ea; }
.hd-chat-hora { align-self: flex-end; font-size: 0.66rem; opacity: 0.7; margin-top: 0.1rem; }

.hd-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem;
  border-top: 1px solid var(--hd-chat-borda);
  background: var(--hd-chat-fundo);
}

.hd-chat-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--hd-chat-borda);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  background: var(--hd-chat-area);
  color: var(--hd-chat-texto);
  max-height: 120px;
}

.hd-chat-form textarea:focus { outline: 2px solid #2b6fbb55; border-color: #2b6fbb; }
.hd-chat-form textarea:disabled { opacity: 0.6; }
.hd-chat-form .btn { border-radius: 10px; padding: 0.45rem 0.7rem; display: flex; align-items: center; }

/* ===================== Chat: balao flutuante (usuario) ===================== */
.hd-chat-widget {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.hd-chat-bolha {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #2b6fbb, #123a6f);
  color: #fff;
  box-shadow: 0 6px 20px rgba(18, 58, 111, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}
.hd-chat-bolha:hover { transform: scale(1.06); }
.hd-chat-bolha .app-notif-badge { top: 0; right: 0; }

.hd-chat-painel {
  width: 360px;
  height: 500px;
  max-height: calc(100vh - 120px);
  background: var(--hd-chat-fundo);
  border: 1px solid var(--hd-chat-borda);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.hd-chat-painel[hidden] { display: none; }

body:has(.hd-chat-widget) #notifToastContainer { bottom: 6rem; }

@media (max-width: 576px) {
  .hd-chat-widget { right: 0.9rem; bottom: 0.9rem; }
  .hd-chat-widget--aberto { left: 0; right: 0; top: 0; bottom: 0; gap: 0; }
  .hd-chat-widget--aberto .hd-chat-painel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
  .hd-chat-widget--aberto .hd-chat-bolha { display: none; }
}

/* ===================== Chat: pagina /chat ===================== */
.hd-chat-pagina {
  height: calc(100vh - 230px);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hd-chat-borda);
  border-radius: 14px;
  overflow: hidden;
  background: var(--hd-chat-fundo);
  max-width: 760px;
  margin: 0 auto;
}

.hd-inbox {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 230px);
  min-height: 460px;
  border: 1px solid var(--hd-chat-borda);
  border-radius: 14px;
  overflow: hidden;
  background: var(--hd-chat-fundo);
}

.hd-inbox-lista {
  border-right: 1px solid var(--hd-chat-borda);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hd-inbox-abas { display: flex; border-bottom: 1px solid var(--hd-chat-borda); }
.hd-inbox-aba {
  flex: 1;
  background: none;
  border: 0;
  padding: 0.7rem;
  font-size: 0.85rem;
  color: var(--hd-chat-suave);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.hd-inbox-aba.ativa { color: var(--hd-chat-texto); border-bottom-color: #2b6fbb; font-weight: 600; }

.hd-inbox-itens { overflow-y: auto; flex: 1; }

.hd-inbox-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hd-chat-borda);
  padding: 0.7rem 0.9rem;
  color: var(--hd-chat-texto);
  cursor: pointer;
}
.hd-inbox-item:hover { background: var(--hd-chat-area); }
.hd-inbox-item.ativo { background: var(--hd-chat-ativo); }

.hd-inbox-item-topo { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.hd-inbox-nome { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-inbox-hora { font-size: 0.7rem; color: var(--hd-chat-suave); flex-shrink: 0; }
.hd-inbox-meta { font-size: 0.72rem; color: var(--hd-chat-suave); }
.hd-inbox-previa {
  font-size: 0.8rem;
  color: var(--hd-chat-suave);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.hd-inbox-nao-lidas {
  background: #dc3545;
  color: #fff;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  min-width: 18px;
  padding: 0.05rem 0.35rem;
  text-align: center;
  flex-shrink: 0;
}

.hd-inbox-conversa { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.hd-inbox-conversa .hd-chat-cabecalho { flex-wrap: wrap; }
.hd-inbox-acoes { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.hd-inbox-acoes .btn { font-size: 0.78rem; padding: 0.25rem 0.6rem; }
.hd-inbox-voltar { display: none; }

@media (max-width: 768px) {
  .hd-inbox { grid-template-columns: 1fr; height: calc(100vh - 190px); }
  .hd-inbox-lista { border-right: 0; }
  .hd-inbox.com-conversa .hd-inbox-lista { display: none; }
  .hd-inbox:not(.com-conversa) .hd-inbox-conversa { display: none; }
  .hd-inbox-voltar { display: inline-flex; }
  .hd-chat-pagina { height: calc(100vh - 190px); }
}
