/* Agente de ventas web — alineado a tokens SaludNova (--primary, --gradient) */

.sn-sales-chat {
  --sn-sales-primary: var(--primary, #581FF0);
  --sn-sales-hover: var(--primary-hover, #1FADF0);
  --sn-sales-dark: var(--primary-dark, #1F2AF0);
  --sn-sales-ink: #1a1f3c;
  --sn-sales-muted: #5b6280;
  --sn-sales-shell: #f4f6fc;
  --sn-sales-radius: 22px;
  font-family: "Montserrat", "Noto Sans", sans-serif;
  position: fixed;
  right: 22px;
  bottom: 88px;
  z-index: 1200;
  pointer-events: none;
}

.sn-sales-chat * {
  box-sizing: border-box;
}

.sn-sales-fab,
.sn-sales-panel.is-open {
  pointer-events: auto;
}

.sn-sales-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: var(--gradient, linear-gradient(120deg, #1FADF0 0%, #581FF0 55%, #1F2AF0 100%));
  background-size: 180% 180%;
  padding: 14px 18px 14px 16px;
  border-radius: 999px;
  box-shadow:
    0 14px 34px rgba(88, 31, 240, 0.35),
    0 4px 12px rgba(31, 42, 240, 0.18);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
  animation: snSalesFabIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both, snSalesGradient 8s ease infinite;
}

.sn-sales-fab:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 18px 40px rgba(88, 31, 240, 0.42),
    0 6px 16px rgba(31, 173, 240, 0.22);
}

.sn-sales-fab.is-open {
  padding: 16px;
  border-radius: 50%;
}

.sn-sales-fab.is-open .sn-sales-fab__label {
  max-width: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
}

.sn-sales-fab.is-open .sn-sales-fab__icon--chat {
  opacity: 0;
  transform: scale(0.4) rotate(-20deg);
  position: absolute;
}

.sn-sales-fab.is-open .sn-sales-fab__icon--close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  position: relative;
}

.sn-sales-fab__pulse {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(255, 255, 255, 0.45);
  animation: snSalesPulse 2.4s ease-out infinite;
  pointer-events: none;
}

.sn-sales-fab.is-open .sn-sales-fab__pulse {
  display: none;
}

.sn-sales-fab__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.3s ease;
}

.sn-sales-fab__icon--close {
  opacity: 0;
  position: absolute;
  transform: scale(0.4) rotate(40deg);
}

.sn-sales-fab__label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  max-width: 140px;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.3s ease, opacity 0.25s ease;
}

.sn-sales-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 140px));
  display: none;
  flex-direction: column;
  border-radius: var(--sn-sales-radius);
  overflow: hidden;
  background: #fff;
  box-shadow:
    0 28px 60px rgba(26, 31, 60, 0.22),
    0 0 0 1px rgba(88, 31, 240, 0.08);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1), transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.sn-sales-panel.is-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Con formulario de datos: reserva el hilo de conversación arriba (no lo tapa el intake). */
.sn-sales-panel.is-open.sn-sales-panel--intake {
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto;
  align-content: stretch;
}

.sn-sales-panel.is-open.sn-sales-panel--intake .sn-sales-panel__thread {
  min-height: 180px;
  max-height: none;
}

.sn-sales-panel.is-open.sn-sales-panel--intake .sn-sales-panel__intake,
.sn-sales-panel.is-open.sn-sales-panel--intake .sn-sales-panel__footnote {
  min-height: 0;
}

.sn-sales-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  color: #fff;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.22) 0, transparent 42%),
    linear-gradient(125deg, #1FADF0 0%, #581FF0 48%, #1F2AF0 100%);
}

.sn-sales-panel__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sn-sales-panel__avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(6px);
}

.sn-sales-panel__title {
  margin: 0;
  font-family: "Oswald", "Montserrat", sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.sn-sales-panel__status {
  margin: 3px 0 0;
  font-size: 12px;
  opacity: 0.95;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sn-sales-panel__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7dffa8;
  box-shadow: 0 0 0 0 rgba(125, 255, 168, 0.7);
  animation: snSalesOnline 1.8s ease-out infinite;
}

.sn-sales-panel__minimize {
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sn-sales-panel__minimize:hover {
  background: rgba(255, 255, 255, 0.26);
}

.sn-sales-panel__thread {
  flex: 1 1 auto;
  min-height: 168px;
  overflow: auto;
  padding: 12px 14px;
  background:
    radial-gradient(circle at 0% 0%, rgba(88, 31, 240, 0.06) 0, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(31, 173, 240, 0.08) 0, transparent 42%),
    var(--sn-sales-shell);
  scroll-behavior: smooth;
}

.sn-sales-msg {
  display: flex;
  margin-bottom: 10px;
  animation: snSalesMsgIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sn-sales-msg.is-user {
  justify-content: flex-end;
}

.sn-sales-msg.is-assistant,
.sn-sales-msg.is-system {
  justify-content: flex-start;
}

.sn-sales-msg__bubble {
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--sn-sales-ink);
  word-break: break-word;
  white-space: normal;
}

.sn-sales-msg__bubble strong {
  font-weight: 700;
}

.sn-sales-msg__bubble em {
  font-style: italic;
}

.sn-sales-msg__bubble .sn-sales-li {
  display: block;
  position: relative;
  padding-left: 1.1em;
  margin: 0.35em 0;
}

.sn-sales-msg__bubble .sn-sales-li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: inherit;
  opacity: 0.75;
}

.sn-sales-msg.is-assistant .sn-sales-msg__bubble,
.sn-sales-msg.is-system .sn-sales-msg__bubble {
  background: #fff;
  border: 1px solid rgba(88, 31, 240, 0.08);
  border-bottom-left-radius: 6px;
  box-shadow: 0 6px 16px rgba(26, 31, 60, 0.05);
}

.sn-sales-msg.is-user .sn-sales-msg__bubble {
  color: #fff;
  background: linear-gradient(135deg, #581FF0 0%, #1F2AF0 100%);
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 18px rgba(88, 31, 240, 0.28);
}

.sn-sales-msg.is-system .sn-sales-msg__bubble {
  background: #eef3ff;
  color: #33406a;
  font-size: 13px;
}

.sn-sales-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 12px 14px;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(88, 31, 240, 0.08);
}

.sn-sales-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sn-sales-primary);
  opacity: 0.35;
  animation: snSalesTyping 1.2s ease-in-out infinite;
}

