/* Floating dock: invitation bubble, advisor button, WhatsApp shortcut,
 * and the advisor chat panel. */

.dock {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

/* Invitation bubble */

.dock__bubble {
  position: relative;
  align-self: flex-end;
  max-width: 260px;
  background: var(--nx-white);
  border: 1px solid var(--nx-bone-3);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 40px -18px rgba(14, 28, 42, .45);
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.dock__bubble[hidden] {
  display: none;
}

.dock__bubble-open {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dock__bubble-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--nx-ink);
}

.dock__bubble-text {
  font-size: 13.5px;
  color: var(--nx-500);
  line-height: 1.45;
}

.dock__bubble-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--nx-400);
  display: flex;
  flex: 0 0 auto;
}

.dock__bubble-close .icon {
  --icon-size: 15px;
}

.dock__bubble-tail {
  position: absolute;
  right: 26px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--nx-white);
  border-right: 1px solid var(--nx-bone-3);
  border-bottom: 1px solid var(--nx-bone-3);
  transform: rotate(45deg);
  display: block;
}

/* Advisor button */

.dock__advisor {
  width: 62px;
  height: 62px;
  position: relative;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: block;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}

.dock__advisor:hover {
  transform: scale(1.06);
  box-shadow: 0 18px 38px -12px rgba(14, 28, 42, .5);
}

.dock__advisor-avatar {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  flex: 0 0 auto;
}

.dock__advisor-photo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--nx-billing-soft);
  overflow: hidden;
  border: 3px solid var(--nx-white);
  box-shadow: 0 10px 26px -12px rgba(14, 28, 42, .45);
}

.dock__advisor-photo img {
  display: block;
  width: 100%;
  height: 100%;
}

.dock__advisor-status {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  border-radius: var(--r-pill);
  background: var(--nx-success);
  border: 2.5px solid var(--nx-bone);
  display: block;
  animation: nxPulse 2.6s ease-in-out infinite;
}

/* WhatsApp shortcut */

.dock__whatsapp {
  width: 60px;
  height: 60px;
  border-radius: var(--r-pill);
  background: var(--nx-whatsapp);
  color: var(--nx-white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px -8px rgba(37, 211, 102, .7);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
  flex: 0 0 auto;
}

.dock__whatsapp:hover {
  transform: scale(1.08);
  box-shadow: 0 16px 34px -8px rgba(37, 211, 102, .85);
  color: var(--nx-white);
}

.dock__whatsapp .icon {
  --icon-size: 30px;
}

/* Chat panel */

.chat {
  position: fixed;
  right: 18px;
  bottom: calc(174px + env(safe-area-inset-bottom));
  z-index: 121;
  width: 340px;
  height: 480px;
  max-height: calc(100vh - 220px);
  display: flex;
  flex-direction: column;
  background: var(--nx-bone);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: 0 40px 80px -30px rgba(14, 28, 42, .55);
}

.chat[hidden] {
  display: none;
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--nx-ink);
  flex: 0 0 auto;
}

.chat__avatar {
  position: relative;
  display: block;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}

.chat__avatar-photo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--nx-billing-soft);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .9);
}

.chat__avatar-photo img {
  display: block;
  width: 100%;
  height: 100%;
}

.chat__avatar-badge {
  position: absolute;
  left: 50%;
  bottom: 3px;
  transform: translateX(-50%) rotate(-6deg);
  width: 7px;
  height: 7px;
  opacity: .92;
}

.chat__identity {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat__name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--nx-white);
}

.chat__status {
  font-size: 12.5px;
  color: var(--nx-billing-2);
}

.chat__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--nx-400);
  display: flex;
  flex: 0 0 auto;
}

.chat__close:hover {
  color: var(--nx-white);
}

.chat__close .icon {
  --icon-size: 19px;
}

/* Conversation */

.chat__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--nx-bone-2);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat__row {
  display: flex;
  justify-content: flex-start;
}

.chat__row--user {
  justify-content: flex-end;
}

.chat__bubble {
  max-width: 84%;
  font-size: 14.5px;
  line-height: 1.5;
  padding: 11px 14px;
  background: var(--nx-white);
  color: var(--nx-ink);
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 2px 6px -3px rgba(14, 28, 42, .3);
}

.chat__row--user .chat__bubble {
  background: var(--nx-billing);
  color: var(--nx-white);
  border-radius: 14px 14px 4px 14px;
  box-shadow: none;
}

.chat__typing {
  display: flex;
  gap: 4px;
  align-items: center;
  background: var(--nx-white);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  box-shadow: 0 2px 6px -3px rgba(14, 28, 42, .3);
}

.chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--nx-400);
  display: block;
  animation: nxPulse 1s ease-in-out infinite;
}

.chat__typing span:nth-child(2) {
  animation-delay: .15s;
}

.chat__typing span:nth-child(3) {
  animation-delay: .3s;
}

/* Quick intent replies */

.chat__quick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.chat__quick-btn {
  width: 100%;
  text-align: left;
  background: var(--nx-white);
  border: 1px solid var(--nx-200);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--nx-ink);
  cursor: pointer;
  transition: background .2s var(--ease), border-color .2s;
}

.chat__quick-btn:hover {
  background: var(--nx-100);
  border-color: var(--nx-300);
}

/* Hand-off */

.chat__exit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.chat__whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--nx-whatsapp);
  color: var(--nx-white);
  font-size: 15px;
  font-weight: 600;
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 10px 24px -12px rgba(37, 211, 102, .9);
}

.chat__whatsapp:hover {
  color: var(--nx-white);
  box-shadow: 0 14px 30px -12px rgba(37, 211, 102, 1);
}

.chat__whatsapp .icon {
  --icon-size: 20px;
}

.chat__mail {
  text-align: center;
  font-size: 13px;
  color: var(--nx-500);
}

.chat__mail:hover {
  color: var(--nx-billing);
}

/* Name form */

.chat__form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--nx-bone);
  border-top: 1px solid var(--nx-bone-3);
}

.chat__form[hidden] {
  display: none;
}

.chat__input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--nx-200);
  border-radius: var(--r);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--nx-ink);
  background: var(--nx-white);
}

.chat__send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--r);
  background: var(--nx-billing);
  color: var(--nx-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat__send .icon {
  --icon-size: 19px;
}

@media (max-width: 1080px) {
  .dock {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    gap: 12px;
  }

  .dock__advisor {
    width: 60px;
    height: 60px;
  }

  .dock__whatsapp {
    width: 56px;
    height: 56px;
  }

  .chat {
    left: auto;
    right: 12px;
    top: 12px;
    bottom: calc(160px + env(safe-area-inset-bottom));
    width: min(460px, calc(100% - 24px));
    height: auto;
    max-height: none;
    box-shadow: 0 40px 80px -30px rgba(14, 28, 42, .6);
  }
}

/* Short viewports (landscape phones): the dock would eat most of the height,
 * leaving the conversation a few lines tall. Give the panel the full height
 * and drop the floating buttons while it is open — the panel has its own
 * close control, so nothing becomes unreachable. */
@media (max-height: 560px) {
  .chat {
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  body.is-chat-open .dock {
    display: none;
  }
}

/* Scrolling down tucks the dock away so it stops covering content — on a phone
 * it otherwise sits on top of whatever is at the bottom right of the screen,
 * including comparison values and call-to-action buttons. Scrolling up, or
 * reaching the end of the page, brings it straight back. */
.dock {
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}

.dock--tucked {
  transform: translateY(calc(100% + 28px));
  opacity: 0;
  pointer-events: none;
}
