.jsa-root {
  --jsa-accent: #25d366;
  --jsa-accent-dark: #128c7e;
  --jsa-bg: #fff;
  --jsa-border: #e2e8f0;
  --jsa-text: #1f2937;
  --jsa-muted: #64748b;
  position: fixed;
  right: 20px;
  bottom: 20px;
  left: auto;
  z-index: 99999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  color: var(--jsa-text);
  display: none;
}

.jsa-root.jsa-ready {
  display: block;
}

/* Mini-carrito Astra (z-index 10000): el FAB no debe tapar botones ni cantidad. */
html.ast-mobile-cart-active .jsa-root {
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

.jsa-fab {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px 12px 14px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(37, 211, 102, 0.45);
  font-weight: 700;
  max-width: calc(100vw - 32px);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.jsa-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(37, 211, 102, 0.55);
}

.jsa-fab-open {
  opacity: 0.92;
}

.jsa-fab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.jsa-fab-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.jsa-fab-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  text-align: left;
}

.jsa-fab-title {
  font-size: 15px;
}

.jsa-fab-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.9;
}

.jsa-panel {
  position: absolute;
  right: 0;
  left: auto;
  bottom: calc(100% + 12px);
  width: min(360px, calc(100vw - 40px));
  max-height: min(520px, calc(100vh - 120px));
  background: var(--jsa-bg);
  border: 1px solid var(--jsa-border);
  border-radius: 16px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.jsa-root.is-open .jsa-panel {
  display: flex !important;
}

.jsa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--jsa-border);
  background: linear-gradient(180deg, #f0fdf4 0%, #f8fafc 100%);
}

.jsa-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.jsa-header-text strong {
  font-size: 15px;
  color: var(--jsa-text);
}

.jsa-powered {
  font-size: 11px;
  color: var(--jsa-muted);
}

.jsa-close {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--jsa-muted);
  flex-shrink: 0;
  z-index: 3;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.jsa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}

.jsa-msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.jsa-msg-bot {
  align-self: flex-start;
  background: #f1f5f9;
}

.jsa-msg-user {
  align-self: flex-end;
  background: #dcfce7;
}

.jsa-product {
  border: 1px solid var(--jsa-border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  gap: 8px;
  margin-top: 6px;
  background: #fff;
}

.jsa-product img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.jsa-product a {
  color: var(--jsa-accent-dark);
  font-weight: 600;
  text-decoration: none;
}

.jsa-wa {
  display: inline-block;
  margin-top: 8px;
  background: #25d366;
  color: #fff !important;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

.jsa-chips {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 10px;
  border-top: 1px solid var(--jsa-border);
  background: #fafafa;
}

.jsa-chips-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.jsa-chips-section:first-child {
  padding-top: 10px;
}

.jsa-chips-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--jsa-muted);
}

.jsa-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.jsa-chip {
  border: 1px solid var(--jsa-border);
  background: #fff;
  color: var(--jsa-text);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-decoration: none;
  display: inline-block;
}

.jsa-chip-cat,
.jsa-chip-faq {
  border-color: #86efac;
  background: #f0fdf4;
}

.jsa-chip-cat:hover,
.jsa-chip-faq:hover {
  border-color: #22c55e;
  background: #dcfce7;
  color: var(--jsa-text);
}

.jsa-chip-wa {
  border-color: #25d366;
  background: #25d366;
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
}

.jsa-chip-wa svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.jsa-chip-wa:hover {
  background: #1ebe57;
  border-color: #1ebe57;
  color: #fff !important;
}

.jsa-form {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--jsa-border);
}

.jsa-form input {
  flex: 1;
  border: 1px solid var(--jsa-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--jsa-text);
  background: #fff;
}

.jsa-form button {
  border: 0;
  background: var(--jsa-accent-dark);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

@media (max-width: 480px) {
  .jsa-root {
    right: 12px;
    bottom: 12px;
    left: auto;
  }

  .jsa-fab-sub {
    display: none;
  }

  .jsa-fab {
    padding: 12px 16px 12px 12px;
  }
}
