/* ============================================================
   WEB LAUNCH CO. — CHATBOT WIDGET  v1.0
   All selectors scoped under #wlc-* — zero impact on page CSS.
============================================================ */

/* ── FAB stack (shared fixed container for both buttons) ─────── */
#wlc-stack {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  right: max(18px, env(safe-area-inset-right, 0px));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  pointer-events: none; /* let children capture events */
}
#wlc-stack > * { pointer-events: auto; }

/* ── WhatsApp FAB ───────────────────────────────────────────── */
#wlc-wa {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #25D366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4), 0 1px 6px rgba(0,0,0,0.3);
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.22s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
#wlc-wa svg { width: 17px; height: 17px; }
#wlc-wa:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 12px 32px rgba(37, 211, 102, 0.5), 0 4px 12px rgba(0,0,0,0.35);
}
#wlc-wa:focus-visible {
  outline: 2px solid #86efac;
  outline-offset: 3px;
}

/* ── Chat FAB (floating trigger button) ─────────────────────── */
#wlc-fab {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.25s ease;
  outline: none;
  position: relative; /* needed for ::before pulse ring */
}
#wlc-fab:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: none;
}
#wlc-fab:focus-visible {
  outline: 2px solid #c4b5fd;
  outline-offset: 3px;
}
/* Icon containers inside FAB */
#wlc-fab .wlc-icon-chat,
#wlc-fab .wlc-icon-close {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
#wlc-fab .wlc-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}
#wlc-fab.is-open .wlc-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}
#wlc-fab.is-open .wlc-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Pulse ring (attention animation, stops once opened once) */
#wlc-fab::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
  opacity: 0.3;
  animation: wlcPulse 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  z-index: -1;
}
#wlc-fab.no-pulse::before { animation: none; opacity: 0; }
@keyframes wlcPulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50%       { transform: scale(1.28); opacity: 0; }
}

/* ── Receptionist image inside FAB ──────────────────────────── */
.wlc-receptionist-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  pointer-events: none;
}

/* ── Blur backdrop (shown when panel is open) ────────────────── */
#wlc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 997;
  background: transparent;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  pointer-events: none;
}
#wlc-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Hide the whole stack + panel + backdrop when mobile nav is open */
body.nav-menu-open #wlc-stack,
body.nav-menu-open #wlc-panel,
body.nav-menu-open #wlc-backdrop {
  display: none !important;
}

/* ── Panel ──────────────────────────────────────────────────── */
#wlc-panel {
  position: fixed;
  /* stack height: 32px (WA) + 7px (gap) + 32px (chat) = 71px, +12px clearance */
  bottom: calc(max(18px, env(safe-area-inset-bottom, 0px)) + 71px + 12px);
  right: max(18px, env(safe-area-inset-right, 0px));
  z-index: 999;
  width: min(390px, calc(100vw - 32px));
  height: min(580px, calc(100dvh - 130px));
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 14, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 2px 12px rgba(0,0,0,0.3);
  overflow: hidden;
  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.28s cubic-bezier(0.4,0,0.2,1),
              visibility 0.28s cubic-bezier(0.4,0,0.2,1),
              transform 0.28s cubic-bezier(0.34,1.4,0.64,1);
  pointer-events: none;
}
#wlc-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Panel Header ───────────────────────────────────────────── */
#wlc-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.wlc-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.wlc-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  background: #22C55E;
  border-radius: 50%;
  border: 2px solid rgba(10,10,14,0.97);
}
.wlc-head-info { flex: 1; min-width: 0; }
.wlc-head-name {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wlc-head-sub {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11.5px;
  color: #71717a;
  margin-top: 1px;
}
#wlc-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: #a1a1aa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  outline: none;
}
#wlc-close:hover { background: rgba(255,255,255,0.12); color: #fff; }
#wlc-close:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }

