/* Support chat widget — left-edge launcher + slide-in panel.
   Brand: crimson #8b2942, gold #c9a227. No italics anywhere. */

.hc-chat {
  --hc-crimson: #8b2942;
  --hc-crimson-dark: #6f1f35;
  --hc-gold: #c9a227;
  --hc-ink: #1f2733;
  --hc-muted: #5c6570;
  --hc-line: #e2e6ea;
  --hc-agent-bg: #fbf3df;
  font-family: var(--font, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
}

/* ---- Launcher (left middle) ---- */
.hc-chat__launcher {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.6rem 0.9rem 0.6rem 0.7rem;
  border: 0;
  border-top-right-radius: 999px;
  border-bottom-right-radius: 999px;
  background: linear-gradient(135deg, var(--hc-crimson) 0%, var(--hc-crimson-dark) 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  border: 1px solid var(--hc-gold);
  border-left: 0;
  transition: padding 0.15s ease, transform 0.15s ease;
}
.hc-chat__launcher:hover {
  transform: translateY(-50%) translateX(2px);
}
.hc-chat__launcher svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: #fff;
}
.hc-chat__launcher-text {
  white-space: nowrap;
}
.hc-chat.is-open .hc-chat__launcher,
.hc-chat__launcher.is-hidden { display: none; }

/* ---- Panel ---- */
.hc-chat__panel {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 1201;
  display: none;
  flex-direction: column;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 32px);
  background: #fff;
  border: 1px solid var(--hc-line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.hc-chat.is-open .hc-chat__panel {
  display: flex;
  animation: hc-rise 0.18s ease;
}
@keyframes hc-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Header ---- */
.hc-chat__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 0.9rem;
  background: linear-gradient(135deg, var(--hc-crimson) 0%, var(--hc-crimson-dark) 100%);
  color: #fff;
  border-bottom: 2px solid var(--hc-gold);
}
.hc-chat__avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--hc-gold);
  color: var(--hc-crimson-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
}
.hc-chat__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.hc-chat__head-meta { flex: 1 1 auto; min-width: 0; }
.hc-chat__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
}
.hc-chat__status {
  margin: 0;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.hc-chat__status .hc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}
.hc-chat__status.is-online .hc-dot { background: #34d399; }
.hc-chat__status.is-offline .hc-dot { background: #f87171; }
.hc-chat__close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.hc-chat__close:hover { background: rgba(255, 255, 255, 0.28); }

/* ---- Body / messages ---- */
.hc-chat__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.9rem;
  background: #f8f9fb;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  -webkit-overflow-scrolling: touch;
}
.hc-msg {
  max-width: 82%;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.hc-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.hc-msg--agent {
  align-self: flex-start;
  background: var(--hc-agent-bg);
  border: 1px solid var(--hc-line);
  color: var(--hc-ink);
  border-bottom-left-radius: 4px;
}
.hc-msg--user {
  align-self: flex-end;
  background: var(--hc-crimson);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.hc-msg--user a { color: #fff; }
.hc-msg__name {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--hc-crimson);
  margin-bottom: 0.15rem;
}
.hc-sys {
  align-self: center;
  max-width: 92%;
  text-align: center;
  font-size: 0.78rem;
  color: var(--hc-muted);
  background: transparent;
  padding: 0.2rem 0.4rem;
}
.hc-sys strong { color: var(--hc-ink); }

/* typing indicator */
.hc-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.7rem;
  background: var(--hc-agent-bg);
  border: 1px solid var(--hc-line);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.hc-typing__label {
  font-size: 0.74rem;
  color: var(--hc-muted);
}
.hc-typing__dots { display: inline-flex; gap: 3px; }
.hc-typing__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hc-crimson);
  opacity: 0.4;
  animation: hc-blink 1.2s infinite both;
}
.hc-typing__dots span:nth-child(2) { animation-delay: 0.2s; }
.hc-typing__dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes hc-blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ---- Footer / composer ---- */
.hc-chat__foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--hc-line);
  background: #fff;
  padding: 0.6rem;
}
.hc-chat__intro {
  font-size: 0.82rem;
  color: var(--hc-muted);
  margin: 0 0 0.5rem;
}
.hc-chat__row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.hc-chat__input {
  flex: 1 1 auto;
  resize: none;
  min-height: 2.6rem;
  max-height: 7rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--hc-line);
  border-radius: 10px;
  font: inherit;
  /* 16px stops iOS Safari from auto-zooming (and "expanding") on focus. */
  font-size: 16px;
  line-height: 1.35;
  color: var(--hc-ink);
  outline: none;
}
.hc-chat__input:focus { border-color: var(--hc-crimson); }
.hc-chat__send {
  flex: 0 0 auto;
  height: 2.75rem;
  min-width: 2.75rem;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 10px;
  background: var(--hc-crimson);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.hc-chat__send:hover { background: var(--hc-crimson-dark); }
.hc-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

.hc-chat__offline {
  text-align: center;
  font-size: 0.86rem;
  color: var(--hc-muted);
  padding: 0.3rem 0.2rem;
}
.hc-chat__offline strong { color: var(--hc-ink); }

.hc-chat__foot--hidden { display: none; }

/* ---- Mobile: full-screen panel ---- */
@media (max-width: 480px) {
  .hc-chat__panel {
    left: 0;
    top: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    /* JS sets an exact pixel height from visualViewport so the input never
       hides behind the iOS keyboard; this is the no-JS fallback. */
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
  .hc-chat__launcher-text { display: none; }
  .hc-chat__launcher { padding: 0.7rem; }
  /* Stop the page behind the chat from scrolling/bouncing on iOS. */
  html.hc-chat-open,
  html.hc-chat-open body {
    overflow: hidden;
    height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hc-chat.is-open .hc-chat__panel { animation: none; }
  .hc-typing__dots span { animation: none; }
}
