/* Onxeera Assistant: website chat widget (inc/lead-chat.php, assets/js/lead-chat.js).
   Everything is scoped to #onx-lc so theme styles and the widget never collide. */

#onx-lc {
  --lc-accent: var(--onx-blue, #B5532F);
  --lc-ink: var(--onx-ink, #141413);
  --lc-tx2: var(--onx-tx2, #3D3D3A);
  --lc-mu: var(--onx-mu, #5E5D59);
  --lc-paper: var(--onx-paper, #FAF9F5);
  --lc-line: var(--onx-line, #E6E3DA);
  --lc-tint: var(--onx-tint, #FBF4EF);
  --lc-good: #0F7A45;
  --lc-mid: #9A4A00;
  --lc-low: #B42318;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9990;
  font-family: var(--onx-sans, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--lc-ink);
}
#onx-lc *, #onx-lc *::before, #onx-lc *::after { box-sizing: border-box; }
#onx-lc .onx-lc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Launcher */
#onx-lc .onx-lc-launch {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 20px 0 16px; margin: 0 0 0 auto;
  background: var(--lc-ink); color: #fff;
  border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(20,20,19,.45);
  transition: background-color .15s ease;
}
#onx-lc .onx-lc-launch:hover { background: var(--lc-accent); }
#onx-lc .onx-lc-launch:focus-visible { outline: 3px solid var(--onx-sky, #E3A68A); outline-offset: 3px; }
#onx-lc.is-open .onx-lc-launch-label { display: none; }
#onx-lc.is-open .onx-lc-launch { padding: 0; width: 52px; justify-content: center; }

/* Panel */
#onx-lc .onx-lc-panel {
  position: absolute; right: 0; bottom: 64px;
  width: 380px; height: min(620px, calc(100vh - 110px));
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--lc-line); border-radius: 14px;
  box-shadow: 0 24px 48px -20px rgba(20,20,19,.28);
  overflow: hidden;
}
#onx-lc .onx-lc-panel[hidden] { display: none; }

#onx-lc .onx-lc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--lc-line); background: var(--lc-paper);
}
#onx-lc .onx-lc-head img { border-radius: 6px; flex: none; }
#onx-lc .onx-lc-head > div { flex: 1; min-width: 0; }
#onx-lc .onx-lc-title { font-family: var(--onx-serif, Georgia, serif); font-size: 19px; line-height: 1.2; }
#onx-lc .onx-lc-sub { font-size: 12.5px; color: var(--lc-mu); }
#onx-lc .onx-lc-close {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--lc-tx2); cursor: pointer;
}
#onx-lc .onx-lc-close:hover { background: var(--lc-line); color: var(--lc-ink); }

/* Messages */
#onx-lc .onx-lc-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fff; overscroll-behavior: contain; }
#onx-lc .onx-lc-msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; word-wrap: break-word; overflow-wrap: anywhere; }
#onx-lc .onx-lc-bot { align-self: flex-start; background: var(--lc-paper); border: 1px solid var(--lc-line); border-bottom-left-radius: 4px; color: var(--lc-ink); }
#onx-lc .onx-lc-user { align-self: flex-end; background: var(--lc-ink); color: #fff; border-bottom-right-radius: 4px; }
#onx-lc .onx-lc-bot a { color: var(--lc-accent); text-decoration: underline; }
#onx-lc .onx-lc-bot strong { font-weight: 600; }

#onx-lc .onx-lc-typing { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
#onx-lc .onx-lc-typing span:not(.onx-lc-sr) { width: 7px; height: 7px; border-radius: 50%; background: var(--lc-mu); animation: onx-lc-dot 1.2s infinite ease-in-out; }
#onx-lc .onx-lc-typing span:nth-child(2) { animation-delay: .15s; }
#onx-lc .onx-lc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes onx-lc-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Cards (scan result, lead form) */
#onx-lc .onx-lc-card { align-self: stretch; background: #fff; border: 1px solid var(--lc-line); border-radius: 12px; padding: 14px; }
#onx-lc .onx-lc-eyebrow { font-family: var(--onx-mono, ui-monospace, monospace); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--lc-mu); }

#onx-lc .onx-lc-scan-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
#onx-lc .onx-lc-host { font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
#onx-lc .onx-lc-score { font-family: var(--onx-serif, Georgia, serif); line-height: 1; white-space: nowrap; }
#onx-lc .onx-lc-score b { font-weight: 400; font-size: 38px; }
#onx-lc .onx-lc-score span { font-size: 15px; color: var(--lc-mu); }
#onx-lc .onx-lc-score.onx-lc-good b { color: var(--lc-good); }
#onx-lc .onx-lc-score.onx-lc-mid b { color: var(--lc-mid); }
#onx-lc .onx-lc-score.onx-lc-low b { color: var(--lc-low); }
#onx-lc .onx-lc-bar { height: 6px; background: var(--lc-line); border-radius: 99px; margin-top: 10px; overflow: hidden; }
#onx-lc .onx-lc-bar i { display: block; height: 100%; border-radius: 99px; }
#onx-lc .onx-lc-bar i.onx-lc-good { background: var(--lc-good); }
#onx-lc .onx-lc-bar i.onx-lc-mid { background: var(--lc-mid); }
#onx-lc .onx-lc-bar i.onx-lc-low { background: var(--lc-low); }
#onx-lc .onx-lc-issues { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
#onx-lc .onx-lc-issues li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
#onx-lc .onx-lc-issues li div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#onx-lc .onx-lc-issues li strong { font-weight: 600; }
#onx-lc .onx-lc-issues li span:not(.onx-lc-pri) { color: var(--lc-tx2); }
#onx-lc .onx-lc-pri { flex: none; margin-top: 1px; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
#onx-lc .onx-lc-pri-high { background: #FDE8E6; color: var(--lc-low); }
#onx-lc .onx-lc-pri-medium { background: #FCEFD9; color: var(--lc-mid); }
#onx-lc .onx-lc-pri-low { background: var(--lc-paper); color: var(--lc-tx2); border: 1px solid var(--lc-line); }
#onx-lc .onx-lc-ok, #onx-lc .onx-lc-more { margin: 10px 0 0; font-size: 13px; color: var(--lc-mu); }

/* Lead form */
#onx-lc .onx-lc-lead { display: flex; flex-direction: column; gap: 10px; background: var(--lc-tint); border-color: #EBD3C5; }
#onx-lc .onx-lc-lead label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--lc-ink); }
#onx-lc .onx-lc-lead label small { font-weight: 400; color: var(--lc-mu); }
#onx-lc .onx-lc-lead input[type=text], #onx-lc .onx-lc-lead input[type=email], #onx-lc .onx-lc-lead input[type=tel], #onx-lc .onx-lc-lead select {
  width: 100%; min-height: 42px; padding: 8px 11px; margin: 0;
  font: inherit; font-size: 15px; color: var(--lc-ink);
  background: #fff; border: 1px solid #D4D0C4; border-radius: 8px; box-shadow: none;
}
#onx-lc .onx-lc-lead input:focus, #onx-lc .onx-lc-lead select:focus { outline: 2px solid var(--lc-accent); outline-offset: 0; border-color: var(--lc-accent); }
#onx-lc .onx-lc-lead .onx-lc-consent { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--lc-tx2); }
#onx-lc .onx-lc-consent input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--lc-accent); }
#onx-lc .onx-lc-consent a { color: var(--lc-accent); }
#onx-lc .onx-lc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
#onx-lc .onx-lc-err { margin: 0; font-size: 13px; color: var(--lc-low); min-height: 0; }
#onx-lc .onx-lc-err:empty { display: none; }
#onx-lc .onx-lc-btn {
  min-height: 46px; padding: 0 16px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--lc-accent); color: #fff; font: inherit; font-weight: 600;
}
#onx-lc .onx-lc-btn:hover { background: var(--lc-ink); }
#onx-lc .onx-lc-btn:disabled { opacity: .7; cursor: progress; }
#onx-lc .onx-lc-skip { min-height: 44px; background: transparent; border: 0; color: var(--lc-tx2); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; }

