/* ════════════════════════════════════════════════════════════
   MãoCerta — chat_whatsapp.css
   Cole este bloco no FINAL do style.css existente
   (ele sobrescreve os seletores antigos pelo efeito cascade)
   ════════════════════════════════════════════════════════════ */

/* ── Variáveis extras ─────────────────────────────────────── */
:root {
  --chat-bg:        #ECE5DD;     /* fundo do chat — tom clássico */
  --bubble-me:      #DCF8C6;     /* meu balão — verde WhatsApp */
  --bubble-me-dk:   #C8EEA8;
  --bubble-out:     #FFFFFF;     /* balão do outro */
  --tick-sent:      #8696A0;     /* ✓  (enviado) — cinza */
  --tick-read:      #53BDEB;     /* ✓✓ (lido)    — azul */
  --header-chat:    #075E54;     /* header verde WhatsApp */
  --header-text:    #FFFFFF;
  --sep-chip:       rgba(255,255,255,0.85);
  --input-bar-bg:   #F0F2F5;
}

/* ── PAGE-CHAT: fundo texturizado ─────────────────────────── */
#page-chat.chat-page {
  background: var(--chat-bg);
  background-image:
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c4b9a8' fill-opacity='0.18'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ── Header (verde escuro estilo WA) ──────────────────────── */
.chat-header {
  background: var(--header-chat);
  border-bottom: none;
  box-shadow: 0 2px 12px rgba(0,0,0,0.22);
  min-height: 64px;
  padding: 10px 16px;
}
.chat-back {
  color: #fff;
  font-size: 20px;
  opacity: 0.9;
}
.chat-back:hover { opacity: 1; }

