/* v5.1.97 — final mobile stability owner
   One late layer for the parts that were fighting each other:
   fixed mobile appbar, scoped homepage category cards, buybox grid,
   clean category arrows, mobile admin-bar safety. */

@media (max-width: 782px) {
  :root { --vlg-mobile-appbar-h: 78px; }

  html body.vlg-theme {
    padding-bottom: calc(var(--vlg-mobile-appbar-h, 78px) + 18px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: clip !important;
  }

  html body.vlg-theme.home,
  html body.vlg-theme.single-product,
  html body.vlg-theme.tax-product_cat,
  html body.vlg-theme.woocommerce-shop,
  html body.vlg-theme.archive {
    padding-bottom: calc(var(--vlg-mobile-appbar-h, 78px) + 18px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html body.vlg-theme .vlg-mobile-appbar {
    display: grid !important;
    position: fixed !important;
    top: auto !important;
    left: max(10px, env(safe-area-inset-left, 0px)) !important;
    right: max(10px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
    inset-block-start: auto !important;
    inset-inline-start: max(10px, env(safe-area-inset-left, 0px)) !important;
    inset-inline-end: max(10px, env(safe-area-inset-right, 0px)) !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    transform: translate3d(0, 0, 0) !important;
    translate: none !important;
    z-index: 2147483000 !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    will-change: auto !important;
    backface-visibility: hidden !important;
    contain: layout paint style !important;
  }

  html body.vlg-theme.vlg-menu-open .vlg-mobile-appbar,
  html body.vlg-theme.vlg-mobile-search-open .vlg-mobile-appbar {
    opacity: .96 !important;
    pointer-events: auto !important;
  }

  html body.vlg-theme .vlg-mobile-appbar__item {
    min-width: 0 !important;
    min-height: 56px !important;
    transform: none !important;
    touch-action: manipulation !important;
  }

  html body.vlg-theme .vlg-mobile-appbar__item--primary {
    transform: translate3d(0, -8px, 0) !important;
    margin-top: 0 !important;
  }

  html body.vlg-theme .vlg-mobile-appbar__item--primary::after,
  html body.vlg-theme .vlg-mobile-appbar__item--primary:after {
    display: none !important;
    content: none !important;
  }

  html body.admin-bar.vlg-theme {
    --wp-admin--admin-bar--height: 0px !important;
    padding-top: 0 !important;
  }

  html body.admin-bar.vlg-theme #wpadminbar {
    display: none !important;
  }

  html body.vlg-theme .vlg-site-header,
  html body.admin-bar.vlg-theme .vlg-site-header,
  html body.admin-bar.vlg-sticky-header .vlg-site-header {
    top: 0 !important;
  }
}

/* Homepage popular category cards: scoped only to the homepage section. */
@media (max-width: 767px) {
  html body.vlg-theme #kategooriad,
  html body.vlg-theme #kategooriad * { box-sizing: border-box !important; }

  html body.vlg-theme #kategooriad .vlg-category-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  html body.vlg-theme #kategooriad .vlg-category-grid > a.vlg-category-card {
    position: relative !important;
    display: grid !important;
    grid-template-columns: 82px minmax(0, 1fr) !important;
    gap: 16px !important;
    align-items: center !important;
    width: 100% !important;
    min-height: 112px !important;
    margin: 0 !important;
    padding: 14px 16px !important;
    overflow: hidden !important;
    border-radius: 20px !important;
  }

  html body.vlg-theme #kategooriad .vlg-category-grid > a.vlg-category-card > img {
    position: static !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    display: block !important;
    width: 72px !important;
    height: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    padding: 7px !important;
    border-radius: 16px !important;
    background: #f8fafc !important;
    transform: none !important;
  }

  html body.vlg-theme #kategooriad .vlg-category-grid > a.vlg-category-card > div {
    position: static !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: flex-start !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
    z-index: auto !important;
  }

  html body.vlg-theme #kategooriad .vlg-category-grid > a.vlg-category-card > div > strong {
    display: block !important;
    width: 100% !important;
    margin: 0 0 6px !important;
    font-size: 17px !important;
    line-height: 1.12 !important;
    font-weight: 950 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  html body.vlg-theme #kategooriad .vlg-category-grid > a.vlg-category-card > div > small {
    display: block !important;
    width: 100% !important;
    margin: 0 0 8px !important;
    font-size: 13px !important;
    line-height: 1.22 !important;
  }

  html body.vlg-theme #kategooriad .vlg-category-grid > a.vlg-category-card > div > span {
    display: inline-flex !important;
    width: auto !important;
    margin: 0 !important;
    white-space: nowrap !important;
  }
}

