/* ============================================
   LUMI — janela de conversa da IA da AP.LAB
   ============================================ */

.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);
}

/* Retrato da Lumi. A foto nunca é deformada: os estados animam só o anel ao redor. */
.chat__avatar {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #28302F;
  cursor: zoom-in;
}

.chat__avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat__ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.35;
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
}

.chat[data-state="attentive"] .chat__ring { opacity: 0.85; }
.chat[data-state="thinking"] .chat__ring { opacity: 0.9; animation: lumi-think 1.4s ease-in-out infinite; }
.chat[data-state="responding"] .chat__ring { opacity: 1; transform: scale(1.1); }

@keyframes lumi-think {
  0%, 100% { transform: scale(1); opacity: 0.45; }
  50% { transform: scale(1.12); opacity: 1; }
}

.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; }

/* Apresentação na primeira abertura */
.chat__intro {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 4px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-dark);
  transition: opacity 350ms var(--ease), transform 350ms var(--ease);
}

.chat__intro img {
  display: block;
  width: auto;
  height: 184px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.8);
}

.chat__intro-name { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.1; }
.chat__intro-role { margin-top: 4px; font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); }
.chat__intro-quote { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--sage); max-width: 22ch; }
.chat__intro.is-gone { opacity: 0; transform: translateY(-8px); }

/* Retrato ampliado */
.lumi-view {
  width: auto;
  max-width: min(92vw, 520px);
  max-height: 92vh;
  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.8);
  overflow: hidden;
}

.lumi-view[open] { display: grid; animation: chat-in 0.3s var(--ease); }
.lumi-view::backdrop { background: rgba(10, 14, 14, 0.85); backdrop-filter: blur(6px); }
.lumi-view__img { display: block; width: 100%; height: auto; max-height: calc(92vh - 52px); object-fit: contain; }
.lumi-view__cap { padding: 12px 16px 14px; font-family: var(--font-mono); font-size: 12px; color: var(--sage); }

.lumi-view__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(20, 28, 28, 0.78);
  color: var(--text-light);
  font-size: 15px;
  backdrop-filter: blur(4px);
  transition: background 250ms, color 250ms;
}

.lumi-view__close:hover { background: var(--accent); color: var(--ink); }

@media (max-width: 560px) {
  .chat__intro { gap: 14px; }
  .chat__intro img { height: 164px; }
  .chat__intro-name { font-size: 21px; }
  .lumi-view { max-width: calc(100vw - 20px); }
}

@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; }
}

@media (prefers-reduced-motion: reduce) {
  .chat[open], .chat__msg { animation: none; }
  .chat__ring { transition: none; }
  .chat[data-state="thinking"] .chat__ring { animation: none; opacity: 1; }
  .chat[data-state="responding"] .chat__ring { transform: none; }
  .chat__intro { transition: none; }
  .lumi-view[open] { animation: none; }
  .chat__typing i { animation: none; opacity: 0.7; }
}


/* ============================================
   BALÃO FLUTUANTE DA LUMI (canto inferior direito)
   ============================================ */

.lumi-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.lumi-fab > * { pointer-events: auto; }

.lumi-fab__btn {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #1C2323;
  box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(14, 18, 18, 0.55);
  cursor: pointer;
  transition: transform 250ms var(--ease), box-shadow 250ms var(--ease);
}

.lumi-fab__btn:hover { transform: translateY(-2px) scale(1.04); }
.lumi-fab__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.lumi-fab__btn img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.lumi-fab__dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1C2323;
}

.lumi-fab__tip {
  position: relative;
  max-width: 220px;
  padding: 11px 34px 11px 14px;
  border-radius: 14px 14px 4px 14px;
  background: #28302F;
  border: 1px solid var(--border-dark);
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translateY(6px);
  visibility: hidden;
  transition: opacity 350ms var(--ease), transform 350ms var(--ease), visibility 0s linear 350ms;
}

.lumi-fab.is-tip .lumi-fab__tip {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}

.lumi-fab__tip-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--sage);
  font-size: 11px;
}

.lumi-fab__tip-x:hover { color: var(--accent); }

