/* ============================================================
   BRChina — Chat de cadastro (overlay) · premium refit
   ============================================================ */
.chat-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(10, 30, 19, 0.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s var(--ease);
}
.chat-overlay.open { opacity: 1; pointer-events: auto; }

.chat-panel {
  width: min(420px, 100%);
  height: min(700px, calc(100dvh - 48px));
  background: var(--cream);
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 40px 90px -24px rgba(8, 20, 13, 0.55), 0 8px 24px -12px rgba(8, 20, 13, 0.3);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(28px) scale(0.97);
  transition: transform 0.45s var(--ease);
}
.chat-overlay.open .chat-panel { transform: none; }
@media (max-width: 560px) {
  .chat-overlay { padding: 0; }
  .chat-panel {
    width: 100%; height: 100dvh; border-radius: 0; border: 0;
  }
}

/* ---- header ---- */
.chat-head {
  background: linear-gradient(150deg, #123a24 0%, var(--green-dark) 70%);
  color: #fff;
  padding: 18px 20px calc(18px);
  display: flex; align-items: center; gap: 13px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 18px -12px rgba(0, 0, 0, 0.5);
}
.chat-head .av {
  width: 46px; height: 46px; border-radius: 50%;
  background: #123a24 url("assets/ana-avatar.jpg") center / cover;
  color: transparent;
  display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: 1.15rem;
  position: relative; flex-shrink: 0;
  box-shadow: 0 4px 12px -4px rgba(14, 138, 62, 0.6), 0 0 0 3px rgba(255, 255, 255, 0.08);
}
.chat-head .av::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  width: 12px; height: 12px; border-radius: 50%;
  background: #4ade80; border: 2.5px solid #123a24;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.4);
}
.chat-head .ch-name {
  font-family: var(--f-display); font-weight: 700; font-size: 1.05rem;
  line-height: 1.2; letter-spacing: -0.01em;
}
.chat-head .ch-sub {
  font-size: 0.78rem; color: #9fb8a8; margin-top: 2px;
  display: flex; align-items: center; gap: 5px;
}
.chat-head .ch-close {
  margin-left: auto; background: rgba(255,255,255,0.1); border: 0; color: #fff;
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 1.1rem;
  line-height: 1; display: grid; place-items: center;
  transition: background 0.25s, transform 0.25s;
}
.chat-head .ch-close:hover { background: rgba(255,255,255,0.22); transform: rotate(90deg); }

/* ---- progress ---- */
.chat-prog { height: 3px; background: rgba(12,36,23,0.07); flex-shrink: 0; }
.chat-prog .bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), #4ade80);
  transition: width 0.5s var(--ease);
}

/* ---- thread ---- */
.chat-thread {
  flex: 1; overflow-y: auto;
  padding: 22px 18px 14px;
  display: flex; flex-direction: column; gap: 11px;
  scroll-behavior: smooth;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(14, 138, 62, 0.05), transparent 60%),
    var(--cream);
}
.chat-thread::-webkit-scrollbar { width: 7px; }
.chat-thread::-webkit-scrollbar-thumb { background: rgba(21,33,26,0.14); border-radius: 99px; }

.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg .bub {
  font-family: var(--f-body);
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 0.95rem; line-height: 1.55; letter-spacing: -0.005em;
  animation: msgIn 0.4s var(--ease);
}
@keyframes msgIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.msg.bot .bub {
  background: #fff; color: var(--ink);
  border: 1px solid rgba(21, 33, 26, 0.05);
  border-bottom-left-radius: 7px;
  box-shadow: 0 8px 22px -12px rgba(21,33,26,0.22), 0 1px 2px rgba(21,33,26,0.04);
}
.msg.user .bub {
  background: linear-gradient(145deg, #12a04a, var(--green-deep));
  color: #fff;
  border-bottom-right-radius: 7px;
  box-shadow: 0 8px 20px -10px rgba(10, 95, 44, 0.5);
}
.msg .bub b { font-weight: 700; }
.msg .bub .hint { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.msg.user .edit-link {
  font-size: 0.75rem; color: var(--muted); margin-top: 5px; cursor: pointer;
  background: none; border: 0; font-family: var(--f-body); padding: 2px 4px;
}
.msg.user .edit-link:hover { color: var(--ink); text-decoration: underline; }

/* typing dots */
.msg.bot .typing, .typing {
  display: inline-flex; gap: 5px; padding: 15px 18px; align-items: center;
}
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2);
  animation: tdot 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.16s; }
