/* ============================================================
   ElisIA — Redesign overrides (carregado POR ÚLTIMO)
   Agenda legível · animação calma · toggle de tema no header
   ============================================================ */

/* ---------- Agenda: legibilidade dos day-cards ---------- */
.sf-agenda-week,
.sf-day-cards {
  display: flex;
  gap: 6px;
  padding: 8px 10px 10px;
}
.sf-day-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 3px;
  line-height: 1.18;
  overflow: visible;
  text-align: center;
}
.sf-day-weekday {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.sf-day-date {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}
.sf-day-count {
  font-size: 8.5px;
  line-height: 1.1;
}
.sf-day-count strong {
  display: block;
  font-size: 13px;
  line-height: 1.1;
}
.sf-day-status {
  font-size: 8.5px;
  line-height: 1.15;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  word-break: normal;
  white-space: normal;
}
.sf-day-status svg {
  width: 9px;
  height: 9px;
  flex: none;
}

/* ---------- Wallpaper do chat (padrão WhatsApp) ---------- */
.messages-container {
  background-color: var(--bg-chat);
}
[data-theme="light"] .messages-container {
  background-image: none !important;
  background-color: var(--bg-chat) !important;
  position: relative;
}
[data-theme="light"] .messages-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../images/chat-bg-light.jpg');
  background-repeat: repeat;
  background-size: 380px auto;
  opacity: 0.30;            /* wallpaper sutil */
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] .messages-container > * {
  position: relative;
  z-index: 1;
}

/* Textarea no tema claro: focar não pode escurecer (era #323f49 hardcoded) */
[data-theme="light"] .composer-textarea:focus {
  background: #ffffff !important;
}

/* Timestamp visível no tema claro (era branco 45% hardcoded → invisível em bolha clara) */
[data-theme="light"] .msg-time,
[data-theme="light"] .sf-msg-time {
  color: #667781 !important;
}

/* ---------- ATENÇÃO: animação calma (sem glitch) ---------- */
.sf-dot {
  animation: sf-blink 3s ease-in-out infinite !important;
}
@keyframes sf-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
/* caso a JS aplique pulse-escalated em produção, deixa gentil */
@keyframes pulse-escalated {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .75; transform: scale(1.06); }
}
/* Dot pulsante da escalação tem animation INLINE (scale 1→1.3, glitch).
   Override por atributo + !important: só opacidade, SEM mudar tamanho. */
[style*="pulse-escalated"] {
  animation: sf-dot-calm 2.4s ease-in-out infinite !important;
}
@keyframes sf-dot-calm {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
  .sf-dot,
  [style*="pulse-escalated"] { animation: none !important; }
}

/* ============================================================
   Animações estilo WhatsApp (com dados reais)
   ============================================================ */

/* ---------- Ticks de status: "lido" em azul + transição ---------- */
.msg-tick { transition: color .25s ease; }
.tick-read,
.msg-tick.tick-read { color: #53bdeb !important; }            /* azul WhatsApp = lido */
[data-theme="light"] .tick-read,
[data-theme="light"] .msg-tick.tick-read { color: #34b7f1 !important; }
.tick-failed, .msg-tick.tick-failed { color: var(--danger) !important; }
/* pop sutil quando o svg do tick é (re)inserido — dispara em updateTick() */
.msg-tick svg { animation: tick-pop .26s ease; }
@keyframes tick-pop {
  0%   { transform: scale(.8); opacity: .5; }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Atendente online: pulso suave (radiação) ---------- */
.status-dot.online {
  animation: online-pulse 2.2s ease-out infinite;
}
@keyframes online-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, .45); }
  70%  { box-shadow: 0 0 0 6px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* ---------- Gravando áudio (secretária): reativa o pulso ---------- */
.voice-recording-dot {
  animation: voice-pulse 1.4s ease-in-out infinite !important;
}

/* ---------- "Elise está digitando…" (3 pontos) ---------- */
.sf-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 11px 14px;
  margin: 4px 0;
  width: fit-content;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  background: var(--wa-bubble-in, var(--bg-lead));
  box-shadow: var(--shadow-xs);
}
.sf-typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  opacity: 1;                       /* 1º ponto sempre visível ("." ) */
}
/* revelar em sequência: "." -> ".." -> "..." -> reinicia */
.sf-typing-indicator span:nth-child(2) { animation: sf-typing-seq2 1.5s infinite ease; }
.sf-typing-indicator span:nth-child(3) { animation: sf-typing-seq3 1.5s infinite ease; }
@keyframes sf-typing-seq2 {
  0%, 28%  { opacity: 0; }          /* escondido no início */
  33%, 100% { opacity: 1; }         /* aparece (..) e segura até o reset */
}
@keyframes sf-typing-seq3 {
  0%, 61%  { opacity: 0; }
  66%, 100% { opacity: 1; }         /* aparece (...) e segura até o reset */
}
.sf-typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 14px 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* reduced-motion: desliga as animações de presença/ticks */
@media (prefers-reduced-motion: reduce) {
  .status-dot.online,
  .voice-recording-dot,
  .sf-typing-indicator span,
  .msg-tick svg { animation: none !important; }
}

/* ---------- Toggle de tema integrado no header ---------- */
.sf-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  padding: 0;
}
.sf-theme-toggle:hover {
  background: var(--bg-hover, rgba(var(--hover-rgb), .5));
  color: var(--text-primary);
}
.sf-theme-toggle:active { transform: scale(.9); }
.sf-theme-toggle svg { width: 18px; height: 18px; }
.sf-theme-toggle .icon-sun { display: none; }
[data-theme="light"] .sf-theme-toggle .icon-sun { display: block; }
[data-theme="light"] .sf-theme-toggle .icon-moon { display: none; }
