/* ============================================
   LP-PV-5 — CHATBOT CONVERSATIONNEL
   Messenger-style quiz funnel
   Font: Plus Jakarta Sans
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a2e;
  background: #ECE5DD;
  height: 100%;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --primary: #059669;
  --primary-hover: #047857;
  --primary-light: #d1fae5;
  --accent: #e8850e;
  --bot-bg: #ffffff;
  --user-bg: #DCF8C6;
  --user-text: #111b21;
  --bg: #ECE5DD;
  --text: #1a1a2e;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

/* ============================
   CHAT HEADER
   ============================ */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #075E54;
  border-bottom: none;
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}
.ch-inner { display: flex; align-items: center; justify-content: space-between; max-width: 600px; margin: 0 auto; }
.ch-left { display: flex; align-items: center; gap: 0.75rem; }
.ch-avatar { position: relative; flex-shrink: 0; }
.ch-avatar img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.ch-online { position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; background: #25D366; border: 2.5px solid #075E54; border-radius: 50%; }
.ch-name { display: block; font-size: 0.95rem; font-weight: 700; color: #fff; }
.ch-status { font-size: 0.72rem; color: rgba(255,255,255,0.75); font-weight: 500; }
.ch-badge { font-size: 0.65rem; font-weight: 700; color: #fff; background: rgba(255,255,255,0.15); padding: 0.2rem 0.6rem; border-radius: 100px; }

/* ============================
   CHAT CONTAINER
   ============================ */
.chat-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-messages {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ============================
   MESSAGE BUBBLES
   ============================ */
.msg-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  animation: msgIn 0.3s ease;
  max-width: 85%;
}
.msg-row.bot { align-self: flex-start; }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.msg-row.user .msg-avatar { display: none; }

.msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.55;
  box-shadow: var(--shadow);
  word-break: break-word;
}
.msg-row.bot .msg-bubble {
  background: var(--bot-bg);
  color: var(--text);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
}
.msg-row.user .msg-bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-radius: var(--radius) 0 var(--radius) var(--radius);
}
.msg-bubble strong { font-weight: 700; }
.msg-bubble .text-green { color: var(--primary); font-weight: 700; }
.msg-bubble .text-orange { color: var(--accent); font-weight: 700; }

/* Consecutive bot messages: hide avatar, adjust spacing */
.msg-row.bot.no-avatar .msg-avatar { visibility: hidden; }

/* ============================
   TYPING INDICATOR
   ============================ */
.typing-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  align-self: flex-start;
  max-width: 85%;
}
.typing-bubble {
  background: var(--bot-bg);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ============================
   QUICK REPLY BUTTONS
   ============================ */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0 0.25rem 2.5rem;
  animation: msgIn 0.3s ease;
}
.qr-btn {
  background: #ffffff;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 100px;
  padding: 0.6rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.qr-btn:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }
.qr-btn:active { transform: translateY(0); }

/* ============================
   CHAT FORM (step 4: contact)
   ============================ */
