/* src/css/components/chat-bubble.css — Gaia v2: Premium Design */

.chatbot-wrapper {
  position: fixed;
  bottom: var(--space-6, 24px);
  right: var(--space-6, 24px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

/* ═══ BURBUJA FLOTANTE CON AVATAR ═══ */
.chatbot-bubble {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary, #2d6a4f), #1b4332);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(45, 106, 79, 0.45), 0 0 0 0 rgba(45, 106, 79, 0.3);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  pointer-events: auto;
  position: relative;
  overflow: visible;
}

.chatbot-bubble::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  background: var(--primary, #2d6a4f);
  opacity: 0.5;
  z-index: -1;
  animation: chatbotPulse 2s infinite;
}

.chatbot-bubble:hover {
  transform: scale(1.12);
  box-shadow: 0 12px 40px rgba(45, 106, 79, 0.5);
}

.chatbot-bubble-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.6);
}

.chatbot-bubble-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chatbot-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chatbot-bubble .close-icon { display: none; }
.chatbot-wrapper.is-open .chatbot-bubble .chatbot-bubble-avatar { display: none; }
.chatbot-wrapper.is-open .chatbot-bubble .chatbot-bubble-badge { display: none; }
.chatbot-wrapper.is-open .chatbot-bubble .close-icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: white;
}

@keyframes chatbotPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes badgePop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ═══ PANEL DEL CHAT ═══ */
.chatbot-panel {
  width: 400px;
  height: 580px;
  max-height: calc(100vh - 120px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(45, 106, 79, 0.12);
  border-radius: 24px;
  box-shadow:
    0 24px 64px rgba(0,0,0,0.15),
    0 8px 24px rgba(45, 106, 79, 0.1);
  margin-bottom: var(--space-4, 16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px) scale(0.92);
  transform-origin: bottom right;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.chatbot-wrapper.is-open .chatbot-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ═══ HEADER PREMIUM ═══ */
.chatbot-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #1b4332, #2d6a4f, #40916c);
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.chatbot-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,243,208,0.4), transparent);
}

.chatbot-avatar-container {
  position: relative;
  flex-shrink: 0;
}

.chatbot-avatar-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a7f3d0, #6ee7b7);
  padding: 2px;
  position: relative;
  z-index: 2;
}

.chatbot-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: white;
}

.chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Avatar Voice Pulse */
.chatbot-avatar-pulse {
  position: absolute;
  top: 50%; left: 50%;
  width: 48px; height: 48px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}

.chatbot-avatar-pulse.speaking {
  animation: avatarSpeak 0.6s ease-in-out infinite;
  background: rgba(167, 243, 208, 0.4);
  box-shadow: 0 0 20px rgba(110, 231, 183, 0.3);
}

@keyframes avatarSpeak {
  0%   { width: 48px; height: 48px; opacity: 0.7; }
  50%  { width: 68px; height: 68px; opacity: 0.2; }
  100% { width: 48px; height: 48px; opacity: 0.7; }
}

.chatbot-info { flex: 1; }

.chatbot-info h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-ai-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  background: linear-gradient(135deg, rgba(167,243,208,0.4), rgba(110,231,183,0.3));
  border: 1px solid rgba(167,243,208,0.3);
  border-radius: 8px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
}

.chatbot-info p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chatbot-status-dot {
  width: 8px; height: 8px;
  background: #10B981;
  border-radius: 50%;
  display: inline-block;
  animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Header Actions */
.chatbot-header-actions {
  display: flex;
  gap: 6px;
}

.chatbot-voice-toggle,
.chatbot-minimize {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chatbot-voice-toggle:hover,
.chatbot-minimize:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.2);
}

/* ═══ ÁREA DE MENSAJES ═══ */
.chatbot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(45,106,79,0.2);
  border-radius: 4px;
}

.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  animation: slideInMsg 0.3s ease forwards;
}

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