.typing i:nth-child(3) { animation-delay: 0.32s; }
@keyframes tdot { 0%, 60%, 100% { transform: none; opacity: 0.35; } 30% { transform: translateY(-5px); opacity: 1; } }

/* recap card */
.recap {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 4px 16px; font-size: 0.9rem;
  box-shadow: 0 8px 22px -14px rgba(21,33,26,0.2);
  animation: msgIn 0.4s var(--ease);
}
.recap .rrow {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.recap .rrow:last-child { border-bottom: 0; }
.recap .rk { color: var(--muted); flex-shrink: 0; }
.recap .rv { font-weight: 700; text-align: right; }

/* esteira badge */
.lane-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green-soft); color: var(--green-deep);
  border-radius: var(--r-pill); padding: 8px 14px;
  font-size: 0.85rem; font-weight: 700;
  animation: msgIn 0.4s var(--ease);
}
.lane-badge .d { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* ---- input dock ---- */
.chat-dock {
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  background: linear-gradient(0deg, var(--cream) 82%, rgba(247,245,240,0));
  border-top: 1px solid rgba(21,33,26,0.05);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip {
  font-family: var(--f-body); font-weight: 600; font-size: 0.9rem;
  background: #fff; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--r-pill);
  padding: 11px 18px; cursor: pointer;
  transition: all 0.22s var(--ease);
  animation: msgIn 0.4s var(--ease) backwards;
}
.chip:nth-child(2) { animation-delay: 0.06s; }
.chip:nth-child(3) { animation-delay: 0.12s; }
.chip:nth-child(4) { animation-delay: 0.18s; }
.chip:nth-child(5) { animation-delay: 0.24s; }
.chip:hover { border-color: var(--green); color: var(--green-deep); background: var(--green-soft); }
.chip.alt { border-style: dashed; color: var(--muted); }
.chip:disabled { opacity: 0.5; cursor: default; }

.chat-form { display: flex; gap: 9px; align-items: center; }
.chat-form input {
  flex: 1; font-family: var(--f-body); font-size: 1rem; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--r-pill);
  padding: 14px 20px; outline: none; min-width: 0;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.chat-form input::placeholder { color: var(--muted-2); }
.chat-form input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(14,138,62,0.1); }
.chat-form.err input { border-color: var(--red); background: var(--red-soft); }
.chat-form .send {
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(145deg, #12a04a, var(--green-deep));
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 18px -8px rgba(10, 95, 44, 0.6);
  transition: transform 0.25s var(--ease), box-shadow 0.25s, filter 0.2s;
  flex-shrink: 0;
}
.chat-form .send:hover { transform: scale(1.06); filter: brightness(1.08); box-shadow: 0 10px 22px -8px rgba(10, 95, 44, 0.7); }
.chat-form .send:active { transform: scale(0.96); }
.chat-form .send svg, .chat-form .send i { pointer-events: none; }
.dock-err {
  font-size: 0.8rem; color: var(--red-deep); padding: 6px 8px 0;
  display: none;
}
.dock-err.show { display: block; animation: msgIn 0.3s var(--ease); }
.dock-skip {
  background: none; border: 0; font-family: var(--f-body);
  font-size: 0.82rem; color: var(--muted); cursor: pointer;
  padding: 8px 8px 0; text-decoration: underline;
}
.dock-skip:hover { color: var(--ink); }
