/* ApexLane native public live chat widget */
.apex-plc-root {
  /* Lift whole widget above .sticky-cta-bar (4000) but below header/drawers (5000+). Without z-index, isolation creates a context that loses to sticky CTA. */
  position: relative;
  z-index: 4600;
  /* Reserve space for sticky promo + nav ([header.css] --z-site-header ~5000). Override on html if your header is taller, e.g. --apex-plc-top-safe: 11rem; */
  --apex-plc-top-safe: 7.5rem;
  --apex-plc-bottom-gap: 5.75rem;
  /* Matches [enhancements.css] body padding when .sticky-cta-bar is shown (display:none above 768px) */
  --apex-plc-sticky-cta: 0px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  box-sizing: border-box;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  color: #0f172a;
  isolation: isolate;
}
.apex-plc-root *, .apex-plc-root *::before, .apex-plc-root *::after { box-sizing: border-box; }
.apex-plc-root input,
.apex-plc-root textarea,
.apex-plc-root button {
  font-family: inherit;
  font-size: max(16px, 0.9rem);
}

.apex-plc-launcher {
  position: fixed;
  /* Above panel; stacking vs rest of page comes from .apex-plc-root z-index */
  z-index: 2;
  bottom: calc(var(--apex-plc-sticky-cta, 0px) + 1.25rem + env(safe-area-inset-bottom, 0px));
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  pointer-events: auto !important;
  touch-action: manipulation;
}
.apex-plc-launcher:hover { transform: scale(1.04); box-shadow: 0 6px 28px rgba(15, 23, 42, 0.22); }
.apex-plc-launcher:focus-visible { outline: 3px solid rgba(59, 130, 246, 0.5); outline-offset: 2px; }

.apex-plc-pos-right .apex-plc-launcher { right: 1.25rem; }
.apex-plc-pos-left .apex-plc-launcher { left: 1.25rem; }

/*
  Do NOT rely on [hidden] alone: many themes set .apex-plc-panel { display:flex },
  which overrides attribute hidden in the cascade and leaves a transparent hit-box
  that steals clicks from the launcher and breaks “close”.
*/
.apex-plc-root .apex-plc-panel {
  position: fixed;
  z-index: 1;
  bottom: calc(var(--apex-plc-sticky-cta, 0px) + 5.25rem + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  transition: width 0.2s ease, max-height 0.2s ease;
  width: min(100vw - 2rem, 380px);
  max-height: min(65vh, 520px, calc(100dvh - var(--apex-plc-top-safe) - var(--apex-plc-bottom-gap)));
  display: none !important;
  pointer-events: none !important;
  flex-direction: column;
}
.apex-plc-root .apex-plc-panel.apex-plc-panel-open {
  display: flex !important;
  pointer-events: auto !important;
}
.apex-plc-panel.apex-plc-size-compact {
  width: min(100vw - 2rem, 300px);
  max-height: min(52vh, 400px, calc(100dvh - var(--apex-plc-top-safe) - var(--apex-plc-bottom-gap)));
}
.apex-plc-panel.apex-plc-size-expanded {
  width: min(100vw - 2rem, 520px);
  max-height: min(80vh, 680px, calc(100dvh - var(--apex-plc-top-safe) - var(--apex-plc-bottom-gap)));
}
.apex-plc-pos-right .apex-plc-panel { right: 1.25rem; }
.apex-plc-pos-left .apex-plc-panel { left: 1.25rem; }

@media (max-width: 768px) {
  .apex-plc-root {
    --apex-plc-sticky-cta: 72px;
    --apex-plc-bottom-gap: calc(5.75rem + var(--apex-plc-sticky-cta) + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 480px) {
  .apex-plc-root {
    --apex-plc-top-safe: 10rem;
    /* Sheet sits above sticky CTA; reserve that strip for max-height (768 rule may use a larger gap for corner layout) */
    --apex-plc-bottom-gap: calc(var(--apex-plc-sticky-cta) + 0.75rem + env(safe-area-inset-bottom, 0px));
  }
  .apex-plc-root .apex-plc-panel.apex-plc-panel-open {
    left: 0 !important;
    right: 0 !important;
    bottom: calc(var(--apex-plc-sticky-cta, 0px) + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: none;
    max-height: min(70vh, 560px, calc(100dvh - var(--apex-plc-top-safe) - var(--apex-plc-bottom-gap)));
    border-radius: 16px 16px 0 0;
  }
  .apex-plc-panel.apex-plc-size-compact {
    max-height: min(52vh, 380px, calc(100dvh - var(--apex-plc-top-safe) - var(--apex-plc-bottom-gap)));
  }
  .apex-plc-panel.apex-plc-size-expanded {
    max-height: min(78vh, 720px, calc(100dvh - var(--apex-plc-top-safe) - var(--apex-plc-bottom-gap)));
  }
}

/* Single accent block: title row + status (avoids white gap / clipped text) */
.apex-plc-header {
  padding: 0.95rem 1.1rem 0.85rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  flex-shrink: 0;
}
.apex-plc-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
}
.apex-plc-header-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0.25rem;
}
.apex-plc-header-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.apex-plc-size-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 0.15rem;
  padding: 2px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}
.apex-plc-size-btn {
  width: 1.65rem !important;
  height: 1.65rem !important;
  min-width: 1.65rem !important;
  border-radius: 6px !important;
  font-size: 0.65rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.02em;
  line-height: 1 !important;
  padding: 0 !important;
  opacity: 0.85;
}
.apex-plc-size-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.95) !important;
  color: #0f172a !important;
  opacity: 1;
}
.apex-plc-header .apex-plc-icon-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.22);
  border: none;
  color: #fff;
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  pointer-events: auto !important;
  touch-action: manipulation;
  position: relative;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
}
.apex-plc-header .apex-plc-icon-btn:hover { background: rgba(255,255,255,0.32); }
.apex-plc-header .apex-plc-icon-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.apex-plc-header .apex-plc-close-btn {
  font-size: 1.35rem;
  font-weight: 300;
  line-height: 1;
}