.chat-form {
  padding: 0.5rem 0 0.25rem 2.5rem;
  animation: msgIn 0.3s ease;
  max-width: 320px;
}
.cf-group { margin-bottom: 0.625rem; }
.cf-group label { display: block; font-size: 0.72rem; font-weight: 600; color: var(--text-dim); margin-bottom: 0.2rem; }
.cf-group input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.cf-group input::placeholder { color: var(--text-muted); }
.cf-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5,150,105,0.1); }
.cf-group input.error { border-color: #ef4444; }
.cf-error { font-size: 0.7rem; color: #ef4444; margin-top: 0.15rem; }
.cf-fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.cf-consent {
  display: flex; gap: 0.4rem; align-items: flex-start;
  font-size: 0.68rem; color: var(--text-dim); line-height: 1.4;
  cursor: pointer; margin-bottom: 0.75rem;
}
.cf-consent input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 15px; height: 15px;
  border: 2px solid #94a3b8;
  border-radius: 3px;
  flex-shrink: 0; margin-top: 1px;
  position: relative; cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.cf-consent input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
.cf-consent input[type="checkbox"]:checked::after { content: '\2713'; position: absolute; top: -1px; left: 1.5px; font-size: 0.62rem; color: #fff; font-weight: 800; }
.cf-consent a { color: var(--primary); text-decoration: underline; }

.cf-submit {
  display: block; width: 100%;
  background: var(--primary); color: #fff;
  font-weight: 700; font-size: 0.95rem;
  padding: 0.75rem; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-family: inherit;
  transition: background var(--transition), transform var(--transition);
  box-shadow: 0 2px 8px rgba(5,150,105,0.2);
}
.cf-submit:hover { background: var(--primary-hover); transform: translateY(-1px); }
.cf-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.cf-reassurance {
  display: flex; gap: 0.625rem; margin-top: 0.5rem;
  font-size: 0.65rem; color: var(--text-muted); flex-wrap: wrap;
}

/* ============================
   CHAT INPUT BAR (for CP step)
   ============================ */
.chat-input-area {
  position: sticky;
  bottom: 0;
  background: #f0f0f0;
  border-top: none;
  padding: 0.5rem 0.75rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}
.cia-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
}
.cia-inner input {
  flex: 1;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.cia-inner input:focus { border-color: var(--primary); }
.cia-inner input::placeholder { color: var(--text-muted); }
.cia-send {
  width: 44px; height: 44px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 50%;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
.cia-send:hover { background: var(--primary-hover); transform: scale(1.05); }

/* ============================
   CONFIRMATION CARD (in chat)
   ============================ */
.confirm-card {
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-left: 2.5rem;
  animation: msgIn 0.3s ease;
  max-width: 320px;
}
.confirm-card h4 { font-size: 1rem; font-weight: 800; color: var(--primary); margin-bottom: 0.75rem; text-align: center; }
.cc-row { display: flex; justify-content: space-between; padding: 0.4rem 0; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
.cc-row:last-child { border-bottom: none; }
.cc-row span { color: var(--text-dim); }
.cc-row strong { color: var(--text); }

/* ============================
   FOOTER
   ============================ */
.footer {
  display: none;
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.footer.visible { display: block; }
.footer-links { margin: 0.4rem 0 0.75rem; display: flex; justify-content: center; gap: 1.25rem; }
.footer-links a { color: var(--text-dim); text-decoration: underline; }
.footer-disclaimer { max-width: 500px; margin: 0 auto; font-size: 0.6rem; color: var(--text-muted); line-height: 1.5; }
.footer-disclaimer p { margin-bottom: 0.35rem; }

/* ============================
   MODALES
   ============================ */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 10000; justify-content: center; align-items: center; padding: 1rem; }
.modal.active { display: flex; }
.modal-content { background: #fff; border-radius: var(--radius-sm); padding: 2rem; max-width: 560px; width: 100%; max-height: 80vh; overflow-y: auto; position: relative; box-shadow: var(--shadow-md); }
.modal-close { position: absolute; top: 0.75rem; right: 0.75rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { color: var(--text); }
.modal-content h2 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--text); font-weight: 800; }
.modal-content h3 { font-size: 0.95rem; margin-top: 1rem; margin-bottom: 0.4rem; color: var(--text); font-weight: 700; }
.modal-content p { font-size: 0.82rem; color: var(--text-dim); line-height: 1.6; }
.modal-content a { color: var(--primary); }
.modal-date { font-style: italic; color: var(--text-muted) !important; font-size: 0.75rem !important; }

/* ============================
   FORM POPUP (chat-style)
   ============================ */
.form-popup-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.45);
  z-index: 9000;
  justify-content: center;
  align-items: flex-end;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}
.form-popup-overlay.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-popup {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.35s ease;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
}

.fp-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border-radius: 20px 20px 0 0;
  border-bottom: 1px solid var(--border);
}
.fp-header img {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.fp-header-text { flex: 1; }
.fp-header-name { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.fp-header-sub { font-size: 0.72rem; color: var(--text-muted); }
.fp-close {
  background: none; border: none;
  font-size: 1.4rem; color: var(--text-muted);
  cursor: pointer; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background var(--transition);
}
.fp-close:hover { background: var(--bg); color: var(--text); }

.fp-bubble {
  margin: 1rem 1.25rem 0.75rem;
  background: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  box-shadow: var(--shadow);
}

.fp-form {
  padding: 0 1.25rem 1.25rem;
}
.fp-form .cf-group { margin-bottom: 0.625rem; }
.fp-form .cf-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}
.fp-form .cf-group input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.fp-form .cf-group input::placeholder { color: var(--text-muted); }
.fp-form .cf-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5,150,105,0.1); }
.fp-form .cf-group input.error { border-color: #ef4444; }

.fp-form .cf-consent {
  display: flex; gap: 0.4rem; align-items: flex-start;
  font-size: 0.68rem; color: var(--text-dim); line-height: 1.4;
  cursor: pointer; margin-bottom: 0.75rem;
}
.fp-form .cf-submit {
  display: block; width: 100%;
  background: var(--primary); color: #fff;
  font-weight: 700; font-size: 1rem;
  padding: 0.85rem; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-family: inherit;
  transition: background var(--transition), transform var(--transition);
  box-shadow: 0 4px 14px rgba(5,150,105,0.25);
}
.fp-form .cf-submit:hover { background: var(--primary-hover); transform: translateY(-1px); }
.fp-form .cf-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.fp-form .cf-reassurance {
  display: flex; gap: 0.625rem; margin-top: 0.6rem;
  font-size: 0.65rem; color: var(--text-muted);
  justify-content: center; flex-wrap: wrap;
}

/* Desktop: center the popup */
@media (min-width: 768px) {
  .form-popup-overlay { align-items: center; }
  .form-popup { border-radius: 20px; max-width: 400px; }
  .fp-header { border-radius: 20px 20px 0 0; }
}

/* ============================
   EXIT POPUP — Classic
   ============================ */
.exit-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  z-index: 9500;
  justify-content: center;
  align-items: center;
  padding: 1.25rem;
  animation: exitFadeIn 0.25s ease;
}
.exit-overlay.active { display: flex; }

@keyframes exitFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes exitPopIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.exit-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 2rem 1.5rem 1.5rem;
  animation: exitPopIn 0.35s cubic-bezier(0.23,1,0.32,1);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  position: relative;
}
.exit-close {
  position: absolute;
  top: 0.75rem; right: 0.75rem;
  background: none; border: none;
  font-size: 1.4rem; color: var(--text-muted);
  cursor: pointer; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}
