/* =========================
   BASE LAYOUT
   ========================= */
.content { padding-top: 70px; }

/* No desktop, a navbar deve começar depois da sidebar (250px) */
@media (min-width: 992px) {
  .desktop-topbar { left: 250px; right: 0; }
}

/* =========================
   CHAT (CSS)
   ========================= */
:root{
  --vvh: 1vh;   /* altura real do viewport (mobile) */
  --kb: 0px;    /* “altura do teclado” */
}

/* Chat Panel - desktop */
#chatPanel{
  position: fixed;
  right: 18px;
  bottom: 78px;
  width: 550px;
  max-width: calc(100vw - 24px);
  height: 540px;
  z-index: 1080;
  display: none;
}

/* Fullscreen no mobile */
@media (max-width: 576px){
  #chatPanel{
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: calc(var(--kb)) !important;

    width: 100vw !important;
    max-width: 100vw !important;

    height: calc(var(--vvh) * 100) !important;
    max-height: calc(var(--vvh) * 100) !important;

    border-radius: 0 !important;
    box-shadow: none !important;
  }

  #chatPanel .card-header{ border-radius: 0 !important; }

  /* no fullscreen, mantém conv + contatos sempre visíveis */
  #chatPanel[data-view="list"] .chat-conv { display: flex !important; }
  #chatPanel[data-view="list"] .chat-contacts{
    width: 140px;
    display: block !important;
  }

  .chat-contacts{ width: 140px !important; }
}

/* Layout interno */
.chat-wrap{
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chat-body{
  flex: 1;
  display: flex;
  min-height: 0; /* scroll ok */
}

.chat-contacts{
  width: 150px;
  border-right: 1px solid #e9ecef;
  overflow: auto;
}

.chat-conv{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-messages{
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: #f8f9fa;
}

.chat-compose{
  width: 100%;
  border-top: 1px solid #e9ecef;
  padding: 10px;
  background: #fff;
}

/* Contatos */
.chat-contact-item{
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 10px;
  border-bottom: 1px solid #f1f3f5;
  cursor: pointer;
}
.chat-contact-item:hover{ background: #f8f9fa; }
.chat-contact-item.active{ background: #e9f2ff; }

.chat-contact-name{ font-weight: 600; font-size: .95rem; }
.chat-contact-last{
  font-size: .80rem;
  color: #6c757d;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-pill{
  font-size: .70rem;
  padding: 2px 6px;
  border-radius: 999px;
}

/* Mensagens */
.msg-row{ display: flex; margin-bottom: 8px; }
.msg-row.me{ justify-content: flex-end; }
.msg-row.them{ justify-content: flex-start; }

.msg-bubble{
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(0,0,0,.05);
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-row.me .msg-bubble{
  background: #0d6efd;
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg-row.them .msg-bubble{
  background: #fff;
  color: #212529;
  border: 1px solid #e9ecef;
  border-bottom-left-radius: 6px;
}

.msg-meta{
  font-size: .70rem;
  color: #6c757d;
  margin-top: 2px;
}

/* Estado vazio */
.chat-empty{
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  padding: 16px;
  text-align: center;
}

/* Mobile: modo list/conv (mantido pro comportamento) */
@media (max-width: 576px){
  .chat-conv{ display: none; }
  #chatPanel[data-view="conv"] .chat-contacts{ display: none; }
  #chatPanel[data-view="conv"] .chat-conv{ display: flex; }
}

/* Online dot + read receipt */
.chat-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.chat-read-receipt{
  font-size: .72rem;
  margin-top: 2px;
  opacity: .9;
}

/* Links dentro das mensagens */
.msg-bubble a{
  color: inherit;              /* fica branco na bolha azul e escuro na branca */
  text-decoration: underline;
  word-break: break-word;
}
.msg-bubble a:hover{
  text-decoration: underline;
  opacity: .95;
}

/* Link no chat: não quebra o layout com URL gigante */
.chat-link {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: underline;
}