.sn-sales-typing span:nth-child(2) { animation-delay: 0.15s; }
.sn-sales-typing span:nth-child(3) { animation-delay: 0.3s; }

.sn-sales-panel__intake {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 0 0 auto;
  padding: 7px 12px 5px;
  border-top: 1px solid rgba(88, 31, 240, 0.08);
  background: #fff;
  position: relative;
  animation: snSalesMsgIn 0.35s ease both;
}

.sn-sales-panel__intake.is-hidden,
.sn-sales-panel__composer.is-hidden {
  display: none !important;
}

.sn-sales-intake__intro {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  color: var(--sn-sales-muted);
}

.sn-sales-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--sn-sales-ink);
}

.sn-sales-field input {
  width: 100%;
  border: 1px solid #dde2f2;
  border-radius: 12px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sn-sales-ink);
  background: #fafbff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sn-sales-field input:focus {
  outline: none;
  border-color: rgba(88, 31, 240, 0.45);
  box-shadow: 0 0 0 3px rgba(88, 31, 240, 0.12);
  background: #fff;
}

.sn-sales-consents {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 0;
}

.sn-sales-check {
  display: grid;
  grid-template-columns: 15px 1fr;
  gap: 6px;
  align-items: start;
  margin: 0;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--sn-sales-muted);
  cursor: pointer;
}

.sn-sales-check input {
  width: 14px;
  height: 14px;
  margin-top: 1px;
  accent-color: var(--sn-sales-primary);
}

.sn-sales-check a {
  color: var(--sn-sales-primary);
  text-decoration: underline;
  font-weight: 600;
}

.sn-sales-intake__error {
  margin: 0;
  font-size: 11px;
  color: #b42318;
  line-height: 1.3;
}

.sn-sales-intake__submit {
  border: 0;
  border-radius: 12px;
  padding: 8px 12px;
  margin-top: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #581FF0, #1F2AF0);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sn-sales-intake__submit:hover:not(:disabled) {
  transform: translateY(-1px);
}

.sn-sales-intake__submit:disabled {
  opacity: 0.55;
  cursor: wait;
}

.sn-sales-panel__composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 12px 8px;
  border-top: 1px solid rgba(88, 31, 240, 0.08);
  background: #fff;
  position: relative;
}

.sn-sales-panel__composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid #dde2f2;
  border-radius: 14px;
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--sn-sales-ink);
  background: #fafbff;
  min-height: 46px;
  max-height: 110px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sn-sales-panel__composer textarea:focus {
  outline: none;
  border-color: rgba(88, 31, 240, 0.45);
  box-shadow: 0 0 0 3px rgba(88, 31, 240, 0.12);
  background: #fff;
}

.sn-sales-send {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #581FF0, #1F2AF0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  align-self: end;
}

.sn-sales-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.sn-sales-send:disabled {
  opacity: 0.55;
  cursor: wait;
}

.sn-sales-panel__footnote {
  margin: 0;
  padding: 0 12px 8px;
  font-size: 10.5px;
  color: var(--sn-sales-muted);
  background: #fff;
  line-height: 1.3;
  flex: 0 0 auto;
}

.sn-sales-hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.sn-sales-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes snSalesFabIn {
  from { opacity: 0; transform: translateY(18px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes snSalesGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes snSalesPulse {
  0% { transform: scale(1); opacity: 0.7; }
  70% { transform: scale(1.12); opacity: 0; }
  100% { transform: scale(1.12); opacity: 0; }
}

@keyframes snSalesOnline {
  0% { box-shadow: 0 0 0 0 rgba(125, 255, 168, 0.65); }
  70% { box-shadow: 0 0 0 8px rgba(125, 255, 168, 0); }
  100% { box-shadow: 0 0 0 0 rgba(125, 255, 168, 0); }
}

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

@keyframes snSalesTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-3px); opacity: 1; }
}

@media only screen and (max-width: 575px) {
  .sn-sales-chat {
    right: 12px;
    bottom: 72px;
  }

  .sn-sales-fab__label {
    display: none;
  }

  .sn-sales-fab {
    padding: 15px;
    border-radius: 50%;
  }

  .sn-sales-panel {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: 78px;
    width: auto;
    height: min(70vh, 560px);
  }
}
