/* ══════════════════════════════════════════════════
   Talk Method — Chat (Sofia / Emma / Kate)
   Cores via --prof-primary e --prof-secondary no #chat-sofia
   ══════════════════════════════════════════════════ */

#chat-sofia {
  --prof-primary: #16a34a;
  --prof-secondary: #22c55e;
}

/* ── Botão flutuante ─────────────────────────────── */
.btn-sofia-float {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--prof-primary, #16a34a) 0%, var(--prof-secondary, #22c55e) 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  z-index: 1040;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-sofia-float:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(124, 58, 237, 0.6);
}
.btn-sofia-float:active { transform: scale(0.96); }

/* Tooltip do botão */
.sofia-tooltip {
  position: absolute;
  right: 70px;
  background: #1e1e2e;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  font-family: 'Inter', sans-serif;
}
.btn-sofia-float:hover .sofia-tooltip { opacity: 1; }

/* ── Janela do chat ──────────────────────────────── */
.chat-sofia-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 560px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1039;
  animation: slideUp 0.25s ease;
  font-family: 'Inter', sans-serif;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Mobile: full-screen */
@media (max-width: 480px) {
  .chat-sofia-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
  }
  .btn-sofia-float { bottom: 16px; right: 16px; }
}

/* ── Header ──────────────────────────────────────── */
.chat-header {
  background: linear-gradient(135deg, var(--prof-primary) 0%, var(--prof-secondary) 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sofia-avatar,
.sofia-avatar-lg,
.sofia-avatar-sm {
  overflow: hidden;
}
.sofia-avatar img,
.sofia-avatar-lg img,
.sofia-avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
  display: block;
}
.sofia-avatar.has-foto,
.sofia-avatar-lg.has-foto,
.sofia-avatar-sm.has-foto {
  background: transparent;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
.sofia-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.chat-header-name {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
}
.chat-header-sub {
  color: rgba(255,255,255,0.75);
  font-size: 0.72rem;
}
.online-dot {
  width: 9px;
  height: 9px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.4);
}
.btn-chat-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-chat-close:hover { background: rgba(255,255,255,0.3); }

/* ── Área de mensagens ───────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f7ff;
  min-height: 300px;
  max-height: 360px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #d8b4fe; border-radius: 2px; }

/* Placeholder inicial */
.chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 1rem;
}
.sofia-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--prof-primary), var(--prof-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.8rem;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
}
.btn-iniciar-chat {
  background: linear-gradient(135deg, var(--prof-primary), var(--prof-secondary));
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-iniciar-chat:hover { opacity: 0.9; }

/* ── Bolhas de mensagem ──────────────────────────── */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 90%;
}
/* Professora: esquerda */
.msg-row.sofia { align-self: flex-start; }
/* Aluno: direita */
.msg-row.aluno { align-self: flex-end; flex-direction: row-reverse; }

.sofia-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--prof-primary), var(--prof-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.45;
  max-width: 260px;
  word-wrap: break-word;
}
/* Bolha da Professora */
.msg-row.sofia .msg-bubble {
  background: #fff;
  color: #1f2937;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
/* Bolha do Aluno */
.msg-row.aluno .msg-bubble {
  background: linear-gradient(135deg, var(--prof-primary), var(--prof-secondary));
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.msg-time {
  font-size: 0.65rem;
  color: #9ca3af;
  margin-top: 3px;
  padding: 0 4px;
}
.msg-row.aluno .msg-time { text-align: right; }

/* ── Indicador de digitação ──────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #f8f7ff;
  flex-shrink: 0;
}
.typing-dots {
  background: #fff;
  border-radius: 18px;
  padding: 10px 14px;
  display: flex;
  gap: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.typing-dots span {
  width: 7px;
  height: 7px;
  background: #a855f7;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-7px); opacity: 1; }
}

/* ── Input area ──────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #ede9fe;
  background: #fff;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  background: #f9fafb;
}
.chat-input:focus {
  border-color: var(--prof-secondary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(168,85,247,0.1);
}
.chat-input::placeholder { color: #9ca3af; }
.chat-input:disabled { background: #f3f4f6; cursor: not-allowed; }

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--prof-primary), var(--prof-secondary));
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.btn-send:hover  { opacity: 0.9; }
.btn-send:active { transform: scale(0.9); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Erro inline ──────────────────────────────────── */
.msg-erro {
  text-align: center;
  font-size: 0.78rem;
  color: #ef4444;
  padding: 6px 12px;
  background: #fef2f2;
  border-radius: 8px;
  margin: 0 8px;
}

/* ── Utilitários ──────────────────────────────────── */
.text-purple { color: #7c3aed !important; }
