/* Widget del chatbot GS Bot.
   Usa los tokens de color definidos en index.html (:root) para no duplicar la paleta.
   Se ubica abajo a la IZQUIERDA: la esquina derecha ya la ocupan los botones
   flotantes de WhatsApp. */

.gsb-launcher {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 90;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--grad-mix, linear-gradient(135deg, #0a2fd4, #0d3cff));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(13, 60, 255, 0.4);
  transition: transform .3s, box-shadow .3s, opacity .2s;
  font-family: inherit;
}

.gsb-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(13, 60, 255, 0.5);
}

.gsb-launcher:focus-visible {
  outline: 3px solid #0d3cff;
  outline-offset: 3px;
}

.gsb-launcher svg { width: 28px; height: 28px; fill: currentColor; }

.gsb-launcher .gsb-close-icon { display: none; }
.gsb-launcher[aria-expanded="true"] .gsb-open-icon { display: none; }
.gsb-launcher[aria-expanded="true"] .gsb-close-icon { display: block; }

/* Punto de aviso del mensaje de bienvenida no leido */
.gsb-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
}

.gsb-tooltip {
  position: absolute;
  left: 72px;
  white-space: nowrap;
  background: var(--text, #111827);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.gsb-launcher:hover .gsb-tooltip { opacity: 1; }

/* Con el panel abierto el tooltip sobra y tapa contenido */
.gsb-launcher[aria-expanded="true"] .gsb-tooltip { display: none; }

/* ── Panel ── */

.gsb-panel {
  position: fixed;
  bottom: 100px;
  left: 28px;
  z-index: 95;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--surface, #fff);
  border: 1px solid var(--border-light, #e4e5ef);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(17, 24, 39, .18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: inherit;
  transform: translateY(12px) scale(.98);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, transform .22s ease, visibility .22s;
}

.gsb-panel.gsb-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.gsb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--grad-mix, linear-gradient(135deg, #0a2fd4, #0d3cff));
  color: #fff;
  flex-shrink: 0;
}

.gsb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  flex-shrink: 0;
}

.gsb-title { font-weight: 700; font-size: .98rem; line-height: 1.3; }

.gsb-status {
  font-size: .76rem;
  opacity: .9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gsb-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
}

.gsb-header-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  line-height: 0;
  opacity: .85;
}

.gsb-header-close:hover { opacity: 1; background: rgba(255, 255, 255, .15); }
.gsb-header-close svg { width: 18px; height: 18px; fill: currentColor; }

/* ── Mensajes ── */

.gsb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg, #f8f9ff);
  scroll-behavior: smooth;
}

.gsb-messages::-webkit-scrollbar { width: 6px; }
.gsb-messages::-webkit-scrollbar-thumb { background: var(--border, #dbdbe0); border-radius: 3px; }

.gsb-msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.gsb-msg.gsb-bot {
  align-self: flex-start;
  background: var(--surface, #fff);
  color: var(--text, #111827);
  border: 1px solid var(--border-light, #e4e5ef);
  border-bottom-left-radius: 4px;
}

.gsb-msg.gsb-user {
  align-self: flex-end;
  background: var(--primary, #0a2fd4);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.gsb-msg.gsb-error {
  align-self: stretch;
  max-width: 100%;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-size: .85rem;
}

.gsb-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.gsb-msg.gsb-bot a { color: var(--primary, #0a2fd4); }
.gsb-msg strong { font-weight: 700; }

.gsb-badge {
  align-self: center;
  background: rgba(13, 60, 255, .08);
  color: var(--primary, #0a2fd4);
  border: 1px solid rgba(13, 60, 255, .22);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 600;
}

/* Indicador de escritura */
.gsb-typing { display: flex; gap: 4px; align-items: center; padding: 14px; }
.gsb-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted-2, #9ba3af);
  animation: gsbBounce 1.3s infinite;
}
.gsb-typing span:nth-child(2) { animation-delay: .18s; }
.gsb-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes gsbBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Sugerencias rapidas */
.gsb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px; background: var(--bg, #f8f9ff); }

.gsb-chip {
  background: var(--surface, #fff);
  border: 1px solid var(--border-light, #e4e5ef);
  color: var(--primary, #0a2fd4);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: .81rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s, border-color .2s;
}

.gsb-chip:hover { background: rgba(13, 60, 255, .06); border-color: var(--primary, #0a2fd4); }

/* ── Entrada ── */

.gsb-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--border-light, #e4e5ef);
  background: var(--surface, #fff);
  flex-shrink: 0;
}

.gsb-input {
  flex: 1;
  border: 1px solid var(--border-light, #e4e5ef);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--text, #111827);
  background: var(--bg, #f8f9ff);
  resize: none;
  max-height: 110px;
  line-height: 1.5;
}

.gsb-input:focus { outline: none; border-color: var(--primary, #0a2fd4); background: #fff; }

.gsb-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 11px;
  background: var(--primary, #0a2fd4);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, opacity .2s;
}

.gsb-send:hover:not(:disabled) { background: var(--primary-light, #0d3cff); }
.gsb-send:disabled { opacity: .45; cursor: not-allowed; }
.gsb-send svg { width: 18px; height: 18px; fill: currentColor; }

.gsb-legal {
  padding: 0 14px 10px;
  font-size: .7rem;
  color: var(--muted-2, #9ba3af);
  text-align: center;
  background: var(--surface, #fff);
}

/* ── Movil ── */

@media (max-width: 560px) {
  .gsb-launcher { bottom: 20px; left: 20px; width: 54px; height: 54px; }
  .gsb-launcher svg { width: 25px; height: 25px; }
  .gsb-tooltip { display: none; }

  /* Anclado entre la barra de navegacion (fija, ~86px) y el lanzador, para que
     el encabezado del chat no quede tapado por el navbar. */
  .gsb-panel {
    left: 10px;
    right: 10px;
    top: 94px;
    bottom: 84px;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gsb-launcher, .gsb-panel { transition: none; }
  .gsb-typing span { animation: none; }
}
