/* candidate/chat.ejs */
/* ===== WhatsApp Web / Mobile clone ===== */
.wa-chat { background: #d1d7db; font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.wa-chat .chat-main { background: #d1d7db; }
.wa-chat .wa-header {
  min-height: 59px;
  padding: 10px 16px;
  background: #008069;
  color: #fff;
  border-bottom: 0;
  box-shadow: 0 1px 3px rgb(0 0 0 / 14%);
}
.wa-chat .wa-header-text { min-width: 0; flex: 1; }
.wa-chat .wa-header strong {
  display: block;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-chat .wa-header #typingIndicator {
  display: block;
  font-size: 13px;
  color: rgb(255 255 255 / 78%);
}
.wa-chat .avatar,
.wa-chat .avatar-trigger {
  width: 49px;
  height: 49px;
  min-width: 49px;
  min-height: 49px;
  max-width: 49px;
  max-height: 49px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 49px;
  padding: 0;
  border: 0;
}
.wa-chat .avatar-trigger {
  border: 0;
  padding: 0;
  cursor: zoom-in;
  background: #128c7e;
}
.wa-chat .avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.wa-chat .wa-messages {
  padding: 10px 12px 8px;
  background-color: #efeae2;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  padding: 4px 12px;
  animation: message-enter .28s ease both;
}
.message-row.ai { justify-content: flex-start; }
.message-row.me { justify-content: flex-end; }
.message-bubble,
.wa-chat .message-row .message {
  max-width: min(72%, 520px);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  flex: 0 0 28px;
  align-self: flex-end;
  margin-bottom: 2px;
  border-radius: 50%;
  overflow: hidden;
  background: #dfe5e7;
  aspect-ratio: 1 / 1;
}
.msg-avatar img,
.msg-avatar span {
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.msg-avatar span {
  display: grid;
  place-items: center;
}
.wa-chat .message {
  max-width: min(72%, 520px);
  padding: 8px 10px 5px;
  border-radius: 16px;
  box-shadow: 0 1px 0.5px rgb(0 0 0 / 13%);
  color: #111b21;
  font-size: 14.2px;
  line-height: 1.4;
  margin-left: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.wa-chat .message.ai {
  align-self: flex-start;
  background: #fff;
  border-top-left-radius: 0;
}
.wa-chat .message.me {
  align-self: flex-end;
  background: #d9fdd3;
  border-top-right-radius: 0;
}
.wa-chat .message.ai::before,
.wa-chat .message.ai::after,
.wa-chat .message.me::after { display: none; }
.wa-chat .message footer {
  margin-top: 2px;
  color: #667781;
  font-size: 11px;
}
.wa-chat .message.me footer { color: #5b7a71; }
.wa-chat .message .delivery {
  color: #53bdeb;
  font-size: 11px;
  letter-spacing: -3px;
  margin-left: 2px;
  font-family: "Segoe UI", sans-serif;
}
.wa-chat .message a { color: #027eb5; font-weight: 500; }
.wa-chat .wa-quick-replies {
  background: #f0f2f5;
  border-top: 1px solid #e0e0e0;
  padding: 8px 10px 6px;
}
.wa-chat .quick-reply {
  border: 1px solid #00a884;
  color: #008069;
  background: #fff;
  border-radius: 18px;
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 1px 1px rgb(0 0 0 / 6%);
}
.wa-chat .quick-replies.forms-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.wa-chat .quick-replies.forms-codes .quick-reply:last-child {
  grid-column: 1 / -1;
  border-color: #8696a0;
  color: #54656f;
}
.wa-chat .wa-composer {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px 48px;
  gap: 8px;
  align-items: end;
  padding: 8px 10px 10px;
  background: #f0f2f5;
  border-top: 1px solid #e0e0e0;
}
.wa-chat .wa-input-wrap {
  min-height: 42px;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 24px;
  padding: 0 14px;
  box-shadow: 0 1px 1px rgb(0 0 0 / 6%);
}
.wa-chat .wa-input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.35;
  color: #111b21;
  min-height: 42px;
}
.wa-chat .wa-input::placeholder { color: #8696a0; }
.wa-chat .wa-icon-btn,
.wa-chat .wa-send-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #54656f;
  padding: 0;
  cursor: pointer;
}
.wa-chat .wa-icon-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}
.wa-chat .wa-send-btn svg,
.admin-send-btn svg {
  width: 20px;
  height: 20px;
  display: block;
  margin: auto;
}
.wa-chat .wa-send-btn,
.admin-send-btn {
  background: #00a884;
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.wa-chat .wa-send-btn:hover {
  background: #06cf9c;
  box-shadow: 0 6px 18px rgb(0 168 132 / 32%);
  transform: scale(1.04);
}
.wa-chat .wa-send-btn:active { transform: scale(.96); }
.wa-chat .wa-send-btn.is-sending {
  animation: send-pulse .65s ease infinite;
  pointer-events: none;
}
.wa-chat .wa-send-btn svg { fill: #fff; stroke: none; }
.admin-send-btn { background: var(--accent); }
.admin-send-btn svg { fill: #fff; }
.wa-chat .wa-icon-btn.mic-btn.recording {
  color: #ea0038;
  animation: pulse-record 1s infinite;
}
.wa-chat .record-tray {
  flex: 0 0 auto;
  display: none;
  grid-template-columns: auto 1fr 40px 40px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f0f2f5;
  border-top: 1px solid #e0e0e0;
}
.wa-chat .record-tray.active,
.wa-chat .record-tray.ready { display: grid; }
.wa-chat .attachment-tray {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: #f0f2f5;
  border-top: 1px solid #e0e0e0;
}
.wa-chat .attachment-tray[hidden] { display: none !important; }
.wa-chat .quick-replies,
.wa-chat .preview,
.wa-chat .drop-zone,
.wa-chat .composer { flex: 0 0 auto; }
.wa-chat .drop-zone.active { display: block; }
.wa-chat .message-job-item {
  border-color: #d1d7db;
  background: #f8f9fa;
}
.wa-chat .message-job-index { background: #00a884; }
.wa-chat .preview,
.wa-chat .record-tray,
.wa-chat .drop-zone { background: #f0f2f5; }

.single-chat { background: #efeae2; }
.messages {
  background-color: #efeae2;
  background-image:
    radial-gradient(circle at 12px 12px, rgb(0 0 0 / 3%) 0 1px, transparent 1px),
    radial-gradient(circle at 26px 28px, rgb(0 0 0 / 2%) 0 1px, transparent 1px);
  background-size: 38px 38px;
  background-position: 0 0, 8px 10px;
}
.message { color: #111827; }
.message a { color: #0b5f59; font-weight: 700; overflow-wrap: anywhere; }
.message.me a { color: #064e3b; }
.message footer { user-select: none; }

@media (max-width: 560px) {
  .wa-chat .chat-main { height: 100dvh; }
  .wa-chat .wa-messages { padding: 8px 10px 6px; }
  .wa-chat .message { max-width: 88%; font-size: 14px; }
  .wa-chat .wa-composer {
    grid-template-columns: 38px minmax(0, 1fr) 38px 44px;
    gap: 6px;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .wa-chat .wa-icon-btn,
  .wa-chat .wa-send-btn,
  .wa-chat .wa-input-wrap,
  .wa-chat .wa-input { min-height: 40px; }
  .wa-chat .avatar,
  .wa-chat .avatar-trigger { width: 45px; height: 45px; flex-basis: 45px; }
}


/* Mobile */
/**
 * WhatsApp-like mobile chat — candidato
 * Carregado após app.css em chat.ejs
 */

@media (max-width: 768px) {
  html:has(.wa-chat.single-chat),
  html:has(.wa-chat.single-chat) body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
  }

  .wa-chat.single-chat {
    position: fixed;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    height: var(--wa-vh, 100dvh);
    max-height: var(--wa-vh, 100dvh);
    overflow: hidden;
    background: #efeae2;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  }

  .wa-chat.single-chat .chat-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    max-height: var(--wa-vh, 100dvh);
    height: var(--wa-vh, 100dvh);
    overflow: hidden;
    transform: translateY(var(--wa-offset, 0px));
    will-change: transform, height;
    background: #efeae2;
  }

  /* Header fixo estilo WhatsApp */
  .wa-chat .wa-header {
    flex: 0 0 auto;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    min-height: 56px;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: #008069;
    color: #fff;
    border-bottom: 0;
    box-shadow: 0 1px 3px rgb(0 0 0 / 16%);
  }

  .wa-chat .wa-header-text {
    min-width: 0;
  }

  .wa-chat .wa-header strong {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0;
  }

  .wa-chat .wa-header #typingIndicator {
    font-size: 13px;
    color: rgb(255 255 255 / 78%);
  }

  /* Avatares — círculo perfeito, nunca oval */
  .wa-chat .avatar,
  .wa-chat .avatar-trigger {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    flex: 0 0 40px;
    border-radius: 50%;
    overflow: hidden;
    aspect-ratio: 1 / 1;
  }

  .wa-chat .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
  }

  .msg-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    max-width: 28px;
    max-height: 28px;
    flex: 0 0 28px;
    align-self: flex-end;
    margin-bottom: 1px;
    border-radius: 50%;
    overflow: hidden;
    background: #dfe5e7;
    aspect-ratio: 1 / 1;
  }

  .msg-avatar img,
  .msg-avatar span {
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    place-items: center;
  }

  .msg-avatar span {
    display: grid;
  }

  /* Área de mensagens */
  .wa-chat .wa-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 6px 0 8px;
    background-color: #efeae2;
    background-size: cover;
    background-position: center;
  }

  /* Linhas de mensagem */
  .wa-chat .message-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    padding: 1px 10px;
    box-sizing: border-box;
    animation: wa-msg-in 0.22s ease both;
  }

  .wa-chat .message-row.ai {
    justify-content: flex-start;
    padding-right: 56px;
  }

  .wa-chat .message-row.me {
    justify-content: flex-end;
    padding-left: 56px;
  }

  .wa-chat .message-row .message {
    max-width: 100%;
    width: fit-content;
    min-width: 0;
    margin: 0;
  }

  /* Bolhas WhatsApp */
  .wa-chat .message {
    position: relative;
    max-width: min(100%, 340px);
    padding: 6px 9px 4px;
    border-radius: 8px;
    font-size: 14.2px;
    line-height: 1.35;
    box-shadow: 0 1px 0.5px rgb(11 20 26 / 13%);
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .wa-chat .message p {
    margin: 0;
    white-space: pre-wrap;
  }

  .wa-chat .message.ai {
    background: #fff;
    color: #111b21;
    border-top-left-radius: 0;
    align-self: flex-start;
  }

  .wa-chat .message.me {
    background: #d9fdd3;
    color: #111b21;
    border-top-right-radius: 0;
    align-self: flex-end;
  }

  .wa-chat .message footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1;
    color: #667781;
  }

  .wa-chat .message.me footer {
    color: #5b7a71;
  }

  .wa-chat .message .delivery {
    color: #53bdeb;
    letter-spacing: -3px;
  }

  /* Rodapé: quick replies, trays, composer */
  .wa-chat .wa-quick-replies,
  .wa-chat .preview,
  .wa-chat .drop-zone,
  .wa-chat .attachment-tray,
  .wa-chat .record-tray,
  .wa-chat .wa-composer {
    flex: 0 0 auto;
    flex-shrink: 0;
    position: relative;
    z-index: 6;
    width: 100%;
    max-width: 100vw;
    background: #f0f2f5;
  }

  .wa-chat .wa-quick-replies {
    border-top: 1px solid #e0e0e0;
    padding: 6px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .wa-chat .quick-reply {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 34px;
    padding: 7px 14px;
    border-radius: 18px;
    font-size: 13px;
  }

  .wa-chat .wa-composer {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px 44px;
    gap: 6px;
    align-items: end;
    padding: 6px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid #e0e0e0;
  }

  .wa-chat .wa-input-wrap {
    min-height: 42px;
    max-height: 120px;
    background: #fff;
    border-radius: 24px;
    padding: 0 12px;
    box-shadow: 0 1px 1px rgb(0 0 0 / 6%);
  }

  .wa-chat .wa-input {
    min-height: 42px;
    font-size: 16px;
    line-height: 1.35;
  }

  .wa-chat .wa-icon-btn,
  .wa-chat .wa-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .wa-chat .wa-send-btn {
    background: #00a884;
  }

  .wa-chat .wa-send-btn:hover {
    background: #06cf9c;
  }

  .wa-chat .attachment-tray[hidden],
  .wa-chat .drop-zone:not(.active) {
    display: none !important;
  }

  .wa-chat .image-preview {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 220px;
    border-radius: 6px;
    object-fit: cover;
  }

  .wa-chat .audio-message,
  .wa-chat .audio-message .audio-bubble {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .wa-preview-backdrop[hidden] {
    display: none !important;
    pointer-events: none;
    visibility: hidden;
  }
}

@keyframes wa-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .wa-chat .message-row {
    animation: none;
  }
}
