/* La Ville Township — rule-based chat widget.
   Self-contained: every rule lives under #lvt-chat-widget so it can drop
   into any page without leaking styles or being affected by the page's own. */

#lvt-chat-widget {
  --lvt-chat-primary: #752a5d;
  --lvt-chat-primary-hover: #5e2249;
  --lvt-chat-accent: #cba967;
  --lvt-chat-dark: #0d0d0d;
  --lvt-chat-ink: #1a1a1a;
  --lvt-chat-cream: #f5f1ea;
  --lvt-chat-cream-2: #f2efe9;
  --lvt-chat-border: #e2d9c8;
  --lvt-chat-muted: #6b6353;
  --lvt-chat-whatsapp: #2fce6b;
  --lvt-chat-maps: #4a89f3;
  --lvt-chat-font-heading: 'Cormorant Garamond', Georgia, serif;
  --lvt-chat-font-body: 'Poppins', Arial, sans-serif;

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: var(--lvt-chat-font-body);
  box-sizing: border-box;
}

#lvt-chat-widget *,
#lvt-chat-widget *::before,
#lvt-chat-widget *::after {
  box-sizing: border-box;
}

/* ---- Launcher bubble ---- */

.lvt-chat-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background-color: var(--lvt-chat-primary);
  color: var(--lvt-chat-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  transition: background-color 0.2s ease, transform 0.2s ease;
  margin-left: auto;
}

.lvt-chat-launcher:hover {
  background-color: var(--lvt-chat-primary-hover);
}

.lvt-chat-launcher svg {
  width: 24px;
  height: 24px;
}

.lvt-chat-launcher .lvt-chat-icon-close {
  display: none;
}

#lvt-chat-widget.is-open .lvt-chat-launcher .lvt-chat-icon-chat {
  display: none;
}

#lvt-chat-widget.is-open .lvt-chat-launcher .lvt-chat-icon-close {
  display: block;
}

/* ---- Panel ---- */

.lvt-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background-color: var(--lvt-chat-cream);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

#lvt-chat-widget.is-open .lvt-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0s;
}

.lvt-chat-panel__header {
  background-color: var(--lvt-chat-dark);
  color: var(--lvt-chat-cream);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.lvt-chat-panel__header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lvt-chat-panel__title {
  font-family: var(--lvt-chat-font-heading);
  font-size: 19px;
  font-weight: 600;
  margin: 0;
}

.lvt-chat-panel__subtitle {
  font-size: 12px;
  color: var(--lvt-chat-accent);
  margin: 0;
}

.lvt-chat-panel__close {
  background: none;
  border: none;
  color: var(--lvt-chat-cream);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.lvt-chat-panel__close:hover {
  opacity: 1;
}

.lvt-chat-panel__close svg {
  width: 18px;
  height: 18px;
}

/* ---- Message log ---- */

.lvt-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--lvt-chat-cream-2);
}

.lvt-chat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 86%;
}

.lvt-chat-row--bot {
  align-self: flex-start;
  align-items: flex-start;
}

.lvt-chat-row--user {
  align-self: flex-end;
  align-items: flex-end;
}

.lvt-chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
  word-break: break-word;
}

.lvt-chat-bubble--bot {
  background-color: #ffffff;
  color: var(--lvt-chat-ink);
  border: 1px solid var(--lvt-chat-border);
  border-bottom-left-radius: 4px;
}

.lvt-chat-bubble--user {
  background-color: var(--lvt-chat-primary);
  color: var(--lvt-chat-cream);
  border-bottom-right-radius: 4px;
}

.lvt-chat-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.lvt-chat-link-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: filter 0.15s ease;
}

.lvt-chat-link-btn:hover {
  filter: brightness(0.94);
}

.lvt-chat-link-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---- Follow-up question chips ---- */

.lvt-chat-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.lvt-chat-followup-btn {
  background-color: #ffffff;
  color: var(--lvt-chat-primary);
  border: 1px solid var(--lvt-chat-border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.lvt-chat-followup-btn:hover {
  background-color: var(--lvt-chat-cream);
  border-color: var(--lvt-chat-primary);
}

.lvt-chat-link-btn--whatsapp {
  background-color: var(--lvt-chat-whatsapp);
  color: #ffffff;
}

.lvt-chat-link-btn--maps {
  background-color: var(--lvt-chat-maps);
  color: #ffffff;
}

.lvt-chat-link-btn--site {
  background-color: var(--lvt-chat-cream);
  color: var(--lvt-chat-primary);
  border-color: var(--lvt-chat-primary);
}

.lvt-chat-link-btn--external {
  background-color: var(--lvt-chat-cream);
  color: var(--lvt-chat-primary);
  border-color: var(--lvt-chat-primary);
}

/* ---- Typing indicator ---- */

.lvt-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  background-color: #ffffff;
  border: 1px solid var(--lvt-chat-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.lvt-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--lvt-chat-muted);
  animation: lvt-chat-bounce 1.2s infinite ease-in-out;
}

.lvt-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.lvt-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes lvt-chat-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---- Input row ---- */

.lvt-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background-color: #ffffff;
  border-top: 1px solid var(--lvt-chat-border);
  flex-shrink: 0;
}

.lvt-chat-input {
  flex: 1;
  border: 1px solid var(--lvt-chat-border);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--lvt-chat-ink);
  background-color: var(--lvt-chat-cream-2);
  outline: none;
}

.lvt-chat-input:focus {
  border-color: var(--lvt-chat-primary);
}

.lvt-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background-color: var(--lvt-chat-primary);
  color: var(--lvt-chat-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.lvt-chat-send:hover {
  background-color: var(--lvt-chat-primary-hover);
}

.lvt-chat-send svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 480px) {
  #lvt-chat-widget {
    right: 16px;
    bottom: 16px;
  }

  .lvt-chat-panel {
    /* Bottom offset clears the WhatsApp/Call/Book-a-Visit FAB (50px tall,
       sitting 24px from the bottom), so the panel never covers it. */
    position: fixed;
    inset: auto 0 90px 0;
    width: 100%;
    max-width: 100%;
    height: min(520px, 65vh);
    max-height: min(520px, 65dvh);
    border-radius: 16px;
    transform: translateY(16px);
    transform-origin: bottom center;
  }

  #lvt-chat-widget.is-open .lvt-chat-panel {
    transform: translateY(0);
  }

  .lvt-chat-input-row {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
