/* ============================================================
   WAYZFINDER SHARED WIDGETS: WhatsApp FAB + AI Assistant chat
   Loaded on all 6 pages. Reuses the site's existing design tokens
   (--emerald-*, --sand-*, --paper, --shadow-*, --ease, --dur-*,
   --radius-*) which are already defined per-page in :root, so no
   token values are duplicated here.
   Positioned to stack above the existing .to-top button (48px,
   fixed at right:22px / bottom:22px in every page) without
   touching that button's own CSS.
   ============================================================ */

.wf-fab{
  position: fixed;
  right: 22px;
  z-index: 999;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md, 0 8px 22px rgba(7,26,19,0.18));
  transition: transform 180ms var(--ease, ease), box-shadow 180ms var(--ease, ease);
}
.wf-fab:hover{ transform: translateY(-2px); }
.wf-fab:active{ transform: translateY(0) scale(0.96); }
.wf-fab svg{ width: 24px; height: 24px; }

.wf-whatsapp{
  bottom: 86px;
  background: #25D366;
  color: #fff;
}
.wf-whatsapp::after{
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(37,211,102,0.45);
  animation: wfPulse 2.6s ease-out infinite;
  pointer-events: none;
}

.wf-chat-launcher{
  bottom: 150px;
  width: 56px;
  height: 56px;
  background: linear-gradient(160deg, var(--emerald-500, #229168), var(--emerald-900, #0B3D2E) 130%);
  color: var(--paper, #F4FAF7);
}
.wf-chat-launcher .wf-chat-close-icon{ display: none; }
.wf-chat-launcher.is-open .wf-chat-open-icon{ display: none; }
.wf-chat-launcher.is-open .wf-chat-close-icon{ display: block; }
.wf-chat-badge{
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sand-500, #C9A25D);
  border: 2px solid var(--paper, #F4FAF7);
}

@keyframes wfPulse{
  0%{ transform: scale(1); opacity: 0.9; }
  70%{ transform: scale(1.35); opacity: 0; }
  100%{ transform: scale(1.35); opacity: 0; }
}

@media (prefers-reduced-motion: reduce){
  .wf-whatsapp::after{ animation: none; display: none; }
}

/* ---------- Chat panel ---------- */
.wf-chat-panel{
  position: fixed;
  right: 22px;
  bottom: 216px;
  z-index: 1000;
  width: min(360px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 260px));
  display: flex;
  flex-direction: column;
  background: var(--white, #fff);
  border-radius: var(--radius-lg, 24px);
  box-shadow: var(--shadow-lg, 0 20px 56px rgba(7,26,19,0.2));
  border: 1px solid var(--line, rgba(15,23,18,0.1));
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 220ms var(--ease, ease), transform 220ms var(--ease, ease), visibility 220ms;
}
.wf-chat-panel.is-open{ opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.wf-chat-head{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(160deg, var(--emerald-500, #229168), var(--emerald-900, #0B3D2E) 130%);
  color: var(--paper, #F4FAF7);
  flex: none;
}
.wf-chat-avatar{
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: rgba(247,249,246,0.16);
  display: grid; place-items: center;
}
.wf-chat-avatar svg{ width: 18px; height: 18px; }
.wf-chat-head-text{ line-height: 1.3; }
.wf-chat-head-text strong{ display: block; font-size: 14.5px; font-weight: 700; }
.wf-chat-head-text span{ font-size: 12px; opacity: 0.82; display: flex; align-items: center; gap: 5px; }
.wf-chat-head-text span::before{ content: ""; width: 7px; height: 7px; border-radius: 50%; background: #6CE6A0; flex: none; }

.wf-chat-body{
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  background: var(--paper, #F4FAF7);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wf-msg{
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
}
.wf-msg a{ color: inherit; text-decoration: underline; }
.wf-msg-bot{
  align-self: flex-start;
  background: var(--white, #fff);
  border: 1px solid var(--line, rgba(15,23,18,0.1));
  border-bottom-left-radius: 4px;
  color: var(--ink, #0F1712);
}
.wf-msg-user{
  align-self: flex-end;
  background: linear-gradient(160deg, var(--emerald-500, #229168), var(--emerald-800, #0F4F3B) 130%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.wf-msg-disclosure{
  font-size: 12px;
  color: var(--ink-45, rgba(15,23,18,0.45));
  text-align: center;
  padding: 4px 12px 8px;
}

.wf-typing{
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--white, #fff);
  border: 1px solid var(--line, rgba(15,23,18,0.1));
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.wf-typing span{
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-45, rgba(15,23,18,0.4));
  animation: wfTyping 1.1s ease-in-out infinite;
}
.wf-typing span:nth-child(2){ animation-delay: 0.15s; }
.wf-typing span:nth-child(3){ animation-delay: 0.3s; }
@keyframes wfTyping{
  0%, 60%, 100%{ transform: translateY(0); opacity: 0.5; }
  30%{ transform: translateY(-4px); opacity: 1; }
}

.wf-chips{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 2px 4px;
}
.wf-chip{
  border: 1px solid var(--emerald-300, #79C9A6);
  background: var(--emerald-50, #EFF9F3);
  color: var(--emerald-700, #146349);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms var(--ease, ease), transform 150ms var(--ease, ease);
}
.wf-chip:hover{ background: var(--emerald-100, #DDEFE6); transform: translateY(-1px); }

.wf-chat-foot{
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--white, #fff);
  border-top: 1px solid var(--line, rgba(15,23,18,0.1));
}
.wf-chat-input{
  flex: 1;
  border: 1px solid var(--line-strong, rgba(15,23,18,0.16));
  border-radius: 999px;
  padding: 0 16px;
  height: 42px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink, #0F1712);
  background: var(--paper, #F4FAF7);
}
.wf-chat-input:focus-visible{ outline: 2.5px solid var(--sand-500, #C9A25D); outline-offset: 2px; }
.wf-chat-send{
  flex: none;
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: linear-gradient(160deg, var(--emerald-500, #229168), var(--emerald-900, #0B3D2E) 130%);
  color: #fff; display: grid; place-items: center; cursor: pointer;
  transition: transform 150ms var(--ease, ease);
}
.wf-chat-send:hover{ transform: scale(1.06); }
.wf-chat-send svg{ width: 17px; height: 17px; }

@media (max-width: 560px){
  .wf-fab{
    right: calc(28px + env(safe-area-inset-right, 0px));
    width: 46px;
    height: 46px;
  }
  .wf-chat-launcher{ width: 50px; height: 50px; }
  .wf-chat-panel{
    right: calc(20px + env(safe-area-inset-right, 0px));
    left: 20px;
    width: auto;
    bottom: 196px;
  }
}