/* Quick replies */
#onx-lc .onx-lc-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; background: #fff; }
#onx-lc .onx-lc-quick:empty { display: none; }
#onx-lc .onx-lc-chip {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  background: #fff; color: var(--lc-ink); border: 1px solid #D4D0C4; border-radius: 999px;
  font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
}
#onx-lc .onx-lc-chip:hover { border-color: var(--lc-ink); color: var(--lc-ink); }
#onx-lc .onx-lc-chip.is-primary { background: var(--lc-accent); border-color: var(--lc-accent); color: #fff; }
#onx-lc .onx-lc-chip.is-primary:hover { background: var(--lc-ink); border-color: var(--lc-ink); }

/* Input */
#onx-lc .onx-lc-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--lc-line); background: var(--lc-paper); margin: 0; }
#onx-lc .onx-lc-input input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; margin: 0;
  font: inherit; font-size: 15px; color: var(--lc-ink);
  background: #fff; border: 1px solid #D4D0C4; border-radius: 999px; box-shadow: none;
}
#onx-lc .onx-lc-input input:focus { outline: 2px solid var(--lc-accent); outline-offset: 0; border-color: var(--lc-accent); }
#onx-lc .onx-lc-input button {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  background: var(--lc-ink); color: #fff; border: 0; border-radius: 50%; cursor: pointer;
}
#onx-lc .onx-lc-input button:hover { background: var(--lc-accent); }

#onx-lc button:focus-visible, #onx-lc a:focus-visible { outline: 3px solid var(--onx-sky, #E3A68A); outline-offset: 2px; }

/* Phones: launcher becomes a round button, panel becomes a full-width sheet */
@media (max-width: 520px) {
  #onx-lc { right: 14px; bottom: 14px; }
  #onx-lc .onx-lc-launch-label { display: none; }
  #onx-lc .onx-lc-launch { width: 56px; min-height: 56px; padding: 0; justify-content: center; }
  #onx-lc.is-open { left: 0; right: 0; bottom: 0; top: 0; }
  #onx-lc.is-open .onx-lc-launch { display: none; }
  #onx-lc .onx-lc-panel { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #onx-lc * { animation: none !important; transition: none !important; }
}

@media print { #onx-lc { display: none !important; } }
