/* Live Help chat — public for everyone (not Admin Preview gated) */

.help-chat-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1150;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: 1px solid rgba(102, 187, 106, 0.55);
  background: #0d1a0d;
  color: var(--lime, #39ff14);
  font: 700 1.25rem/1 var(--font-heading, Onest, system-ui, sans-serif);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body.has-bottom-nav .help-chat-fab {
  bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
}

.help-chat-fab:hover,
.help-chat-fab:focus {
  outline: none;
  border-color: var(--lime, #39ff14);
  box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.2), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.help-chat {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  pointer-events: none; /* let page receive events outside panel; children re-enable */
}

.help-chat__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

/*
 * ROOT CAUSE (www-20261002c): panel used ONLY max-height (height:auto). Flex/grid
 * children then size to their content; overflow:hidden on the panel CLIPPED the
 * message list instead of giving .help-chat__log a bounded scrollport.
 * Fix: definite height + CSS grid row minmax(0,1fr) so the log is the scroller
 * while header / chips / compose / escalate stay fixed.
 */
.help-chat__panel {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  width: min(400px, 100%);
  /* Definite height — required so flex children can shrink into a scrollport */
  height: min(640px, calc(100vh - 1.5rem));
  height: min(640px, calc(100dvh - 1.5rem));
  max-height: min(640px, calc(100vh - 1.5rem));
  max-height: min(640px, calc(100dvh - 1.5rem));
  min-height: 0;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(102, 187, 106, 0.45);
  background: #122012;
  color: #e8ffe8;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.help-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem 0.65rem;
  border-bottom: 1px solid rgba(102, 187, 106, 0.25);
  min-width: 0;
}

.help-chat__title {
  margin: 0;
  font-family: var(--font-heading, Onest, system-ui, sans-serif);
  font-size: 1.05rem;
  color: var(--lime, #39ff14);
}

.help-chat__sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
}

.help-chat__x {
  border: 0;
  background: transparent;
  color: var(--text, #e8ffe8);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  position: relative;
  z-index: 2;
  pointer-events: auto;
  flex-shrink: 0;
  min-width: 2rem;
  min-height: 2rem;
  border-radius: 8px;
}

.help-chat__x:hover,
.help-chat__x:focus {
  outline: none;
  background: rgba(57, 255, 20, 0.12);
  color: var(--lime, #39ff14);
}

.help-chat__log {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 0.75rem 0.85rem;
  box-sizing: border-box;
  display: block;
}

.help-chat__msg {
  display: flex;
  margin: 0 0 0.55rem;
}

.help-chat__msg:last-child {
  margin-bottom: 0;
}

.help-chat__msg--user {
  justify-content: flex-end;
}

.help-chat__msg--bot {
  justify-content: flex-start;
}

.help-chat__bubble {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.help-chat__msg--user .help-chat__bubble {
  background: rgba(57, 255, 20, 0.14);
  border: 1px solid rgba(57, 255, 20, 0.35);
}

.help-chat__msg--bot .help-chat__bubble {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(102, 187, 106, 0.28);
}

.help-chat__msg--agent {
  justify-content: flex-start;
}

.help-chat__msg--system {
  justify-content: center;
}

.help-chat__msg--agent .help-chat__bubble {
  background: rgba(33, 150, 243, 0.16);
  border: 1px solid rgba(33, 150, 243, 0.4);
}

.help-chat__msg--system .help-chat__bubble {
  background: transparent;
  border: 1px dashed rgba(102, 187, 106, 0.35);
  color: rgba(200, 230, 201, 0.92);
  font-size: 0.82rem;
  text-align: center;
  max-width: 100%;
}

.help-chat__agent-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 0.2rem;
  color: rgba(144, 202, 249, 0.95);
}


.help-chat__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.85rem 0.55rem;
  min-width: 0;
}

.help-chat__chip {
  border-radius: 999px;
  border: 1px solid rgba(102, 187, 106, 0.4);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text, #e8ffe8);
  font: inherit;
  font-size: 0.75rem;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
}

.help-chat__chip:hover,
.help-chat__chip:focus {
  border-color: var(--lime, #39ff14);
  outline: none;
}

.help-chat__compose {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border-top: 1px solid rgba(102, 187, 106, 0.22);
  min-width: 0;
}

.help-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(102, 187, 106, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text, #e8ffe8);
  font: inherit;
  padding: 0.45rem 0.6rem;
}

.help-chat__input:focus {
  outline: none;
  border-color: var(--lime, #39ff14);
  box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.15);
}

.help-chat__escalate {
  flex: 0 1 auto;
  padding: 0.55rem 0.85rem 0.85rem;
  border-top: 1px solid rgba(102, 187, 106, 0.22);
  background: rgba(0, 0, 0, 0.12);
  min-width: 0;
  min-height: 0;
  max-height: 14rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.help-chat__escalate-label {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
}

.help-chat__escalate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.help-chat__fields {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.help-chat__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
}

.help-chat__field input,
.help-chat__field textarea {
  border-radius: 10px;
  border: 1px solid rgba(102, 187, 106, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text, #e8ffe8);
  font: inherit;
  padding: 0.4rem 0.55rem;
  resize: vertical;
}

.help-chat__field input:focus,
.help-chat__field textarea:focus {
  outline: none;
  border-color: var(--lime, #39ff14);
}

.help-chat__field .req {
  color: var(--lime, #39ff14);
}

.help-chat__status {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
}


.help-chat__header,
.help-chat__suggest,
.help-chat__compose {
  flex-shrink: 0;
}


.help-chat__disconnect {
  border-color: rgba(255, 138, 128, 0.55);
  color: #ffab91;
}

.help-chat__disconnect:hover,
.help-chat__disconnect:focus {
  outline: none;
  border-color: #ff8a80;
  background: rgba(255, 138, 128, 0.12);
  color: #ffccbc;
}

.help-chat__disconnect[hidden] {
  display: none !important;
}

.help-chat__hours {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
}

.help-chat .btn.is-disabled,
.help-chat .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 520px) {
  /* Keep the sticky/fixed site header above an open Help panel so the
     logo and hamburger remain visible and tappable on small screens. */
  .help-chat {
    inset: var(--header-height, 64px) 0 0;
    padding: 0;
    align-items: stretch;
  }
  .help-chat__panel {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .help-chat__escalate {
    max-height: 12rem;
  }
}

/* WWW utilities — self-contained so help-chat does not need app chrome CSS */
.help-chat .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.help-chat .muted {
  color: rgba(232, 255, 232, 0.65);
}

.help-chat .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 999px;
  font: 600 0.82rem/1.2 var(--font-heading, Onest, system-ui, sans-serif);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}

.help-chat .btn--sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.help-chat .btn--primary {
  background: rgba(57, 255, 20, 0.16);
  border-color: rgba(57, 255, 20, 0.55);
  color: var(--lime, #39ff14);
}

.help-chat .btn--primary:hover,
.help-chat .btn--primary:focus {
  outline: none;
  border-color: var(--lime, #39ff14);
  background: rgba(57, 255, 20, 0.24);
}

.help-chat .btn--outline {
  background: transparent;
  border-color: rgba(102, 187, 106, 0.45);
  color: #e8ffe8;
}

.help-chat .btn--outline:hover,
.help-chat .btn--outline:focus {
  outline: none;
  border-color: var(--lime, #39ff14);
}

#app-toast.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%) translateY(0.5rem);
  z-index: 1300;
  max-width: min(90vw, 22rem);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(57, 255, 20, 0.4);
  background: #0d1a0d;
  color: #e8ffe8;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#app-toast.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* [hidden] must beat author display:flex/block (same class of bug as panel close) */
.help-chat__fields[hidden],
.help-chat__hours[hidden],
.help-chat [hidden] {
  display: none !important;
}

/* [hidden] must win over .help-chat { display: flex } (author CSS beats UA [hidden]) */
.help-chat[hidden],
.help-chat:not(.is-open) {
  display: none !important;
}

.help-chat.is-open {
  display: flex !important;
}

/* no-fab-20261010 (Rich 2:32 PM): no floating "?" anywhere. Live Help = Menu > Help > Live Help. */
.help-chat-fab { display: none !important; }
body.has-help-chat:not(.help-fab-hidden)::after { content: none; height: 0; }
