/* IMASoL AI chat widget */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-widget {
  position: fixed;
  right: clamp(12px, 2.5vw, 28px);
  bottom: calc(clamp(12px, 2.5vw, 28px) + var(--cookie-banner-height, 0px));
  z-index: 300;
  font-family: var(--font-sans);
  pointer-events: none;
}

.chat-widget > * {
  pointer-events: auto;
}

/* 3D floating launcher — robot mascot + pill button */
.chat-widget__launcher-float {
  position: relative;
  display: inline-block;
  animation: chat-launcher-float 5.5s ease-in-out infinite;
  transform-style: preserve-3d;
  perspective: 600px;
}

.chat-widget.is-chat-open .chat-widget__launcher-float {
  animation: none;
}

.chat-widget__launcher.chat-widget__launcher-cluster {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.chat-widget__launcher-inner {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
}

.chat-widget__mascot-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: clamp(50px, 11vw, 62px);
  height: clamp(50px, 11vw, 62px);
  margin: -4px 0 -2px;
  background: transparent;
  transform: perspective(480px) rotateY(-12deg) rotateX(8deg) translateZ(12px);
  transform-style: preserve-3d;
}

.chat-widget__mascot {
  display: block;
  width: 118%;
  height: 118%;
  margin: 0;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  background: transparent;
  mix-blend-mode: normal;
  filter:
    drop-shadow(0 10px 12px rgba(22, 40, 68, 0.45))
    drop-shadow(0 2px 0 rgba(255, 255, 255, 0.35));
  transform-origin: center bottom;
  animation: chat-mascot-bob 5.5s ease-in-out infinite;
}

.chat-widget.is-chat-open .chat-widget__mascot {
  animation: none;
}

@keyframes chat-mascot-bob {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }

  50% {
    transform: translate3d(0, -4px, 0) scale(1.03);
  }
}

.chat-widget__launcher-shadow {
  pointer-events: none;
  position: absolute;
  left: 18%;
  right: 8%;
  bottom: -10px;
  height: 14px;
  border-radius: 50%;
  background: rgba(33, 49, 78, 0.32);
  filter: blur(8px);
  transform: scaleX(1);
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.chat-widget__launcher {
  position: relative;
  z-index: 1;
  display: block;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-widget__launcher-face {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  padding: 12px 22px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(
    168deg,
    #6f8fc4 0%,
    var(--brand-blue) 28%,
    #355580 72%,
    #2a4568 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -5px 0 rgba(33, 49, 78, 0.45),
    0 5px 0 #253a5c,
    0 9px 0 rgba(37, 55, 90, 0.55),
    0 14px 28px rgba(63, 95, 151, 0.38),
    0 22px 40px rgba(33, 49, 78, 0.22);
  transform: perspective(520px) rotateX(12deg) translateZ(0);
  transform-style: preserve-3d;
  text-shadow: 0 1px 2px rgba(33, 49, 78, 0.35);
}

.chat-widget__launcher-face::after {
  content: "";
  pointer-events: none;
  position: absolute;
  left: 8px;
  bottom: 6px;
  width: 42%;
  height: 28%;
  border-radius: 50%;
  background: rgba(33, 49, 78, 0.28);
  filter: blur(6px);
  transform: perspective(520px) rotateX(75deg) scaleY(0.45);
  opacity: 0.55;
}

.chat-widget__launcher-shine {
  pointer-events: none;
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  z-index: 0;
  background: radial-gradient(
    ellipse 75% 55% at 28% 18%,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0.12) 42%,
    transparent 62%
  );
}

.chat-widget__launcher:hover .chat-widget__launcher-face {
  transform: perspective(520px) rotateX(6deg) translateY(-2px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 0 -5px 0 rgba(33, 49, 78, 0.4),
    0 7px 0 #253a5c,
    0 12px 0 rgba(37, 55, 90, 0.5),
    0 18px 34px rgba(63, 95, 151, 0.42),
    0 26px 48px rgba(33, 49, 78, 0.24);
}

.chat-widget__launcher:hover + .chat-widget__launcher-shadow {
  transform: scaleX(1.08);
  opacity: 0.85;
}

.chat-widget__launcher:focus:not(:focus-visible) {
  outline: none;
}

.chat-widget__launcher:focus-visible .chat-widget__launcher-face {
  outline: 2px solid var(--accent-gold);
  outline-offset: 4px;
}

.chat-widget__launcher-cluster.is-popping {
  animation: chat-launcher-pop 0.72s cubic-bezier(0.34, 1.35, 0.64, 1);
}

.chat-widget__launcher-cluster.is-popping + .chat-widget__launcher-shadow {
  animation: chat-launcher-shadow-pop 0.72s ease;
}

.chat-widget__launcher-cluster.is-popping .chat-widget__mascot-wrap {
  animation: chat-mascot-pop-wrap 0.72s cubic-bezier(0.34, 1.35, 0.64, 1);
}

.chat-widget__launcher-cluster.is-popping .chat-widget__mascot {
  animation: chat-mascot-pop 0.72s cubic-bezier(0.34, 1.35, 0.64, 1);
}

@keyframes chat-launcher-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(0, -7px, 0);
  }
}

@keyframes chat-launcher-pop {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }

  35% {
    transform: translate3d(0, -16px, 0) scale(1.1);
  }

  55% {
    transform: translate3d(0, -6px, 0) scale(1.04);
  }

  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes chat-launcher-shadow-pop {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.75;
  }

  35% {
    transform: scaleX(0.82);
    opacity: 0.45;
  }
}

