/* Reactive Digital — go2 website chat widget
   A 416px conversation panel, pill launcher, optional teaser, Peter's avatar,
   and a compact lead card. No framework, no external assets except the avatar. */

#rdchat, #rdchat *{
  box-sizing: border-box;
}

#rdchat{
  --rd-primary: #821fa0;
  --rd-primary-dark: #64157d;
  --rd-primary-ink: #6d1889;
  --rd-ink: #1f1b2d;
  --rd-muted: #6b6478;
  --rd-line: #e7e1ee;
  --rd-surface: #f8f5fc;
  --rd-base: #ffffff;
  --rd-on-primary: #ffffff;
  --rd-field-border: #d9d2e3;
  --rd-focus: #b45bd0;
  --rd-radius: 16px;
  --rd-radius-sm: 10px;
  --rd-pill: 999px;
  --rd-ease: cubic-bezier(.2,.8,.2,1);
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  color: var(--rd-ink);
  font-family: Montserrat, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
}

#rdchat button, #rdchat input, #rdchat textarea{
  font: inherit;
}

#rdchat button{
  appearance: none;
  -webkit-appearance: none;
}

#rdchat .rdchat__sr-only{
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---- launcher ---------------------------------------------------------- */
#rdchat .rdchat__launcher{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  min-height: 56px;
  padding: 0 18px 0 8px;
  border: 1px solid var(--rd-line);
  border-radius: var(--rd-pill);
  background: var(--rd-base);
  color: var(--rd-ink);
  box-shadow: 0 8px 28px rgba(31, 27, 45, .16);
  cursor: pointer;
  transition: border-color .2s var(--rd-ease), box-shadow .2s var(--rd-ease), transform .2s var(--rd-ease);
}

#rdchat .rdchat__launcher:hover{
  border-color: var(--rd-primary);
  box-shadow: 0 10px 32px rgba(31, 27, 45, .2);
  transform: translateY(-1px);
}

#rdchat .rdchat__launcher:focus-visible{
  outline: 2px solid var(--rd-focus);
  outline-offset: 3px;
}

#rdchat .rdchat__launcher-ico{
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--rd-pill);
  background: var(--rd-primary);
  color: var(--rd-on-primary);
}

#rdchat .rdchat__launcher-ico svg{
  grid-area: 1 / 1;
  width: 22px;
  height: 22px;
  display: block;
  transition: opacity .2s var(--rd-ease), transform .25s var(--rd-ease);
}

#rdchat .rdchat__launcher-ico .rdchat__i-close{
  opacity: 0;
  transform: rotate(-90deg);
}

#rdchat .rdchat__launcher[aria-expanded="true"] .rdchat__launcher-ico svg:not(.rdchat__i-close){
  opacity: 0;
  transform: rotate(90deg);
}

#rdchat .rdchat__launcher[aria-expanded="true"] .rdchat__i-close{
  opacity: 1;
  transform: none;
}

#rdchat .rdchat__launcher-label{
  color: var(--rd-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

#rdchat .rdchat__launcher[aria-expanded="true"] .rdchat__launcher-label{
  color: var(--rd-ink);
}

/* ---- shared avatar ----------------------------------------------------- */
#rdchat .rdchat__avatar{
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: var(--rd-pill);
  background: var(--rd-primary);
  color: var(--rd-on-primary);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

#rdchat .rdchat__avatar img{
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- teaser ------------------------------------------------------------ */
#rdchat .rdchat__teaser{
  position: absolute;
  right: 0;
  bottom: calc(100% + 28px);
  width: min(286px, calc(100vw - 32px));
  padding: 26px 16px 16px;
  border: 1px solid var(--rd-line);
  border-radius: var(--rd-radius);
  background: var(--rd-base);
  box-shadow: 0 16px 46px rgba(31, 27, 45, .2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s var(--rd-ease), transform .3s var(--rd-ease);
}

#rdchat .rdchat__teaser[hidden]{
  display: none;
}

#rdchat .rdchat__teaser.is-in{
  opacity: 1;
  transform: none;
}

#rdchat .rdchat__teaser .rdchat__avatar--teaser{
  position: absolute;
  top: -22px;
  left: 50%;
  width: 44px;
  height: 44px;
  border: 3px solid var(--rd-base);
  translate: -50% 0;
}

#rdchat .rdchat__teaser-x{
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--rd-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

#rdchat .rdchat__teaser-x:hover{
  color: var(--rd-ink);
}

#rdchat .rdchat__teaser-open{
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

#rdchat .rdchat__teaser-open:focus-visible{
  outline: 2px solid var(--rd-focus);
  outline-offset: 2px;
  border-radius: var(--rd-radius-sm);
}