.chat-msg.bot {
  align-self: flex-start;
  background: white;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(45, 106, 79, 0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chat-msg.bot strong {
  color: var(--primary, #2d6a4f);
  font-weight: 600;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2d6a4f, #1b4332);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(45, 106, 79, 0.25);
}

/* ═══ PRODUCT CARDS IN CHAT ═══ */
.chat-product-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 90%;
  align-self: flex-start;
  animation: slideInMsg 0.3s ease forwards;
}

.chat-product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 1px solid rgba(45,106,79,0.1);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chat-product-card:hover {
  border-color: var(--primary, #2d6a4f);
  box-shadow: 0 4px 16px rgba(45,106,79,0.12);
  transform: translateY(-1px);
}

.chat-product-card img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #f0fdf4;
}

.chat-product-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-product-info strong {
  font-size: 13px;
  color: #1a1a2e;
  line-height: 1.3;
}

.chat-product-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary, #2d6a4f);
}

/* ═══ INTERACTIVE PRODUCT CARD ACTIONS ═══ */
.chat-card-img-link {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-card-stock {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}
.chat-card-stock.low {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}
.chat-card-stock.out {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.chat-card-name {
  text-decoration: none;
  color: inherit;
  transition: color 0.15s;
}
.chat-card-name:hover {
  color: var(--primary, #2d6a4f);
}
.chat-card-name strong {
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.chat-card-btn {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}

.chat-card-btn--cart {
  background: var(--primary, #2d6a4f);
  color: white;
}
.chat-card-btn--cart:hover:not(:disabled) {
  background: #1b4332;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.3);
}
.chat-card-btn--cart:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chat-card-btn--cart.added {
  background: #22c55e;
  pointer-events: none;
}

.chat-card-btn--detail {
  background: rgba(45, 106, 79, 0.08);
  color: var(--primary, #2d6a4f);
  border: 1px solid rgba(45, 106, 79, 0.15);
}
.chat-card-btn--detail:hover {
  background: rgba(45, 106, 79, 0.15);
  transform: translateY(-1px);
}

/* ═══ QUICK REPLIES ═══ */
.chatbot-quick-replies {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  background: white;
}

.chatbot-quick-replies.visible {
  display: flex;
  animation: slideInMsg 0.3s ease forwards;
}

.quick-reply-pill {
  padding: 8px 16px;
  border-radius: 20px;
  background: #f0fdf4;
  border: 1px solid rgba(45,106,79,0.15);
  color: var(--primary, #2d6a4f);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-reply-pill:hover {
  background: var(--primary, #2d6a4f);
  color: white;
  border-color: var(--primary, #2d6a4f);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45,106,79,0.2);
}

/* Typing Indicator */
.chat-typing {
  align-self: flex-start;
  background: white;
  padding: 10px 16px;
  border-radius: 18px;
  display: none;
  gap: 5px;
  border: 1px solid rgba(45, 106, 79, 0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chat-typing.active { display: flex; }

.typing-dot {
  width: 7px; height: 7px;
  background: var(--primary, #2d6a4f);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
  opacity: 0.6;
}

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

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

/* ═══ INPUT DUAL: TEXTO / VOZ ═══ */
.chatbot-input-zone {
  border-top: 1px solid rgba(45, 106, 79, 0.08);
  background: white;
}

/* MODO TEXTO */
.chatbot-input--text {
  padding: 10px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  border-top: none;
}

.chatbot-input--text input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(45, 106, 79, 0.15);
  border-radius: 24px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fafffe;
}

.chatbot-input--text input:focus {
  border-color: var(--primary, #2d6a4f);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.08);
}

/* Botón Toggle (texto → voz) */
.chatbot-mode-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(45, 106, 79, 0.2);
  color: var(--primary, #2d6a4f);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-mode-toggle:hover {
  background: rgba(45, 106, 79, 0.07);
  border-color: var(--primary, #2d6a4f);
  transform: scale(1.05);
}

/* MODO VOZ */
.chatbot-input--voice {
  padding: 18px 16px 14px;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-top: none;
}

.voice-mode-hint {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
  text-align: center;
  min-height: 18px;
  transition: color 0.3s;
}

/* Mic grande centrado — el elemento estrella del modo voz */
.chatbot-mic-big {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d6a4f, #1b4332);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  box-shadow: 0 6px 24px rgba(45, 106, 79, 0.35);
}

.chatbot-mic-big:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 32px rgba(45, 106, 79, 0.45);
}

.chatbot-mic-big.recording {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 6px 24px rgba(220, 38, 38, 0.4);
  animation: micBigPulse 1.5s infinite;
}

.chatbot-mic-big svg {
  width: 28px; height: 28px;
  fill: none;
}

@keyframes micBigPulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(220,38,38,0.4), 0 0 0 0 rgba(220,38,38,0.3); }
  50% { box-shadow: 0 6px 24px rgba(220,38,38,0.4), 0 0 0 14px rgba(220,38,38,0); }
}

.mic-recording-indicator {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid white;
  display: none;
}

.mic-recording-indicator.active {
  display: block;
  animation: micDotPulse 1s infinite;
}

/* Botón volver a texto */
.chatbot-mode-toggle--back {
  width: auto;
  height: 30px;
  border-radius: 16px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 500;
  gap: 5px;
  display: flex;
  align-items: center;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

@keyframes micDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Send Button */
.chatbot-send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d6a4f, #1b4332);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.chatbot-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(45, 106, 79, 0.35);
}

.chatbot-send-btn svg {
  width: 18px; height: 18px;
  fill: none;
}

/* ═══ KIOSCO VOICE VISUALIZER ═══ */
.voice-visualizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
}
.voice-bar {
  width: 4px; height: 8px;
  background: var(--primary, #2d6a4f);
  border-radius: 2px;
  transition: height 0.1s ease;
}
.voice-visualizer.active .voice-bar {
  animation: voiceBounce 0.5s infinite alternate;
}
.voice-visualizer.active .voice-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-visualizer.active .voice-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-visualizer.active .voice-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-visualizer.active .voice-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes voiceBounce {
  from { height: 8px; }
  to { height: 32px; }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 480px) {
  .chatbot-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    border-radius: 20px;
  }

  .chatbot-wrapper {
    bottom: 16px;
    right: 16px;
  }

  .chatbot-bubble {
    width: 56px;
    height: 56px;
  }

  .chatbot-bubble-avatar {
    width: 48px;
    height: 48px;
  }

  .quick-reply-pill {
    font-size: 12px;
    padding: 6px 12px;
  }
}
