#jx-chat-widget {
  --jx-teal: #0F4C44;
  --jx-teal-dark: #0A3832;
  --jx-orange: #DD7541;
  --jx-orange-dark: #C4602F;
  --jx-cream: #FBF3E7;
  --jx-sage: #D9E8DE;
  --jx-text: #1A2E2A;
}

.jx-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.jx-chat-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--jx-teal) 0%, var(--jx-orange) 130%);
  box-shadow: 0 6px 18px rgba(15, 76, 68, 0.35);
  transition: transform 0.15s ease;
}

.jx-chat-toggle:hover {
  transform: scale(1.05);
}

.jx-chat-toggle .jx-icon-close {
  display: none;
}

.jx-chat-widget.jx-open .jx-chat-toggle .jx-icon-chat {
  display: none;
}

.jx-chat-widget.jx-open .jx-chat-toggle .jx-icon-close {
  display: block;
}

.jx-chat-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(15, 76, 68, 0.28);
  overflow: hidden;
}

.jx-chat-panel[hidden] {
  display: none;
}

.jx-chat-header {
  background: linear-gradient(135deg, var(--jx-teal) 0%, #1B6358 100%);
  color: #fff;
  padding: 18px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.jx-chat-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.jx-chat-title {
  font-size: 17px;
  font-weight: 700;
}

.jx-chat-subtitle {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.4;
  max-width: 280px;
}

.jx-chat-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  opacity: 0.85;
}

.jx-chat-header button:hover {
  opacity: 1;
}

.jx-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  min-height: 240px;
  max-height: 340px;
  background: var(--jx-cream);
}

.jx-chat-starters-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--jx-text);
  margin: 4px 0 2px;
}

.jx-chat-starters-subtitle {
  font-size: 12.5px;
  color: #5c6b66;
  margin: 0 0 12px;
}

.jx-starter-chip {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--jx-sage);
  color: var(--jx-teal-dark);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.jx-starter-chip:hover {
  border-color: var(--jx-orange);
  background: #fff8f2;
}

.jx-chat-msg {
  margin-bottom: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  max-width: 88%;
}

.jx-chat-msg-user {
  background: var(--jx-teal);
  color: #fff;
  margin-left: auto;
  text-align: right;
}

.jx-chat-msg-assistant {
  background: #fff;
  color: var(--jx-text);
  border: 1px solid #eee1d2;
}

.jx-chat-msg-products {
  background: var(--jx-sage);
  color: var(--jx-teal-dark);
  font-size: 12.5px;
  border: none;
}

/* Animated response indicator */
.jx-chat-typing-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 2px 0 10px;
  max-width: 94%;
}

.jx-chat-typing-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--jx-teal) 0%, #27796d 100%);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.25px;
  box-shadow: 0 3px 10px rgba(15, 76, 68, 0.18);
}

.jx-chat-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 13px 13px 13px 4px;
  border: 1px solid #eadfce;
  background: rgba(255, 255, 255, 0.96);
  color: #5b6864;
  box-shadow: 0 3px 12px rgba(15, 76, 68, 0.07);
}

.jx-chat-typing-label {
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.jx-chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 27px;
}

.jx-chat-typing-dots > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jx-orange);
  opacity: 0.35;
  transform: translateY(0);
  animation: jxTypingBounce 1.15s infinite ease-in-out;
}

.jx-chat-typing-dots > span:nth-child(2) { animation-delay: 0.14s; }
.jx-chat-typing-dots > span:nth-child(3) { animation-delay: 0.28s; }

@keyframes jxTypingBounce {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.jx-chat-msg-enter {
  animation: jxMessageIn 0.22s ease-out both;
}

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

#jx-chat-widget.jx-open > .jx-chat-panel {
  animation: jxPanelIn 0.2s ease-out both;
  transform-origin: bottom right;
}

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

.jx-chat-help-link {
  display: block;
  padding: 9px 14px;
  border-top: 1px solid #eee;
  color: var(--jx-teal-dark);
  font-size: 12px;
  line-height: 1.4;
  text-decoration: underline;
}
.jx-chat-help-link:hover,
.jx-chat-help-link:focus-visible { color: var(--jx-orange-dark); }

.jx-chat-form {
  display: flex;
  border-top: 1px solid #eee;
  padding: 8px;
  gap: 8px;
}

.jx-chat-form input {
  flex: 1;
  border: 1px solid #e2e2e2;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13.5px;
  outline: none;
}

