/* JA AI chat widget — bottom-left (Tawk stays bottom-right) */
.ja-chat {
  position: fixed;
  left: 1.1rem;
  right: auto;
  bottom: 1.1rem;
  z-index: 99990;
  font-family: var(--ja-font, inherit);
}
.ja-chat[hidden] { display: none !important; }

.ja-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 3.15rem;
  padding: 0 1.05rem 0 .85rem;
  border: 0;
  border-radius: 999px;
  background: var(--ja-orange, #A81F28);
  color: #fff;
  font-family: var(--ja-font-display, inherit);
  font-weight: 750;
  font-size: .92rem;
  box-shadow: 0 12px 28px rgba(168, 31, 40, .35);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.ja-chat__launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(168, 31, 40, .42);
}
.ja-chat__launcher-icon {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
}

.ja-chat__panel {
  position: absolute;
  left: 0;
  right: auto;
  bottom: 4rem;
  width: min(100vw - 1.5rem, 24.5rem);
  height: min(72vh, 36rem);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--ja-line, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 22px 50px rgba(13, 59, 102, .22);
  overflow: hidden;
}
.ja-chat__panel[hidden] { display: none !important; }

.ja-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .95rem 1rem;
  background: linear-gradient(135deg, #0D3B66, #134a7a);
  color: #fff;
}
.ja-chat__eyebrow {
  margin: 0;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .75;
  font-weight: 700;
}
.ja-chat__title {
  margin: .1rem 0 0;
  font-size: 1.05rem;
  font-family: var(--ja-font-display, inherit);
  font-weight: 800;
}
.ja-chat__head-actions { display: flex; gap: .25rem; }
.ja-chat__icon-btn {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
}
.ja-chat__icon-btn:hover { background: rgba(255,255,255,.22); }
.ja-chat__composer .ja-chat__icon-btn {
  background: var(--ja-bg, #F4F4F4);
  color: var(--ja-primary, #0D3B66);
  flex: 0 0 auto;
}

.ja-chat__messages {
  flex: 1 1 auto;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  background: #f7f9fc;
}
.ja-chat__bubble {
  max-width: 92%;
  padding: .75rem .9rem;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.ja-chat__bubble--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--ja-line, #e5e7eb);
  color: var(--ja-text, #1A1D23);
  border-bottom-left-radius: 4px;
}
.ja-chat__bubble--user {
  align-self: flex-end;
  background: var(--ja-blue, #0D3B66);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ja-chat__bubble--status {
  align-self: center;
  background: transparent;
  color: var(--ja-muted, #7F8C8D);
  font-size: .78rem;
  padding: .2rem;
}

.ja-chat__products {
  display: grid;
  gap: .55rem;
  padding: .65rem 1rem;
  border-top: 1px solid var(--ja-line, #e5e7eb);
  background: #fff;
  max-height: 11rem;
  overflow: auto;
}
.ja-chat__products[hidden] { display: none !important; }
.ja-chat__product {
  display: grid;
  grid-template-columns: 3.25rem 1fr auto;
  gap: .65rem;
  align-items: center;
  padding: .45rem;
  border: 1px solid var(--ja-line, #e5e7eb);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  background: #fff;
}
.ja-chat__product img {
  width: 3.25rem;
  height: 3.25rem;
  object-fit: cover;
  border-radius: 8px;
  background: #f3f4f6;
}
.ja-chat__product-name {
  display: block;
  font-size: .82rem;
  font-weight: 750;
  color: var(--ja-blue, #0D3B66);
  line-height: 1.25;
}
.ja-chat__product-meta {
  display: block;
  margin-top: .15rem;
  font-size: .72rem;
  color: var(--ja-muted, #7F8C8D);
}
.ja-chat__match {
  display: inline-block;
  margin-top: .28rem;
  padding: .12rem .4rem;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 750;
  letter-spacing: .02em;
  line-height: 1.2;
}
.ja-chat__match--high {
  background: rgba(31, 173, 82, .12);
  color: #147a3a;
}
.ja-chat__match--medium {
  background: rgba(13, 59, 102, .1);
  color: #0D3B66;
}
.ja-chat__match--low {
  background: rgba(127, 140, 141, .14);
  color: #5f6b6d;
}
.ja-chat__product-quote {
  border: 0;
  border-radius: 8px;
  background: var(--ja-orange, #A81F28);
  color: #fff;
  font-size: .7rem;
  font-weight: 750;
  padding: .45rem .55rem;
  cursor: pointer;
  white-space: nowrap;
}

.ja-chat__preview {
  position: relative;
  padding: .5rem 1rem 0;
  background: #fff;
}
.ja-chat__preview[hidden] { display: none !important; }
.ja-chat__preview img {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--ja-line, #e5e7eb);
}
.ja-chat__preview-clear {
  position: absolute;
  left: 5rem;
  top: .35rem;
  width: 1.4rem;
  height: 1.4rem;
  border: 0;
  border-radius: 50%;
  background: var(--ja-primary, #0D3B66);
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

.ja-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: .4rem;
  padding: .75rem 0.75rem 0.35rem;
  background: #fff;
  border-top: 1px solid var(--ja-line, #e5e7eb);
}
.ja-chat__composer textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 2.45rem;
  max-height: 6.5rem;
  border: 1px solid var(--ja-line, #e5e7eb);
  border-radius: 12px;
  padding: .65rem .75rem;
  font: inherit;
  font-size: .9rem;
  line-height: 1.35;
}
.ja-chat__composer textarea:focus {
  outline: 2px solid rgba(13, 59, 102, .25);
  border-color: var(--ja-blue, #0D3B66);
}
.ja-chat__send {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border: 0;
  border-radius: 12px;
  background: var(--ja-orange, #A81F28);
  color: #fff;
  cursor: pointer;
  flex: 0 0 auto;
}
.ja-chat__send:disabled { opacity: .55; cursor: wait; }
.ja-chat__fineprint {
  margin: 0;
  padding: 0 .9rem .65rem;
  font-size: .68rem;
  color: var(--ja-muted, #7F8C8D);
  background: #fff;
  line-height: 1.35;
}

/* Opposite corners: Ask JA left, Tawk right — no vertical lift needed. */
body.ja-chat-ready {
  --ja-chat-clearance: 5.5rem;
}

@media (max-width: 768px) {
  .ja-chat {
    left: .75rem;
    right: auto;
    bottom: max(0.85rem, env(safe-area-inset-bottom));
  }
  .ja-chat__panel {
    left: 0;
    right: auto;
    width: min(100vw - 1rem, 24.5rem);
    height: min(78vh, 34rem);
    bottom: 3.85rem;
  }
  .ja-chat__launcher-label { display: none; }
  .ja-chat__launcher {
    width: 3.25rem;
    height: 3.25rem;
    padding: 0;
    justify-content: center;
  }
  /* Social dock shares the left edge on mobile — lift it above Ask JA */
  body.ja-chat-ready .ja-float-social {
    bottom: 5.75rem;
  }
  body.single-product .ja-chat {
    bottom: 6.75rem;
  }
  body.single-product.ja-chat-ready .ja-float-social {
    bottom: 11.5rem;
  }
}
