/* CentrixPlus chatbot widget — scoped to #cx-chatbot, classes prefixed cxb-. */
#cx-chatbot {
  --cxb-color: #40798c;
  --cxb-color-dark: #2f5c6b;
  --cxb-bg: #f4f7f9;
  --cxb-text: #1d2b31;
  --cxb-muted: #6b8087;
  --cxb-border: #e1e8eb;
  --cxb-radius: 18px;
  --cxb-side: 26px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--cxb-text);
}
#cx-chatbot *, #cx-chatbot *::before, #cx-chatbot *::after { box-sizing: border-box; }
#cx-chatbot button { font: inherit; cursor: pointer; }

/* Launcher — sits above the WhatsApp button (bottom-right, 58px) */
.cxb-launcher {
  position: fixed; bottom: 96px; right: var(--cxb-side); z-index: 1250;
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--cxb-color); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 14px 30px -10px rgba(20, 40, 50, .55);
  transition: transform .2s, background .2s;
}
.cxb-left .cxb-launcher { right: auto; left: var(--cxb-side); bottom: 26px; }
.cxb-launcher:hover { transform: scale(1.06); background: var(--cxb-color-dark); }
.cxb-launcher:focus-visible { outline: 3px solid #fff; box-shadow: 0 0 0 6px var(--cxb-color); }
.cxb-launcher svg { width: 28px; height: 28px; transition: transform .25s, opacity .2s; }
.cxb-launcher .cxb-ico-logo { position: relative; display: block; width: 30px; height: 34px; transition: transform .25s, opacity .2s; }
.cxb-launcher .cxb-ico-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cxb-launcher .cxb-ico-badge {
  position: absolute; right: -11px; bottom: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; color: var(--cxb-color); display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(20, 40, 50, .3);
}
.cxb-launcher .cxb-ico-badge svg { width: 14px; height: 14px; margin-top: 1px; }
.cxb-launcher:hover .cxb-ico-badge { color: var(--cxb-color-dark); }
.cxb-launcher .cxb-ico-close { position: absolute; opacity: 0; transform: rotate(-90deg); }
.cxb-open .cxb-launcher .cxb-ico-chat { opacity: 0; transform: rotate(90deg); }
.cxb-open .cxb-launcher .cxb-ico-close { opacity: 1; transform: none; }
.cxb-dot { position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 50%; background: #e5484d; border: 2px solid #fff; }
.cxb-open .cxb-dot { display: none; }

.cxb-teaser {
  position: fixed; bottom: 104px; right: calc(var(--cxb-side) + 70px); z-index: 1250;
  max-width: 240px; background: #fff; color: var(--cxb-text); border-radius: 14px 14px 4px 14px;
  padding: .7rem .9rem; font-size: .88rem; box-shadow: 0 12px 34px -12px rgba(20, 40, 50, .45);
  animation: cxb-pop .35s ease-out; border: 0; text-align: left;
}
.cxb-left .cxb-teaser { right: auto; left: calc(var(--cxb-side) + 70px); bottom: 34px; border-radius: 14px 14px 14px 4px; }
.cxb-open .cxb-teaser { display: none; }

/* Panel */
.cxb-panel {
  position: fixed; bottom: 166px; right: var(--cxb-side); z-index: 1251;
  width: 390px; height: min(640px, calc(100vh - 190px)); max-height: 640px;
  background: #fff; border-radius: var(--cxb-radius);
  box-shadow: 0 24px 60px -18px rgba(15, 35, 45, .45), 0 0 0 1px rgba(15, 35, 45, .06);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(.98); pointer-events: none; visibility: hidden;
  transition: opacity .22s, transform .22s, visibility 0s .22s;
}
.cxb-left .cxb-panel { right: auto; left: var(--cxb-side); bottom: 96px; }
.cxb-open .cxb-panel { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .22s, transform .22s; }

.cxb-head {
  display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem;
  background: linear-gradient(135deg, var(--cxb-color), var(--cxb-color-dark)); color: #fff;
}
.cxb-avatar { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; background: #fff; display: grid; place-items: center; overflow: visible; }
.cxb-avatar img { width: 26px; height: 26px; object-fit: contain; }
.cxb-avatar::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #3ccf7e; border: 2px solid var(--cxb-color); }
.cxb-title { flex: 1; min-width: 0; }
.cxb-name { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cxb-tagline { font-size: .78rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cxb-head-btn { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; }
.cxb-head-btn:hover { background: rgba(255, 255, 255, .26); }
.cxb-head-btn svg { width: 18px; height: 18px; }

.cxb-body { flex: 1; overflow-y: auto; padding: 1rem; background: var(--cxb-bg); display: flex; flex-direction: column; gap: .75rem; scroll-behavior: smooth; overscroll-behavior: contain; }

.cxb-msg { display: flex; flex-direction: column; max-width: 88%; animation: cxb-pop .25s ease-out; }
.cxb-msg.cxb-user { align-self: flex-end; align-items: flex-end; }
.cxb-bubble { padding: .65rem .85rem; border-radius: 16px 16px 16px 4px; background: #fff; box-shadow: 0 1px 2px rgba(15, 35, 45, .06); border: 1px solid var(--cxb-border); word-wrap: break-word; overflow-wrap: anywhere; }
.cxb-user .cxb-bubble { background: var(--cxb-color); color: #fff; border-color: transparent; border-radius: 16px 16px 4px 16px; }
.cxb-bubble p { margin: 0 0 .5em; }
.cxb-bubble p:last-child { margin-bottom: 0; }
.cxb-bubble ul, .cxb-bubble ol { margin: .2em 0 .5em; padding-left: 1.2em; }
.cxb-bubble li { margin: .15em 0; }
.cxb-bubble a { color: var(--cxb-color); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.cxb-user .cxb-bubble a { color: #fff; }
.cxb-bubble code { background: rgba(0, 0, 0, .06); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.cxb-bubble h4 { font-size: 1em; margin: .4em 0 .2em; font-weight: 700; }

.cxb-sources { margin-top: .35rem; font-size: .76rem; color: var(--cxb-muted); display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.cxb-sources a, .cxb-sources span.cxb-src { color: var(--cxb-muted); background: #fff; border: 1px solid var(--cxb-border); border-radius: 999px; padding: .1rem .55rem; text-decoration: none; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cxb-sources a:hover { color: var(--cxb-color); border-color: var(--cxb-color); }

.cxb-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.cxb-opt {
  border: 1.5px solid var(--cxb-color); background: #fff; color: var(--cxb-color);
  border-radius: 999px; padding: .38rem .85rem; font-size: .86rem; font-weight: 600; line-height: 1.3;
  display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; transition: background .15s, color .15s;
}
.cxb-opt:hover:not(:disabled) { background: var(--cxb-color); color: #fff; }
.cxb-opt:disabled { opacity: .45; cursor: default; }
.cxb-opt.cxb-chosen { background: var(--cxb-color); color: #fff; opacity: .8; }
.cxb-opt.cxb-ghost { border-color: var(--cxb-border); color: var(--cxb-muted); font-weight: 500; }
.cxb-opt.cxb-ghost:hover:not(:disabled) { background: var(--cxb-border); color: var(--cxb-text); }
.cxb-opt i { font-style: normal; }

.cxb-rate { display: flex; gap: .2rem; margin-top: .3rem; }
.cxb-rate button { border: 0; background: transparent; color: var(--cxb-muted); padding: .15rem .3rem; border-radius: 6px; display: grid; place-items: center; }
.cxb-rate button:hover, .cxb-rate button.cxb-on { color: var(--cxb-color); background: #fff; }
.cxb-rate svg { width: 15px; height: 15px; }
.cxb-rate-note { font-size: .74rem; color: var(--cxb-muted); align-self: center; margin-left: .2rem; }

.cxb-typing { display: inline-flex; gap: 4px; padding: .8rem .95rem; }
.cxb-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--cxb-muted); animation: cxb-blink 1.2s infinite ease-in-out; }
.cxb-typing span:nth-child(2) { animation-delay: .15s; }
.cxb-typing span:nth-child(3) { animation-delay: .3s; }
.cxb-typing-note { font-size: .74rem; color: var(--cxb-muted); margin-top: .25rem; }

.cxb-suggest { display: flex; gap: .4rem; overflow-x: auto; padding: .55rem .9rem 0; background: #fff; scrollbar-width: none; }
.cxb-suggest::-webkit-scrollbar { display: none; }
.cxb-suggest:empty { display: none; }
.cxb-suggest button { flex: none; border: 1px solid var(--cxb-border); background: var(--cxb-bg); color: var(--cxb-text); border-radius: 999px; padding: .3rem .75rem; font-size: .8rem; white-space: nowrap; }
.cxb-suggest button:hover { border-color: var(--cxb-color); color: var(--cxb-color); }

.cxb-form { display: flex; align-items: flex-end; gap: .5rem; padding: .7rem .8rem; background: #fff; border-top: 1px solid var(--cxb-border); }
.cxb-suggest:not(:empty) + .cxb-form { border-top: 0; }
.cxb-input {
  flex: 1; resize: none; border: 1.5px solid var(--cxb-border); border-radius: 14px; padding: .6rem .85rem;
  font: inherit; font-size: .93rem; color: var(--cxb-text); background: var(--cxb-bg); max-height: 120px; min-height: 42px; line-height: 1.4; outline: none;
}
.cxb-input:focus { border-color: var(--cxb-color); background: #fff; }
.cxb-send { flex: none; width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--cxb-color); color: #fff; display: grid; place-items: center; transition: background .15s, opacity .15s; }
.cxb-send:hover:not(:disabled) { background: var(--cxb-color-dark); }
.cxb-send:disabled { opacity: .45; cursor: default; }
.cxb-send svg { width: 19px; height: 19px; }
.cxb-send.cxb-stop { background: #c4453f; }
.cxb-send.cxb-stop:hover { background: #a3352f; }
.cxb-stop-link { border: 0; background: none; padding: 0 .1rem; color: var(--cxb-color); font-weight: 600; text-decoration: underline; font-size: inherit; }
.cxb-stop-link:hover { color: var(--cxb-color-dark); }
.cxb-foot { text-align: center; font-size: .68rem; color: var(--cxb-muted); padding: 0 0 .5rem; background: #fff; }

.cxb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes cxb-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cxb-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Phones: full screen */
@media (max-width: 575.98px) {
  #cx-chatbot { --cxb-side: 16px; }
  .cxb-launcher { bottom: 92px; width: 54px; height: 54px; }
  .cxb-left .cxb-launcher { bottom: 20px; }
  .cxb-teaser { bottom: 100px; right: 80px; max-width: calc(100vw - 110px); }
  .cxb-panel, .cxb-left .cxb-panel { inset: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .cxb-open .cxb-launcher { display: none; }
  .cxb-input { font-size: 16px; } /* no iOS zoom on focus */
}
@media (prefers-reduced-motion: reduce) {
  #cx-chatbot *, #cx-chatbot *::before, #cx-chatbot *::after { animation: none !important; transition: none !important; }
}

/* Header link button (open full page) */
a.cxb-head-btn { text-decoration: none; }

/* Full-page mode (/chat/): the panel fills its container — no launcher, no floating */
#cx-chatbot.cxb-page { height: 100%; }
#cx-chatbot.cxb-page .cxb-panel {
  position: relative; inset: auto; width: 100%; height: 100%; max-height: none;
  opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition: none;
  border-radius: var(--cxb-radius);
}
#cx-chatbot.cxb-page .cxb-body { padding: 1.25rem clamp(1rem, 4vw, 2.5rem); }
#cx-chatbot.cxb-page .cxb-msg { max-width: min(78%, 720px); }
#cx-chatbot.cxb-page .cxb-form,
#cx-chatbot.cxb-page .cxb-suggest { padding-left: clamp(.8rem, 4vw, 2.5rem); padding-right: clamp(.8rem, 4vw, 2.5rem); }
@media (max-width: 575.98px) {
  #cx-chatbot.cxb-page .cxb-panel { position: relative; inset: auto; border-radius: 0; }
  #cx-chatbot.cxb-page .cxb-msg { max-width: 90%; }
}
.cxb-opt.cxb-ghost.cxb-chosen { background: var(--cxb-border); color: var(--cxb-text); border-color: var(--cxb-border); }

/* Typing suggestions (autocomplete) — floats above the input */
.cxb-form { position: relative; }
.cxb-ac {
  position: absolute; left: .8rem; right: .8rem; bottom: calc(100% + 6px); z-index: 3;
  background: #fff; border: 1px solid var(--cxb-border); border-radius: 14px;
  box-shadow: 0 16px 40px -14px rgba(15, 35, 45, .35); max-height: 280px; overflow-y: auto; padding: .3rem;
  animation: cxb-pop .15s ease-out;
}
.cxb-ac[hidden] { display: none; }
.cxb-ac-item { display: flex; flex-direction: column; gap: .1rem; padding: .5rem .7rem; border-radius: 10px; cursor: pointer; }
.cxb-ac-item:hover, .cxb-ac-item.cxb-active { background: var(--cxb-bg); }
.cxb-ac-item.cxb-active { box-shadow: inset 3px 0 0 var(--cxb-color); }
.cxb-ac-q { font-size: .9rem; color: var(--cxb-text); }
.cxb-ac-q mark { background: none; color: var(--cxb-color); font-weight: 700; padding: 0; }
.cxb-ac-cat { font-size: .72rem; color: var(--cxb-muted); }
#cx-chatbot.cxb-page .cxb-ac { left: clamp(.8rem, 4vw, 2.5rem); right: clamp(.8rem, 4vw, 2.5rem); }

/* Contact form under an unanswered reply */
.cxb-lead { margin-top: .5rem; background: #fff; border: 1.5px solid var(--cxb-color); border-radius: 14px; padding: .8rem; display: grid; gap: .45rem; max-width: 340px; box-shadow: 0 6px 18px -12px rgba(15, 35, 45, .4); }
.cxb-lead-title { font-weight: 600; font-size: .88rem; color: var(--cxb-text); }
.cxb-field { width: 100%; border: 1px solid var(--cxb-border); border-radius: 10px; padding: .5rem .65rem; font: inherit; font-size: .88rem; color: var(--cxb-text); background: var(--cxb-bg); outline: none; resize: vertical; }
.cxb-field:focus { border-color: var(--cxb-color); background: #fff; }
.cxb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cxb-lead-error { font-size: .8rem; color: #c0392b; }
.cxb-lead-actions { display: flex; gap: .5rem; align-items: center; }
.cxb-lead-send { border: 0; background: var(--cxb-color); color: #fff; border-radius: 10px; padding: .5rem .9rem; font-weight: 600; font-size: .86rem; }
.cxb-lead-send:hover:not(:disabled) { background: var(--cxb-color-dark); }
.cxb-lead-send:disabled { opacity: .6; }
.cxb-lead-skip { border: 0; background: none; color: var(--cxb-muted); font-size: .82rem; text-decoration: underline; }
.cxb-lead-privacy { font-size: .7rem; color: var(--cxb-muted); }
.cxb-lead-open { display: block; margin-top: .5rem; border: 1.5px dashed var(--cxb-color); background: #fff; color: var(--cxb-color-dark); border-radius: 12px; padding: .5rem .75rem; font-size: .84rem; font-weight: 600; text-align: left; max-width: 340px; }
.cxb-lead-open:hover { background: var(--cxb-bg); border-style: solid; }
.cxb-lead-done { margin-top: .4rem; font-size: .8rem; color: var(--cxb-muted); }
@media (max-width: 575.98px) { .cxb-field { font-size: 16px; } }

/* Related questions inside an unanswered reply — one per line */
.cxb-related { margin-top: .5rem; display: flex; flex-direction: column; gap: .35rem; max-width: 360px; }
.cxb-related-title { font-size: .78rem; color: var(--cxb-muted); font-weight: 600; margin-bottom: .1rem; }
.cxb-related-item {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem; text-align: left;
  background: #fff; border: 1.5px solid var(--cxb-border); border-radius: 12px; padding: .5rem .75rem;
  font-size: .86rem; color: var(--cxb-text); line-height: 1.35; transition: border-color .15s, background .15s, color .15s;
}
.cxb-related-item i { font-style: normal; color: var(--cxb-color); font-size: 1.1rem; line-height: 1; }
.cxb-related-item:hover:not(:disabled) { border-color: var(--cxb-color); color: var(--cxb-color); }
.cxb-related-item.cxb-chosen { background: var(--cxb-bg); border-color: var(--cxb-color); color: var(--cxb-muted); }

/* Replies appear piece by piece, like a live answer */
.cxb-reveal { opacity: 0; animation: cxb-in .35s ease-out forwards; }
@keyframes cxb-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #cx-chatbot .cxb-reveal { opacity: 1 !important; } }
