/* ============================================================
   Instagram DM-style chat — experimento /tk2
   Mapeado pra engine custom em chat-desafio.js
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

body { overflow-x: hidden; }

/* ---------- Header (mimético do header de DM do Instagram) ---------- */
.ig-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  border-bottom: 1px solid #dbdbdb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  height: 56px;
}

.ig-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ig-back {
  font-size: 24px;
  color: #000;
  line-height: 1;
  user-select: none;
  font-weight: 300;
}

.ig-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.ig-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #efefef;
}

.ig-active-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  background: #2ecc71;
  border: 2px solid #fff;
  border-radius: 50%;
}

.ig-name-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ig-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #000;
}

.ig-verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: #3897f0;
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  font-weight: bold;
  flex-shrink: 0;
}

.ig-status {
  font-size: 12px;
  color: #8e8e8e;
}

.ig-header-icons {
  display: flex;
  gap: 18px;
  color: #000;
  font-size: 22px;
  user-select: none;
}

/* ---------- Progress bar com cores Instagram ---------- */
.progress-bar-bg {
  position: sticky;
  top: 56px;
  z-index: 15;
  height: 2px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #833ab4, #fd1d1d, #fcb045);
  transition: width 0.4s ease;
}

/* ---------- Chat container ---------- */
.chat-container {
  padding: 16px 12px 100px 12px;
  background: #ffffff;
  min-height: calc(100vh - 58px);
  scroll-behavior: smooth;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Bot message group ---------- */
.bot-group {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 6px;
  animation: ig-fade-up 0.3s ease;
}

@keyframes ig-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #efefef;
  flex-shrink: 0;
}

.bot-avatar-placeholder {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.bot-bubbles {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 75%;
  min-width: 0;
}

.bot-bubble {
  background: #efefef;
  color: #000;
  padding: 10px 14px;
  border-radius: 22px;
  font-size: 15px;
  line-height: 1.35;
  word-wrap: break-word;
  align-self: flex-start;
  max-width: 100%;
}

.bot-bubble b, .bot-bubble strong {
  font-weight: 700;
}

/* imagens/gifs em bubbles */
.bot-bubble:has(img) {
  background: transparent;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  max-width: 240px;
}

.bot-bubble img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: #efefef;
}

/* ---------- Typing indicator ---------- */
.typing-bubble {
  background: #efefef;
  padding: 12px 16px;
  border-radius: 22px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8e8e8e;
  animation: ig-typing 1.4s infinite ease-in-out;
}

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

@keyframes ig-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Mensagem da usuária (gradiente IG) ---------- */
.guest-bubble {
  background: linear-gradient(135deg, #833ab4 0%, #c13584 35%, #e1306c 60%, #fd1d1d 85%, #fcb045 100%);
  color: #fff;
  padding: 10px 16px;
  border-radius: 22px;
  font-size: 15px;
  line-height: 1.35;
  align-self: flex-end;
  max-width: 75%;
  margin-left: auto;
  margin-top: 4px;
  margin-bottom: 6px;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  animation: ig-slide-right 0.25s ease;
}

@keyframes ig-slide-right {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Botões de escolha (quick replies do IG) ---------- */
.choices-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  margin: 10px 0 8px;
  width: 100%;
}

.choice-btn {
  background: #ffffff;
  border: 1.5px solid #dbdbdb;
  border-radius: 22px;
  padding: 11px 20px;
  font-size: 14px;
  color: #262626;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  max-width: 80%;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  animation: ig-pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation-fill-mode: both;
}

.choice-btn:hover {
  background: #fafafa;
  border-color: #a8a8a8;
}

.choice-btn:active {
  transform: scale(0.97);
}

@keyframes ig-pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.choices-container.fade-out {
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* CTA de checkout — destaque maior com gradiente IG
   (classe gerada pela engine custom: choice-btn cta-checkout) */
.choice-btn.cta-checkout {
  background: linear-gradient(135deg, #833ab4 0%, #c13584 35%, #e1306c 60%, #fd1d1d 85%, #fcb045 100%);
  color: #ffffff !important;
  border: none;
  font-weight: 700;
  padding: 14px 24px;
  font-size: 15px;
  max-width: 90%;
  box-shadow: 0 4px 14px rgba(225, 48, 108, 0.35);
  letter-spacing: 0.2px;
  text-decoration: none;
}

.choice-btn.cta-checkout:hover {
  filter: brightness(1.05);
  border: none;
}

/* ---------- Input de número ---------- */
.number-input-container {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  width: 100%;
  justify-content: flex-end;
}

.number-input-container input {
  flex: 1;
  max-width: 220px;
  padding: 12px 18px;
  border: 1.5px solid #dbdbdb;
  border-radius: 22px;
  font-size: 15px;
  font-family: inherit;
  background: #fafafa;
  color: #000;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.number-input-container input:focus {
  border-color: #8e8e8e;
  background: #ffffff;
}

.number-input-container button {
  padding: 10px 22px;
  border: none;
  border-radius: 22px;
  background: #0095f6;
  color: #ffffff;
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.number-input-container button:hover {
  background: #1877f2;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .ig-header { padding: 8px 12px; height: 52px; }
  .progress-bar-bg { top: 52px; }
  .chat-container { padding: 14px 10px 90px 10px; min-height: calc(100vh - 54px); }
  .bot-bubbles { max-width: 80%; }
  .bot-bubble:has(img) { max-width: 220px; }
  .guest-bubble { max-width: 80%; }
  .choice-btn { max-width: 90%; padding: 10px 18px; }
}
