/* BJ Live Chat — scoped under #blc-root, no global selectors. */

#blc-root {
  --blc-accent: #2f6f4e;
  --blc-accent-ink: #ffffff;
  --blc-bg: #ffffff;
  --blc-surface: #f4f5f7;
  --blc-ink: #15181d;
  --blc-ink-soft: #5b6470;
  --blc-line: #e3e6ea;
  --blc-bubble-in: #f0f2f5;
  --blc-shadow: 0 12px 40px rgba(16, 20, 26, .18), 0 2px 8px rgba(16, 20, 26, .08);
  --blc-radius: 16px;
}

@media (prefers-color-scheme: dark) {
  #blc-root {
    --blc-bg: #16191e;
    --blc-surface: #1e2229;
    --blc-ink: #eef1f5;
    --blc-ink-soft: #9aa4b1;
    --blc-line: #2c323b;
    --blc-bubble-in: #252b33;
    --blc-shadow: 0 12px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  }
}

#blc-root *,
#blc-root *::before,
#blc-root *::after { box-sizing: border-box; }

/* ---------- launcher ---------- */

.blc-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99990;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 0 16px;
  height: 52px;
  border: 0;
  border-radius: 26px;
  background: var(--blc-accent);
  color: var(--blc-accent-ink);
  font: 600 15px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  cursor: pointer;
  box-shadow: var(--blc-shadow);
  transition: transform .18s ease, box-shadow .18s ease;
  -webkit-tap-highlight-color: transparent;
}

.blc-launcher:hover { transform: translateY(-2px); }
.blc-launcher:focus-visible { outline: 3px solid var(--blc-accent); outline-offset: 3px; }
.blc-launcher svg { flex: 0 0 auto; width: 22px; height: 22px; }
.blc-launcher-text { white-space: nowrap; }
.blc-launcher-text-sm { display: none; white-space: nowrap; }
.blc-launcher[hidden] { display: none; }

/* `hidden` has to win inside the widget. .blc-panel sets display:flex, and an
   author rule beats the browser's own [hidden]{display:none}, which left the
   panel stuck open — on a phone it is full-screen, so that buried the site. */
#blc-root [hidden],
.blc-panel[hidden] { display: none !important; }

.blc-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e5484d;
  border: 2px solid var(--blc-accent);
}

@media (max-width: 480px) {
  /* A bare circle on a phone reads as a mystery button. Keep the words. */
  .blc-launcher {
    right: 12px;
    bottom: 12px;
    height: 46px;
    padding: 0 16px 0 13px;
    gap: 8px;
    font-size: 14px;
    max-width: calc(100vw - 24px);
  }
  .blc-launcher svg { width: 19px; height: 19px; }
  .blc-launcher-text { display: none; }
  .blc-launcher-text-sm { display: inline; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- panel ---------- */

.blc-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  /* Above other floating widgets (WPLoyalty sits at 999999999),
     but still below age-verification modals, which must never be covered. */
  z-index: 1000000000;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--blc-bg);
  color: var(--blc-ink);
  border: 1px solid var(--blc-line);
  border-radius: var(--blc-radius);
  box-shadow: var(--blc-shadow);
  font: 400 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  animation: blc-in .18s ease-out;
}

@keyframes blc-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
  /* Full-screen on a phone, and dragging is off — so an inline position set on a
     bigger screen must not leak in here and strand the panel. */
  .blc-panel {
    right: 0 !important; bottom: 0 !important; left: 0 !important; top: 0 !important;
    width: 100%; height: 100%;
    max-width: none; max-height: none;
    border: 0; border-radius: 0;
  }
  /* A thumb needs a bigger target than a mouse. */
  .blc-close { width: 46px; height: 46px; }
  .blc-close svg { width: 22px; height: 22px; }
  .blc-head { padding: 16px 12px 16px 18px; }
}

.blc-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 18px;
  background: var(--blc-accent);
  color: var(--blc-accent-ink);
}

