.center {
  @apply flex items-center justify-center;
}
.container-xl {
  @apply max-w-[1304px] sm:px-[40px];
}

/* Jivo layering and positioning controls */
:root {
  --jivo-z-index: 35;
  --jivo-sidebar-offset: 0px;
  --jivo-mobile-bottom-offset: 50px;
  --scroll-to-top-mobile-left: -30px;
  --scroll-to-top-mobile-bottom: 50px;
  --scroll-to-top-mobile-cart-bottom: 100px;
  --bitrix-z-index: 20;
  --bitrix-sidebar-offset: 0px;
  --bitrix-mobile-bottom-offset: 72px;
}

/* Desktop cart sidebar width ~= 420px + gap */
body.cart-sidebar-open {
  --jivo-sidebar-offset: 440px;
  --bitrix-sidebar-offset: 440px;
}

/* Keep Jivo below dialogs/drawers but above regular page content */
body #jivo-iframe-container,
body iframe#jivo_container,
body iframe[name='jivo_container'],
body > jdiv #jvLabelWrap,
body > jdiv #jcont,
body > jdiv [style*='position: fixed'] {
  z-index: var(--jivo-z-index) !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Shift Jivo left when cart sidebar is open */
body > jdiv #jvLabelWrap {
  right: calc(40px + var(--jivo-sidebar-offset)) !important;
}

body > jdiv #jcont {
  right: calc(30px + var(--jivo-sidebar-offset)) !important;
}

html.jivo-site-full-block,
html.jivo-site-full-block body {
  inset: auto !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
  position: static !important;
  width: auto !important;
}

/* Bitrix24 widget layering and positioning controls */
body [data-b24-crm-button-cont],
body .b24-widget-button-wrapper,
body .b24-widget-button-popup,
body .b24-widget-button-shadow {
  z-index: var(--bitrix-z-index) !important;
}

body.cookie-sonner-open [data-b24-crm-button-cont],
body.cookie-sonner-open .b24-widget-button-wrapper,
body.cookie-sonner-open .b24-widget-button-popup,
body.cookie-sonner-open .b24-widget-button-shadow {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

body.cookie-sonner-open > jdiv #jvLabelWrap,
body.cookie-sonner-open > jdiv #jcont,
body.cookie-sonner-open > jdiv > jdiv.jv-mobile [class*='__jivoMobileButton'] {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Shift Bitrix left when desktop cart sidebar is open */
body.cart-sidebar-open [data-b24-crm-button-cont].b24-widget-button-position-bottom-right,
body.cart-sidebar-open
  .b24-widget-button-wrapper.b24-widget-button-position-bottom-right {
  right: calc(20px + var(--bitrix-sidebar-offset)) !important;
}

/* Mobile offset from fixed bottom navigation */
@media (max-width: 1024px) {
  body:has(> jdiv #jvLabelWrap),
  body:has(> jdiv #jcont),
  body:has(> jdiv > jdiv.jv-mobile) {
    --scroll-to-top-mobile-left: -24px;
    --scroll-to-top-mobile-bottom: calc(var(--jivo-mobile-bottom-offset) + 108px);
    --scroll-to-top-mobile-cart-bottom: calc(var(--jivo-mobile-bottom-offset) + 108px);
  }

  body > jdiv #jvLabelWrap,
  body > jdiv #jcont {
    bottom: calc(
      var(--jivo-mobile-bottom-offset) + env(safe-area-inset-bottom, 0px)
    ) !important;
  }

  /* Mobile Jivo has another markup (.__jivoMobileButton), handle it separately */
  body > jdiv > jdiv.jv-mobile,
  body > jdiv > jdiv.jv-mobile * {
    z-index: var(--jivo-z-index) !important;
  }

  body > jdiv > jdiv.jv-mobile [class*='__jivoMobileButton'] {
    bottom: calc(
      var(--jivo-mobile-bottom-offset) + env(safe-area-inset-bottom, 0px)
    ) !important;
    right: 16px !important;
  }

  body > jdiv > jdiv.jv-mobile [class*='menuWrapper__'],
  body > jdiv > jdiv.jv-mobile [class*='menu__'] {
    z-index: calc(var(--jivo-z-index) + 1) !important;
  }

  body > jdiv > jdiv.jv-mobile [class*='main__'] {
    z-index: calc(var(--jivo-z-index) - 1) !important;
  }

  body [data-b24-crm-button-cont].b24-widget-button-position-bottom-right,
  body .b24-widget-button-wrapper.b24-widget-button-position-bottom-right {
    bottom: calc(
      var(--bitrix-mobile-bottom-offset) + env(safe-area-inset-bottom, 0px)
    ) !important;
    right: 16px !important;
  }
}
