:root {
  --nl-assistant-green: #004f2d;
  --nl-assistant-ink: #17211d;
  --nl-assistant-paper: #f5f6f2;
  --nl-assistant-line: rgba(0, 79, 45, 0.16);
}

.nestlab-assistant {
  position: fixed;
  z-index: 260;
  right: 24px;
  bottom: 24px;
  font-family: Inter, Arial, sans-serif;
}

.nl-assistant__launcher {
  position: relative;
  display: grid;
  width: 104px;
  height: 86px;
  place-items: center;
  overflow: visible;
  border: 0;
  border-radius: 14px;
  background: transparent;
  transition: opacity 160ms ease, transform 180ms ease;
}

.nl-assistant__launcher:hover,
.nl-assistant__launcher:focus-visible {
  transform: translateY(-3px) scale(1.035);
}

.nl-assistant__launcher:focus-visible {
  outline: 3px solid rgba(0, 79, 45, 0.35);
  outline-offset: 4px;
}

.nl-assistant__launcher-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: 98px;
  height: 80px;
  transform-style: preserve-3d;
  animation: nl-assistant-float 3.8s ease-in-out infinite;
  filter: drop-shadow(0 13px 9px rgba(0, 31, 18, 0.2));
}

.nl-assistant__launcher-logo::before,
.nl-assistant__launcher-logo::after {
  position: absolute;
  inset: 0;
  background: var(--nl-assistant-green);
  content: "";
  -webkit-mask: url("./assets/optimized/nestlab-symbol-cutout.webp") center / contain no-repeat;
  mask: url("./assets/optimized/nestlab-symbol-cutout.webp") center / contain no-repeat;
  pointer-events: none;
}

.nl-assistant__launcher-logo::before {
  z-index: 0;
  transform: translate3d(6px, 7px, -2px);
  background: #002f1c;
  opacity: 0.9;
}

.nl-assistant__launcher-logo::after {
  z-index: 1;
  transform: translate3d(3px, 4px, -1px);
  background: linear-gradient(135deg, #147247 8%, #003d25 72%);
}

.nl-assistant__logo-shadow {
  position: absolute;
  z-index: -1;
  right: 4px;
  bottom: -3px;
  width: 74%;
  height: 14px;
  border-radius: 50%;
  background: rgba(0, 30, 18, 0.24);
  filter: blur(7px);
  transform: rotate(-2deg);
  pointer-events: none;
}

.nl-assistant__launcher-logo img {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter:
    drop-shadow(-1px 0 0 rgba(247, 250, 247, 0.9))
    drop-shadow(1px 0 0 rgba(247, 250, 247, 0.82))
    drop-shadow(0 -1px 0 rgba(247, 250, 247, 0.9))
    drop-shadow(0 1px 0 rgba(247, 250, 247, 0.74));
  pointer-events: none;
}

.nl-assistant__status {
  position: absolute;
  z-index: 4;
  right: -2px;
  bottom: 8px;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #08a64f;
  box-shadow: 0 2px 8px rgba(0, 45, 27, 0.28);
}

.nl-assistant__teaser {
  position: absolute;
  z-index: 5;
  right: 86px;
  bottom: 62px;
  width: max-content;
  max-width: min(220px, calc(100vw - 132px));
  padding: 10px 14px;
  border: 1px solid rgba(0, 79, 45, 0.12);
  border-radius: 14px 14px 4px 14px;
  background: rgba(252, 252, 248, 0.97);
  box-shadow: 0 10px 28px rgba(0, 37, 22, 0.17);
  color: #0b422b;
  font: 500 13px/1.25 Inter, Arial, sans-serif;
  white-space: nowrap;
  opacity: 0;
  transform: translate3d(8px, 8px, 0) scale(0.96);
  transform-origin: bottom right;
  animation: nl-assistant-teaser-in 420ms 650ms ease forwards;
  pointer-events: none;
}

.nl-assistant__teaser::after {
  position: absolute;
  right: -1px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: inherit;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  content: "";
}

.nestlab-assistant.has-engaged .nl-assistant__teaser {
  display: none;
}

.nl-assistant__panel {
  position: absolute;
  right: 0;
  bottom: 94px;
  width: min(368px, calc(100vw - 32px));
  height: min(440px, calc(100svh - 132px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  overscroll-behavior: contain;
  border: 1px solid var(--nl-assistant-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 62px rgba(0, 37, 22, 0.25);
  opacity: 0;
  transform: translateY(12px) scale(0.975);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.nestlab-assistant.is-open .nl-assistant__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.nestlab-assistant.is-open .nl-assistant__launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.9);
}

@keyframes nl-assistant-float {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.35deg); }
  50% { transform: translate3d(0, -4px, 0) rotate(0.45deg); }
}

@keyframes nl-assistant-teaser-in {
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.nl-assistant__topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 9px 10px 9px 14px;
  border-bottom: 1px solid var(--nl-assistant-line);
  background: #fff;
}

.nl-assistant__topbar-brand {
  display: grid;
  width: 48px;
  height: 34px;
  place-items: center;
  overflow: visible;
}

.nl-assistant__topbar-brand img {
  width: 48px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(0, 49, 29, 0.16));
}

