/* ==========================================================================
   Encore Digital — Chat assistant widget
   Everything is namespaced under .edb so it cannot leak into the site.
   Light theme by default; follows <html data-theme="dark"> from the toggle.
   ========================================================================== */

.edb {
  --edb-navy: #071427;
  --edb-blue: #4168e9;
  --edb-blue-ink: #3556d4;
  --edb-gold: #d8a837;
  --edb-wa: #0c7c6c;
  --edb-wa-hover: #0a695b;

  --edb-bg: #ffffff;
  --edb-log: #f4f6fb;
  --edb-ink: #0e1b30;
  --edb-muted: #5d6878;
  --edb-line: #dfe4ee;
  --edb-bot: #ffffff;
  --edb-bot-line: #e3e8f1;
  --edb-link: #3556d4;
  --edb-chip: #ffffff;
  --edb-chip-ink: #3556d4;
  --edb-input: #f4f6fb;
  --edb-shadow: 0 24px 60px rgba(7, 20, 39, .28), 0 4px 14px rgba(7, 20, 39, .12);

  font-family: "DM Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] .edb {
  --edb-bg: #0c1d3a;
  --edb-log: #091630;
  --edb-ink: #e9f0fc;
  --edb-muted: #9db0cf;
  --edb-line: rgba(130, 170, 240, .22);
  --edb-bot: #152a4e;
  --edb-bot-line: rgba(130, 170, 240, .16);
  --edb-link: #7db4ff;
  --edb-chip: #0f2243;
  --edb-chip-ink: #8fc0ff;
  --edb-input: #091630;
  --edb-shadow: 0 24px 60px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .35);
}

.edb *, .edb *::before, .edb *::after { box-sizing: border-box; }
/* :where() keeps these resets at zero specificity so component colours below always win */
:where(.edb) button { font: inherit; margin: 0; }
:where(.edb) a { text-decoration: none; }

.edb :focus-visible {
  outline: 2px solid var(--edb-gold);
  outline-offset: 2px;
}

/* ---------- Launcher ---------- */
.edb-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 190;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, #1a3c75, #071427);
  box-shadow: 0 10px 28px rgba(7, 20, 39, .4), inset 0 0 0 1px rgba(255, 255, 255, .1);
  transition: transform .28s cubic-bezier(.34, 1.56, .64, 1), box-shadow .28s ease;
}
.edb-launcher:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 16px 34px rgba(7, 20, 39, .45), inset 0 0 0 1px rgba(255, 255, 255, .14); }
.edb-launcher::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid var(--edb-gold);
  opacity: 0;
  animation: edb-ring 3s ease-out 2.5s 3;
  pointer-events: none;
}
.edb-launcher svg { width: 26px; height: 26px; grid-area: 1 / 1; transition: transform .3s ease, opacity .25s ease; }
.edb-launcher .edb-i-close { opacity: 0; transform: rotate(-70deg) scale(.6); }
.edb.edb-open .edb-launcher .edb-i-chat { opacity: 0; transform: rotate(70deg) scale(.6); }
.edb.edb-open .edb-launcher .edb-i-close { opacity: 1; transform: none; }

.edb-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--edb-gold);
  border: 2px solid #071427;
}
.edb.edb-open .edb-dot, .edb.edb-seen .edb-dot { display: none; }

@keyframes edb-ring {
  0%   { opacity: .9; transform: scale(.92); }
  100% { opacity: 0;  transform: scale(1.35); }
}

/* ---------- Teaser bubble ---------- */
.edb-teaser {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 190;
  max-width: 250px;
  padding: 12px 34px 12px 14px;
  border-radius: 14px 14px 4px 14px;
  background: var(--edb-bg);
  color: var(--edb-ink);
  border: 1px solid var(--edb-line);
  box-shadow: 0 14px 34px rgba(7, 20, 39, .22);
  font-size: 13.5px;
  line-height: 1.45;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .3s ease, transform .3s ease, visibility .3s ease;
}
.edb-teaser.edb-show { opacity: 1; visibility: visible; transform: none; }
.edb-teaser b { font-weight: 600; }
.edb-teaser-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--edb-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.edb-teaser-x:hover { background: var(--edb-log); color: var(--edb-ink); }
.edb.edb-open .edb-teaser { display: none; }

/* ---------- Panel ---------- */
.edb-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 190;
  width: 392px;
  max-width: calc(100vw - 24px);
  height: min(640px, calc(100vh - 116px));
  height: min(640px, calc(100dvh - 116px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--edb-bg);
  color: var(--edb-ink);
  border: 1px solid var(--edb-line);
  border-radius: 20px;
  box-shadow: var(--edb-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .25s ease, transform .32s cubic-bezier(.2, .8, .2, 1), visibility .25s ease;
}
.edb.edb-open .edb-panel { opacity: 1; visibility: visible; transform: none; }

/* Header */
.edb-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 15px 16px;
  color: #fff;
  background: radial-gradient(circle at 88% -10%, #1d4283 0, transparent 58%), var(--edb-navy);
}
.edb-head::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--edb-gold), rgba(216, 168, 55, 0) 72%);
}
.edb-av {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--edb-blue);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .18);
}
.edb-av img { display: block; width: 100%; height: 100%; object-fit: cover; }
.edb-who { flex: 1; min-width: 0; }
.edb-title {
  font: 500 18px/1.1 "Playfair Display", Georgia, serif;
  letter-spacing: -.02em;
}
.edb-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  font: 400 10px/1 "DM Mono", ui-monospace, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .75;
}
.edb-sub i { width: 6px; height: 6px; border-radius: 50%; background: #3ddc97; box-shadow: 0 0 0 3px rgba(61, 220, 151, .2); }
.edb-x {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s ease;
}
.edb-x:hover { background: rgba(255, 255, 255, .18); }
.edb-x svg { width: 16px; height: 16px; }

/* Message log */
.edb-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px 10px;
  background: var(--edb-log);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--edb-line) transparent;
}
.edb-log::-webkit-scrollbar { width: 6px; }
.edb-log::-webkit-scrollbar-thumb { background: var(--edb-line); border-radius: 6px; }

