/*
 * messages.css - Chat Messages Component
 * ========================================
 * PORQUE: Bolhas de mensagem (user + athena), avatares, actions,
 * e o indicador de digitacao. O coracao visual do chat.
 *
 * RETROFIT:
 * - font-weight do corpo de mensagens ajustado de 300 para 400
 *   (300 em Windows ClearType parece lavado e fino)
 * - Hardcoded #2e2e2e substituido por var(--border-subtle)
 * - Hardcoded #222 substituido por var(--scrollbar-thumb)
 * - Animacoes spring preservadas intactas
 */

/* ── Messages container ── */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.messages-wrap::-webkit-scrollbar { width: 5px; }
.messages-wrap::-webkit-scrollbar-track { background: transparent; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

.messages-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Message groups ── */
.msg-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeUp 0.3s ease both;
}

.msg-row {
  display: flex;
  gap: 14px;
  padding: 10px 0;
  align-items: flex-start;
  animation: springIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.msg-row.user { flex-direction: row-reverse; }

/* ── Avatares ── */
.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.msg-avatar.athena {
  background: #0a0a0a;
  border: 1px solid var(--border);
  overflow: hidden;
}

.msg-avatar.athena img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-avatar.user {
  background: linear-gradient(135deg, var(--red-dim), var(--red));
  color: #f0ece6;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  overflow: hidden;
}

/* Google profile photo in user avatar */
.msg-avatar.user img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Message body ── */
.msg-body { flex: 1; min-width: 0; }

.msg-sender {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.msg-sender.athena-name { color: var(--red); opacity: 0.85; }

/* ── Bubbles ── */
/* RETROFIT: font-weight ajustado de 300 para 400.
   Peso 300 (light) em telas Windows com subpixel rendering
   desligado parece fino e lavado. 400 e o peso padrao legivel. */
.msg-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.72;
  font-weight: 400;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.msg-bubble.athena {
  background: var(--athena-bubble);
  border: 1px solid var(--border);
  color: var(--white);
  border-radius: 4px 12px 12px 12px;
  animation: springInRight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* RETROFIT: hardcoded #2e2e2e substituido por token */
.msg-bubble.user {
  background: var(--user-bubble);
  border: 1px solid var(--border-subtle);
  color: var(--white);
  border-radius: 12px 4px 12px 12px;
  animation: springInLeft 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

html.light .msg-bubble.user {
  border-color: var(--border);
}

.msg-bubble strong { color: var(--white); font-weight: 600; }
.msg-bubble em { color: #c8b89a; }

html.light .msg-avatar.athena {
  background: var(--bg-surface);
}

/* ── Hover actions (copiar, etc) ── */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  animation: pillReveal 0.3s ease 0.35s both;
}

.msg-row:hover .msg-actions { opacity: 1; }

.action-pill {
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.action-pill:hover {
  border-color: var(--red-dim);
  color: var(--white);
  animation: rippleOut 0.4s ease;
}

/* ── Typing indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 16px;
  background: var(--athena-bubble);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  width: fit-content;
  animation: springIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
  overflow: hidden;
}

.typing-indicator::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.03) 40%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 60%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmerSlide 2s ease-in-out infinite;
  pointer-events: none;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Feedback buttons ── */
.feedback-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 2px;
  align-self: center;
}

.feedback-btn { padding: 4px 6px !important; gap: 0 !important; }

.feedback-btn:hover svg { transform: scale(1.15); transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }

.feedback-active-positive {
  border-color: #22c55e !important;
  color: #22c55e !important;
  background: rgba(34, 197, 94, 0.08) !important;
}

.feedback-active-positive svg { stroke: #22c55e; fill: rgba(34, 197, 94, 0.2); }

.feedback-active-negative {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

.feedback-active-negative svg { stroke: #ef4444; fill: rgba(239, 68, 68, 0.2); }

.feedback-btn:disabled:not(.feedback-active-positive):not(.feedback-active-negative) {
  opacity: 0.3;
  cursor: default;
}