.chat-header-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #128C7E;
  border: 2px solid rgba(255,255,255,0.25);
  font-size: 17px;
}
.chat-header-avatar.prestador { background: #25D366; }

.chat-header-nome {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.chat-header-sub {
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Status dot no sub-header */
.chat-status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #25D366;
}
.chat-status-dot.typing-dot-header {
  background: #FFD700;
  animation: typingBounce 1s infinite;
}

/* ── Chat messages área ───────────────────────────────────── */
.chat-messages {
  padding: 12px 10px 6px;
  gap: 2px;
  background: transparent;
}

/* ── Separador de data (chip estilizado) ──────────────────── */
.chat-date-sep {
  display: flex;
  justify-content: center;
  margin: 14px 0 8px;
}
.chat-date-sep::before, .chat-date-sep::after { display: none; }
.chat-date-sep span {
  background: var(--sep-chip);
  color: #54656F;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  letter-spacing: 0.02em;
}

/* ── Bubble (refatorado) ──────────────────────────────────── */
.chat-msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: min(80%, 420px);
  animation: msgEntry 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.1);
}
@keyframes msgEntry {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-msg-wrap.me  { align-self: flex-end;   align-items: flex-end; }
.chat-msg-wrap.out { align-self: flex-start; align-items: flex-start; }

/* Espaçamento entre grupos */
.chat-msg-wrap + .chat-msg-wrap { margin-top: 3px; }
.chat-msg-wrap.grouped { margin-top: 1px; }

/* Animação sutil ao mudar status */
@keyframes statusFlash {
  0%   { opacity: 1; }
  40%  { opacity: 0.5; }
  100% { opacity: 1; }
}
.chat-msg-wrap.status-changed .chat-msg-tick {
  animation: statusFlash 0.4s ease;
}

/* Bubble principal */
.chat-bubble {
  padding: 7px 12px 4px;
  border-radius: 12px;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

/* Bubble "meu" — verde, cauda direita */
.chat-msg-wrap.me .chat-bubble {
  background: var(--bubble-me);
  border-bottom-right-radius: 4px;
}
.chat-msg-wrap.me.grouped .chat-bubble {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

/* Bubble "outro" — branco, cauda esquerda */
.chat-msg-wrap.out .chat-bubble {
  background: var(--bubble-out);
  border-bottom-left-radius: 4px;
}
.chat-msg-wrap.out.grouped .chat-bubble {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

/* Texto + meta dentro do bubble */
.chat-bubble-text {
  font-size: 14.5px;
  line-height: 1.5;
  color: #111B21;
  font-weight: 500;
}
.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 2px;
}
.chat-msg-time {
  font-size: 10.5px;
  color: #667781;
  font-weight: 500;
  white-space: nowrap;
}
.chat-link {
  color: #007AFF;
  text-decoration: underline;
  word-break: break-all;
}

/* ── Ticks (SVG inline) ───────────────────────────────────── */
.chat-msg-tick {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.chat-tick { vertical-align: middle; }
.chat-tick.enviado   { color: var(--tick-sent); }
.chat-tick.entregue  { color: var(--tick-sent); }
.chat-tick.lido      { /* cor já no SVG stroke="#4FC3F7" */ }
.chat-tick.sending   { color: var(--tick-sent); opacity: 0.6; }

/* ── Typing indicator (bolinhas dentro do chat) ───────────── */
#chat-typing-indicator.chat-typing-bubble {
  display: none;
  align-self: flex-start;
  background: #fff;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  margin: 2px 0 4px;
  gap: 4px;
  align-items: center;
  animation: msgEntry 0.16s ease-out;
}
#chat-typing-indicator.chat-typing-bubble.show { display: flex; }

.typing-dot {
  width: 7px; height: 7px;
  background: #8696A0;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0) scale(1); }
  30%          { transform: translateY(-5px) scale(1.1); }
}

/* ── Loading dots (substituição do spinner no chat) ──────── */
.chat-loading-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-loading-dots span {
  width: 9px; height: 9px;
  background: #128C7E;
  border-radius: 50%;
  animation: typingBounce 1s infinite ease-in-out;
  opacity: 0.7;
}
.chat-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-loading-dots span:nth-child(3) { animation-delay: 0.30s; }

/* ── Input bar ────────────────────────────────────────────── */
.chat-input-bar {
  background: var(--input-bar-bg);
  border-top: 1px solid rgba(0,0,0,0.08);
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  gap: 8px;
}
.chat-input-wrap {
  background: #fff;
  border: none;
  border-radius: 24px;
  padding: 8px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s;
}
.chat-input-wrap:focus-within {
  box-shadow: 0 1px 6px rgba(0,0,0,0.15);
}
.chat-textarea {
  font-size: 15px;
  color: #111B21;
}
.chat-textarea::placeholder { color: #ADB5BD; }

.chat-send-btn {
  width: 48px; height: 48px;
  background: #128C7E;
  box-shadow: 0 2px 8px rgba(18,140,126,0.4);
  transition: all 0.2s;
}
.chat-send-btn:not(:disabled):hover { background: #0d7a6e; }
.chat-send-btn.sending {
  animation: sendPulse 0.6s ease infinite alternate;
}
@keyframes sendPulse {
  from { transform: scale(1); box-shadow: 0 2px 8px rgba(18,140,126,0.4); }
  to   { transform: scale(1.06); box-shadow: 0 4px 14px rgba(18,140,126,0.55); }
}
.chat-send-btn:disabled { background: #B0BEC5; box-shadow: none; }

/* ── Mensagem de sistema ──────────────────────────────────── */
.chat-system-msg {
  background: rgba(255,255,255,0.78);
  color: #54656F;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ── Blocked bar ──────────────────────────────────────────── */
.chat-blocked-bar {
  background: #FFF3CD;
  color: #856404;
  border-top: 1px solid #FFEEBA;
  font-size: 12.5px;
  font-weight: 700;
  padding: 10px 16px;
  text-align: center;
}

/* ── Scroll-to-bottom + badge de novas msgs ──────────────── */
.scroll-down-btn {
  bottom: 80px;
  right: calc(50% - 220px);
  width: 42px; height: 42px;
  background: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0 3px 14px rgba(0,0,0,0.18);
  font-size: 18px;
  color: #128C7E;
  position: relative;
  flex-direction: column;
  gap: 0;
}
.scroll-down-btn.show { display: flex; }
.scroll-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: #25D366;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}
@media (max-width: 480px) {
  .scroll-down-btn { right: 14px; }
}

/* ── Lista de conversas (refatorada) ──────────────────────── */
.chat-list-loading {
  display: flex;
  justify-content: center;
  padding: 32px;
}
.conversa-item {
  padding: 13px 4px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  gap: 12px;
  border-radius: 0;
  transition: background 0.15s;
}
.conversa-item:active { background: rgba(0,0,0,0.04); }

.conversa-avatar {
  width: 52px; height: 52px;
  font-size: 21px;
  background: #128C7E;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.conversa-avatar.prestador-av { background: #25D366; }

.conv-unread-dot {
  position: absolute;
  top: -3px; right: -3px;
  background: #25D366;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  padding: 0 3px;
}

.conversa-body { flex: 1; min-width: 0; gap: 0; }

.conversa-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.conversa-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.conversa-nome {
  font-size: 15px;
  font-weight: 700;
  color: #111B21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversa-hora {
  font-size: 11px;
  color: #8696A0;
  font-weight: 500;
  flex-shrink: 0;
}
.conversa-hora.unread-hora { color: #25D366; font-weight: 700; }

.conversa-preview {
  font-size: 13px;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 400;
}
.conversa-preview.unread { color: #111B21; font-weight: 600; }

/* Ticks na lista */
.conv-tick { display: inline-flex; align-items: center; flex-shrink: 0; }
.conv-tick svg { vertical-align: middle; }

.conversa-unread-badge {
  background: #25D366;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.conversa-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #E8F5E9;
  color: #2E7D32;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.conversa-chip.chip-green { background: #E8F5E9; color: #2E7D32; }
.conversa-chip:not(.chip-green) { background: #F3F4F6; color: #6B7280; }

/* Remove estilos antigos sobrepostos */
.conversa-servico-chip { display: none !important; }
.conversa-right        { display: none !important; }