/* ── Body (scrollable content area) ────────────────────────── */
#wlc-body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ── Menu View ──────────────────────────────────────────────── */
#wlc-menu {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
#wlc-menu.wlc-hidden {
  opacity: 0;
  transform: translateX(-18px);
  pointer-events: none;
}
.wlc-greeting {
  background: linear-gradient(135deg, rgba(139,92,246,0.12) 0%, rgba(236,72,153,0.08) 100%);
  border: 1px solid rgba(139,92,246,0.2);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.wlc-greeting p {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13.5px;
  color: #d4d4d8;
  line-height: 1.6;
  margin: 0;
}
.wlc-greeting p + p { margin-top: 6px; }
.wlc-greeting strong { color: #fff; }
.wlc-menu-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #52525b;
  margin-bottom: 8px;
  padding: 0 2px;
}
.wlc-faq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wlc-faq-btn {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  color: #d4d4d8;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.wlc-faq-btn:hover,
.wlc-faq-btn:focus-visible {
  background: rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.35);
  color: #fff;
  transform: translateX(3px);
}
.wlc-faq-btn:active { transform: translateX(3px) scale(0.98); }
.wlc-faq-n {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wlc-faq-text { flex: 1; }

/* ── Chat View ──────────────────────────────────────────────── */
#wlc-chat {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
#wlc-chat.wlc-hidden {
  opacity: 0;
  transform: translateX(18px);
  pointer-events: none;
}
#wlc-back {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #a78bfa;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  text-align: left;
}
#wlc-back:hover { color: #c4b5fd; background: rgba(139,92,246,0.06); }
#wlc-back:focus-visible { outline: 2px solid #c4b5fd; outline-offset: -2px; }
#wlc-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Messages */
.wlc-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  animation: wlcMsgIn 0.22s cubic-bezier(0.34,1.4,0.64,1) both;
}
@keyframes wlcMsgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.wlc-msg--bot {
  align-self: flex-start;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e4e4e7;
  border-bottom-left-radius: 5px;
}
.wlc-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.wlc-msg p  { margin: 0; }
.wlc-msg p + p { margin-top: 7px; }
.wlc-msg ul,
.wlc-msg ol { margin: 7px 0 0; padding-left: 1.3em; }
.wlc-msg li + li { margin-top: 4px; }
.wlc-msg a {
  color: #c4b5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wlc-msg--user a { color: rgba(255,255,255,0.85); }
.wlc-msg a:hover { color: #e9d5ff; }

/* Typing indicator */
.wlc-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  border-bottom-left-radius: 5px;
}
.wlc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #71717a;
  animation: wlcDot 1.2s infinite ease-in-out;
}
.wlc-typing span:nth-child(2) { animation-delay: 0.2s; }
.wlc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes wlcDot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%            { transform: scale(1);   opacity: 1; }
}

/* ── Footer (input bar) ─────────────────────────────────────── */
#wlc-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.02);
}
#wlc-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 13px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 11px;
  color: #fff;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
#wlc-input::placeholder { color: #52525b; }
#wlc-input:focus {
  border-color: rgba(139,92,246,0.55);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
#wlc-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
#wlc-send:hover  { opacity: 0.88; transform: scale(1.06); }
#wlc-send:active { transform: scale(0.94); }
#wlc-send:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }

/* ── Scrollbar styling (Webkit) ─────────────────────────────── */
#wlc-log::-webkit-scrollbar,
#wlc-menu::-webkit-scrollbar { width: 4px; }
#wlc-log::-webkit-scrollbar-track,
#wlc-menu::-webkit-scrollbar-track { background: transparent; }
#wlc-log::-webkit-scrollbar-thumb,
#wlc-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Mobile adjustments ─────────────────────────────────────── */
@media (max-width: 480px) {
  #wlc-stack {
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
    gap: 7px;
  }
  #wlc-panel {
    right: max(10px, env(safe-area-inset-right, 0px));
    /* 32 + 7 + 32 = 71px stack + 10px clearance */
    bottom: calc(max(14px, env(safe-area-inset-bottom, 0px)) + 71px + 10px);
    width: calc(100vw - 20px);
    height: min(520px, calc(100dvh - 110px));
    border-radius: 18px;
  }
}
@media (max-width: 360px) {
  #wlc-stack { right: 10px; }
  #wlc-panel { right: 6px; width: calc(100vw - 12px); }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #wlc-fab, #wlc-wa,
  #wlc-panel,
  .wlc-faq-btn,
  .wlc-msg,
  #wlc-menu,
  #wlc-chat { transition: none !important; animation: none !important; }
  #wlc-fab::before { animation: none; }
}
