/* ============================================================
   FAQ CHATBOT WIDGET — SCOPED STYLES (assets/css/chatbot.css)
   Design tokens (--ink, --ivory, --marigold, --maroon, --gold-soft,
   --shadow-card, --ease, etc.) already live in main.css and are
   enqueued site-wide. This file loads on top of that, site-wide
   (everywhere the shared footer renders), via
   wp_enqueue_style('adharva-chatbot', ...) — see functions.php.

   Ported from the static homepage's "STICKY HELP CHATBOT" block
   and hardened for production:
   - honours prefers-reduced-motion
   - iOS safe-area aware positioning
   - clearer focus states for keyboard users
   ============================================================ */

.sticky-help {
  position: fixed;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  right: 22px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--marigold), var(--marigold-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px -6px rgba(232, 116, 12, 0.55);
  z-index: 900;
  cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.sticky-help:hover,
.sticky-help:focus-visible { transform: scale(1.08); }
/* Recede while the page is actively being scrolled (class toggled by
   main.js), same treatment as .sticky-wa in main.css, so it stops sitting
   on top of scrolling content. Skipped while the button is in its "open"
   (close-chat) state so it never disappears while the panel is open. */
body.is-scrolling .sticky-help:not(.open) { opacity: 0.32; transform: scale(0.84); pointer-events: none; }
body.is-scrolling .help-teaser.show { opacity: 0; pointer-events: none; }
.sticky-help:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.sticky-help svg { width: 26px; height: 26px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.2s; }
.sticky-help .icon-close { display: none; }
.sticky-help.open .icon-chat { display: none; }
.sticky-help.open .icon-close { display: block; }
.sticky-help .help-dot { position: absolute; top: 6px; right: 6px; width: 11px; height: 11px; border-radius: 50%; background: #5fd97a; border: 2px solid var(--ivory); }
.sticky-help.open .help-dot { display: none; }

/* Intro teaser bubble — shows once, points at the help button */
.help-teaser {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  right: 90px;
  max-width: 200px;
  background: var(--white);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: var(--shadow-card);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  z-index: 899;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.help-teaser.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; cursor: pointer; }
.help-teaser button { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; line-height: 1; cursor: pointer; }
.help-teaser button:focus-visible { outline: 2px solid var(--marigold); outline-offset: 2px; }

@media (max-width: 480px) {
  .sticky-help { bottom: calc(82px + env(safe-area-inset-bottom, 0px)); right: 16px; width: 50px; height: 50px; }
  .sticky-help svg { width: 22px; height: 22px; }
  .help-teaser { bottom: calc(78px + env(safe-area-inset-bottom, 0px)); right: 74px; max-width: 170px; font-size: 0.78rem; }
}

/* Chat panel */
.help-panel {
  position: fixed;
  bottom: calc(160px + env(safe-area-inset-bottom, 0px));
  right: 22px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 200px);
  background: var(--ivory);
  border-radius: 20px;
  box-shadow: 0 30px 70px -18px rgba(26, 20, 16, 0.4);
  z-index: 950;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transform-origin: bottom right;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.help-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.help-panel-head { background: linear-gradient(120deg, var(--maroon-deep), var(--maroon) 70%); padding: 16px 18px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.help-panel-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--marigold), var(--marigold-deep)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.help-panel-avatar svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; }
.help-panel-title { color: var(--ivory); font-weight: 600; font-size: 0.92rem; line-height: 1.2; }
.help-panel-status { display: flex; align-items: center; gap: 5px; color: #c9b89e; font-size: 0.7rem; margin-top: 2px; }
.help-panel-status .dot { width: 6px; height: 6px; border-radius: 50%; background: #5fd97a; flex-shrink: 0; }
.help-panel-close { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.12); display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; cursor: pointer; }
.help-panel-close svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.help-panel-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.help-panel-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.help-panel-body::-webkit-scrollbar { width: 5px; }
.help-panel-body::-webkit-scrollbar-thumb { background: var(--mist); border-radius: 10px; }
.help-msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 0.83rem; line-height: 1.55; }
.help-msg.bot { background: var(--white); color: var(--ink-soft); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: 0 2px 8px rgba(26, 20, 16, 0.06); }
.help-msg.bot p + p { margin-top: 8px; }
.help-msg.user { background: linear-gradient(135deg, var(--marigold), var(--marigold-deep)); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.help-msg.bot.help-msg-cat { font-weight: 600; color: var(--ink); }
.help-crumb { align-self: flex-start; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--marigold-deep); font-weight: 600; padding: 0 2px; }
.help-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 4px; }
.help-chip { padding: 8px 14px; border-radius: 20px; border: 1.3px solid var(--gold-soft); background: var(--white); color: var(--marigold-deep); font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: background 0.25s, color 0.25s, transform 0.25s; text-align: left; line-height: 1.3; }
.help-chip:hover, .help-chip:focus-visible { background: var(--marigold); color: #fff; border-color: var(--marigold); transform: translateY(-1px); }
.help-chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.help-chip.help-chip-ghost { background: transparent; border-style: dashed; color: var(--ink-soft); }
.help-chip.help-chip-ghost:hover, .help-chip.help-chip-ghost:focus-visible { background: var(--ink); border-color: var(--ink); border-style: solid; color: #fff; }
.help-chip.help-chip-wa { border-color: #25D366; color: #1a8f4a; }
.help-chip.help-chip-wa:hover, .help-chip.help-chip-wa:focus-visible { background: #25D366; border-color: #25D366; color: #fff; }
.help-panel-foot { flex-shrink: 0; padding: 12px 16px 16px; border-top: 1px solid var(--mist); background: var(--ivory); }
.help-wa-cta { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; background: #25D366; color: #fff; padding: 11px; border-radius: 30px; font-size: 0.82rem; font-weight: 600; transition: transform 0.25s; }
.help-wa-cta:hover, .help-wa-cta:focus-visible { transform: translateY(-2px); }
.help-wa-cta:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.help-wa-cta svg { width: 16px; height: 16px; flex-shrink: 0; }
.help-typing { display: flex; gap: 4px; align-self: flex-start; background: var(--white); padding: 12px 15px; border-radius: 14px; border-bottom-left-radius: 4px; box-shadow: 0 2px 8px rgba(26, 20, 16, 0.06); }
.help-typing span { width: 6px; height: 6px; border-radius: 50%; background: #c9b7a0; animation: helpTyping 1.1s ease-in-out infinite; }
.help-typing span:nth-child(2) { animation-delay: 0.15s; }
.help-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes helpTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  .help-panel { bottom: calc(142px + env(safe-area-inset-bottom, 0px)); right: 16px; width: calc(100vw - 32px); height: min(485px, calc(100vh - 180px)); }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .sticky-help,
  .help-teaser,
  .help-panel,
  .help-chip,
  .help-wa-cta {
    transition: none !important;
  }
  .help-typing span { animation: none !important; opacity: 0.7; }
}
