/**
 * Chatbot Widget Styles
 * Widget flotante de ayuda para Clocki
 */

/* Botón flotante */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 9999;
}

.chatbot-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

.chatbot-toggle:active {
  transform: scale(0.95);
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: white;
}

.chatbot-toggle .chat-icon {
  display: block;
}

.chatbot-toggle .close-icon {
  display: none;
}

.chatbot-toggle.active .chat-icon {
  display: none;
}

.chatbot-toggle.active .close-icon {
  display: block;
}

/* Badge de notificación */
.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
  border: 2px solid white;
}

/* Contenedor del chat */
.chatbot-container {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  animation: chatbot-slide-up 0.3s ease-out;
}

.chatbot-container.open {
  display: flex;
}

@keyframes chatbot-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header del chat */
.chatbot-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-avatar svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.chatbot-avatar img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.chatbot-header-info {
  flex: 1;
}

.chatbot-header-title {
  font-weight: 600;
  font-size: 16px;
  margin: 0;
}

.chatbot-header-subtitle {
  font-size: 12px;
  opacity: 0.9;
  margin: 2px 0 0;
}

/* Botón cerrar móvil - oculto en desktop */
.chatbot-close-mobile {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: white;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.chatbot-close-mobile:hover {
  opacity: 1;
}

.chatbot-close-mobile svg {
  width: 24px;
  height: 24px;
}

/* Área de mensajes */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

/* Mensajes */
.chatbot-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: message-appear 0.2s ease-out;
}

@keyframes message-appear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.user {
  align-self: flex-end;
  background: #22c55e;
  color: white;
  border-bottom-right-radius: 4px;
}

.chatbot-message.assistant {
  align-self: flex-start;
  background: white;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Indicador de escritura */
.chatbot-typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: none;
}

.chatbot-typing.active {
  display: block;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite;
}

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

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

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* Sugerencias rápidas */
.chatbot-suggestions {
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.chatbot-suggestion {
  padding: 6px 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.chatbot-suggestion:hover {
  background: #22c55e;
  color: white;
  border-color: #22c55e;
}

/* Input del chat */
.chatbot-input-container {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
}

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

.chatbot-input:focus {
  border-color: #22c55e;
}

.chatbot-input::placeholder {
  color: #94a3b8;
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #22c55e;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chatbot-send:hover {
  background: #16a34a;
}

.chatbot-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.chatbot-send svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Mensaje de error */
.chatbot-error {
  background: #fef2f2 !important;
  color: #dc2626 !important;
  border: 1px solid #fecaca !important;
}

/* Responsive - Móvil moderno tipo app de chat */
@media (max-width: 480px) {
  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.5);
  }

  .chatbot-toggle.active {
    opacity: 0;
    pointer-events: none;
  }

  .chatbot-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    background: #ffffff;
    color-scheme: light;
    animation: chatbot-slide-up-mobile 0.3s ease-out;
  }

  /* Fondo blanco fijo detrás del chat */
  .chatbot-container.open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: -1;
  }

  @keyframes chatbot-slide-up-mobile {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .chatbot-header {
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    border-radius: 0;
  }

  /* Botón cerrar visible en móvil */
  .chatbot-close-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  .chatbot-messages {
    padding: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  }

  .chatbot-message {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 15px;
    border-radius: 18px;
  }

  .chatbot-message.user {
    border-bottom-right-radius: 6px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  }

  .chatbot-message.assistant {
    border-bottom-left-radius: 6px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }

  .chatbot-suggestions {
    padding: 12px 16px;
    gap: 10px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
  }

  .chatbot-suggestion {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 20px;
    background: #f1f5f9;
    border: none;
    color: #475569;
  }

  .chatbot-input-container {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    gap: 10px;
  }

  .chatbot-input {
    padding: 12px 18px;
    font-size: 16px; /* Evita zoom en iOS */
    border-radius: 24px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
  }

  .chatbot-input:focus {
    background: #ffffff;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
  }

  .chatbot-send {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
  .chatbot-container {
    width: 360px;
    right: 16px;
    bottom: 88px;
  }
}
