.jh-chat-root {
  --jh-chat-red: #e11d2e;
  --jh-chat-red-dark: #b91422;
  --jh-chat-ink: #1a1a1a;
  --jh-chat-muted: #6b7280;
  --jh-chat-line: #ececec;
  --jh-chat-bg: #fafafa;
  /* Space above WhatsApp + Call + Chat stack */
  --jh-chat-stack-clear: calc(118px + 54px * 3 + 14px * 2 + 12px);
  --jh-chat-top-gap: 12px;
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, sans-serif;
}

.jh-chat-fab-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
}

.jh-chat-root--solo .jh-chat-fab-wrap {
  position: fixed;
  right: 18px;
  bottom: 118px;
  z-index: 99980;
}

.jh-chat-ico {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  fill: currentColor;
  color: inherit;
}

.jh-chat-ico--sm {
  width: 14px;
  height: 14px;
}

button.jh-chat-launcher,
.jh-chat-launcher {
  position: relative;
  z-index: 2;
  -webkit-appearance: none;
  appearance: none;
  border: 2px solid #e11d2e !important;
  border-radius: 50% !important;
  cursor: pointer;
  color: #ffffff !important;
  background: #e11d2e !important;
  background-image: linear-gradient(145deg, #ff2a3d, #b91422) !important;
  box-shadow: 0 4px 16px rgba(185, 20, 34, 0.32);
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 54px !important;
  height: 54px !important;
  font-size: 22px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
  padding: 0 !important;
  margin: 0;
  text-decoration: none;
  overflow: visible;
  line-height: 1;
}

.jh-chat-launcher-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(225, 29, 46, 0.55);
  animation: jhChatPulse 2s ease-out infinite;
  pointer-events: none;
}

.jh-chat-launcher.is-open .jh-chat-launcher-pulse {
  display: none;
}

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

.jh-chat-launcher:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 8px 22px rgba(185, 20, 34, 0.4);
}

.jh-chat-launcher.is-open {
  background: #1f2937 !important;
  background-image: none !important;
  border-color: #1f2937 !important;
  color: #ffffff !important;
}

/* Nudge: "How can I help you?" */
.jh-chat-nudge {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: var(--jh-chat-red-dark);
  border: 1px solid rgba(225, 29, 46, 0.28);
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
  box-shadow: 0 8px 24px rgba(185, 20, 34, 0.18);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  z-index: 3;
}

.jh-chat-nudge.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}

.jh-chat-nudge[hidden] {
  display: none !important;
}

.jh-chat-nudge::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #fff;
  border-right: 1px solid rgba(225, 29, 46, 0.28);
  border-top: 1px solid rgba(225, 29, 46, 0.28);
  transform: translateY(-50%) rotate(45deg);
}

.jh-chat-nudge-text {
  border: none;
  background: transparent;
  color: var(--jh-chat-red-dark);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1.2;
}

.jh-chat-nudge-text:hover {
  color: var(--jh-chat-red);
}

button.jh-chat-nudge-close,
.jh-chat-nudge-close {
  -webkit-appearance: none;
  appearance: none;
  width: 24px !important;
  height: 24px !important;
  border: none !important;
  border-radius: 50% !important;
  background: #e11d2e !important;
  color: #ffffff !important;
  display: grid !important;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 !important;
  margin: 0;
  line-height: 1;
  transition: background 0.15s ease;
}

.jh-chat-nudge-close:hover {
  background: #b91422 !important;
}

.jh-chat-nudge-close .jh-chat-ico {
  color: #ffffff !important;
  fill: #ffffff !important;
}

.jh-chat-launcher .jh-chat-ico {
  color: #ffffff !important;
  fill: #ffffff !important;
}

.jh-chat-panel {
  position: fixed;
  right: 18px;
  bottom: var(--jh-chat-stack-clear);
  z-index: 99981;
  width: min(390px, calc(100vw - 24px));
  /* Never taller than space between top of viewport and CTA stack */
  height: min(520px, calc(100vh - var(--jh-chat-stack-clear) - var(--jh-chat-top-gap)));
  height: min(520px, calc(100dvh - var(--jh-chat-stack-clear) - var(--jh-chat-top-gap)));
  max-height: calc(100vh - var(--jh-chat-stack-clear) - var(--jh-chat-top-gap));
  max-height: calc(100dvh - var(--jh-chat-stack-clear) - var(--jh-chat-top-gap));
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--jh-chat-line);
  box-shadow: 0 22px 50px rgba(25, 10, 12, 0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: jhChatIn 0.28s ease;
}

/* Keep scroll-to-top clear of the CTA + chat stack */
body.jh-chat-docked .touria-scrolltop {
  right: 18px;
  bottom: 1.25rem;
}