.blc-head-title { font-weight: 700; font-size: 16px; line-height: 1.25; }
.blc-head-sub { font-size: 12.5px; opacity: .85; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.blc-head-text { flex: 1 1 auto; min-width: 0; }

.blc-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa4b1; flex: 0 0 auto; }
.blc-status-dot.is-online { background: #46d16f; }

.blc-head-draggable { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.blc-head-draggable:active { cursor: grabbing; }
.blc-head-draggable .blc-close { cursor: pointer; }

.blc-close {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .15);
  color: inherit;
  cursor: pointer;
}
.blc-close:hover { background: rgba(255, 255, 255, .28); }
.blc-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.blc-close svg { width: 18px; height: 18px; }

.blc-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--blc-bg);
  -webkit-overflow-scrolling: touch;
}

/* ---------- messages ---------- */

.blc-msg { max-width: 84%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.blc-msg-in  { align-self: flex-start; background: var(--blc-bubble-in); border-bottom-left-radius: 4px; }
.blc-msg-out { align-self: flex-end; background: var(--blc-accent); color: var(--blc-accent-ink); border-bottom-right-radius: 4px; }
.blc-msg-sys { align-self: center; max-width: 100%; text-align: center; font-size: 13px; color: var(--blc-ink-soft); background: none; padding: 4px 0; }

.blc-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--blc-bubble-in); border-radius: 14px; border-bottom-left-radius: 4px; }
.blc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--blc-ink-soft); animation: blc-blink 1.2s infinite; }
.blc-typing i:nth-child(2) { animation-delay: .2s; }
.blc-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blc-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------- FAQ ---------- */

.blc-faq-intro { font-size: 13px; color: var(--blc-ink-soft); margin: 4px 0 2px; }

.blc-faq-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 1px solid var(--blc-line);
  border-radius: 12px;
  background: var(--blc-surface);
  color: var(--blc-ink);
  font: inherit;
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.blc-faq-btn:hover { border-color: var(--blc-accent); }
.blc-faq-btn:focus-visible { outline: 2px solid var(--blc-accent); outline-offset: 2px; }

/* ---------- composer / form ---------- */

.blc-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--blc-line);
  padding: 12px;
  background: var(--blc-bg);
}

.blc-row { display: flex; gap: 8px; align-items: flex-end; }

.blc-input,
.blc-text {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--blc-line);
  border-radius: 10px;
  background: var(--blc-surface);
  color: var(--blc-ink);
  font: inherit;
  font-size: 15px;
  resize: none;
}
.blc-input:focus,
.blc-text:focus { outline: 2px solid var(--blc-accent); outline-offset: -1px; border-color: transparent; }
.blc-text { min-height: 44px; max-height: 120px; line-height: 1.4; }

.blc-send {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: var(--blc-accent);
  color: var(--blc-accent-ink);
  cursor: pointer;
}
.blc-send:disabled { opacity: .45; cursor: default; }
.blc-send:focus-visible { outline: 2px solid var(--blc-accent); outline-offset: 2px; }
.blc-send svg { width: 20px; height: 20px; }

.blc-fields { display: flex; flex-direction: column; gap: 8px; }
.blc-label { font-size: 12.5px; font-weight: 600; color: var(--blc-ink-soft); }

.blc-submit {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--blc-accent);
  color: var(--blc-accent-ink);
  font: 600 15px/1 inherit;
  font-family: inherit;
  cursor: pointer;
}
.blc-submit:disabled { opacity: .5; cursor: default; }
.blc-submit:focus-visible { outline: 2px solid var(--blc-accent); outline-offset: 2px; }

.blc-error { font-size: 13px; color: #e5484d; }
.blc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.blc-fineprint { font-size: 11.5px; color: var(--blc-ink-soft); text-align: center; margin-top: 8px; line-height: 1.4; }

@media (prefers-reduced-motion: reduce) {
  .blc-panel, .blc-launcher { animation: none; transition: none; }
  .blc-typing i { animation: none; opacity: .5; }
}

/* While the chat panel is open, stand down other floating launchers that would
   otherwise punch through it. Harmless on sites without these plugins. */
body.blc-panel-open .wll-launcher-button-container,
body.blc-panel-open .wlr-launcher-button-container,
body.blc-panel-open #perfecty-push-bell {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity .15s ease;
}
