/*
  Ultracell V20.44 — Xiaomi Android Scroll Fix
  Camada final para destravar rolagem em Android Xiaomi/MIUI, Chrome e WebView.
  Mantém iPhone/desktop preservados e não altera regras de negócio.
*/

@media (max-width: 760px) {
  html,
  body {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-x: none !important;
    overscroll-behavior-y: auto !important;
    touch-action: pan-y !important;
    -webkit-text-size-adjust: 100% !important;
  }

  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) {
    position: static !important;
    inset: auto !important;
    display: block !important;
    min-height: 100dvh !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: auto !important;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) #app {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100dvh !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    transform: none !important;
    contain: none !important;
    touch-action: pan-y !important;
  }

  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-app {
    position: relative !important;
    inset: auto !important;
    display: block !important;
    width: min(100vw, 430px) !important;
    min-width: 0 !important;
    min-height: 100dvh !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 auto !important;
    padding-bottom: calc(132px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    overscroll-behavior-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    transform: none !important;
    contain: none !important;
    will-change: auto !important;
  }

  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-topbar,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .catalog-dev-notice,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .catalog-dev-notice-v19,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-section-title,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-active-filter,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-grid,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) #v19-product-grid,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-product,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-product-info {
    transform: none !important;
    contain: none !important;
    will-change: auto !important;
    touch-action: pan-y !important;
  }

  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) .v19-grid,
  body.v19-store-mobile-active:not(.modal-open):not(.uc-image-viewer-open) #v19-product-grid {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    padding-bottom: calc(144px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Barras horizontais: permitem deslizar lateralmente sem matar a rolagem vertical do Android/MIUI. */
  body.v19-store-mobile-active .v19-category-strip,
  body.v19-store-mobile-active .v19-filter-strip {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    touch-action: pan-x pan-y !important;
    overscroll-behavior-x: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Páginas internas: no Xiaomi é mais confiável rolar a página interna explicitamente. */
  body.v19-store-mobile-active .v19-page[hidden] {
    display: none !important;
  }

  body.v19-store-mobile-active .v19-page:not([hidden]) {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    top: 0 !important;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px)) !important;
    transform: translateX(-50%) !important;
    width: min(100vw, 430px) !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 82px - env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden !important;
    overflow-y: scroll !important;
    overscroll-behavior-y: contain !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    contain: none !important;
    will-change: auto !important;
    padding-bottom: calc(124px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.v19-store-mobile-active .v19-page-news:not([hidden]) .v19-grid,
  body.v19-store-mobile-active .v19-page-categories:not([hidden]) .v19-categories-content,
  body.v19-store-mobile-active .v19-page-profile:not([hidden]) {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    padding-bottom: calc(132px + env(safe-area-inset-bottom, 0px)) !important;
    touch-action: pan-y !important;
  }

  /* Carrinho mantém rolagem interna porque possui footer próprio. */
  body.v19-store-mobile-active .v19-page-cart:not([hidden]) {
    padding-bottom: 0 !important;
    overflow: hidden !important;
  }

  body.v19-store-mobile-active .v19-page-cart:not([hidden]) .v19-cart-content {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* A navegação inferior não pode criar uma camada invisível que rouba o gesto vertical. */
  body.v19-store-mobile-active .v19-bottom-nav {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    z-index: 90 !important;
  }

  body.v19-store-mobile-active .v19-bottom-nav::before,
  body.v19-store-mobile-active .v19-bottom-nav::after {
    content: none !important;
    display: none !important;
    pointer-events: none !important;
  }

  body.v19-store-mobile-active .v19-bottom-nav button,
  body.v19-store-mobile-active .v19-nav-btn {
    touch-action: manipulation !important;
  }

  body.modal-open,
  body.uc-image-viewer-open {
    overflow: hidden !important;
    touch-action: none !important;
  }
}
