.ccai-sales {
  position: fixed;
  bottom: 20px;
  z-index: 99999;
  width: min(360px, calc(100vw - 32px));
  color: #172033;
  font: inherit;
}

.ccai-sales--bottom-right {
  right: 20px;
}
.ccai-sales--bottom-left {
  left: 20px;
}

.ccai-sales__launcher,
.ccai-sales__form button,
.ccai-sales__action,
.ccai-sales__lead-toggle,
.ccai-sales__lead button {
  padding: 10px 14px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--ccai-sales-color, #4338ca);
  border: 0;
  border-radius: 9px;
}

.ccai-sales__launcher {
  display: grid;
  float: right;
  width: 56px;
  height: 56px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgb(15 23 42 / 24%);
}
.ccai-sales--bottom-left .ccai-sales__launcher {
  float: left;
}

.ccai-sales__panel {
  display: grid;
  clear: both;
  gap: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d9deea;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgb(15 23 42 / 22%);
}

.ccai-sales__header {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  color: #fff;
  background: var(--ccai-sales-color, #4338ca);
}

.ccai-sales__close {
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 0;
}
.ccai-sales__messages {
  display: grid;
  gap: 8px;
  max-height: 320px;
  padding: 0 14px;
  overflow-y: auto;
}
.ccai-sales__message {
  max-width: 88%;
  margin: 0;
  padding: 9px 11px;
  border-radius: 10px;
}
.ccai-sales__message--assistant {
  background: #f1f3f8;
}
.ccai-sales__message--visitor {
  justify-self: end;
  color: #fff;
  background: var(--ccai-sales-color, #4338ca);
}
.ccai-sales__message--notice {
  color: #5a4a00;
  background: #fff5cb;
}
.ccai-sales__product {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: #f8f9fc;
  border: 1px solid #e2e5ed;
  border-radius: 9px;
}
.ccai-sales__product span {
  font-weight: 600;
}
.ccai-sales__product small {
  color: #5d687c;
}
.ccai-sales__product a {
  color: #343caa;
  overflow-wrap: anywhere;
}
.ccai-sales__action,
.ccai-sales__lead-toggle {
  width: max-content;
  text-decoration: none;
}
.ccai-sales__form {
  display: flex;
  gap: 8px;
  align-items: end;
  padding: 0 14px 14px;
}
.ccai-sales__lead {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

/* The send control is the same round arrow the merchant panel uses. */
.ccai-sales__send {
  display: grid;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  font-size: 15px;
  line-height: 1;
  border-radius: 50%;
}
.ccai-sales__form textarea,
.ccai-sales__lead input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px;
  font: inherit;
  border: 1px solid #b8c0d0;
  border-radius: 8px;
}
.ccai-sales__lead label {
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.ccai-sales__lead label:has(input[type='checkbox']) {
  display: flex;
  align-items: start;
  gap: 7px;
}
.ccai-sales__lead input[type='checkbox'] {
  width: auto;
  margin-top: 3px;
}

@media (max-width: 480px) {
  .ccai-sales {
    bottom: 12px;
    width: calc(100vw - 24px);
  }
  .ccai-sales--bottom-right,
  .ccai-sales--bottom-left {
    right: 12px;
    left: 12px;
  }
}

/* A visible focus ring of our own, so the control is findable on any background. */
.ccai-sales button:focus-visible,
.ccai-sales a:focus-visible,
.ccai-sales textarea:focus-visible,
.ccai-sales input:focus-visible {
  outline: 3px solid var(--ccai-sales-color, #087d58);
  outline-offset: 2px;
}

/* Respect a visitor who asked the system for less motion. */
@media (prefers-reduced-motion: reduce) {
  .ccai-sales,
  .ccai-sales * {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 480px) {
  /* dvh follows the browser chrome, so the composer is not hidden behind it. */
  .ccai-sales__panel {
    height: 100dvh;
    max-height: 100dvh;
  }
}

/* The launcher icon takes the colour the merchant chose for the button. */
.ccai-sales__glyph {
  display: grid;
  place-items: center;
}

.ccai-sales .ccai-icon {
  display: block;
  width: 24px;
  height: 24px;
}

.ccai-sales__form button .ccai-icon {
  width: 18px;
  height: 18px;
}
