/* =============================================
   WHATSAPP WIDGET - Runa Inmobiliaria
   Soporte Desktop + Mobile Completo
   ============================================= */

/* Botón flotante */
.whatsapp-float {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: #25D366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.5);
  cursor: pointer;
  z-index: 9990;
  transition: all 0.3s ease;
  border: none;
  padding: 0;
  /* Touch-action para dispositivos táctiles */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.whatsapp-float:hover,
.whatsapp-float:focus {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.7);
  outline: none;
}

.whatsapp-float svg {
  width: 30px;
  height: 30px;
  fill: white;
}

/* Contador de notificaciones */
.whatsapp-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* Ventana del chat (Desktop) */
.chat-widget {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 360px;
  height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: none;
  flex-direction: column;
  z-index: 9995;
  overflow: hidden;
  animation: chatSlideIn 0.3s ease;
}

@keyframes chatSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

/* Cabecera del chat */
.chat-header {
  background: linear-gradient(135deg, #25D366, #128C7E);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header h3 {
  color: white;
  font-size: 1rem;
  margin: 0;
  font-family: sans-serif;
}

.chat-header p {
  color: rgba(255,255,255,0.85);
  font-size: 0.75rem;
  margin: 0;
  font-family: sans-serif;
}

/* Área de mensajes */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #ECE5DD;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch; /* scroll suave en iOS */
}

/* Burbujas de mensajes */
.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  font-family: sans-serif;
  word-wrap: break-word;
  position: relative;
}

.message.bot {
  background: white;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.user {
  background: #DCF8C6;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-time {
  font-size: 0.7rem;
  color: #999;
  margin-top: 4px;
  text-align: right;
}

/* Área del input */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f0f0;
  border-top: 1px solid #ddd;
  flex-shrink: 0;
  align-items: center;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 0.9rem;
  outline: none;
  background: white;
  font-family: sans-serif;
  /* Previene zoom automático en iOS al hacer foco */
  font-size: 16px;
}

.chat-input-area input:focus {
  border-color: #25D366;
}

.chat-input-area button {
  background: #25D366;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.chat-input-area button:hover {
  background: #128C7E;
}

/* =============================================
   RESPONSIVE - MÓVIL
   ============================================= */
@media (max-width: 480px) {
  /* El botón flotante va más abajo y a la derecha con margen táctil */
  .whatsapp-float {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  /* El chat ocupa casi toda la pantalla en móvil */
  .chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 85vh; /* deja espacio para la barra del navegador */
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
  }

  /* Input más grande para facilitar escritura en móvil */
  .chat-input-area input {
    font-size: 16px; /* crucial: evita zoom en iOS */
    padding: 12px 14px;
  }

  .chat-messages {
    padding: 12px;
  }
}
