/* Handover Pro chat widget */
:root {
  --hp-ink: #0f2a24;
  --hp-accent: #1a6b54;
  --hp-accent-soft: #d8efe7;
  --hp-surface: #f7faf8;
  --hp-border: rgba(15, 42, 36, 0.12);
  --hp-shadow: 0 18px 50px rgba(15, 42, 36, 0.18);
  --hp-launcher-bottom: 1.25rem;
  --hp-launcher-right: 1.25rem;
}

.hp-launcher {
  position: fixed;
  right: var(--hp-launcher-right);
  bottom: var(--hp-launcher-bottom);
  z-index: 99980;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 0;
  cursor: pointer;
  background: var(--hp-ink);
  color: #fff;
  padding: 0.7rem 1rem 0.7rem 0.75rem;
  border-radius: 999px;
  box-shadow: var(--hp-shadow);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 0.2s ease, background 0.2s ease;
}
.hp-launcher:hover { transform: translateY(-2px); background: #2a3530; }
.hp-launcher-icon {
  position: relative;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: #ffcc00;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: visible;
  isolation: isolate;
}
.hp-icon-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(255, 204, 0, 0.85);
  animation: hpIconPulse 1.8s ease-out infinite;
  pointer-events: none;
}
.hp-icon-face {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  width: 100%;
  height: 100%;
}
.hp-icon-dot {
  display: block;
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 50%;
  background: #0f2a24;
  animation: hpIconDot 0.9s ease-in-out infinite;
  will-change: transform, opacity;
}
.hp-icon-dot:nth-child(1) { animation-delay: 0s; }
.hp-icon-dot:nth-child(2) { animation-delay: 0.18s; }
.hp-icon-dot:nth-child(3) { animation-delay: 0.36s; }

/* Peek: wait ~10s → 2 eyes look around → leave with Amazon-style smile */
.hp-icon-peek {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.hp-icon-eyes {
  position: absolute;
  left: 50%;
  top: -0.2rem;
  display: flex;
  gap: 0.28rem;
  transform: translateX(-50%);
  opacity: 0;
  animation: hpEyesCycle 20s ease-in-out infinite;
  will-change: transform, opacity;
}
.hp-icon-eye {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #0f2a24;
  box-shadow: 0 2px 6px rgba(15, 42, 36, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.hp-icon-eye-pupil {
  display: block;
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: #0f2a24;
  animation: hpEyeLook 20s ease-in-out infinite;
  will-change: transform;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}
.hp-icon-smile {
  position: absolute;
  left: 50%;
  bottom: 0.1rem;
  width: 1.75rem;
  height: 0.85rem;
  transform: translateX(-50%);
  opacity: 0;
  animation: hpSmileCycle 20s ease-in-out infinite;
  will-change: transform, opacity;
}
.hp-icon-smile svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

@keyframes hpIconPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  70% { transform: scale(1.45); opacity: 0; }
  100% { transform: scale(1.45); opacity: 0; }
}
@keyframes hpIconDot {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  50% { transform: translateY(-5px); opacity: 1; }
}
@keyframes hpEyesCycle {
  0%, 50% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.4);
  }
  54% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.06);
  }
  58%, 72% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  76% {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px) scale(0.5);
  }
  77%, 100% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.4);
  }
}
@keyframes hpEyeLook {
  0%, 50% { transform: translate(0, 0); }
  56% { transform: translate(2px, 0); }
  60% { transform: translate(-2px, 1px); }
  64% { transform: translate(2px, -1px); }
  68% { transform: translate(-1px, 0); }
  72%, 100% { transform: translate(0, 0); }
}
@keyframes hpSmileCycle {
  0%, 74% {
    opacity: 0;
    transform: translateX(-50%) scale(0.6) translateY(4px);
  }
  78% {
    opacity: 1;
    transform: translateX(-50%) scale(1.05) translateY(0);
  }
  82%, 88% {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
  }
  94%, 100% {
    opacity: 0;
    transform: translateX(-50%) scale(0.85) translateY(2px);
  }
}

.hp-launcher.is-open .hp-icon-ring,
.hp-launcher.is-open .hp-icon-peek { display: none; }
.hp-launcher.is-open .hp-icon-face::before {
  content: "";
  position: absolute;
  width: 0.85rem;
  height: 0.12rem;
  background: #0f2a24;
  border-radius: 2px;
  transform: rotate(45deg);
}
.hp-launcher.is-open .hp-icon-face::after {
  content: "";
  position: absolute;
  width: 0.85rem;
  height: 0.12rem;
  background: #0f2a24;
  border-radius: 2px;
  transform: rotate(-45deg);
}
.hp-launcher.is-open .hp-icon-dot { display: none; }

@media (prefers-reduced-motion: reduce) {
  .hp-icon-ring { animation-duration: 3s; }
  .hp-icon-dot { animation-duration: 1.4s; }
  .hp-icon-eyes,
  .hp-icon-eye-pupil,
  .hp-icon-smile { animation-duration: 28s; }
}

.hp-launcher-label { white-space: nowrap; }
.hp-launcher.is-open .hp-launcher-label { display: none; }
.hp-launcher.is-open { padding: 0.75rem; border-radius: 50%; }