.edb-msg {
  max-width: 88%;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: 16px;
  overflow-wrap: anywhere;
  animation: edb-in .3s ease both;
}
.edb-msg.bot {
  align-self: flex-start;
  background: var(--edb-bot);
  color: var(--edb-ink);
  border: 1px solid var(--edb-bot-line);
  border-bottom-left-radius: 5px;
}
.edb-msg.user {
  align-self: flex-end;
  background: var(--edb-blue);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.edb-msg b { font-weight: 600; }
.edb-msg a:not(.edb-btn) { color: var(--edb-link); text-decoration: underline; text-underline-offset: 2px; }
.edb-msg.user a { color: #fff; }

.edb-ul { margin: 7px 0 2px; padding: 0; list-style: none; }
.edb-ul li { position: relative; margin: 4px 0; padding-left: 16px; }
.edb-ul li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--edb-gold);
}
.edb-small { display: block; margin-top: 8px; font-size: 12.5px; color: var(--edb-muted); }

@keyframes edb-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Typing indicator */
.edb-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  background: var(--edb-bot);
  border: 1px solid var(--edb-bot-line);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
}
.edb-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--edb-muted);
  opacity: .5;
  animation: edb-bounce 1.1s ease-in-out infinite;
}
.edb-typing i:nth-child(2) { animation-delay: .15s; }
.edb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes edb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Handoff buttons (inside a bot message) */
.edb-cta { display: grid; gap: 8px; margin-top: 12px; }

.edb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  font: 600 13px/1 "DM Sans", Arial, sans-serif;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.edb-btn:hover { transform: translateY(-1px); }
.edb-btn svg { width: 17px; height: 17px; flex: none; }
.edb-btn.form { background: var(--edb-blue); color: #fff; }
.edb-btn.form:hover { background: var(--edb-blue-ink); }
.edb-btn.wa { background: var(--edb-wa); color: #fff; }
.edb-btn.wa:hover { background: var(--edb-wa-hover); }

/* Quick-reply chips */
.edb-chips { display: flex; flex-wrap: wrap; gap: 7px; align-self: flex-start; max-width: 100%; animation: edb-in .3s ease both; }
.edb-chip {
  padding: 8px 13px;
  border: 1px solid var(--edb-line);
  border-radius: 999px;
  background: var(--edb-chip);
  color: var(--edb-chip-ink);
  font: 500 12.5px/1.2 "DM Sans", Arial, sans-serif;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.edb-chip:hover { background: var(--edb-blue); border-color: var(--edb-blue); color: #fff; transform: translateY(-1px); }

/* Always-visible handoff bar */
.edb-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 8px;
  background: var(--edb-bg);
  border-top: 1px solid var(--edb-line);
}
.edb-bar .edb-btn { min-height: 40px; font-size: 12.5px; }
.edb-bar .edb-btn.form {
  background: transparent;
  color: var(--edb-link);
  border-color: var(--edb-blue);
}
.edb-bar .edb-btn.form:hover { background: var(--edb-blue); color: #fff; }

/* Composer */
.edb-form { display: flex; gap: 8px; padding: 2px 12px 8px; background: var(--edb-bg); }
.edb-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--edb-line);
  border-radius: 12px;
  background: var(--edb-input);
  color: var(--edb-ink);
  font: 400 14px "DM Sans", Arial, sans-serif;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.edb-input::placeholder { color: var(--edb-muted); opacity: .85; }
.edb-input:focus { border-color: var(--edb-blue); box-shadow: 0 0 0 3px rgba(65, 104, 233, .2); }
.edb .edb-input:focus-visible { outline: none; }   /* the blue ring above is the focus indicator */
.edb-send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--edb-blue);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.edb-send:hover { background: var(--edb-blue-ink); transform: translateY(-1px); }
.edb-send svg { width: 18px; height: 18px; }
.edb-note {
  margin: 0;
  padding: 0 14px 11px;
  background: var(--edb-bg);
  text-align: center;
  color: var(--edb-muted);
  font: 400 10px/1.4 "DM Mono", ui-monospace, monospace;
  letter-spacing: .04em;
}

/* ---------- Keep the site's own floating UI clear of the widget ---------- */
.back-to-top { right: 26px; bottom: 92px; }
.toast-stack { bottom: 92px; }
body.edb-is-open .back-to-top {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ---------- Mobile: full-width bottom sheet ---------- */
@media (max-width: 560px) {
  .edb-launcher { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  .edb-teaser { right: 16px; bottom: 84px; max-width: min(250px, calc(100vw - 32px)); }
  .edb-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    height: min(86vh, 720px);
    height: min(86dvh, 720px);
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    transform: translateY(28px);
    transform-origin: bottom center;
  }
  .edb.edb-open .edb-launcher { display: none; }
  .edb-input { font-size: 16px; }         /* stops iOS zooming on focus */
  .edb-note { padding-bottom: calc(11px + env(safe-area-inset-bottom, 0px)); }
  .back-to-top { right: 20px; bottom: 84px; }
  .toast-stack { bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .edb *, .edb *::before, .edb *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print { .edb { display: none !important; } }
