/* MT Beauté — Avaliação interativa · experiência de conversa (mobile first) */

:root {
  --hd: #075e54;
  --hd-dark: #054a42;
  --wa: #00a884;
  --wa-ink: #067d64;
  --bg: #efeae2;
  --in: #ffffff;
  --out: #d9fdd3;
  --ink: #111b21;
  --muted: #667781;
  --line: #d1d7db;
  --check: #53bdeb;
  --gold: #c9a15c;
  --gold-2: #e3c98d;
  --gold-deep: #a9803f;
  --cream: #faf6ee;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #e9edef;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- janela do app ---------- */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

/* ---------- cabeçalho ---------- */
.chat-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px 4px;
  background: var(--hd);
  color: #fff;
  min-height: 58px;
  z-index: 3;
}
.hd-back { display: grid; place-items: center; width: 24px; flex: none; opacity: .95; }
.hd-avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  background: #f4ece0; border: 1.5px solid rgba(255,255,255,.35);
}
.hd-info { flex: 1 1 auto; min-width: 0; line-height: 1.2; }
.hd-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hd-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hd-badge {
  flex: none;
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
  padding: 2px 7px; border-radius: 20px;
  color: #2c241c;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
}
.hd-status { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12.5px; color: rgba(255,255,255,.88); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: #25d366; box-shadow: 0 0 0 2px rgba(37,211,102,.28);
}
.hd-actions { flex: none; display: flex; align-items: center; gap: 14px; opacity: .95; }

/* progresso discreto: uma linha fina, sem números */
.progress { flex: none; height: 2px; background: rgba(7,94,84,.12); z-index: 3; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .6s ease; }