#rdchat .rdchat__teaser-text{
  display: block;
  color: var(--rd-ink);
  font-size: 13px;
  line-height: 1.6;
  text-wrap: pretty;
}

#rdchat .rdchat__teaser-field{
  display: flex;
  align-items: center;
  min-height: 42px;
  margin-top: 12px;
  padding: 0 13px;
  border: 1px solid var(--rd-field-border);
  border-radius: var(--rd-radius-sm);
  color: var(--rd-muted);
  font-size: 12.5px;
  transition: border-color .2s var(--rd-ease);
}

#rdchat .rdchat__teaser-open:hover .rdchat__teaser-field{
  border-color: var(--rd-primary);
}

/* ---- panel ------------------------------------------------------------- */
#rdchat .rdchat__panel{
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  width: min(416px, calc(100vw - 32px));
  max-height: min(700px, calc(100dvh - 6rem));
  overflow: hidden;
  border: 1px solid var(--rd-line);
  border-radius: var(--rd-radius);
  background: var(--rd-base);
  box-shadow: 0 24px 70px rgba(31, 27, 45, .24);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .2s var(--rd-ease), transform .2s var(--rd-ease);
}

#rdchat .rdchat__panel[hidden]{
  display: none;
}

#rdchat .rdchat__panel.is-open{
  opacity: 1;
  transform: none;
}

#rdchat .rdchat__head{
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  padding: 12px 12px 12px 16px;
  background: linear-gradient(135deg, #8e25ad 0%, #6d1889 100%);
  color: var(--rd-on-primary);
}

#rdchat .rdchat__avatar--head{
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, .7);
}

#rdchat .rdchat__id{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  margin-right: auto;
  line-height: 1.25;
}

#rdchat .rdchat__id strong{
  overflow: hidden;
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#rdchat .rdchat__id small{
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 500;
  opacity: .9;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#rdchat .rdchat__close{
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 25px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

#rdchat .rdchat__close:hover, #rdchat .rdchat__close:focus-visible{
  background: rgba(255, 255, 255, .16);
  outline: none;
}

#rdchat .rdchat__log{
  flex: 1 1 auto;
  min-height: 150px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  background: var(--rd-base);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#rdchat .rdchat__row{
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#rdchat .rdchat__avatar--row{
  width: 30px;
  height: 30px;
  font-size: 11px;
}

#rdchat .rdchat__msg{
  max-width: 86%;
  margin: 0;
  padding: 10px 13px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

#rdchat .rdchat__row .rdchat__msg{
  max-width: calc(100% - 38px);
}

#rdchat .rdchat__msg--bot{
  align-self: flex-start;
  border-color: var(--rd-line);
  border-bottom-left-radius: 5px;
  background: var(--rd-surface);
  color: var(--rd-ink);
}

#rdchat .rdchat__msg--me{
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  background: var(--rd-primary);
  color: var(--rd-on-primary);
}

#rdchat .rdchat__actions{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 0 2px 38px;
}

#rdchat .rdchat__action{
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--rd-primary);
  border-radius: 8px;
  background: var(--rd-base);
  color: var(--rd-primary-ink);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

#rdchat .rdchat__action:hover{
  background: var(--rd-primary);
  color: var(--rd-on-primary);
}

#rdchat .rdchat__action:focus-visible{
  outline: 2px solid var(--rd-focus);
  outline-offset: 2px;
}

#rdchat .rdchat__chips{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 1 auto;
  min-height: 0;
  padding: 0 16px 12px;
}

#rdchat .rdchat__chip{
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--rd-line);
  border-radius: 8px;
  background: var(--rd-base);
  color: var(--rd-ink);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

#rdchat .rdchat__chip:hover{
  border-color: var(--rd-primary);
  color: var(--rd-primary-ink);
}

#rdchat .rdchat__chip--human{
  border-color: var(--rd-primary);
  color: var(--rd-primary-ink);
}

#rdchat .rdchat__chip--human::before{
  content: "→";
  margin-right: 5px;
  font-weight: 800;
}

#rdchat .rdchat__composer{
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--rd-line);
  background: var(--rd-base);
}

#rdchat .rdchat__composer input{
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--rd-field-border);
  border-radius: var(--rd-radius-sm);
  outline: none;
  background: var(--rd-base);
  color: var(--rd-ink);
  font-size: 13px;
  line-height: 1.2;
}

#rdchat .rdchat__composer input::placeholder{
  color: var(--rd-muted);
}

#rdchat .rdchat__composer input:focus{
  border-color: var(--rd-primary);
  box-shadow: 0 0 0 3px rgba(130, 31, 160, .12);
}

#rdchat .rdchat__send{
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--rd-radius-sm);
  background: var(--rd-primary);
  color: var(--rd-on-primary);
  cursor: pointer;
}