@keyframes chat-mascot-pop-wrap {
  0% {
    transform: perspective(480px) rotateY(-12deg) rotateX(8deg) translateZ(12px) scale(1);
  }

  35% {
    transform: perspective(480px) rotateY(-8deg) rotateX(4deg) translateZ(18px) scale(1.08) translateY(-8px);
  }

  100% {
    transform: perspective(480px) rotateY(-12deg) rotateX(8deg) translateZ(12px) scale(1);
  }
}

@keyframes chat-mascot-pop {
  0% {
    transform: translateY(0) scale(1);
  }

  35% {
    transform: translateY(-6px) scale(1.06);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

.chat-widget__launcher-text {
  max-width: 140px;
  text-align: left;
  line-height: 1.2;
}

@media (max-width: 480px) {
  .chat-widget__mascot-wrap {
    width: 44px;
    height: 44px;
    transform: perspective(480px) rotateY(-10deg) rotateX(6deg) translateZ(8px);
  }

  .chat-widget__launcher-text {
    font-size: 0.82rem;
    max-width: 108px;
  }

  .chat-widget__launcher-face {
    padding: 8px 14px 8px 10px;
  }
}

.chat-widget__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100vw - 24px));
  max-height: min(640px, calc(100vh - 120px - var(--cookie-banner-height, 0px)));
  border-radius: 20px;
  border: 1px solid rgba(63, 95, 151, 0.16);
  background: linear-gradient(180deg, #ffffff 0%, #f7fafd 100%);
  box-shadow:
    0 24px 64px rgba(33, 49, 78, 0.2),
    0 8px 24px rgba(63, 95, 151, 0.12);
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 18px, 0) scale(0.94);
  transition:
    opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.38s;
}

.chat-widget.is-chat-open .chat-widget__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
}

.chat-widget__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  background: linear-gradient(135deg, var(--brand-blue) 0%, #4d6fa8 100%);
  color: #fff;
}

.chat-widget__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.chat-widget__subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
  opacity: 0.9;
  line-height: 1.35;
}

.chat-widget__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.chat-widget__close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.chat-widget__contact {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(63, 95, 151, 0.1);
  background: rgba(247, 250, 253, 0.95);
}

.chat-widget__contact-hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.chat-widget__contact-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.chat-widget__field {
  min-width: 0;
}

.chat-widget__field--wide,
.chat-widget__contact-btn--wide {
  grid-column: 1 / -1;
}

.chat-widget__contact-btn--wide {
  display: flex;
  width: 100%;
  justify-content: center;
}

.chat-widget__field input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(63, 95, 151, 0.2);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--ink);
}

.chat-widget__field input::placeholder {
  color: #6d7a88;
  opacity: 1;
}

.chat-widget__contact-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent-gold);
  color: var(--brand-navy);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
}

.chat-widget__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}

.chat-widget__chip {
  padding: 6px 12px;
  border: 1px solid rgba(63, 95, 151, 0.22);
  border-radius: 999px;
  background: #fff;
  color: var(--brand-blue);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-widget__chip:hover {
  background: rgba(63, 95, 151, 0.08);
}

.chat-widget__messages {
  flex: 1 1 auto;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble--user {
  align-self: flex-end;
  background: linear-gradient(145deg, var(--brand-blue), #4d6fa8);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble--assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(63, 95, 151, 0.12);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(63, 95, 151, 0.06);
}

.chat-bubble--typing {
  opacity: 0.75;
  font-style: italic;
}

.chat-widget__composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid rgba(63, 95, 151, 0.1);
  background: #fff;
}

.chat-widget__composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid rgba(63, 95, 151, 0.22);
  border-radius: 12px;
  resize: none;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.chat-widget__send {
  flex-shrink: 0;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  background: var(--brand-blue);
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.chat-widget__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget__launcher-float {
    animation: none;
  }

  .chat-widget__launcher-cluster.is-popping,
  .chat-widget__mascot {
    animation: none;
  }

  .chat-widget__launcher,
  .chat-widget__panel {
    transition: none;
  }

  .chat-widget__panel {
    transform: none;
  }

  .chat-widget:not(.is-chat-open) .chat-widget__panel {
    opacity: 0;
    visibility: hidden;
  }

  .chat-widget.is-chat-open .chat-widget__panel {
    opacity: 1;
    visibility: visible;
  }
}
