/**
 * Lead qualification chat demo — How It Works
 */

/* Stage: top uses .how-it-works bg (transparent); bottom half white for next section */
.how-it-works .lead-chat-demo-stage {
  position: relative;
  z-index: 2;
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 80px 0 100px 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    transparent 50%,
    #ffffff 50%,
    #ffffff 100%
  );
}

.lead-chat-demo {
  position: relative;
  z-index: 1;
  max-width: min(720px, 94vw);
  margin: 0 auto;
}

.lead-chat-widget {
  display: flex;
  flex-direction: column;
  background: #f4f6f6;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0px 15px 64px rgb(3 18 66 / 13%), 0 12px 28px rgba(3, 18, 66, 0.12), 0 0 0 1px rgb(255 255 255 / 66%);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.lead-chat-widget__header,
.lead-chat-widget__footer {
  flex-shrink: 0;
}

/* Header */
.lead-chat-widget__header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #1a2234 0%, #121a2a 100%);
  color: #fff;
}

.lead-chat-widget__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lead-chat-widget__agent-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(17, 185, 86, 0.2);
  border: 1px solid rgba(17, 185, 86, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.lead-chat-widget__agent-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  padding: 3px;
    background-color: #fff;
}

.lead-chat-widget__agent-icon svg {
  width: 20px;
  height: 20px;
  color: var(--primary-green, #11b956);
}

.lead-chat-widget__agent-icon--sm {
  width: 30px;
  height: 30px;
}

.lead-chat-widget__titles {
  min-width: 0;
}

.lead-chat-widget__titles strong {
  display: block;
  font-family: var(--font-primary, sans-serif);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-chat-widget__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  color: rgba(167, 243, 208, 0.85);
  margin-top: 2px;
}

.lead-chat-widget__live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.8);
  animation: leadChatLivePulse 2s ease-in-out infinite;
}

@keyframes leadChatLivePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.9); }
}

.lead-chat-widget__wa-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.lead-chat-widget__wa-badge svg {
  width: 14px;
  height: 14px;
}

.lead-chat-widget__lang {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

/* Messages — fixed height, scroll inside */
.lead-chat-widget__body {
  flex: 0 0 auto;
  height: 400px;
  min-height: 400px;
  max-height: 400px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px;
  background: #f8fafb;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lead-chat-widget__body::-webkit-scrollbar {
  width: 5px;
}

.lead-chat-widget__body::-webkit-scrollbar-thumb {
  background: rgba(3, 18, 66, 0.15);
  border-radius: 999px;
}

.lead-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.lead-chat-msg--visible {
  opacity: 1;
  transform: translateY(0);
}

.lead-chat-msg--client {
  align-self: flex-start;
}

.lead-chat-msg--robot {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: auto;
}

.lead-chat-msg__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: #e2e8f0;
}

.lead-chat-msg__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lead-chat-msg--client .lead-chat-msg__avatar img {
  object-fit: contain;
  padding: 2px;
  background: #1b1b1b;
}

.lead-chat-msg__avatar-bot {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: rgba(17, 185, 86, 0.15);
  color: var(--primary-green, #11b956);
}

.lead-chat-msg__avatar-bot svg {
  width: 18px;
  height: 18px;
}

.lead-chat-msg__bubble {
  position: relative;
  padding: 10px 12px 8px;
  border-radius: 14px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #1e293b;
  border: 1px solid transparent;
}

.lead-chat-msg--client .lead-chat-msg__bubble {
  background: #fff;
  border-color: #e8edf2;
  border-bottom-left-radius: 4px;
  padding-right: 22px;
}

.lead-chat-msg--robot .lead-chat-msg__bubble {
  background: #edf9f0;
  border-color: #c8ebd4;
  border-bottom-right-radius: 4px;
}

.lead-chat-msg__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lead-chat-msg__line {
  display: block;
}

.lead-chat-msg__ticks {
  position: absolute;
  right: 7px;
  bottom: 5px;
  line-height: 0;
  opacity: 0.9;
}

.lead-chat-msg__ticks svg {
  display: block;
  width: 11px;
  height: 8px;
}

/* Robot typing — inline where the next message appears */
.lead-chat-msg--typing {
  opacity: 1;
  transform: none;
  transition: none;
}

.lead-chat-msg--typing .lead-chat-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 52px;
  padding: 12px 16px;
  background: #edf9f0;
  border: 1px solid #c8ebd4;
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(17, 185, 86, 0.08);
}

.lead-chat-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lead-chat-typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
  animation: leadChatTypingDot 1.2s ease-in-out infinite;
}

.lead-chat-typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.lead-chat-typing-bubble span:nth-child(3) { animation-delay: 0.3s; }

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

/* Footer — single line */
.lead-chat-widget__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  padding: 10px 14px;
  background: linear-gradient(180deg, #eef2f8 0%, #e8edf5 100%);
  border-top: 1px solid #dde4ee;
}

.lead-chat-widget__footer p {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.6875rem;
  line-height: 1.3;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-chat-widget__footer strong {
  color: var(--primary-green, #11b956);
  font-weight: 700;
}

.lead-chat-widget__footer-spark {
  flex-shrink: 0;
  color: var(--primary-green, #11b956);
  font-size: 0.8125rem;
  line-height: 1;
}

.lead-chat-widget__progress {
  flex: 0 0 52px;
  width: 52px;
  height: 4px;
  border-radius: 999px;
  background: #d8e0ea;
  overflow: hidden;
}

.lead-chat-widget__progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary-green, #11b956), #34d399);
  transition: width 0.45s ease;
}

@media (max-width: 640px) {
  .how-it-works .lead-chat-demo-stage {
    padding: 40px 20px 56px;
  }

  .lead-chat-demo {
    max-width: 100%;
  }

  .lead-chat-widget__header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
  }

  .lead-chat-widget__lang {
    display: none;
  }

  .lead-chat-widget__wa-badge {
    display: none;
  }

  .lead-chat-widget__body {
    height: 340px;
    min-height: 340px;
    max-height: 340px;
  }

  .lead-chat-msg {
    max-width: 96%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lead-chat-msg {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .lead-chat-widget__live-dot,
  .lead-chat-typing-bubble span {
    animation: none;
  }
}
