/* ==========================================================
   WHATSAPP WIDGET — Burbuja flotante + pre-chat estilo WhatsApp
   ========================================================== */

/* Botón flotante (reemplaza al .whatsapp-float actual) */
.wa-launcher {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
  transition: transform var(--t-base, 0.3s ease);
  cursor: pointer;
  border: none;
  padding: 0;
}

.wa-launcher:hover {
  transform: scale(1.1);
}

.wa-launcher svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

/* Ping animado sutil para llamar la atención */
.wa-launcher::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #25D366;
  opacity: 0.6;
  animation: wa-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  z-index: -1;
}

@keyframes wa-ping {
  75%, 100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Panel del pre-chat */
.wa-panel {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  width: 340px;
  max-width: calc(100vw - 3rem);
  background: #E5DDD5;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  z-index: 91;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: var(--font-body, 'Open Sans', sans-serif);
}

.wa-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 480px) {
  .wa-panel {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 5.5rem;
    width: auto;
  }
}

/* Header verde estilo WhatsApp */
.wa-panel__header {
  background: #075E54;
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wa-panel__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.wa-panel__avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.wa-panel__brand {
  flex: 1;
  min-width: 0;
}

.wa-panel__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  line-height: 1.2;
  margin: 0;
}

.wa-panel__status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.wa-panel__status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4FC3F7;
}

.wa-panel__close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  opacity: 0.85;
  transition: opacity var(--t-base, 0.3s ease);
}

.wa-panel__close:hover {
  opacity: 1;
}

.wa-panel__close svg {
  width: 20px;
  height: 20px;
}

/* Fondo con patrón simil WhatsApp */
.wa-panel__body {
  background: #ECE5DD;
  background-image:
    radial-gradient(circle at 30% 20%, rgba(0,0,0,0.02) 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  padding: 1.5rem 1rem 1rem;
  min-height: 180px;
}

/* Burbuja de mensaje entrante */
.wa-panel__message {
  background: #fff;
  border-radius: 0 8px 8px 8px;
  padding: 0.75rem 0.9rem;
  max-width: 85%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
  margin-bottom: 0.5rem;
  animation: wa-msg-in 0.4s ease;
}

@keyframes wa-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.wa-panel__message p {
  margin: 0;
  color: #303030;
  font-size: 0.9rem;
  line-height: 1.4;
}

.wa-panel__message-time {
  display: block;
  font-size: 0.7rem;
  color: #999;
  text-align: right;
  margin-top: 0.25rem;
}

/* Formulario */
.wa-panel__form {
  padding: 0.75rem;
  background: #F0F0F0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wa-panel__input,
.wa-panel__textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid #D5D5D5;
  border-radius: 20px;
  background: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  color: #303030;
  transition: border-color 0.2s ease;
}

.wa-panel__input:focus,
.wa-panel__textarea:focus {
  outline: none;
  border-color: #25D366;
}

.wa-panel__textarea {
  resize: none;
  min-height: 60px;
  border-radius: 16px;
  line-height: 1.4;
}

.wa-panel__submit {
  align-self: flex-end;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.wa-panel__submit:hover:not(:disabled) {
  background: #128C7E;
  transform: scale(1.05);
}

.wa-panel__submit:disabled {
  background: #B0B0B0;
  cursor: not-allowed;
}

.wa-panel__submit svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

/* Mensaje de error inline */
.wa-panel__error {
  color: #D32F2F;
  font-size: 0.75rem;
  padding: 0 0.25rem;
  margin: 0;
  min-height: 1rem;
}

/* Respeta reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .wa-launcher::before {
    animation: none;
  }
  .wa-panel,
  .wa-panel__message {
    animation: none;
    transition: opacity 0.15s ease;
  }
}