/* Buybox: one stable mobile grid for quantity + CTA. */
@media (max-width: 782px) {
  body.single-product .vlg-product-buybox form.cart:not(.grouped_form),
  body.single-product .vlg-product-buybox .woocommerce-variation-add-to-cart,
  body.single-product .vlg-product-buybox .woocommerce-variation-add-to-cart.variations_button,
  body.single-product .vmp-buybox .woocommerce-variation-add-to-cart,
  body.single-product .vmp-buybox .woocommerce-variation-add-to-cart.variations_button,
  body.single-product .vmp-buybox .variations_button {
    display: grid !important;
    grid-template-columns: 74px minmax(0, 1fr) !important;
    gap: 12px !important;
    align-items: stretch !important;
    width: 100% !important;
  }

  body.single-product .vlg-product-buybox .quantity,
  body.single-product .vmp-buybox .quantity {
    width: auto !important;
    min-width: 0 !important;
    max-width: 74px !important;
    margin: 0 !important;
  }

  body.single-product .vlg-product-buybox .single_add_to_cart_button,
  body.single-product .vmp-buybox .single_add_to_cart_button {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.single-product .vmp-sticky-buy,
  body.vlg-theme .vlg-sticky-cart,
  body.vlg-theme [data-vlg-mobile-buybar] {
    bottom: calc(var(--vlg-mobile-appbar-h, 78px) + 14px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Category tree: one visible chevron, no pseudo double arrows. */
body.vlg-theme .vlg-nav .vlg-cat-subtoggle::before,
body.vlg-theme .vlg-nav .vlg-cat-subtoggle::after,
body.vlg-theme .vlg-nav .vlg-cat-subtoggle span + span {
  display: none !important;
  content: none !important;
}

body.vlg-theme .vlg-nav .vlg-cat-subtoggle span {
  display: inline-block !important;
  transform: none !important;
  font-family: inherit !important;
}

@media (min-width: 901px) {
  body.vlg-theme .vlg-nav .vlg-cat-subtoggle {
    width: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border: 1px solid #d9e3ee !important;
    border-radius: 14px !important;
    background: #f8fbff !important;
    color: #7b8ba1 !important;
    box-shadow: none !important;
  }

  body.vlg-theme .vlg-nav .vlg-cat-item.is-sub-open > .vlg-cat-row .vlg-cat-subtoggle {
    background: #fff7ed !important;
    border-color: #f6c58c !important;
    color: #f28a00 !important;
  }

  /* Click-open only; prevent hover/focus from opening another layer on top. */
  body.vlg-theme .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:not(.is-sub-open):hover > .vlg-cat-submenu,
  body.vlg-theme .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:not(.is-sub-open):focus-within > .vlg-cat-submenu {
    display: none !important;
  }

  body.vlg-theme .vlg-cat-item.is-sub-open > .vlg-cat-submenu {
    position: static !important;
    display: grid !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 7px 0 8px 14px !important;
    padding: 0 0 0 11px !important;
    border-left: 2px solid rgba(242, 138, 0, .24) !important;
    background: transparent !important;
    box-shadow: none !important;
  }
}
