/* ============================================
   ATENDENTE DE IA — janela de conversa
   ============================================ */

.chat {
  width: min(460px, calc(100vw - 20px));
  max-width: none;
  height: min(78vh, 680px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #1C2323;
  color: var(--text-light);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.chat[open] { display: flex; flex-direction: column; animation: chat-in 0.35s var(--ease); }
.chat::backdrop { background: rgba(10, 14, 14, 0.72); backdrop-filter: blur(4px); }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(14px); }
}

.chat :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px 18px;
  border-bottom: 1px solid var(--border-dark);
}

.chat__avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.chat__title { font-family: var(--font-display); font-size: 16px; font-weight: 600; line-height: 1.2; }
.chat__sub { margin-top: 3px; font-size: 12.5px; line-height: 1.4; color: var(--sage); }

.chat__close {
  flex-shrink: 0;
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-dark);
  display: grid;
  place-items: center;
  color: var(--text-light);
  font-size: 14px;
  transition: border-color 250ms, color 250ms;
}

.chat__close:hover { border-color: var(--accent); color: var(--accent); }

.chat__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px;
  overscroll-behavior: contain;
}

.chat__msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: chat-msg 0.3s var(--ease);
}

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

.chat__msg--ai { align-self: flex-start; background: #28302F; border-bottom-left-radius: 4px; }
.chat__msg--user { align-self: flex-end; background: var(--accent); color: var(--ink); border-bottom-right-radius: 4px; }
.chat__msg--note { background: transparent; border: 1px dashed var(--border-dark); color: var(--sage); font-size: 14px; }
.chat__msg--note a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.chat__who { display: block; margin-bottom: 3px; font-family: var(--font-mono); font-size: 11px; color: var(--accent); }

.chat__typing { display: flex; gap: 5px; padding: 15px 16px; }
.chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); animation: chat-dot 1s infinite; }
.chat__typing i:nth-child(2) { animation-delay: 0.15s; }
.chat__typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 12px 10px 16px;
  border-top: 1px solid var(--border-dark);
}

.chat__input {
  flex: 1;
  min-height: 42px;
  max-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  background: #121818;
  color: var(--text-light);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
}

.chat__input::placeholder { color: var(--sage-dim); }
.chat__input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.chat__input:disabled { opacity: 0.6; }

.chat__send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  transition: transform 200ms var(--ease), opacity 200ms;
}

.chat__send:hover { transform: translateY(-1px); }
.chat__send:disabled { opacity: 0.45; transform: none; cursor: default; }

.chat__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
  padding: 8px 16px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--sage-dim);
}

.chat__mail { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 560px) {
  .chat { width: calc(100vw - 12px); height: min(88vh, calc(100dvh - 12px)); border-radius: 16px; }
  .chat__head { padding: 14px 12px 12px 14px; }
  .chat__sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chat[open], .chat__msg { animation: none; }
  .chat__typing i { animation: none; opacity: 0.7; }
}
