/**
 * Onboarding V2 - Part 3: Chat Forms Inside Phone
 * Chat-style forms with typing indicators, message bubbles, and inputs
 */

/* ==========================================================================
   Chat Container (inside .phone-content)
   ========================================================================== */

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 10px 4px;
  padding-bottom: 8px;
  scroll-behavior: smooth;
}

/* Custom scrollbar for chat */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #E0E0E0;
  border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #CCCCCC;
}

/* ==========================================================================
   Chat Message Bubble
   ========================================================================== */

.chat-message {
  max-width: 92%;
  animation: messageSlideIn 0.3s ease-out;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  font-family: "Satoshi", -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-message.bot .chat-bubble {
  background: #F5F5F5;
  color: #141414;
  border-bottom-left-radius: 4px;
}

.chat-message.user .chat-bubble {
  background: #1CD987;
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

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

/* ==========================================================================
   Typing Indicator
   ========================================================================== */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: #F5F5F5;
  border-radius: 20px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  max-width: 70px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* ==========================================================================
   Chat Input Area (fixed at bottom)
   ========================================================================== */

.chat-input-area {
  padding: 8px 4px 10px 4px;
  background: #FFFFFF;
  border-top: 1px solid #F0F0F0;
  flex-shrink: 0;
}

.chat-input-wrapper {
  animation: fadeInUp 0.3s ease-out;
}

.chat-input-wrapper.hidden {
  display: none;
}

.chat-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  font-family: "Satoshi", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: #141414;
  background: #FFFFFF;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.chat-input:focus {
  border-color: #1CD987;
  box-shadow: 0 0 0 3px rgba(28, 217, 135, 0.1);
}

.chat-input::placeholder {
  color: #929292;
}

.chat-input.error {
  border-color: #E53935;
}

.chat-input.valid {
  border-color: #1CD987;
}

/* Input with icon */
.chat-input-with-icon {
  position: relative;
}

.chat-input-with-icon .chat-input {
  padding-right: 44px;
}

.chat-input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.chat-input-icon.valid {
  color: #1CD987;
}

.chat-input-icon.invalid {
  color: #E53935;
}

/* Error message */
.input-error-message {
  color: #E53935;
  font-size: 13px;
  margin-top: 6px;
  padding-left: 4px;
  font-family: "Satoshi", sans-serif;
}

.input-error-message.hidden {
  display: none;
}

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

/* ==========================================================================
   Continue Button
   ========================================================================== */

.chat-continue-btn {
  width: 100%;
  padding: 12px 20px;
  margin-top: 10px;
  background: #141414;
  color: #FFFFFF;
  border: none;
  border-radius: 14px;
  font-family: "Satoshi", sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.chat-continue-btn:hover:not(:disabled) {
  background: #2a2a2a;
  transform: translateY(-1px);
}

.chat-continue-btn:active:not(:disabled) {
  transform: translateY(0);
}

.chat-continue-btn:disabled {
  background: #CCCCCC;
  cursor: not-allowed;
  transform: none;
}

.chat-continue-btn .arrow {
  transition: transform 0.2s ease;
}

.chat-continue-btn:hover:not(:disabled) .arrow {
  transform: translateX(4px);
}

/* ==========================================================================
   Skip Button
   ========================================================================== */

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.chat-skip-btn {
  flex: 0 0 auto;
  padding: 14px 20px;
  background: transparent;
  color: #929292;
  border: 2px solid #E0E0E0;
  border-radius: 16px;
  font-family: "Satoshi", sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-skip-btn:hover {
  border-color: #CCCCCC;
  color: #666;
}

.button-row .chat-continue-btn {
  flex: 1;
  margin-top: 0;
}

/* ==========================================================================
   WhatsApp Final Button
   ========================================================================== */

.whatsapp-btn {
  width: 100%;
  padding: 16px 24px;
  margin-top: 16px;
  background: #25D366;
  color: #FFFFFF;
  border: none;
  border-radius: 16px;
  font-family: "Satoshi", sans-serif;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.whatsapp-btn:hover {
  background: #128C7E;
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.3);
}

.whatsapp-btn:active {
  transform: scale(1);
}

.whatsapp-btn svg {
  width: 22px;
  height: 22px;
}

.whatsapp-note {
  text-align: center;
  color: #929292;
  font-size: 14px;
  margin-top: 12px;
  font-family: "Satoshi", sans-serif;
}

/* ==========================================================================
   Phone Input Group (Country Selector)
   ========================================================================== */

.phone-input-group {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.country-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 12px;
  background: #F5F5F5;
  border: 2px solid #E0E0E0;
  border-radius: 16px;
  font-family: "Satoshi", sans-serif;
  font-size: 15px;
  color: #141414;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s ease;
  flex-shrink: 0;
}

.country-selector:hover {
  border-color: #CCCCCC;
}

.country-selector:focus {
  outline: none;
  border-color: #1CD987;
}

.country-selector .chevron {
  transition: transform 0.2s ease;
}

.country-selector.open .chevron {
  transform: rotate(180deg);
}

.phone-input-group .chat-input {
  flex: 1;
  min-width: 0;
}

/* Country Dropdown */
.country-dropdown-wrapper {
  position: relative;
}

.country-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  z-index: 100;
  overflow: hidden;
  min-width: 120px;
}

.country-dropdown.hidden {
  display: none;
}

.country-dropdown button {
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: none;
  border: none;
  font-family: "Satoshi", sans-serif;
  font-size: 15px;
  color: #141414;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.country-dropdown button:hover {
  background: #F5F5F5;
}

.country-dropdown button:first-child {
  border-radius: 12px 12px 0 0;
}

.country-dropdown button:last-child {
  border-radius: 0 0 12px 12px;
}

.country-dropdown button:only-child {
  border-radius: 12px;
}

/* ==========================================================================
   Suggestion Pills (for service type)
   ========================================================================== */

.suggestion-label {
  font-size: 14px;
  color: #929292;
  margin-bottom: 10px;
  font-family: "Satoshi", sans-serif;
}

.suggestion-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.suggestion-pill {
  padding: 8px 14px;
  background: #F5F5F5;
  border: 1px solid #E0E0E0;
  border-radius: 20px;
  font-family: "Satoshi", sans-serif;
  font-size: 14px;
  color: #141414;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggestion-pill:hover {
  background: #EBEBEB;
  border-color: #CCCCCC;
}

.suggestion-pill.selected {
  background: #1CD987;
  border-color: #1CD987;
  color: #FFFFFF;
}

/* ==========================================================================
   Map Container (Placeholder for now)
   ========================================================================== */

.map-container {
  position: relative;
  width: 100%;
  height: 160px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 12px;
  background: #F5F5F5;
}

.location-map {
  width: 100%;
  height: 100%;
}

/* Map placeholder styling */
.map-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  color: #2E7D32;
  font-family: "Satoshi", sans-serif;
}

.map-placeholder-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.map-placeholder-text {
  font-size: 14px;
  color: #558B59;
}

.map-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  font-size: 32px;
  pointer-events: none;
  z-index: 10;
}