.exit-close:hover { background: var(--bg); color: var(--text); }

.exit-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.75rem;
  display: block;
  border: 3px solid #25D366;
}
.exit-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}
.exit-text {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 1.25rem;
}
.exit-text strong { color: var(--text); }
.exit-cta {
  display: block; width: 100%;
  background: #25D366; color: #fff;
  font-weight: 700; font-size: 1rem;
  padding: 0.85rem; border-radius: 100px;
  border: none; cursor: pointer; font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(37,211,102,0.3);
}
.exit-cta:hover { background: #22c55e; transform: translateY(-1px); }
.exit-cta:active { transform: scale(0.98); }
.exit-dismiss {
  display: block; width: 100%;
  background: none; border: none;
  color: var(--text-muted); font-size: 0.78rem;
  font-family: inherit; cursor: pointer;
  padding: 0.75rem 0.5rem 0;
  transition: color 0.15s;
}
.exit-dismiss:hover { color: var(--text-dim); }

/* ============================
   RESPONSIVE
   ============================ */
@media (min-width: 768px) {
  .chat-messages { padding: 2rem 1rem 3rem; }
  .msg-row { max-width: 70%; }
  .chat-form { max-width: 360px; }
  .confirm-card { max-width: 360px; }
}

@media (max-width: 480px) {
  .msg-row { max-width: 90%; }
  .quick-replies { padding-left: 2rem; }
  .chat-form { padding-left: 2rem; max-width: 100%; }
  .confirm-card { margin-left: 2rem; max-width: 100%; }
  .cf-fields-row { grid-template-columns: 1fr; }
}