.jx-chat-form input:focus {
  border-color: var(--jx-teal);
}

.jx-chat-form button {
  border: none;
  background: var(--jx-orange);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.jx-chat-form button:hover {
  background: var(--jx-orange-dark);
}

.jx-chat-disclaimer {
  font-size: 11px;
  color: #8a8a8a;
  text-align: center;
  padding: 8px;
  margin: 0;
  border-top: 1px solid #f5f5f5;
}

.jx-chat-disclaimer a {
  color: var(--jx-teal);
  text-decoration: underline;
}

@media (max-width: 420px) {
  .jx-chat-panel {
    width: calc(100vw - 40px);
  }
}

/* =========================================================
   Theme / Elementor conflict protection
   Keep the chatbot visually isolated from host-site styles.
   ========================================================= */

#jx-chat-widget,
#jx-chat-widget *,
#jx-chat-widget *::before,
#jx-chat-widget *::after {
  box-sizing: border-box;
}

#jx-chat-widget button,
#jx-chat-widget input {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

/* Floating launcher */
#jx-chat-widget > #jx-chat-toggle.jx-chat-toggle {
  margin: 0 !important;
  padding: 0 !important;
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  border: 0 !important;
  border-radius: 999px !important;
  color: #fff !important;
  background: linear-gradient(135deg, var(--jx-teal) 0%, var(--jx-orange) 130%) !important;
  box-shadow: 0 6px 18px rgba(15, 76, 68, 0.35) !important;
  line-height: 1 !important;
}

/* Header close button */
#jx-chat-widget .jx-chat-header #jx-chat-close {
  margin: 0 0 0 8px !important;
  padding: 0 !important;
  width: auto !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #fff !important;
  box-shadow: none !important;
  font-size: 20px !important;
  font-weight: 400 !important;
  line-height: 1 !important;
}

/* Starter buttons */
#jx-chat-widget .jx-chat-starters > button.jx-starter-chip {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 0 8px 0 !important;
  padding: 10px 12px !important;
  border: 1.5px solid var(--jx-sage) !important;
  border-radius: 10px !important;
  background: #fff !important;
  color: var(--jx-teal-dark) !important;
  box-shadow: none !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  text-align: left !important;
  text-decoration: none !important;
}

#jx-chat-widget .jx-chat-starters > button.jx-starter-chip:hover,
#jx-chat-widget .jx-chat-starters > button.jx-starter-chip:focus {
  border-color: var(--jx-orange) !important;
  background: #fff8f2 !important;
  color: var(--jx-teal-dark) !important;
}

/* Contact-info toggle */
#jx-chat-widget > .jx-chat-panel > button.jx-lead-toggle {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 9px 14px !important;
  border: 0 !important;
  border-top: 1px solid #f0f0f0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--jx-orange-dark) !important;
  box-shadow: none !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  text-align: left !important;
  text-decoration: none !important;
}

/* Lead form controls */
#jx-chat-widget .jx-lead-form input {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 7px 9px !important;
  border: 1px solid #dcdfe3 !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: var(--jx-text) !important;
  box-shadow: none !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}

#jx-chat-widget .jx-lead-form button[type="submit"] {
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 7px 9px !important;
  border: 0 !important;
  border-radius: 6px !important;
  background: var(--jx-orange) !important;
  color: #fff !important;
  box-shadow: none !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
}

/* Message input */
#jx-chat-widget #jx-chat-form.jx-chat-form {
  margin: 0 !important;
}

#jx-chat-widget #jx-chat-input {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  height: 38px !important;
  min-height: 38px !important;
  margin: 0 !important;
  padding: 10px 14px !important;
  border: 1px solid #e2e2e2 !important;
  border-radius: 999px !important;
  background: #fff !important;
  color: var(--jx-text) !important;
  box-shadow: none !important;
  font-size: 13.5px !important;
  line-height: 1.2 !important;
}

#jx-chat-widget #jx-chat-input:focus {
  border-color: var(--jx-teal) !important;
  outline: none !important;
}

/* Send button */
#jx-chat-widget #jx-chat-form > button[type="submit"] {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 38px !important;
  width: 38px !important;
  min-width: 38px !important;
  max-width: 38px !important;
  height: 38px !important;
  min-height: 38px !important;
  max-height: 38px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: var(--jx-orange) !important;
  color: #fff !important;
  box-shadow: none !important;
  line-height: 1 !important;
}