/* Radius Selector */
.radius-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.radius-label {
  font-size: 14px;
  color: #929292;
  white-space: nowrap;
  font-family: "Satoshi", sans-serif;
}

.radius-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radius-pill {
  padding: 6px 12px;
  background: #F5F5F5;
  border: 1px solid #E0E0E0;
  border-radius: 16px;
  font-family: "Satoshi", sans-serif;
  font-size: 13px;
  color: #141414;
  cursor: pointer;
  transition: all 0.2s ease;
}

.radius-pill:hover {
  border-color: #CCCCCC;
}

.radius-pill.selected {
  background: #141414;
  border-color: #141414;
  color: #FFFFFF;
}

/* ==========================================================================
   Textarea (for "Other" flow)
   ========================================================================== */

.chat-textarea {
  resize: none;
  min-height: 80px;
  font-family: "Satoshi", sans-serif;
}

/* ==========================================================================
   Two Input Fields (First/Last name)
   ========================================================================== */

.dual-input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dual-input-group .chat-input {
  width: 100%;
}

/* ==========================================================================
   Responsive Adjustments for Phone Mockup
   ========================================================================== */

@media (max-width: 768px) {
  .chat-messages {
    padding: 8px 4px;
    gap: 10px;
  }

  .chat-bubble {
    font-size: 13px;
    padding: 8px 12px;
  }

  .chat-input {
    font-size: 16px; /* Prevents iOS zoom */
    padding: 10px 12px;
  }

  .chat-continue-btn {
    padding: 10px 16px;
    font-size: 13px;
  }

  .chat-input-area {
    padding: 8px 4px 10px 4px;
  }

  .suggestion-pill {
    padding: 5px 10px;
    font-size: 12px;
  }

  .map-container {
    height: 120px;
  }

  .radius-selector {
    flex-wrap: wrap;
    gap: 6px;
  }

  .radius-label {
    width: 100%;
    font-size: 12px;
  }
}