@media (max-width: 560px) {
  .lumi-fab__btn { width: 58px; height: 58px; }
  .lumi-fab__tip { max-width: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .lumi-fab__btn, .lumi-fab__tip { transition: none; }
}

/* ============================================
   LUMI 3.0 — roteiro em etapas
   ============================================ */

.chat__sub { margin-top: 2px; }
.chat__step { margin-top: 3px; font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); }

.chat__progress { flex: 0 0 auto; height: 3px; background: var(--border-dark); }
.chat__progress i { display: block; height: 100%; width: 6%; background: var(--accent); border-radius: 0 3px 3px 0; transition: width 450ms var(--ease); }

.chat__form {
  display: block;
  padding: 12px 16px 10px;
  border-top: 1px solid var(--border-dark);
  max-height: 52%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat__form[hidden] { display: none; }
.chat__fields { display: grid; gap: 10px; }
.chat__field { display: grid; gap: 5px; }
.chat__label { font-size: 12.5px; color: var(--sage); }
.chat__hint { font-size: 12px; line-height: 1.4; color: var(--sage-dim); }

/* 16px evita o zoom automático do iPhone ao focar o campo */
.chat__input { font-size: 16px; width: 100%; min-height: 44px; }
textarea.chat__input { min-height: 84px; resize: none; }
.chat__phone { display: grid; grid-template-columns: 74px 1fr; gap: 8px; }
.chat__ddi { text-align: center; padding-inline: 6px; }

.chat__err { margin-top: 8px; font-size: 13px; line-height: 1.4; color: #FFB4A8; }
.chat__err[hidden] { display: none; }

.chat__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.chat__send--wide { width: auto; height: 44px; padding: 0 22px; margin-left: auto; font-size: 15px; }

.chat__ghost {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  color: var(--text-light);
  font-size: 14px;
  transition: border-color 200ms, color 200ms;
}
.chat__ghost:hover { border-color: var(--accent); color: var(--accent); }
.chat__ghost[hidden], .chat__send[hidden] { display: none; }

.chat__link { justify-self: start; padding: 4px 0; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

.chat__chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; }
.chat__chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  color: var(--accent);
  font-size: 14px;
  transition: background 200ms, color 200ms;
}
.chat__chip:hover { background: var(--accent); color: var(--ink); }

.chat__done { padding: 6px 0 4px; font-size: 15px; color: var(--accent); }
.chat__form.is-done .chat__fields { grid-template-columns: 1fr auto; align-items: center; }

.chat__foot { flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 16px 12px; }
.chat__foot span { display: block; }

.chat__who-box { min-width: 0; }

@media (max-width: 560px) {
  .chat { height: min(92vh, calc(100dvh - 12px)); }
  .chat__form { max-height: 56%; padding: 10px 12px 8px; }
  .chat__sub { display: block; }
  .chat__ghost { padding: 0 12px; }
  .chat__actions { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat__progress i { transition: none; }
}

/* o formulário nunca encolhe; quem cede espaço é o histórico */
.chat__log { flex: 1 1 0; }
.chat__form { flex: 0 0 auto; max-height: 62%; }
.chat__foot { flex: 0 0 auto; }
@media (max-width: 560px) {
  .chat__foot { padding: 6px 12px 10px; font-size: 10.5px; line-height: 1.45; }
  .chat__fields { gap: 8px; }
  .chat__intro img { height: 140px; }
}

/* Rodapé removido: privacidade e contato ficam num painel sob o botão "i" */
.chat__info {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  margin-right: 6px;
  border: 1px solid var(--border-dark);
  border-radius: 50%;
  color: var(--sage);
  font-family: Georgia, serif; font-style: italic; font-size: 16px;
  transition: border-color 200ms, color 200ms;
}
.chat__info:hover, .chat__info[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.chat { position: fixed; }
.chat__about {
  position: absolute; z-index: 3;
  left: 12px; right: 12px; top: 74px;
  display: grid; gap: 10px;
  padding: 16px;
  background: var(--ink);
  border: 1px solid var(--accent);
  border-radius: 14px;
  font-size: 14px; line-height: 1.5;
  color: var(--text-light);
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
}
.chat__about[hidden] { display: none; }
.chat__about-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.chat__about .chat__mail { font-size: 14px; }
