/* ============================================================
   Asistente Saberly — estilos del widget de la landing
   Todo va prefijado con .sb-asistente para no tocar la landing.
   ============================================================ */

.sb-asistente,
.sb-asistente * {
  box-sizing: border-box;
}

.sb-asistente {
  --sb-navy: #0f1e42;
  --sb-primary: #1e3a8a;
  --sb-primary-600: #24449e;
  --sb-gold: #c9a227;
  --sb-gold-soft: #fbf3d6;
  --sb-green: #128c7e;
  --sb-green-600: #0e7568;
  --sb-ink: #1f2937;
  --sb-muted: #64748b;
  --sb-line: #e2e8f0;
  --sb-bg: #f8fafc;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 890;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--sb-ink);
  line-height: 1.45;
}

/* ---------- Botón flotante ---------- */
.sb-asistente-boton {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 16px 8px 9px;
  border: 1px solid rgba(201, 162, 39, 0.6);
  border-radius: 999px;
  background: var(--sb-navy);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(15, 30, 66, 0.32);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.sb-asistente-boton:hover {
  transform: translateY(-2px);
  background: #162b5c;
  box-shadow: 0 16px 34px rgba(15, 30, 66, 0.4);
}

.sb-asistente-boton:focus-visible,
.sb-asistente-cerrar:focus-visible,
.sb-asistente-form button:focus-visible,
.sb-asistente-sugerencias button:focus-visible,
.sb-asistente a:focus-visible,
.sb-asistente textarea:focus-visible {
  outline: 3px solid rgba(201, 162, 39, 0.85);
  outline-offset: 2px;
}

.sb-asistente-boton-icono {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sb-gold);
  color: var(--sb-navy);
  flex: none;
}

.sb-asistente-boton-icono svg {
  width: 19px;
  height: 19px;
  display: block;
}

.sb-asistente-boton-texto {
  white-space: nowrap;
}

.sb-asistente-notificacion {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 9px rgba(127, 29, 29, 0.3);
  animation: sb-asistente-notificar 2.4s ease-in-out infinite;
}

.sb-asistente-notificacion[hidden] {
  display: none !important;
}

@keyframes sb-asistente-notificar {
  0%, 68%, 100% { transform: scale(1); }
  74% { transform: scale(1.14); }
  80% { transform: scale(1); }
}

.sb-asistente[data-abierto="1"] .sb-asistente-boton {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

/* ---------- Panel ---------- */
.sb-asistente-panel[hidden] {
  display: none !important;
}

.sb-asistente-panel {
  position: fixed;
  right: 18px;
  bottom: 84px;
  width: 380px;
  max-width: calc(100vw - 36px);
  height: min(520px, calc(100dvh - 154px));
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--sb-line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 30, 66, 0.28);
  animation: sb-asistente-entrar 0.2s ease-out;
}

@keyframes sb-asistente-entrar {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sb-asistente-cabecera {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: linear-gradient(135deg, var(--sb-navy) 0%, var(--sb-primary) 100%);
  color: #fff;
  flex: none;
}

.sb-asistente-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sb-gold);
  color: var(--sb-navy);
  font-family: "Sora", "Inter", sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.2px;
}

.sb-asistente-titulos {
  min-width: 0;
  flex: 1;
}

.sb-asistente-titulos h2 {
  margin: 0;
  color: #fff;
  font-family: "Sora", "Inter", sans-serif;
  font-size: 0.98rem;
  line-height: 1.2;
  letter-spacing: -0.1px;
}

.sb-asistente-titulos p {
  margin: 2px 0 0;
  color: #c7d2fe;
  font-size: 0.75rem;
  line-height: 1.3;
}