/* ==========================================================================
   Accessibility - Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .chat-message,
  .chat-input-wrapper,
  .typing-dot {
    animation: none;
  }

  .chat-continue-btn,
  .chat-skip-btn,
  .whatsapp-btn,
  .suggestion-pill,
  .radius-pill,
  .country-selector {
    transition: none;
  }

  .chat-continue-btn:hover:not(:disabled),
  .whatsapp-btn:hover {
    transform: none;
  }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
  .chat-input {
    border-width: 3px;
  }

  .chat-message.bot .chat-bubble {
    border: 2px solid #666;
  }

  .chat-message.user .chat-bubble {
    border: 2px solid #0a8a4a;
  }

  .chat-continue-btn:disabled {
    background: #999;
    color: #fff;
  }
}

/* ==========================================================================
   Loading State for Submit Button
   ========================================================================== */

.whatsapp-btn {
  position: relative;
}

.whatsapp-btn .btn-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.2s ease;
}

.whatsapp-btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.whatsapp-btn.loading .btn-text {
  opacity: 0;
}

.whatsapp-btn.loading .btn-spinner {
  display: block;
}

.btn-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==========================================================================
   Error Display
   ========================================================================== */

.chat-error {
  background: #FEE2E2;
  border: 1px solid #EF4444;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: shake 0.4s ease-out;
}

.chat-error-icon {
  color: #EF4444;
  flex-shrink: 0;
}

.chat-error-text {
  color: #991B1B;
  font-size: 14px;
  line-height: 1.4;
  font-family: "Satoshi", sans-serif;
}

.chat-error-retry {
  color: #EF4444;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  font-family: "Satoshi", sans-serif;
}

.chat-error-retry:hover {
  color: #DC2626;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ==========================================================================
   Success Screen
   ========================================================================== */

.success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 24px;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.success-checkmark {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
}

.success-checkmark svg {
  width: 100%;
  height: 100%;
}

.success-checkmark .circle {
  stroke: #1CD987;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: circleAnim 0.6s ease-out 0.2s forwards;
}

.success-checkmark .check {
  stroke: #1CD987;
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkAnim 0.4s ease-out 0.6s forwards;
}

@keyframes circleAnim {
  to { stroke-dashoffset: 0; }
}

@keyframes checkAnim {
  to { stroke-dashoffset: 0; }
}

.success-title {
  font-size: 24px;
  font-weight: 700;
  color: #141414;
  margin-bottom: 8px;
  font-family: "Satoshi", sans-serif;
}

.success-mascot {
  font-size: 32px;
  margin-bottom: 16px;
}

.success-subtitle {
  font-size: 16px;
  color: #666;
  line-height: 1.5;
  font-family: "Satoshi", sans-serif;
}

/* ==========================================================================
   Phone Tilt Animation (Success)
   ========================================================================== */

@keyframes phoneTiltSuccess {
  0% {
    transform: perspective(1000px) rotateY(0deg) rotateX(0deg);
  }
  50% {
    transform: perspective(1000px) rotateY(-15deg) rotateX(5deg);
  }
  100% {
    transform: perspective(1000px) rotateY(-10deg) rotateX(3deg);
  }
}

.phone-mockup.success-tilt {
  animation: phoneTiltSuccess 0.6s ease-out forwards;
  transform-style: preserve-3d;
}

/* ==========================================================================
   "Other" Flow - Narrow Down Options
   ========================================================================== */

.narrow-down-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.narrow-down-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  background: #F5F5F5;
  border: 2px solid #E0E0E0;
  border-radius: 16px;
  font-family: "Satoshi", sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #141414;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.narrow-down-btn:hover {
  background: #EBEBEB;
  border-color: #CCCCCC;
  transform: translateY(-1px);
}