/* ---------- conversa ---------- */
.thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg) url("../img/chat-bg.svg") repeat;
  background-size: 200px 200px;
}
.day-chip {
  align-self: center; margin: 4px 0 2px;
  font-size: 11.5px; font-weight: 500; letter-spacing: .3px; color: #54656f;
  background: rgba(255,255,255,.92); padding: 4px 10px; border-radius: 8px;
  box-shadow: 0 1px .5px rgba(11,20,26,.13);
}
.notice {
  align-self: center; max-width: 92%;
  display: flex; align-items: flex-start; gap: 6px;
  margin-bottom: 8px; padding: 6px 10px;
  font-size: 12px; line-height: 1.35; text-align: center; color: #54656f;
  background: #ffeecd; border-radius: 8px;
  box-shadow: 0 1px .5px rgba(11,20,26,.13);
}
.notice svg { flex: none; margin-top: 2px; color: #8a7a4c; }
.notice.noscript { display: block; }
.notice a { color: var(--wa-ink); font-weight: 600; }

/* mensagens */
.msg { display: flex; max-width: 84%; animation: pop .22s ease-out both; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.msg.media { max-width: min(92%, 380px); width: min(92%, 380px); }
.msg.wide { max-width: 94%; }
.msg.first { margin-top: 4px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

.bubble {
  position: relative;
  padding: 7px 9px 6px;
  border-radius: 10px;
  font-size: 15px; line-height: 1.38;
  color: var(--ink);
  box-shadow: 0 1px .5px rgba(11,20,26,.14);
  overflow-wrap: anywhere;
  min-width: 0;
}
.bubble::after { content: ""; display: table; clear: both; }
.msg.in .bubble { background: var(--in); }
.msg.out .bubble { background: var(--out); }
.txt { white-space: pre-line; }
.meta {
  float: right; margin: 7px 0 -2px 12px;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; line-height: 1; color: var(--muted);
}
.msg.out .meta { color: #5d7f6f; }
.checks { color: var(--check); }

.msg.in.first .bubble { border-top-left-radius: 0; }
.msg.out.first .bubble { border-top-right-radius: 0; }
.msg.in.first .bubble::before,
.msg.out.first .bubble::before { content: ""; position: absolute; top: 0; width: 0; height: 0; border-style: solid; }
.msg.in.first .bubble::before { left: -7px; border-width: 0 8px 8px 0; border-color: transparent var(--in) transparent transparent; }
.msg.out.first .bubble::before { right: -7px; border-width: 0 0 8px 8px; border-color: transparent transparent transparent var(--out); }

/* indicador de digitação */
.msg.typing .bubble { display: flex; align-items: center; gap: 4px; padding: 13px 14px; }
.msg.typing .bubble::after { display: none; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: #8a9aa3; animation: blink 1.1s infinite ease-in-out; }
.msg.typing i:nth-child(2) { animation-delay: .16s; }
.msg.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- opções (botões de resposta) ---------- */
.options { align-self: flex-start; width: min(78%, 320px); display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.caption {
  margin: 0 0 1px 4px; font-size: 12.5px; color: #54656f;
  animation: pop .25s ease-out both;
}
.options-list { display: flex; flex-direction: column; gap: 6px; }
.opt {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--wa-ink);
  font-size: 15px; font-weight: 600; line-height: 1.25; text-align: center; text-decoration: none;
  box-shadow: 0 1px .5px rgba(11,20,26,.12);
  transition: background .12s, transform .12s, border-color .12s;
  animation: pop .25s ease-out both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.opt:hover { background: #f5f8f7; }
.opt:active { transform: scale(.985); background: #eaf5f1; }
.opt:focus-visible { outline: 2px solid var(--wa); outline-offset: 2px; }
.opt.picked { background: var(--out); border-color: #b9e5b0; }
.options.locked .opt:not(.picked) { opacity: .45; pointer-events: none; }
.opt.primary { border-color: rgba(0,168,132,.55); }
.opt.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.opt.wa:hover { background: #009a78; }
.opt.wa svg { flex: none; }

/* ---------- campos integrados à conversa (nome / WhatsApp) ---------- */
.composer {
  align-self: flex-end; width: min(86%, 340px);
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border-radius: 12px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line);
  box-shadow: 0 1px .5px rgba(11,20,26,.12);
  animation: pop .25s ease-out both;
}
.field {
  width: 100%; min-height: 46px; padding: 10px 12px;
  font-size: 16px; /* evita zoom no iOS */
  color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
  outline: none;
}
.field::placeholder { color: #8696a0; }
.field:focus { border-color: var(--wa); box-shadow: 0 0 0 3px rgba(0,168,132,.16); }
.field.invalid { border-color: #d9534f; box-shadow: 0 0 0 3px rgba(217,83,79,.12); }
.field-err { margin: 0; min-height: 0; font-size: 12.5px; line-height: 1.3; color: #c0392b; }
.field-err:empty { display: none; }
.composer .opt { animation: none; }

/* ---------- galeria de resultados ---------- */
.msg.media .bubble { width: 100%; padding: 4px 4px 6px; }
.gallery { display: block; }
.g-viewport {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  border-radius: 8px; overflow: hidden; background: #f3eee5;
}
.g-track {
  display: flex; width: 100%; height: 100%;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.g-track::-webkit-scrollbar { display: none; }
.g-slide { flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; }
.g-slide img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.g-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; padding: 0 0 3px; border: 0; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 26px; line-height: 1; color: #fff;
  background: rgba(17,27,33,.55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: opacity .15s, background .15s;
}
.g-nav.prev { left: 6px; }
.g-nav.next { right: 6px; }
.g-nav:hover { background: rgba(17,27,33,.72); }
.g-nav:disabled { opacity: 0; pointer-events: none; }
.g-count {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; letter-spacing: .3px; color: #fff;
  background: rgba(17,27,33,.6);
}
.g-note { margin: 6px 4px 0; font-size: 12px; line-height: 1.35; color: var(--muted); }

/* ---------- resumo: "O que entendemos sobre você" ---------- */
.summary { font-size: 15px; }
.msg.wide .bubble { background: var(--cream); border: 1px solid rgba(201,161,92,.55); padding: 12px 13px 8px; }
.msg.wide.first .bubble::before { border-right-color: var(--cream); }
.summary-head {
  display: flex; align-items: center; gap: 7px; margin-bottom: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--gold-deep);
}
.summary-row { margin-bottom: 10px; }
.summary-label { margin: 0 0 2px; font-size: 14px; color: #5b5145; }
.summary-value { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: .2px; line-height: 1.3; color: #2c241c; }
.summary-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(201,161,92,.4); }
.summary-foot p { margin: 0 0 8px; font-size: 14px; line-height: 1.4; }
.summary-foot .summary-disclaimer { font-size: 12.5px; color: var(--muted); }

/* ---------- barra inferior (decorativa) ---------- */
.input-bar {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: #f0f2f5; user-select: none; pointer-events: none;
}
.bar-field {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 0 12px;
  background: #fff; border-radius: 22px; color: #8696a0;
}
.bar-text { flex: 1 1 auto; min-width: 0; font-size: 15px; color: #8696a0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-mic { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--wa); color: #fff; opacity: .55; }

/* ---------- telas pequenas: o nome tem prioridade sobre o resto do cabeçalho ---------- */
@media (max-width: 420px) {
  .hd-title { font-size: 15px; }
  .hd-name { gap: 5px; }
  .hd-badge { font-size: 9.5px; padding: 2px 6px; }
  .hd-actions { gap: 11px; }
  .hd-actions svg { width: 21px; height: 21px; }
}
@media (max-width: 420px) {
  .bar-field > svg:last-of-type { display: none; }
}
@media (max-width: 359px) {
  .hd-actions svg:first-child { display: none; }
}

/* ---------- desktop: janela centralizada ---------- */
@media (min-width: 720px) {
  body { display: grid; place-items: center; background: #d9dbd5; }
  body::before { content: ""; position: fixed; inset: 0 0 auto 0; height: 128px; background: var(--hd-dark); }
  .app {
    position: relative; width: 480px; max-width: 100%;
    height: min(860px, calc(100vh - 48px)); height: min(860px, calc(100dvh - 48px));
    border-radius: 14px;
    box-shadow: 0 6px 30px rgba(11,20,26,.28), 0 0 0 1px rgba(11,20,26,.06);
  }
  .chat-header { padding-top: 8px; }
  .input-bar { padding-bottom: 8px; }
  .thread { padding: 12px 18px 24px; }
}
@media (min-width: 720px) and (max-height: 700px) {
  .app { height: calc(100vh - 16px); height: calc(100dvh - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  .msg, .opt, .caption, .composer { animation: none; }
  .progress i { transition: none; }
  .msg.typing i { animation: none; opacity: .7; }
}
