/**
 * Baazex LiveChat — custom blue launcher + positioning
 * Official LiveChat chat window opens only when the launcher is clicked.
 * Desktop styles: default rules below. Mobile overrides: max-width 767px only.
 */

:root {
  --bz-livechat-primary: #2455ff;
  --bz-livechat-secondary: #4f73ff;
  --bz-livechat-shadow: 0 8px 28px rgba(36, 85, 255, 0.35);
}

/* ---- Desktop (unchanged) ---- */
#chat-widget-container,
iframe#chat-widget,
iframe#chat-widget-minimized {
  z-index: 9990 !important;
}

#chat-widget-container {
  right: var(--bz-livechat-right, 24px) !important;
  bottom: var(--bz-livechat-bottom, 24px) !important;
  left: auto !important;
  transition: bottom 0.25s ease, right 0.25s ease;
}

iframe#chat-widget-minimized,
#chat-widget-minimized {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

#bz-livechat-launcher,
#bz-livechat-launcher.chat-launcher {
  position: fixed;
  right: var(--bz-livechat-right, 24px);
  bottom: var(--bz-livechat-bottom, 24px);
  z-index: 99999 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(135deg, var(--bz-livechat-primary) 0%, var(--bz-livechat-secondary) 100%);
  box-shadow: var(--bz-livechat-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, bottom 0.25s ease, right 0.25s ease;
}

#bz-livechat-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 32px rgba(36, 85, 255, 0.45);
}

#bz-livechat-launcher:active {
  transform: translateY(0) scale(0.98);
}

#bz-livechat-launcher:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

#bz-livechat-launcher svg {
  width: 26px;
  height: 26px;
}

#bz-livechat-launcher[hidden] {
  display: none !important;
}

html.bz-livechat-window-open #bz-livechat-launcher {
  display: none !important;
}

/* ---- Mobile only (max-width 767px) ---- */
@media (max-width: 767px) {
  #bz-livechat-launcher,
  #bz-livechat-launcher.chat-launcher {
    position: fixed !important;
    right: max(16px, env(safe-area-inset-right, 0px)) !important;
    bottom: calc(var(--bz-livechat-bottom-mobile-offset, 20px) + env(safe-area-inset-bottom, 0px)) !important;
    width: 52px !important;
    height: 52px !important;
    min-width: 48px;
    min-height: 48px;
    z-index: 9000 !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  #bz-livechat-launcher svg {
    width: 22px;
    height: 22px;
  }

  /* Hide launcher while full-screen mobile nav is open (menu z-index: 10000) */
  html.bz-livechat-mobile-menu-open #bz-livechat-launcher,
  body.bz-livechat-mobile-menu-open #bz-livechat-launcher {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body.bz-livechat-mobile-menu-open #chat-widget-container {
    z-index: 1 !important;
    pointer-events: none !important;
  }

  /* Minimized widget follows launcher offset on mobile */
  #chat-widget-container {
    right: max(16px, env(safe-area-inset-right, 0px)) !important;
    bottom: calc(var(--bz-livechat-bottom-mobile-offset, 20px) + env(safe-area-inset-bottom, 0px)) !important;
    left: auto !important;
    z-index: 9000 !important;
  }

  /* Open chat window — viewport-safe panel */
  html.bz-livechat-mobile-chat-open #chat-widget-container {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: calc(100vw - 24px) !important;
    max-width: 420px !important;
    height: min(78dvh, 680px) !important;
    max-height: calc(100dvh - 32px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    z-index: 11000 !important;
    transform: none !important;
  }

  html.bz-livechat-mobile-chat-open iframe#chat-widget {
    width: 100% !important;
    height: 100% !important;
    max-height: calc(100dvh - 32px) !important;
    border-radius: 20px !important;
  }

  /* Lock page scroll only while chat is fully open on mobile */
  html.bz-livechat-mobile-chat-open body {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    left: 0;
    right: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* LiveChat close controls — minimum touch target */
  html.bz-livechat-mobile-chat-open #chat-widget-container button,
  html.bz-livechat-mobile-chat-open #chat-widget-container [role="button"] {
    min-width: 44px;
    min-height: 44px;
  }
}
