/* ============================================================
   QStrauss Chatbot — Estilos
   Colores: Navy QStrauss #1B2A4A, Dorado Accent #D4A853, Oscuro #1A1A2E, Blanco #FFFFFF
   ============================================================ */

:root {
  --qs-primary:    #2EBD8E; /* QStrauss Green */
  --qs-primary-dk: #1fa870; /* QStrauss Green Dark */
  --qs-accent:     #D4A853; /* Gold Accent */
  --qs-dark:       #0D1F1A; /* QStrauss Deep Green */
  --qs-dark-2:     #1A2E27; /* QStrauss Mid Green */
  --qs-white:      #ffffff;
  --qs-gray-50:    #f8f9fa;
  --qs-gray-100:   #f1f3f5;
  --qs-gray-300:   #ced4da;
  --qs-gray-500:   #868e96;
  --qs-gray-700:   #495057;
  --qs-radius:     16px;
  --qs-radius-sm:  8px;
  --qs-shadow:     0 8px 32px rgba(0,0,0,0.18);
  --qs-font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --qs-z:          999999;
}

/* ── Wrapper ── */
#qs-chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--qs-z);
  font-family: var(--qs-font);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Botón flotante ── */
#qs-chatbot-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--qs-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(46, 189, 142, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  color: var(--qs-white);
  outline: none;
}

#qs-chatbot-toggle:hover {
  background: var(--qs-primary-dk);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(46, 189, 142, 0.5);
}

#qs-chatbot-toggle:focus-visible {
  outline: 3px solid rgba(46, 189, 142, 0.5);
  outline-offset: 3px;
}

#qs-chatbot-toggle svg {
  width: 24px;
  height: 24px;
}

/* Punto de notificación */
#qs-notification-dot {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #FFD700;
  border-radius: 50%;
  border: 2px solid var(--qs-white);
  animation: qs-pulse 2s infinite;
}

@keyframes qs-pulse {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ── Ventana del chat ── */
#qs-chatbot-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-height: 540px;
  background: var(--qs-white);
  border-radius: var(--qs-radius);
  box-shadow: var(--qs-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(16px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}

#qs-chatbot-window.qs-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
#qs-chat-header {
  background: linear-gradient(135deg, var(--qs-dark) 0%, var(--qs-dark-2) 100%);
  color: var(--qs-white);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#qs-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--qs-primary);
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
}

#qs-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#qs-avatar-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
  font-size: 13px;
  color: var(--qs-white);
  background: var(--qs-primary);
}

#qs-chat-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#qs-chat-header-info strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.qs-status {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: 4px;
}

.qs-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: qs-blink 2.5s infinite;
}

@keyframes qs-blink {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.4; }
}

#qs-chat-minimize {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: var(--qs-radius-sm);
  transition: color 0.15s, background 0.15s;
}

#qs-chat-minimize:hover {
  color: var(--qs-white);
  background: rgba(255,255,255,0.1);
}

/* ── Área de mensajes ── */
#qs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

#qs-chat-messages::-webkit-scrollbar { width: 4px; }
#qs-chat-messages::-webkit-scrollbar-track { background: transparent; }
#qs-chat-messages::-webkit-scrollbar-thumb { background: var(--qs-gray-300); border-radius: 4px; }

/* ── Burbujas ── */
.qs-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: qs-fadeIn 0.2s ease;
}

@keyframes qs-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.qs-msg--bot {
  background: var(--qs-gray-100);
  color: var(--qs-gray-700);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.qs-msg--user {
  background: var(--qs-primary);
  color: var(--qs-white);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Indicador de "escribiendo" */
.qs-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--qs-gray-100);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.qs-typing span {
  width: 7px;
  height: 7px;
  background: var(--qs-gray-500);
  border-radius: 50%;
  animation: qs-bounce 1.2s infinite;
}

.qs-typing span:nth-child(2) { animation-delay: 0.2s; }
.qs-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes qs-bounce {
  0%, 60%, 100% { transform: translateY(0);    }
  30%            { transform: translateY(-6px); }
}

/* ── Opciones rápidas ── */
#qs-quick-options {
  padding: 6px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  max-height: 140px;
  overflow-y: auto;
}

#qs-quick-options::-webkit-scrollbar { width: 3px; }
#qs-quick-options::-webkit-scrollbar-thumb { background: var(--qs-gray-300); border-radius: 3px; }

.qs-option-btn {
  padding: 7px 12px;
  border: 1.5px solid var(--qs-primary);
  border-radius: 20px;
  background: transparent;
  color: var(--qs-primary);
  font-size: 12.5px;
  font-family: var(--qs-font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
  font-weight: 500;
}

.qs-option-btn:hover {
  background: var(--qs-primary);
  color: var(--qs-white);
  transform: translateY(-1px);
}

.qs-option-btn:active {
  transform: translateY(0);
}

/* ── Input ── */
#qs-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--qs-gray-100);
  flex-shrink: 0;
  background: var(--qs-white);
}

#qs-chat-input {
  flex: 1;
  border: 1.5px solid var(--qs-gray-300);
  border-radius: 24px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: var(--qs-font);
  color: var(--qs-dark);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--qs-gray-50);
}

#qs-chat-input::placeholder { color: var(--qs-gray-500); }

#qs-chat-input:focus {
  border-color: var(--qs-primary);
  box-shadow: 0 0 0 3px rgba(46, 189, 142, 0.1);
  background: var(--qs-white);
}

#qs-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--qs-primary);
  color: var(--qs-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#qs-chat-send:hover  { background: var(--qs-primary-dk); transform: scale(1.08); }
#qs-chat-send:active { transform: scale(0.96); }

#qs-chat-send svg {
  width: 18px;
  height: 18px;
}

/* ── Footer ── */
#qs-chat-footer {
  text-align: center;
  padding: 5px 12px 8px;
  font-size: 11px;
  color: var(--qs-gray-500);
  background: var(--qs-white);
  flex-shrink: 0;
}

#qs-chat-footer a {
  color: var(--qs-primary);
  text-decoration: none;
  font-weight: 600;
}

#qs-chat-footer a:hover { text-decoration: underline; }

/* ── Tooltip proactivo ── */
#qs-preview-tip {
  position: absolute;
  bottom: 68px;
  right: 0;
  background: var(--qs-white);
  color: var(--qs-dark);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  animation: qs-tipSlide 0.3s ease;
  transition: transform 0.15s, box-shadow 0.15s;
}

#qs-preview-tip:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}

#qs-preview-tip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: var(--qs-white);
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.08);
}

#qs-preview-tip small {
  display: block;
  color: var(--qs-primary);
  font-weight: 600;
  font-size: 11px;
  margin-top: 2px;
}

@keyframes qs-tipSlide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ── Opciones: permitir wrap en botones largos ── */
.qs-option-btn {
  white-space: normal;
  text-align: left;
}

/* ── Responsive móvil ── */
@media (max-width: 480px) {
  #qs-chatbot-wrapper {
    bottom: 16px;
    right: 12px;
    left: 12px;
  }

  #qs-chatbot-window {
    width: 100%;
    max-height: 75vh;
    bottom: 68px;
    right: 0;
    left: 0;
    border-radius: var(--qs-radius) var(--qs-radius) 0 0;
  }

  #qs-chatbot-toggle {
    position: absolute;
    right: 0;
    bottom: 0;
  }

  #qs-preview-tip {
    right: 0;
    left: auto;
    max-width: calc(100vw - 100px);
    white-space: normal;
  }

  .qs-option-btn {
    font-size: 12px;
    padding: 6px 10px;
  }
}