.narrow-down-btn:active {
  transform: translateY(0);
}

.narrow-down-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.narrow-down-contact {
  background: transparent;
  border-color: #E0E0E0;
  color: #666;
}

.narrow-down-contact:hover {
  background: #F5F5F5;
}

/* ==========================================================================
   Contact Form (Other Flow)
   ========================================================================== */

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-form .chat-input {
  width: 100%;
}

.contact-form .chat-textarea {
  min-height: 80px;
}

/* ==========================================================================
   Responsive Adjustments for New Components
   ========================================================================== */

@media (max-width: 768px) {
  .success-screen {
    padding: 30px 20px;
  }

  .success-checkmark {
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
  }

  .success-title {
    font-size: 20px;
  }

  .success-mascot {
    font-size: 28px;
  }

  .success-subtitle {
    font-size: 14px;
  }

  .narrow-down-btn {
    padding: 12px 16px;
    font-size: 14px;
  }

  .narrow-down-icon {
    font-size: 18px;
  }
}

/* ==========================================================================
   Reduced Motion for New Animations
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .phone-mockup.success-tilt {
    animation: none;
  }

  .success-checkmark .circle,
  .success-checkmark .check {
    animation: none;
    stroke-dashoffset: 0;
  }

  .success-screen {
    animation: none;
  }

  .chat-error {
    animation: none;
  }

  .btn-spinner {
    animation: none;
  }
}

/* ==========================================================================
   Klickie Mascot Greeting Animation
   ========================================================================== */

/* Greeting message - mascot inside chat bubble */
.greeting-message {
  margin-bottom: 4px;  /* space before next message */
}

.greeting-bubble {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Greeting mascot - inline typewriter */
.greeting-mascot {
  font-size: 24px;
  line-height: 1.2;
  font-family: monospace;  /* ensures consistent character width */
  min-height: 28px;
  display: inline-block;
}

/* Typed cursor effect */
.greeting-mascot::after {
  content: '|';
  animation: blink 0.7s infinite;
  opacity: 0;  /* Hidden after typing completes */
}

.greeting-mascot.typing::after {
  opacity: 1;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* After typing, do a bounce */
.greeting-mascot.wave {
  animation: mascotBounce 0.6s ease-out;
  display: inline-block;
}

@keyframes mascotBounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
  60% { transform: translateY(-2px); }
}

/* Greeting text inline with mascot */
.greeting-text-inline {
  display: block;
  line-height: 1.5;
}

.greeting-text-inline .greeting-highlight {
  font-weight: 600;
  color: #0F2C1D;
}

@media (max-width: 768px) {
  .greeting-mascot {
    font-size: 20px;
    min-height: 24px;
  }
}

/* ==========================================================================
   Let's Go Button - shown after greeting
   ========================================================================== */

.lets-go-container {
  display: flex;
  justify-content: center;
  padding: 16px 0;
  animation: fadeInUp 0.3s ease-out;
}

.lets-go-btn {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transition: all 0.2s ease;
  font-family: "Satoshi", sans-serif;
}

.lets-go-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.lets-go-btn:active {
  transform: translateY(0);
}
