/* Widget de Chat Embebible - Estilos */

#webchat-widget-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Botón flotante */
#webchat-button {
  width: 60px;
  height: 60px;
  background: #10B981;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transition: all 0.3s ease;
  font-size: 28px;
  user-select: none;
  animation: pulse 2s infinite;
}

#webchat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.6);
}

#webchat-button.active {
  background: #059669;
  animation: none;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.7);
  }
}

/* Ventana de chat */
#webchat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 350px;
  max-height: 500px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#webchat-window.open {
  display: flex;
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Header */
.webchat-header {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.webchat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.webchat-avatar-header {
  font-size: 28px;
  line-height: 1;
}

.webchat-header-text {
  display: flex;
  flex-direction: column;
}

.webchat-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.webchat-status {
  font-size: 11px;
  opacity: 0.9;
}

.webchat-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.webchat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Mensajes */
.webchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
  max-height: 360px;
}

.webchat-message {
  display: flex;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

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

.webchat-message.webchat-user {
  flex-direction: row-reverse;
}

.webchat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: #e5e7eb;
}

.webchat-user .webchat-avatar {
  background: #3b82f6;
}

.webchat-content {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.webchat-text {
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 14px;
}

.webchat-assistant .webchat-text {
  background: #e5e7eb;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.webchat-user .webchat-text {
  background: #3b82f6;
  color: white;
  border-bottom-right-radius: 4px;
}

.webchat-source {
  font-size: 11px;
  color: #6b7280;
  padding: 0 4px;
  font-style: italic;
}

.webchat-time {
  font-size: 11px;
  color: #9ca3af;
  padding: 0 4px;
}

/* Barra de "escribiendo" en la parte inferior */
.webchat-typing-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #f3f4f6;
  border-top: 1px solid #e5e7eb;
  font-size: 13px;
  color: #6b7280;
}

.webchat-typing-bar.visible {
  display: flex;
}

.webchat-typing-bar .typing-avatar {
  font-size: 18px;
}

.webchat-typing-bar .typing-text {
  font-style: italic;
  color: #6b7280;
}

.webchat-typing-bar .typing-dots {
  display: flex;
  gap: 3px;
  margin-left: 4px;
}

.webchat-typing-bar .typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10B981;
  animation: typing 1.4s infinite;
}

.webchat-typing-bar .typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.webchat-typing-bar .typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* Input */
.webchat-input-container {
  display: flex;
  padding: 12px;
  background: white;
  border-top: 1px solid #e5e7eb;
  gap: 8px;
}

#webchat-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

#webchat-input:focus {
  border-color: #10B981;
}

#webchat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #10B981;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
  flex-shrink: 0;
}

#webchat-send:hover {
  background: #059669;
  transform: scale(1.05);
}

#webchat-send:active {
  transform: scale(0.95);
}

/* Responsive Mobile */
@media (max-width: 480px) {
  #webchat-widget-container {
    bottom: 10px;
    right: 10px;
  }

  #webchat-window {
    width: calc(100vw - 20px);
    max-width: 350px;
    bottom: 70px;
    right: 0;
    max-height: calc(100vh - 90px);
  }

  .webchat-messages {
    max-height: calc(100vh - 200px);
  }
}

/* Scrollbar personalizado */
.webchat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.webchat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.webchat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

