/*
 * Launcher presentation is inert unless the existing modernization switch and
 * controller are enabled. A usable native API enables the compact entry.
 * Iframe contents, provider settings and open panels remain untouched.
 */
/* All breakpoints: only minimized launchers yield, never a widget ancestor,
 * conversation, message preview, rewards panel, or popup owner. */
body.bb-modernization-enabled.bb-chat-tools-yield
  :is(.min-widget > iframe, #min-widget > iframe, .bb-mobile-chat-launcher) {
  visibility: hidden !important;
  pointer-events: none !important;
}

  /* Clear the fixed controls inside the actual footer, not after the page.
   * Its final text stays readable; no body spacer or extra cream band exists. */
  body.bb-modernization-enabled.bb-chat-tools-active .theme-custom-footer .footer-bottom {
    padding-bottom: max(4.625rem, calc(74px + env(safe-area-inset-bottom, 0px)));
  }

  /* A compact, keyboard-native button opens the unchanged Tawk conversation.
   * It is enabled after the supported native API is usable. Unread is optional.
   * JS hides only the minimized native frame; no assumed iframe dimensions. */
  body.bb-modernization-enabled.bb-chat-tools-active .bb-mobile-chat-launcher {
    position: fixed !important;
    inset: auto auto calc(var(--bb-chat-viewport-inset, 0px) + 12px + env(safe-area-inset-bottom, 0px)) 50% !important;
    min-width: 64px;
    max-width: 116px;
    min-height: 44px;
    transform: translateX(-50%) !important;
    z-index: 10990 !important;
  }

  /* Cart only: keep the compact native entry centred and fixed, but clear the
   * actual sticky checkout control. Other routes retain their approved inset. */
  body.bb-modernization-enabled.bb-chat-tools-active.woocommerce-cart .bb-mobile-chat-launcher {
    bottom: calc(max(calc(var(--bb-chat-viewport-inset, 0px) + 12px),
      var(--bb-chat-cart-clearance, 0px)) + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.bb-modernization-enabled.bb-chat-tools-active .bb-mobile-chat-launcher {
    border: 1px solid #4b2854;
    border-radius: 8px;
    background: #4b2854;
    color: #fff;
    padding: 8px 12px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    min-height: 44px;
  }

  body.bb-modernization-enabled.bb-chat-tools-active .bb-mobile-chat-launcher:focus-visible {
    outline: 3px solid #4b2854;
    outline-offset: 3px;
    box-shadow: 0 0 0 3px #fff;
  }

  body.bb-modernization-enabled.bb-chat-tools-active .bb-mobile-chat-launcher[hidden] {
    display: none !important;
  }

@media screen and (max-width: 767px) {
  body.bb-modernization-enabled.bb-mobile-tools-active .theme-custom-footer .footer-bottom {
    padding-bottom: max(4.625rem, calc(74px + env(safe-area-inset-bottom, 0px)));
  }

  /* The native rewards launcher and cart toggle share a lower row. */
  body.bb-modernization-enabled.bb-mobile-tools-active .wll-launcher-button-container {
    position: fixed !important;
    inset: auto auto calc(var(--bb-mobile-tools-footer-clearance, 0px) + 12px + env(safe-area-inset-bottom, 0px)) 12px !important;
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    z-index: 10990 !important;
  }

  body.bb-modernization-enabled.bb-mobile-tools-active #fkcart-floating-toggler {
    position: fixed !important;
    inset: auto 12px calc(var(--bb-mobile-tools-footer-clearance, 0px) + 8px + env(safe-area-inset-bottom, 0px)) auto !important;
    width: 54px !important;
    min-width: 54px !important;
    height: 54px !important;
    min-height: 54px !important;
    z-index: 10990 !important;
  }

  /* Retain independent native rewards/cart checkout and content policies.
   * Chat stays in its approved fixed position, including focus and footer. */
  body.bb-modernization-enabled.bb-mobile-tools-active.bb-mobile-tools-checkout
    :is(.wll-launcher-button-container, #fkcart-floating-toggler),
  body.bb-modernization-enabled.bb-mobile-tools-active.bb-mobile-tools-collision
    :is(.wll-launcher-button-container, #fkcart-floating-toggler) {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Yield only the minimized controls while an overlay, filter, menu or promo
   * notice is active. Provider panels themselves are deliberately unaffected. */
  body.bb-modernization-enabled.bb-mobile-tools-active.bb-mobile-tools-yield
    :is(.wll-launcher-button-container, #fkcart-floating-toggler) {
    visibility: hidden !important;
    pointer-events: none !important;
  }
}