.sb-asistente-cerrar {
  flex: none;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.sb-asistente-cerrar:hover {
  background: rgba(255, 255, 255, 0.24);
}

.sb-asistente-aviso {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0;
  padding: 8px 14px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #854d0e;
  font-size: 0.73rem;
  line-height: 1.35;
  flex: none;
}

.sb-asistente-aviso svg {
  width: 13px;
  height: 13px;
  flex: none;
  margin-top: 1px;
}

/* ---------- Mensajes ---------- */
.sb-asistente-mensajes {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 13px 6px;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  gap: 9px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.sb-asistente-mensajes::-webkit-scrollbar {
  width: 7px;
}

.sb-asistente-mensajes::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

.sb-asistente-fila {
  display: flex;
  width: 100%;
}

.sb-asistente-fila--usuario {
  justify-content: flex-end;
}

.sb-asistente-fila--asistente {
  justify-content: flex-start;
}

.sb-asistente-burbuja {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sb-asistente-fila--asistente .sb-asistente-burbuja {
  background: #fff;
  border: 1px solid var(--sb-line);
  border-bottom-left-radius: 4px;
  color: var(--sb-ink);
  box-shadow: 0 1px 2px rgba(15, 30, 66, 0.04);
}

.sb-asistente-fila--usuario .sb-asistente-burbuja {
  background: var(--sb-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.sb-asistente-burbuja p {
  margin: 0;
}

.sb-asistente-accion {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--sb-green);
  color: #fff !important;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
}

.sb-asistente-accion:hover {
  background: var(--sb-green-600);
}

.sb-asistente-accion svg {
  width: 14px;
  height: 14px;
}

/* Indicador de escritura */
.sb-asistente-escribiendo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 18px;
}

.sb-asistente-escribiendo span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: sb-asistente-punto 1s infinite ease-in-out;
}

.sb-asistente-escribiendo span:nth-child(2) { animation-delay: 0.14s; }
.sb-asistente-escribiendo span:nth-child(3) { animation-delay: 0.28s; }

@keyframes sb-asistente-punto {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ---------- Sugerencias ---------- */
.sb-asistente-sugerencias {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 13px 9px;
  background: var(--sb-bg);
  flex: none;
}

.sb-asistente-sugerencias[hidden] {
  display: none !important;
}

.sb-asistente-sugerencias button {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--sb-primary);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.sb-asistente-sugerencias button:hover {
  border-color: var(--sb-primary);
  background: #eef3ff;
}

/* ---------- Formulario ---------- */
.sb-asistente-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 11px;
  background: #fff;
  border-top: 1px solid var(--sb-line);
  flex: none;
}

.sb-asistente-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 112px;
  resize: none;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  color: var(--sb-ink);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* evita el zoom automático en iOS */
  line-height: 1.35;
}

.sb-asistente-form textarea::placeholder {
  color: #94a3b8;
}

.sb-asistente-form textarea:focus {
  border-color: var(--sb-primary);
}

.sb-asistente-form > button {
  flex: none;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: var(--sb-primary);
  color: #fff;
  cursor: pointer;
}

.sb-asistente-form > button:hover {
  background: var(--sb-primary-600);
}

.sb-asistente-form > button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.sb-asistente-form > button svg {
  width: 19px;
  height: 19px;
}

/* ---------- Pie ---------- */
.sb-asistente-pie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 13px 10px;
  background: #fff;
  border-top: 1px solid #f1f5f9;
  flex: none;
}

.sb-asistente-pie a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
}

.sb-asistente-pie a svg {
  width: 14px;
  height: 14px;
}

.sb-asistente-wa {
  color: var(--sb-green);
}

.sb-asistente-wa:hover {
  color: var(--sb-green-600);
}

.sb-asistente-demo {
  color: var(--sb-primary);
  margin-left: auto;
}

.sb-asistente-demo:hover {
  color: var(--sb-primary-600);
}

/* Accesibilidad: texto solo para lectores */
.sb-asistente-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- Móvil ---------- */
@media (max-width: 520px) {
  .sb-asistente {
    right: 14px;
    bottom: 14px;
  }

  .sb-asistente-boton {
    min-height: 50px;
    padding: 7px 13px 7px 8px;
    font-size: 0.84rem;
  }

  .sb-asistente-boton-icono {
    width: 34px;
    height: 34px;
  }

  .sb-asistente-notificacion {
    top: -6px;
    right: -4px;
  }

  .sb-asistente-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }

  .sb-asistente-cabecera {
    padding-top: calc(13px + env(safe-area-inset-top, 0px));
  }

  .sb-asistente-form {
    padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  }

  .sb-asistente-pie {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb-asistente-boton,
  .sb-asistente-panel,
  .sb-asistente-notificacion,
  .sb-asistente-escribiendo span {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .sb-asistente {
    display: none !important;
  }
}
