/* Used by the chat document and the launcher shadow root.
   Edit a company copy in Settings > Advanced CSS, then save.
   Shared file changes require deployment. See ../README.md#change-widget-css.
   Use data-bot-id selectors for company rules in the shared file. */

html:has(.chat-widget),
body:has(.chat-widget) {
  background: transparent;
  min-width: 0;
  overflow: hidden;
}

.chat-widget {
  --widget-header-bg: var(--widget-config-header, #296f8d);
  --widget-header-ink: var(--widget-config-header-ink, #fff);
  --widget-visitor-bg: var(--widget-config-visitor, #dcecf3);
  --widget-visitor-ink: var(--widget-config-visitor-ink, #000);
  --widget-assistant-bg: var(--widget-config-assistant, #fff);
  --widget-assistant-ink: var(--widget-config-assistant-ink, #000);
  --widget-frame-border: 2px solid #fff;
  --widget-radius: 16px;
  --widget-surface: #f3f6f8;
  --widget-focus: #1e789e;
  box-sizing: border-box;
  border: var(--widget-frame-border);
  border-radius: var(--widget-radius);
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--widget-surface);
  color: #1d3542;
  overflow: hidden;
  font-family: 'Public Sans Variable', system-ui, sans-serif;
  font-size: max(1rem, 16px);
}
.widget-header {
  background: var(--widget-header-bg);
  color: var(--widget-header-ink);
  padding: 21px 20px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex: none;
}
.widget-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.widget-identity > svg {
  flex: none;
}
.widget-identity img {
  min-width: 0;
  max-width: 130px;
  max-height: 44px;
  object-fit: contain;
}
.widget-identity h1 {
  font-size: 1.05rem;
  letter-spacing: -0.015em;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.widget-icon {
  color: inherit;
  border: 0;
  background: transparent;
  padding: 7px;
  min-height: 44px;
  min-width: 44px;
  flex: none;
  border-radius: 5px;
}
.widget-icon:hover {
  box-shadow: inset 0 0 0 1px currentColor;
}
.widget-header-actions {
  display: flex;
  align-items: center;
  flex: none;
  gap: 2px;
}
.widget-reset {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font-size: 0.82rem;
  white-space: nowrap;
}
.widget-reset:hover {
  box-shadow: inset 0 0 0 1px currentColor;
}
.widget-reset:disabled {
  opacity: 0.5;
}

.widget-local {
  background: #fff8e8;
  color: #755723;
  padding: 8px 15px;
  font-size: 0.69rem;
  line-height: 1.5;
  border-bottom: 1px solid #eee0b9;
  flex: none;
}
.widget-conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 17px 18px;
  scrollbar-color: #bdced7 #f3f6f8;
  scrollbar-width: thin;
}
.chat-bubble {
  padding: 13px 15px;
  border-radius: 12px;
  font-family: var(--widget-message-font, 'Public Sans Variable', system-ui, sans-serif);
  font-size: var(--widget-message-size, 16px);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 95%;
}
.chat-answer {
  background: var(--widget-assistant-bg);
  color: var(--widget-assistant-ink);
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  margin-bottom: 18px;
  border-bottom-left-radius: 4px;
}
.chat-question {
  background: var(--widget-visitor-bg);
  color: var(--widget-visitor-ink);
  margin: 20px 0 15px auto;
  border-bottom-right-radius: 4px;
  max-width: 87%;
}
.welcome-message {
  margin-top: 1px;
}
.chat-turn + .chat-turn {
  margin-top: 6px;
}
.chat-sources {
  border-top: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  margin-top: 8px;
  padding-top: 4px;
  white-space: normal;
  font-family: 'Public Sans Variable', system-ui, sans-serif;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0 10px;
}
.chat-sources > span {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  font-size: 0.68rem;
  color: inherit;
  font-weight: 600;
}
.chat-sources a {
  grid-column: 2;
  font-size: 0.74rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1.55;
  color: inherit;
  text-decoration: underline;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 0;
  overflow-wrap: anywhere;
}
.chat-sources a > svg {
  flex: none;
}
.chat-thinking {
  display: flex;
  gap: 5px;
  align-items: center;
  margin: 10px 0 20px;
  padding: 14px 17px;
  min-height: 42px;
}
.chat-thinking > span:not(.sr-only) {
  height: 6px;
  width: 6px;
  background: #799bab;
  border-radius: 50%;
  animation: thinking 1.2s ease-in-out infinite;
}
.chat-thinking > span:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-thinking > span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes thinking {
  50% {
    opacity: 0.35;
    transform: translateY(-2px);
  }
}
.widget-error {
  font-size: 0.79rem;
  line-height: 1.6;
  color: #953b30;
  background: #fff1ee;
  padding: 11px 13px;
  border-radius: 7px;
  margin: 10px 0;
}
.widget-error button {
  border: 0;
  background: transparent;
  color: #753326;
  text-decoration: underline;
  padding: 5px 0;
}
.widget-contact {
  display: flex;
  gap: 0 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 14px 4px;
  font-size: 0.74rem;
  flex: none;
}
.widget-contact a {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: #39677e;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  padding: 8px 4px;
  justify-content: center;
  overflow-wrap: anywhere;
}
.widget-contact a > svg {
  flex: none;
}
.widget-composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  background: #fff;
  border-top: 1px solid #dce5ea;
  border-radius: 0 0 calc(var(--widget-radius) - 2px) calc(var(--widget-radius) - 2px);
  padding: 8px 14px;
  flex: none;
}
.widget-composer textarea {
  border: 0 !important;
  background: transparent !important;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  padding: 9px 5px;
  font-family: var(--widget-message-font, 'Public Sans Variable', system-ui, sans-serif);
  font-size: var(--widget-message-size, 16px);
  line-height: 1.6;
}
.widget-composer textarea:focus {
  outline: 0;
}
.widget-composer:focus-within {
  box-shadow: inset 0 0 0 2px var(--widget-focus);
}
.widget-send {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--widget-header-bg);
  color: var(--widget-header-ink);
}
.widget-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.widget-send:hover:not(:disabled) {
  box-shadow: inset 0 0 0 2px currentColor;
}
.widget-privacy-notice {
  max-width: 65ch;
  margin: 0 0 18px;
  font-size: 0.79rem;
  line-height: 1.55;
  color: #536b77;
}

.widget-header :focus-visible,
.chat-bubble a:focus-visible {
  outline-color: currentColor;
}

/* This section styles only the loader's shadow root. */
:host {
  --widget-launcher-bg: var(--widget-config-launcher, #296f8d);
  --widget-launcher-ink: var(--widget-config-launcher-ink, #fff);
  --widget-radius: 16px;
}
:host(.widget-loader) {
  all: initial;
  position: fixed;
  bottom: calc(var(--chat-bottom, 0px) + 20px);
  right: 20px;
  z-index: 2147483000;
  font-family: system-ui, sans-serif;
}
:host(.widget-loader[hidden]) {
  display: none;
}
.widget-launcher {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  max-width: 100%;
  padding: 0 19px;
  border-radius: 28px;
  background: var(--widget-launcher-bg);
  color: var(--widget-launcher-ink);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 22px #123c5033;
}
.widget-launcher:hover {
  box-shadow: 0 8px 26px #123c5044;
}
.widget-launcher:focus-visible {
  outline: 3px solid #1e789e;
  outline-offset: 4px;
}
.widget-launcher svg {
  width: 22px;
  height: 22px;
  flex: none;
}
.widget-launcher span {
  overflow-wrap: anywhere;
}
.widget-frame {
  display: block;
  width: 390px;
  height: min(650px, calc(var(--chat-height, 100dvh) - 104px));
  border: 0;
  border-radius: var(--widget-radius);
  background: transparent;
  box-shadow: 0 12px 46px #102f4633;
  margin-bottom: 12px;
}
.widget-frame[hidden] {
  display: none;
}
.widget-launcher-row {
  display: flex;
  justify-content: flex-end;
}
@media (max-width: 480px) {
  :host(.widget-loader) {
    bottom: calc(var(--chat-bottom, 0px) + 12px);
    right: 12px;
    left: 12px;
  }
  .widget-frame {
    width: 100%;
    height: calc(var(--chat-height, 100dvh) - 98px);
    max-height: 680px;
  }
  .widget-launcher {
    min-height: 50px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .widget-launcher {
    transition: background 0.16s ease;
  }
}

@media (max-width: 720px) {
  .widget-header {
    padding: 18px 16px;
  }
  .widget-identity h1 {
    font-size: 1rem;
  }
  .widget-conversation {
    padding: 20px 14px 16px;
  }
}
@media (max-width: 370px) {
  .widget-header {
    padding: 16px 13px;
  }
  .widget-identity {
    gap: 8px;
  }
  .widget-identity > svg {
    display: none;
  }
  .widget-identity h1 {
    font-size: 0.92rem;
  }
  .widget-identity img {
    max-width: 100px;
  }
  .widget-contact {
    font-size: 0.69rem;
    gap: 0 8px;
  }
}

@media (max-width: 300px) {
  .widget-header {
    flex-wrap: wrap;
    gap: 4px;
  }
  .widget-identity {
    flex-basis: 100%;
  }
  .widget-header-actions {
    margin-left: auto;
  }
}
