/* ================= ZETABOT WIDGET ================= */
#zetabot-container {
  position: fixed;
  bottom: 120px; /* Separado del menú inferior flotante (Dock) */
  right: 20px;
  z-index: 9999;
  font-family: inherit;
}

/* Botón flotante */
#zetabot-toggle {
  width: 60px;
  height: 60px;
  min-width: 60px;
  min-height: 60px;
  flex-shrink: 0;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 2px solid var(--accent-red, #d7263d);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: visible; /* Changed from hidden to allow dot to overflow */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  animation: zetabot-buzz 4s infinite ease-in-out;
}

/* Animación de leve zumbido/rebote */
@keyframes zetabot-buzz {
  0% { transform: scale(1); }
  5% { transform: scale(1.05) rotate(3deg); }
  10% { transform: scale(1.05) rotate(-3deg); }
  15% { transform: scale(1.05) rotate(3deg); }
  20% { transform: scale(1) rotate(0); }
  100% { transform: scale(1); }
}

/* Punto verde en el botón flotante */
#zetabot-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background-color: #25D366; /* Verde online */
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  z-index: 10;
}

#zetabot-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(215, 38, 61, 0.4);
}

#zetabot-toggle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Ventana de Chat */
#zetabot-window {
  position: absolute;
  bottom: 75px; /* Relativo al botón */
  right: 0;
  width: 310px; /* Más compacto para PC */
  height: 420px; /* Más compacto para PC */
  max-height: calc(100vh - 150px);
  background-color: var(--bg-body, #131722);
  border: 1px solid var(--border-soft, rgba(255,255,255,0.1));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#zetabot-container:not(.zetabot-closed) #zetabot-window {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#zetabot-container:not(.zetabot-closed) #zetabot-toggle {
  display: none;
}

/* Header */
.zetabot-header {
  background-color: var(--bg-card, #1c2130);
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-soft, rgba(255,255,255,0.1));
}

.zetabot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zetabot-avatar-container {
  position: relative;
  width: 45px;
  height: 45px;
  min-width: 45px;
  min-height: 45px;
  flex-shrink: 0;
}

.zetabot-avatar-container img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid var(--border-soft, rgba(255,255,255,0.1));
  object-fit: cover;
}

/* Status indicator (WhatsApp style) */
.zetabot-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background-color: #25D366; /* WhatsApp Green */
  border-radius: 50%;
  border: 2px solid var(--bg-card, #1c2130);
  z-index: 2;
}

.zetabot-header-info h4 {
  margin: 0;
  font-size: 1rem;
  color: #fff;
  font-weight: 600;
}

.zetabot-header-info p {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.2;
}

.zetabot-header-actions {
  display: flex;
  gap: 8px;
}

.zetabot-header-actions button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.zetabot-header-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Messages Area */
#zetabot-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

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

.zetabot-msg.user {
  align-self: flex-end;
  background-color: var(--accent-red, #d7263d);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.zetabot-msg.model {
  align-self: flex-start;
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-bottom-left-radius: 4px;
}

.zetabot-msg.error {
  align-self: center;
  background-color: rgba(255, 0, 0, 0.1);
  color: #ff6b6b;
  font-size: 0.85rem;
  text-align: center;
  border-radius: 6px;
  width: 100%;
}

/* Typing Indicator */
.zetabot-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  align-self: flex-start;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.zetabot-typing span {
  width: 6px;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: zetabot-bounce 1.4s infinite ease-in-out both;
}

.zetabot-typing span:nth-child(1) { animation-delay: -0.32s; }
.zetabot-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes zetabot-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.zetabot-input-area {
  display: flex;
  padding: 12px;
  background-color: var(--bg-card, #1c2130);
  border-top: 1px solid var(--border-soft, rgba(255,255,255,0.1));
  gap: 10px;
  align-items: flex-end;
}

#zetabot-input {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft, rgba(255,255,255,0.1));
  border-radius: 20px;
  color: #fff;
  padding: 10px 15px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s;
  overflow-y: hidden;
}

#zetabot-input:focus {
  border-color: var(--accent-red, #d7263d);
}

#zetabot-send {
  background-color: var(--accent-red, #d7263d);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

#zetabot-send:hover {
  background-color: #f03a53;
  transform: scale(1.05);
}

#zetabot-send:disabled {
  background-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
  transform: none;
}

/* Scrollbar para mensajes */
#zetabot-messages::-webkit-scrollbar {
  width: 6px;
}
#zetabot-messages::-webkit-scrollbar-track {
  background: transparent;
}
#zetabot-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}
#zetabot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Responsive (Móvil) */
@media (max-width: 480px) {
  #zetabot-container {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px)); /* Sobre el menú flotante móvil */
    right: 15px;
  }
  
  #zetabot-window {
    position: fixed;
    right: 10px;
    left: 10px;
    width: auto;
    height: calc(100dvh - 150px - env(safe-area-inset-bottom, 0px)); /* Más pequeño para no tapar menú inferior ni header superior */
    max-height: none;
    border-radius: 12px;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }
}