/* Prevent theme paragraph/link margins from changing the footer. */
#jx-chat-widget .jx-chat-disclaimer {
  margin: 0 !important;
}

#jx-chat-widget .jx-chat-disclaimer a {
  color: var(--jx-teal) !important;
  text-decoration: underline !important;
}


/* =========================================================
   Responsive viewport sizing (iPad / iPhone / large text)
   Keep the composer and submit button inside the viewport.
   ========================================================= */
@media (max-width: 1024px) {
  #jx-chat-widget > .jx-chat-panel {
    width: min(340px, calc(100vw - 32px));
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
  }

  #jx-chat-widget .jx-chat-log {
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #jx-chat-widget .jx-chat-header,
  #jx-chat-widget #jx-chat-form.jx-chat-form,
  #jx-chat-widget .jx-chat-disclaimer,
  #jx-chat-widget .jx-lead-form {
    flex-shrink: 0;
  }
}

@media (max-width: 600px) {
  #jx-chat-widget.jx-chat-widget {
    right: 12px;
    bottom: 12px;
  }

  #jx-chat-widget > .jx-chat-panel {
    right: 0;
    bottom: 64px;
    width: min(330px, calc(100vw - 24px));
    max-height: calc(100vh - 92px);
    max-height: calc(100dvh - 92px);
    border-radius: 12px;
  }

  #jx-chat-widget .jx-chat-header {
    padding: 13px 14px;
  }

  #jx-chat-widget .jx-chat-log {
    padding: 11px;
  }
}

@media (max-width: 380px) {
  #jx-chat-widget > .jx-chat-panel {
    width: calc(100vw - 20px);
  }
}

/* Milestone 2: source/citation links */
#jx-chat-widget .jx-chat-msg-sources { font-size: 12px; line-height: 1.45; }
#jx-chat-widget .jx-chat-msg-sources strong { display: block; margin-bottom: 4px; }
#jx-chat-widget .jx-chat-msg-sources a { text-decoration: underline; overflow-wrap: anywhere; }

/* Loading state for the composer */
#jx-chat-widget #jx-chat-form > button[type="submit"]:disabled {
  cursor: wait !important;
  opacity: 0.58 !important;
  transform: scale(0.96);
}

#jx-chat-widget #jx-chat-form[data-busy="1"] #jx-chat-input {
  border-color: #d8ddd9 !important;
}

@media (max-width: 380px) {
  #jx-chat-widget .jx-chat-typing-label {
    max-width: 176px;
    white-space: normal;
    line-height: 1.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  #jx-chat-widget .jx-chat-typing-dots > span,
  #jx-chat-widget .jx-chat-msg-enter,
  #jx-chat-widget.jx-open > .jx-chat-panel {
    animation: none !important;
  }
}

/* v1.7.0: authority metadata for form/package availability results */
#jx-chat-widget .jx-product-result + .jx-product-result {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(24, 82, 75, 0.14);
}
#jx-chat-widget .jx-product-authority {
  margin-top: 7px;
  font-size: 11.5px;
  line-height: 1.5;
}
#jx-chat-widget .jx-product-authority > div {
  margin-top: 2px;
  overflow-wrap: anywhere;
}
#jx-chat-widget .jx-product-authority span {
  font-weight: 700;
}


/* v1.8.0: header actions and New Chat control */
#jx-chat-widget .jx-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

#jx-chat-widget .jx-chat-header .jx-chat-new {
  margin: 0 !important;
  padding: 6px 9px !important;
  width: auto !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.45) !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.10) !important;
  color: #fff !important;
  box-shadow: none !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  white-space: nowrap;
}

#jx-chat-widget .jx-chat-header .jx-chat-new:hover,
#jx-chat-widget .jx-chat-header .jx-chat-new:focus-visible {
  background: rgba(255, 255, 255, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.72) !important;
}

#jx-chat-widget .jx-chat-header-actions > #jx-chat-close {
  margin: 0 !important;
}

@media (max-width: 380px) {
  #jx-chat-widget .jx-chat-header {
    gap: 8px;
  }

  #jx-chat-widget .jx-chat-subtitle {
    max-width: 185px;
  }

  #jx-chat-widget .jx-chat-header .jx-chat-new {
    padding: 5px 7px !important;
    font-size: 10.5px !important;
  }
}

.jx-chat-msg-assistant { white-space: pre-wrap; }