.nl-assistant__contact-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.nl-assistant__contact-actions a,
.nl-assistant__close {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #fff;
  color: var(--nl-assistant-green);
  transition: background 160ms ease, transform 160ms ease;
}

.nl-assistant__contact-actions a:hover,
.nl-assistant__contact-actions a:focus-visible,
.nl-assistant__close:hover,
.nl-assistant__close:focus-visible {
  transform: translateY(-1px);
  background: #f4f7f5;
}

.nl-assistant__contact--whatsapp { color: #1f9d55 !important; }
.nl-assistant__contact--phone { color: #e26b35 !important; }
.nl-assistant__contact--message,
.nl-assistant__contact--email { color: #1d6fc7 !important; }
.nl-assistant__close { color: #4f5d56; }

.nl-assistant__contact-actions svg,
.nl-assistant__close svg,
.nl-assistant__send svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.nl-assistant__close { flex: 0 0 auto; border: 0; }

.nl-assistant__body {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  background: var(--nl-assistant-paper);
}

.nl-assistant__message {
  width: fit-content;
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
}

.nl-assistant__message--assistant {
  align-self: flex-start;
  border: 1px solid var(--nl-assistant-line);
  border-top-left-radius: 3px;
  background: #fff;
  color: var(--nl-assistant-ink);
}

.nl-assistant__message--visitor {
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  background: var(--nl-assistant-green);
  color: #fff;
}

.nl-assistant__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--nl-assistant-line);
  background: #fff;
}

.nl-assistant__input {
  min-height: 42px;
  max-height: 88px;
  resize: none;
  padding: 11px 12px;
  border: 1px solid rgba(0, 79, 45, 0.2);
  border-radius: 9px;
  outline: none;
  color: var(--nl-assistant-ink);
  font: 12px/1.35 Inter, Arial, sans-serif;
}

.nl-assistant__input:focus-visible { border-color: var(--nl-assistant-green); box-shadow: 0 0 0 3px rgba(0, 79, 45, 0.1); }

.nl-assistant__send {
  align-self: end;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--nl-assistant-green);
  color: #fff;
}

.nl-assistant__send:hover,
.nl-assistant__send:focus-visible { background: #003d24; }
.nl-assistant__send:disabled { cursor: wait; opacity: 0.55; }

@media (max-width: 640px) {
  .nestlab-assistant {
    right: 8px;
    bottom: max(14px, env(safe-area-inset-bottom));
    transition: opacity 180ms ease, transform 180ms ease;
  }
  .nestlab-assistant.is-footer-obscured {
    opacity: 0;
    transform: translateY(24px);
    pointer-events: none;
  }
  .nl-assistant__launcher { width: 100px; height: 78px; }
  .nl-assistant__launcher-logo { width: 94px; height: 66px; }
  .nl-assistant__status { right: -2px; bottom: 5px; width: 17px; height: 17px; border-width: 2px; }
  .nl-assistant__teaser { right: 82px; bottom: 58px; max-width: calc(100vw - 116px); padding: 9px 12px; font-size: 12px; }
  .nl-assistant__panel { position: fixed; right: 10px; bottom: calc(82px + env(safe-area-inset-bottom)); left: 10px; width: auto; height: min(480px, calc(100svh - 108px - env(safe-area-inset-bottom))); transform-origin: bottom center; }
  .nl-assistant__topbar { min-height: 56px; padding: 6px 7px 6px 10px; }
  .nl-assistant__contact-actions { gap: 5px; }
  .nl-assistant__contact-actions a, .nl-assistant__close { width: 40px; height: 40px; }
  .nl-assistant__body { padding: 12px; }
  .nl-assistant__message { font-size: 13px; }
  .nl-assistant__form { padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .nl-assistant__input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .nl-assistant__launcher,
  .nl-assistant__launcher-logo,
  .nl-assistant__teaser,
  .nl-assistant__panel,
  .nl-assistant__contact-actions a,
  .nl-assistant__close { transition: none; }
  .nl-assistant__launcher-logo { animation: none; }
  .nl-assistant__teaser { animation: none; opacity: 1; transform: none; }
}
