/* =====================================================
   CHAT — Widget del asistente virtual
   Se apila encima del botón flotante de WhatsApp (bottom: 28px).
   ===================================================== */

.chat__burbuja {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 9999px;
  background: var(--color-blue);
  color: var(--color-white);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat__burbuja:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.55);
}

.chat--abierto .chat__burbuja {
  transform: scale(0.9);
}

.chat__panel {
  position: fixed;
  bottom: 168px;
  right: 28px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 480px;
  max-height: calc(100vh - 200px);
  overflow: hidden;
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 16px;
  background: var(--color-gray);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
}

.chat__panel[hidden] {
  display: none;
}

.chat__cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--color-blue), var(--color-cyan));
  color: var(--color-white);
}

.chat__cabecera strong {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.chat__cabecera span {
  display: block;
  font-size: 0.75rem;
  opacity: 0.85;
}

.chat__cerrar {
  border: none;
  background: transparent;
  color: var(--color-white);
  font-size: 1rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  opacity: 0.85;
}

.chat__cerrar:hover {
  opacity: 1;
}

.chat__mensajes {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
}

.chat__msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat__msg--bot {
  align-self: flex-start;
  background: rgba(124, 58, 237, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.2);
  color: var(--color-slate);
  border-bottom-left-radius: 4px;
}

.chat__msg--usuario {
  align-self: flex-end;
  background: var(--color-blue);
  color: var(--color-white);
  border-bottom-right-radius: 4px;
}

/* Indicador de "escribiendo…" */
.chat__msg--escribiendo {
  display: flex;
  gap: 4px;
  padding: 14px;
}

.chat__msg--escribiendo span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-blue-light);
  animation: chat-punto 1.2s infinite ease-in-out;
}

.chat__msg--escribiendo span:nth-child(2) { animation-delay: 0.2s; }
.chat__msg--escribiendo span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-punto {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat__form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(167, 139, 250, 0.15);
  background: rgba(0, 0, 0, 0.2);
}

.chat__form input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-white);
  font-family: inherit;
  font-size: 0.875rem;
}

.chat__form input::placeholder {
  color: var(--color-gray-darker);
}

.chat__form input:focus {
  outline: none;
  border-color: var(--color-blue-light);
}

.chat__form button {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--color-blue);
  color: var(--color-white);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chat__form button:hover {
  background: var(--color-blue-light);
}

.chat__oculto {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  .chat__burbuja {
    bottom: 92px;
    right: 20px;
    width: 52px;
    height: 52px;
  }

  .chat__panel {
    bottom: 156px;
    right: 20px;
    left: 20px;
    width: auto;
    height: 60vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat__burbuja,
  .chat__form button,
  .chat__msg--escribiendo span {
    transition: none;
    animation: none;
  }
}