@media only screen and (max-width: 991px) {
  body.jh-chat-docked .touria-scrolltop {
    /* Above mobile CTA stack: bottom 170 + 3×44 + 2×10 + gap */
    bottom: calc(170px + 44px * 3 + 10px * 2 + 18px);
    right: 15px;
  }
}

.jh-chat-panel.is-open { display: flex; }

@keyframes jhChatIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.jh-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--jh-chat-red), var(--jh-chat-red-dark));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.jh-chat-header-copy {
  flex: 1;
  min-width: 0;
}

.jh-chat-header-close {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: none !important;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.jh-chat-header-close:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

.jh-chat-header-close .jh-chat-ico {
  color: #fff !important;
  fill: #fff !important;
  width: 16px;
  height: 16px;
}

.jh-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.2);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.jh-chat-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.jh-chat-header p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  opacity: 0.9;
}

.jh-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--jh-chat-bg);
}

.jh-chat-gate {
  background: #fff;
  border: 1px solid var(--jh-chat-line);
  border-radius: 16px;
  padding: 16px;
}

.jh-chat-gate h4 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--jh-chat-ink);
}

.jh-chat-gate > p {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--jh-chat-muted);
  line-height: 1.45;
}

.jh-chat-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.jh-chat-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--jh-chat-ink);
}

.jh-chat-field input {
  border: 1px solid var(--jh-chat-line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  outline: none;
  background: #fff;
}

.jh-chat-field input:focus {
  border-color: var(--jh-chat-red);
  box-shadow: 0 0 0 3px rgba(225, 29, 46, 0.14);
}

.jh-chat-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.jh-chat-btn {
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 650;
  font-size: 0.9rem;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

.jh-chat-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.jh-chat-btn--primary {
  background: linear-gradient(135deg, var(--jh-chat-red), var(--jh-chat-red-dark));
  color: #fff;
}

.jh-chat-btn--primary:hover {
  filter: brightness(1.05);
}

.jh-chat-btn--ghost {
  background: #fff;
  color: var(--jh-chat-red-dark);
  border: 1px solid rgba(225, 29, 46, 0.35);
}

.jh-chat-btn--ghost:hover {
  background: #fff5f5;
}

.jh-chat-error {
  color: #b42318;
  font-size: 0.78rem;
  margin: 0 0 8px;
  min-height: 1em;
}

.jh-chat-msgs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jh-chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.jh-chat-bubble--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--jh-chat-line);
  color: var(--jh-chat-ink);
  border-bottom-left-radius: 4px;
}

.jh-chat-bubble--user {
  align-self: flex-end;
  background: var(--jh-chat-red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.jh-chat-typing {
  align-self: flex-start;
  font-size: 0.78rem;
  color: var(--jh-chat-muted);
  padding: 2px 4px;
}

.jh-chat-footer {
  border-top: 1px solid var(--jh-chat-line);
  padding: 10px;
  background: #fff;
  display: none;
  gap: 8px;
}

.jh-chat-footer.is-visible { display: flex; }

.jh-chat-footer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--jh-chat-line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.88rem;
  min-height: 44px;
  max-height: 90px;
  outline: none;
  background: #fff;
}

.jh-chat-footer textarea:focus {
  border-color: var(--jh-chat-red);
  box-shadow: 0 0 0 3px rgba(225, 29, 46, 0.12);
}

.jh-chat-send {
  width: 44px;
  height: 44px;
  border: none !important;
  border-radius: 12px;
  background: #e11d2e !important;
  color: #fff !important;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
}

.jh-chat-send .jh-chat-ico {
  color: #fff !important;
  fill: #fff !important;
}

.jh-chat-send:hover {
  background: var(--jh-chat-red-dark);
}

.jh-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 576px) {
  .jh-chat-fab-wrap,
  .jh-chat-launcher {
    width: 44px;
    height: 44px;
  }

  .jh-chat-launcher {
    font-size: 18px;
  }

  .jh-chat-root--solo .jh-chat-fab-wrap {
    right: 15px;
    bottom: 170px;
  }

  .jh-chat-nudge {
    right: calc(100% + 8px);
    padding: 7px 8px 7px 10px;
  }

  .jh-chat-nudge-text {
    font-size: 0.8rem;
  }

  /* Full-screen chat sheet on mobile */
  .jh-chat-panel {
    inset: 0;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: 100000;
    animation: jhChatSheetIn 0.28s ease;
  }

  .jh-chat-panel.is-open {
    display: flex;
  }

  body:has(.jh-chat-panel.is-open) .floating-contact-icons,
  body:has(.jh-chat-panel.is-open) .touria-scrolltop {
    visibility: hidden;
    pointer-events: none;
  }

  .jh-chat-header {
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
    border-radius: 0;
  }

  .jh-chat-body {
    padding: 16px;
  }

  .jh-chat-footer {
    padding: 12px 14px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .jh-chat-footer textarea {
    min-height: 48px;
  }

  @keyframes jhChatSheetIn {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: none; }
  }
}
