/* Botón flotante del chat - se apila arriba de .carrito-float y .whatsapp-float */
.chat-float {
  position: fixed;
  bottom: 170px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s;
  z-index: 1000;
}

.chat-float:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

/* Preparado para cuando se sume la imagen/ícono de Oriana: alcanza con
   poner un <img src="..."> dentro de #chat-float en vez del <i> de
   Font Awesome, y va a quedar recortado en círculo automáticamente. */
.chat-float img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Burbuja de bienvenida (teaser) que invita a abrir el chat sin que el
   usuario tenga que hacer clic primero. Aparece sola a los pocos
   segundos de cargar la página (ver chat.js) y se puede cerrar con la X
   sin abrir el chat. */
.chat-teaser {
  display: none;
  position: fixed;
  bottom: 175px;
  right: 100px;
  max-width: 220px;
  background: var(--card-bg);
  color: var(--text-primary);
  padding: 10px 30px 10px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  line-height: 1.35;
  cursor: pointer;
  z-index: 999;
  animation: fadeIn 0.3s;
}

.chat-teaser.visible {
  display: block;
}

.chat-teaser p {
  margin: 0;
}

.chat-teaser::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
  border-width: 8px 0 8px 8px;
  border-style: solid;
  border-color: transparent transparent transparent var(--card-bg);
}

.chat-teaser-close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

/* Panel del chat */
.chat-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 240px;
  right: 30px;
  width: 570px; /* 50% más ancho que antes (380px); max-width de abajo es el límite real "si la pantalla lo permite" */
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 280px);
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 1001;
  animation: fadeIn 0.2s;
}

.chat-panel-header {
  padding: 18px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-disclaimer {
  margin: 0;
  padding: 8px 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.chat-mensajes::-webkit-scrollbar {
  width: 8px;
}

.chat-mensajes::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.chat-mensajes::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

.chat-mensaje {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-mensaje-user {
  align-self: flex-end;
  background: var(--primary-color);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-mensaje-model {
  align-self: flex-start;
  background: var(--bg-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-mensaje-error {
  align-self: center;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  font-size: 0.8rem;
  text-align: center;
}

.chat-escribiendo {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.chat-escribiendo span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: chatEscribiendoPulso 1.2s infinite ease-in-out;
}

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

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

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.9rem;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--primary-color);
}

.chat-form button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--primary-color);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.chat-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Responsive móvil: panel casi pantalla completa */
@media (max-width: 768px) {
  .chat-float {
    bottom: 160px;
    right: 20px;
    width: 55px;
    height: 55px;
    font-size: 1.4rem;
  }

  .chat-teaser {
    bottom: 165px;
    right: 85px;
    max-width: 180px;
  }

  .chat-panel {
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
  }
}
