/* eQMO chat widget. Self-contained: brand colours from the eQMO design system. */
.eqmo-chat {
  --eqmo-primary: #260a5e;
  --eqmo-primary-2: #5b2bc4;
  --eqmo-ink: #030108;
  --eqmo-muted: #7d7c80;
  --eqmo-line: #cbcacc;
  --eqmo-bg: #f6f6f6;
  position: fixed;
  right: max(2.5rem, calc(env(safe-area-inset-right) + 1.25rem));
  bottom: max(3.75rem, calc(env(safe-area-inset-bottom) + 1.25rem));
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--eqmo-ink);
}

.eqmo-chat--left {
  right: auto;
  left: max(2.5rem, calc(env(safe-area-inset-left) + 1.25rem));
  align-items: flex-start;
}

.eqmo-chat *,
.eqmo-chat *::before {
  box-sizing: border-box;
}

.eqmo-chat button {
  font: inherit;
  cursor: pointer;
}

.eqmo-chat :focus-visible {
  outline: 2px solid var(--eqmo-primary-2);
  outline-offset: 3px;
}

/* Launcher */
.eqmo-chat__launcher {
  display: flex;
  width: 3.75rem;
  height: 3.75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--eqmo-primary), var(--eqmo-primary-2));
  box-shadow: 0 18px 40px -14px rgb(91 43 196 / 0.7);
  touch-action: none;
  transition: scale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.eqmo-chat__launcher:hover {
  scale: 1.06;
}

/* Panel */
.eqmo-chat__panel {
  display: flex;
  width: min(24rem, calc(100vw - 5rem));
  height: min(36rem, calc(100dvh - 10.75rem));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--eqmo-line);
  border-radius: 1.5rem;
  background: #fff;
  box-shadow: 0 28px 64px -20px rgb(38 10 94 / 0.4);
  animation: eqmo-chat-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.eqmo-chat__panel[hidden] {
  display: none;
}

@keyframes eqmo-chat-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

.eqmo-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 1rem 1.25rem;
  color: #fff;
  background:
    radial-gradient(70% 120% at 100% 0%, rgb(116 70 219 / 0.55), transparent 62%),
    linear-gradient(160deg, #260a5e, #10042b);
}

.eqmo-chat__title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.eqmo-chat__dots {
  display: flex;
  gap: 0.25rem;
}

.eqmo-chat__dot {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 999px;
}

.eqmo-chat__dot--red {
  background: #fa0a50;
}

.eqmo-chat__dot--amber {
  background: #ffcf00;
}

.eqmo-chat__dot--green {
  background: #04ac63;
}

.eqmo-chat__dot--cyan {
  background: #00bde8;
}

.eqmo-chat__close {
  display: flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgb(255 255 255 / 0.12);
}

.eqmo-chat__close:hover {
  background: rgb(255 255 255 / 0.22);
}

.eqmo-chat__note {
  margin: 0;
  padding: 0.625rem 1.25rem;
  border-bottom: 1px solid #e6e6e8;
  font-size: 0.75rem;
  color: var(--eqmo-muted);
  background: var(--eqmo-bg);
}

.eqmo-chat__log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.625rem;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  overscroll-behavior: contain;
}

.eqmo-chat__msg {
  max-width: 88%;
  margin: 0;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.eqmo-chat__msg--bot {
  align-self: flex-start;
  border-bottom-left-radius: 0.25rem;
  background: var(--eqmo-bg);
}

.eqmo-chat__msg--user {
  align-self: flex-end;
  border-bottom-right-radius: 0.25rem;
  color: #fff;
  background: var(--eqmo-primary);
}

.eqmo-chat__msg--error {
  align-self: stretch;
  max-width: none;
  border: 1px solid rgb(250 10 80 / 0.25);
  font-size: 0.8125rem;
  color: #a3063a;
  background: rgb(250 10 80 / 0.06);
}

.eqmo-chat__msg--typing {
  color: var(--eqmo-muted);
  animation: eqmo-chat-pulse 1.2s ease-in-out infinite;
}

@keyframes eqmo-chat-pulse {
  50% {
    opacity: 0.45;
  }
}

.eqmo-chat__msg a {
  color: var(--eqmo-primary-2);
  font-weight: 500;
  text-decoration: underline;
}

.eqmo-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0 1.25rem 0.75rem;
}

.eqmo-chat__suggestions[hidden] {
  display: none;
}

.eqmo-chat__suggestion {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--eqmo-line);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--eqmo-primary);
  background: #fff;
  transition:
    background-color 0.2s,
    color 0.2s,
    border-color 0.2s;
}

.eqmo-chat__suggestion:hover {
  border-color: transparent;
  color: #fff;
  background: var(--eqmo-primary);
}

.eqmo-chat__form {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.25rem 1.25rem;
  border-top: 1px solid #e6e6e8;
}

.eqmo-chat__input {
  flex: 1;
  min-height: 2.75rem;
  max-height: 7.5rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--eqmo-line);
  border-radius: 1rem;
  font: inherit;
  color: var(--eqmo-ink);
  background: #fff;
  resize: none;
}

.eqmo-chat__input:focus {
  border-color: var(--eqmo-primary-2);
  outline: none;
  box-shadow: 0 0 0 4px rgb(116 70 219 / 0.16);
}

.eqmo-chat__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.eqmo-chat__send {
  display: flex;
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--eqmo-primary);
}

.eqmo-chat__send:disabled {
  cursor: default;
  opacity: 0.5;
}

.eqmo-chat__count {
  padding: 0 1.25rem 0.625rem;
  font-size: 0.6875rem;
  text-align: right;
  color: var(--eqmo-muted);
}

/* Phones: the panel becomes a sheet across the bottom of the screen. */
@media (max-width: 480px) {
  .eqmo-chat--open {
    inset: auto 0 0 0;
    align-items: stretch;
    gap: 0;
  }

  .eqmo-chat--open .eqmo-chat__panel {
    width: 100%;
    height: min(85dvh, 40rem);
    border-width: 1px 0 0;
    border-radius: 1.5rem 1.5rem 0 0;
  }

  .eqmo-chat--open .eqmo-chat__launcher {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .eqmo-chat__panel,
  .eqmo-chat__msg--typing {
    animation: none;
  }

  .eqmo-chat__launcher {
    transition: none;
  }
}