.hp-panel {
  position: fixed;
  right: var(--hp-launcher-right);
  bottom: calc(var(--hp-launcher-bottom) + 3.5rem);
  width: min(380px, calc(100vw - 1.5rem));
  height: min(560px, calc(100vh - 6.5rem));
  z-index: 99981;
  background: var(--hp-surface);
  border: 1px solid var(--hp-border);
  border-radius: 18px;
  box-shadow: var(--hp-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--hp-ink);
}
.hp-panel.is-open { display: flex; animation: hpRise 0.28s ease; }
@keyframes hpRise {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.hp-header {
  background: linear-gradient(135deg, #0f2a24 0%, #1a6b54 100%);
  color: #fff;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.hp-header-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: grid;
  place-items: center;
}
.hp-header-text { flex: 1; min-width: 0; }
.hp-header-title { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.hp-header-sub { font-size: 0.75rem; opacity: 0.85; margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-header-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.85;
}
.hp-header-close:hover { opacity: 1; }

.hp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background:
    radial-gradient(circle at top right, rgba(26,107,84,0.08), transparent 40%),
    var(--hp-surface);
}

.hp-bubble {
  max-width: 88%;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.hp-bubble--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--hp-border);
  border-bottom-left-radius: 4px;
}
.hp-bubble--user {
  align-self: flex-end;
  background: var(--hp-accent-soft);
  border-bottom-right-radius: 4px;
}
.hp-bubble--system {
  align-self: center;
  background: transparent;
  color: #667;
  font-size: 0.78rem;
  text-align: center;
}

.hp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.9rem 0.5rem;
}
.hp-chip {
  border: 1px solid var(--hp-border);
  background: #fff;
  color: var(--hp-ink);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.hp-chip:hover { border-color: var(--hp-accent); color: var(--hp-accent); }

.hp-composer {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem;
  border-top: 1px solid var(--hp-border);
  background: #fff;
}
.hp-composer input {
  flex: 1;
  border: 1px solid var(--hp-border);
  border-radius: 999px;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  outline: none;
}
.hp-composer input:focus { border-color: var(--hp-accent); }
.hp-composer button {
  border: 0;
  background: var(--hp-accent);
  color: #fff;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  cursor: pointer;
}
.hp-composer button:disabled { opacity: 0.5; cursor: wait; }

.hp-typing {
  align-self: flex-start;
  font-size: 0.8rem;
  color: #667;
  padding: 0 0.25rem;
}

/* Proactive help nudge */
.hp-nudge {
  position: fixed;
  right: var(--hp-launcher-right);
  bottom: calc(var(--hp-launcher-bottom) + 4.1rem);
  z-index: 99979;
  width: min(300px, calc(100vw - 1.75rem));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.35s;
}
.hp-nudge.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}
.hp-nudge-inner {
  position: relative;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.95rem 1rem 1rem;
  background: #fff;
  border: 1px solid var(--hp-border);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 42, 36, 0.16);
  background-image:
    radial-gradient(circle at top left, rgba(26, 107, 84, 0.1), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, #f7faf8 100%);
}
.hp-nudge-avatar {
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f2a24 0%, #1a6b54 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(26, 107, 84, 0.28);
}
.hp-nudge-copy { flex: 1; min-width: 0; padding-right: 0.85rem; }
.hp-nudge-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--hp-ink);
  margin: 0 0 0.3rem;
}
.hp-nudge-body {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: rgba(15, 42, 36, 0.72);
}
.hp-nudge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.hp-nudge-yes,
.hp-nudge-no {
  border: 0;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  transition: transform 0.15s ease, background 0.15s ease;
}
.hp-nudge-yes {
  background: var(--hp-accent);
  color: #fff;
}
.hp-nudge-yes:hover { background: #145744; transform: translateY(-1px); }
.hp-nudge-no {
  background: transparent;
  color: rgba(15, 42, 36, 0.65);
  border: 1px solid var(--hp-border);
}
.hp-nudge-no:hover { border-color: var(--hp-accent); color: var(--hp-accent); }
.hp-nudge-dismiss {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  z-index: 2;
  border: 0;
  background: transparent;
  color: rgba(15, 42, 36, 0.45);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
}
.hp-nudge-dismiss:hover { color: var(--hp-ink); background: rgba(15, 42, 36, 0.06); }
.hp-nudge-tail {
  display: block;
  width: 0;
  height: 0;
  margin: -1px 1.55rem 0 auto;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 10px solid #fff;
  filter: drop-shadow(0 2px 1px rgba(15, 42, 36, 0.08));
}

@media (max-width: 480px) {
  .hp-nudge {
    right: 0.85rem;
    bottom: calc(0.85rem + 3.75rem);
    width: min(280px, calc(100vw - 1.4rem));
  }
}

body:has(.pending-booking-bar) {
  --hp-launcher-bottom: calc(1.25rem + 3.5rem);
}
@media (max-width: 480px) {
  body:has(.pending-booking-bar) {
    --hp-launcher-bottom: calc(0.85rem + 3.5rem);
  }
}

@media (max-width: 480px) {
  :root {
    --hp-launcher-right: 0.85rem;
    --hp-launcher-bottom: 0.85rem;
  }
  .hp-launcher-label { display: none; }
  .hp-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    bottom: calc(var(--hp-launcher-bottom) + 3.35rem);
    height: min(70vh, 560px);
  }
}

/* Keep scroll-to-top clear of the chat pill (move it left) */
body:has(#handoverProRoot) .scroll-to-top {
  right: 12.75rem;
  z-index: 99970;
}
@media (max-width: 480px) {
  body:has(#handoverProRoot) .scroll-to-top {
    right: 4.75rem;
  }
}