#rdchat .rdchat__send:hover{
  background: var(--rd-primary-dark);
}

#rdchat .rdchat__send:focus-visible{
  outline: 2px solid var(--rd-focus);
  outline-offset: 2px;
}

#rdchat .rdchat__send[aria-busy="true"]{
  opacity: .65;
  cursor: wait;
}

#rdchat .rdchat__send svg{
  width: 20px;
  height: 20px;
  display: block;
}

/* ---- lead card --------------------------------------------------------- */
#rdchat .rdchat__lead{
  margin: 4px 0 0;
  padding: 12px;
  border: 1px solid var(--rd-line);
  border-radius: 12px;
  background: var(--rd-surface);
}

#rdchat .rdchat__lead-title{
  margin: 0 0 3px;
  color: var(--rd-ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

#rdchat .rdchat__lead-sub{
  margin: 0 0 10px;
  color: var(--rd-muted);
  font-size: 11px;
  line-height: 1.45;
}

#rdchat .rdchat__field{
  display: block;
  margin-bottom: 8px;
}

#rdchat .rdchat__field > span{
  display: block;
  margin-bottom: 4px;
  color: #3b3449;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.2;
  text-transform: uppercase;
}

#rdchat .rdchat__field input, #rdchat .rdchat__field textarea{
  display: block;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--rd-field-border);
  border-radius: 8px;
  outline: none;
  background: var(--rd-base);
  color: var(--rd-ink);
  font-size: 13px;
  line-height: 1.4;
}

#rdchat .rdchat__field input{
  height: 38px;
}

#rdchat .rdchat__field textarea{
  min-height: 68px;
  resize: vertical;
}

#rdchat .rdchat__field input:focus, #rdchat .rdchat__field textarea:focus{
  border-color: var(--rd-primary);
  box-shadow: 0 0 0 3px rgba(130, 31, 160, .12);
}

#rdchat .rdchat__consent{
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 10px;
  color: var(--rd-muted);
  font-size: 11px;
  line-height: 1.45;
}

#rdchat .rdchat__consent input{
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--rd-primary);
}

#rdchat .rdchat__consent a{
  color: var(--rd-primary-ink);
  text-decoration: underline;
}

#rdchat .rdchat__hp{
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#rdchat .rdchat__turnstile{
  min-height: 0;
  margin: 0 0 9px;
}

#rdchat .rdchat__turnstile:empty{
  margin: 0;
}

#rdchat .rdchat__lead-submit{
  width: 100%;
  min-height: 42px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--rd-primary);
  color: var(--rd-on-primary);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

#rdchat .rdchat__lead-submit:hover{
  background: var(--rd-primary-dark);
}

#rdchat .rdchat__lead-submit:disabled{
  opacity: .65;
  cursor: wait;
}

#rdchat .rdchat__status{
  min-height: 14px;
  margin: 8px 0 0;
  color: var(--rd-muted);
  font-size: 11px;
  line-height: 1.4;
}

#rdchat .rdchat__status.is-error{
  color: #b42318;
}

#rdchat .rdchat__success{
  margin: 4px 0;
  padding: 13px;
  border: 1px solid #b7e4cc;
  border-radius: 10px;
  background: #f0fbf5;
  color: #087443;
  font-size: 12px;
  line-height: 1.5;
}

#rdchat .rdchat__success strong{
  font-weight: 800;
}

/* ---- phone ------------------------------------------------------------- */
@media (max-width: 760px) {
  #rdchat{
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  #rdchat .rdchat__launcher{
    width: 54px;
    height: 54px;
    min-height: 54px;
    justify-content: center;
    padding: 0;
    gap: 0;
  }

  #rdchat .rdchat__launcher-ico{
    width: 40px;
    height: 40px;
  }

  #rdchat .rdchat__launcher-label{
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  #rdchat .rdchat__panel{
    position: fixed;
    inset-inline: 8px;
    bottom: calc(14px + 54px + 10px);
    width: auto;
    max-height: min(78dvh, calc(100dvh - 8rem));
  }

  #rdchat .rdchat__teaser{
    display: none !important;
  }

  #rdchat .rdchat__log{
    min-height: 0;
  }

  #rdchat .rdchat__composer input{
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  #rdchat .rdchat__panel{
    inset-inline: 4px;
  }

  #rdchat .rdchat__log{
    padding: 13px;
  }

  #rdchat .rdchat__chips{
    padding-inline: 13px;
  }

  #rdchat .rdchat__composer{
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #rdchat .rdchat__teaser, #rdchat .rdchat__panel, #rdchat .rdchat__launcher, #rdchat .rdchat__launcher-ico svg{
    transition: none;
  }

  #rdchat .rdchat__teaser, #rdchat .rdchat__panel{
    transform: none;
  }
}