.apex-plc-status {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
  color: rgba(255,255,255,0.92);
  min-height: 1.1em;
}
.apex-plc-status:empty { display: none; }

.apex-plc-body { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #f8fafc; }

.apex-plc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.apex-plc-bubble {
  max-width: 88%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.apex-plc-bubble-visitor {
  align-self: flex-end;
  background: var(--apex-plc-accent, #16a34a);
  color: #fff;
}
.apex-plc-bubble-staff {
  align-self: flex-start;
  background: #e2e8f0;
  color: #0f172a;
}
.apex-plc-bubble-system {
  align-self: flex-start;
  background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid rgba(15, 23, 42, 0.06);
  color: #334155;
  font-size: 0.875rem;
  line-height: 1.55;
  padding: 0.72rem 0.92rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.apex-plc-meta { font-size: 0.65rem; opacity: 0.75; margin-top: 0.2rem; }

.apex-plc-start {
  padding: 1.15rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}
.apex-plc-greeting {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: #334155;
}
.apex-plc-field { display: flex; flex-direction: column; gap: 0.4rem; }
.apex-plc-start label { font-size: 0.8rem; font-weight: 600; color: #475569; }
.apex-plc-start input, .apex-plc-start textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  background: #fff;
  color: #0f172a;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.apex-plc-start input::placeholder,
.apex-plc-start textarea::placeholder { color: #94a3b8; }
.apex-plc-start input:focus, .apex-plc-start textarea:focus {
  outline: none;
  border-color: var(--apex-plc-accent, #16a34a);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}
.apex-plc-start textarea { min-height: 4.5rem; resize: vertical; max-height: 8rem; }

.apex-plc-btn-primary {
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.75rem 1rem !important;
  border-radius: 10px !important;
  border: none !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  cursor: pointer !important;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.apex-plc-btn-primary:hover { filter: brightness(1.05); }
.apex-plc-btn-primary:active { transform: scale(0.99); }
.apex-plc-btn-primary:focus-visible {
  outline: 2px solid var(--apex-plc-accent, #16a34a);
  outline-offset: 2px;
}
.apex-plc-btn-primary:disabled { opacity: 0.55; cursor: not-allowed !important; }
.apex-plc-honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.apex-plc-visitor-end {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid #e2e8f0;
  background: #f1f5f9;
}
.apex-plc-visitor-end-btn {
  padding: 0.35rem 0.65rem !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  border: none !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: #64748b !important;
  cursor: pointer !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.apex-plc-visitor-end-btn:hover {
  color: #0f172a !important;
}
.apex-plc-visitor-end-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
}
.apex-plc-visitor-end-btn:focus-visible {
  outline: 2px solid var(--apex-plc-accent, #16a34a);
  outline-offset: 2px;
}

.apex-plc-compose {
  padding: 0.75rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.apex-plc-compose textarea {
  flex: 1;
  min-height: 2.5rem;
  max-height: 6rem;
  resize: vertical;
  padding: 0.5rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
}
.apex-plc-compose button {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--apex-plc-accent, #16a34a);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
}
.apex-plc-compose button:disabled { opacity: 0.55; cursor: not-allowed; }

.apex-plc-ended {
  padding: 1rem;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}
