/* =========================================================
   v2.6.4 — Mobile drawer full-height fit + checkout edge fixes
   ---------------------------------------------------------
   - The mobile menu now uses the full available viewport instead of a short
     bottom sheet, so product categories are not cut off on phones.
   - Only the category list scrolls when "Kõik kategooriad" is opened.
   - Checkout company invoice toggling no longer hides section headings,
     wrapper borders or the billing/transport divider.
   ========================================================= */

@media (max-width: 900px) {
  html.vlg-mobile-menu-lock,
  html.vlg-mobile-menu-lock body,
  body.vlg-theme.vlg-menu-open,
  body.vlg-menu-open {
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  body.vlg-theme .vlg-mobile-backdrop:not([hidden]) {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: var(--vlg-visual-height, 100vh) !important;
    background: rgba(7, 18, 36, .46) !important;
    z-index: 100000 !important;
  }

  body.vlg-theme .vlg-nav.is-open,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    position: fixed !important;
    left: max(8px, env(safe-area-inset-left)) !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    top: max(8px, env(safe-area-inset-top)) !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 1px solid rgba(218, 228, 240, .98) !important;
    border-radius: 24px !important;
    background: #fff !important;
    box-shadow: 0 22px 80px rgba(7, 18, 36, .34) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
    z-index: 100010 !important;
  }

  body.admin-bar.vlg-theme .vlg-nav.is-open,
  body.admin-bar.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    top: calc(var(--wp-admin--admin-bar--height, 46px) + max(8px, env(safe-area-inset-top))) !important;
  }

  body.vlg-theme .vlg-nav.is-open::before,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open::before {
    flex: 0 0 auto !important;
    display: block !important;
    width: 46px !important;
    height: 5px !important;
    margin: 10px auto 6px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-nav-inner,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-nav-inner {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    height: calc(100% - 21px) !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 12px max(12px, env(safe-area-inset-bottom)) !important;
    overflow: hidden !important;
    overscroll-behavior: contain !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-mobile-nav-head,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-mobile-nav-head {
    min-height: 42px !important;
    max-height: 52px !important;
    padding: 0 2px 6px !important;
  }

  body.vlg-theme.vlg-mobile-categories-only .vlg-nav.is-open .vlg-mobile-quick-links,
  body.vlg-theme.vlg-mobile-hide-quick-links .vlg-nav.is-open .vlg-mobile-quick-links,
  body.vlg-theme.vlg-mobile-categories-only .vlg-nav.is-open .vlg-primary-menu,
  body.vlg-theme.vlg-mobile-hide-primary-menu .vlg-nav.is-open .vlg-primary-menu {
    display: none !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-menu,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-menu {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-button,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button {
    flex: 0 0 auto !important;
    min-height: 48px !important;
    max-height: 56px !important;
  }

  body.vlg-theme.vlg-mobile-categories-only:not(.vlg-mobile-auto-open-categories) .vlg-nav.is-open .vlg-category-menu:not(.is-open) .vlg-category-dropdown,
  body.vlg-theme.vlg-mobile-categories-only:not(.vlg-mobile-auto-open-categories) .vlg-nav.is-open .vlg-category-button[aria-expanded="false"] + .vlg-category-dropdown,
  body.vlg-theme.vlg-mobile-categories-only:not(.vlg-mobile-auto-open-categories) .vlg-nav.is-open .vlg-category-dropdown[aria-hidden="true"] {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown,
  body.vlg-theme.vlg-mobile-auto-open-categories .vlg-nav.is-open .vlg-category-dropdown,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown > ul,
  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-category-dropdown > .vlg-cat-dropdown-list,
  body.vlg-theme .vlg-nav.is-open .vlg-category-menu.is-open .vlg-cat-tree,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown > ul,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown > .vlg-cat-dropdown-list,
  body.vlg-theme .vlg-nav.is-open .vlg-category-button[aria-expanded="true"] + .vlg-category-dropdown .vlg-cat-tree,
  body.vlg-theme.vlg-mobile-auto-open-categories .vlg-nav.is-open .vlg-cat-tree {
    display: grid !important;
    align-content: start !important;
    gap: 7px !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 8px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    scrollbar-gutter: stable both-edges !important;
    border: 1px solid #dbe5f1 !important;
    border-radius: 18px !important;
    background: #f8fafc !important;
    list-style: none !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-row,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-cat-tree .vlg-cat-row {
    grid-template-columns: minmax(0, 1fr) 44px !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-link,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-cat-tree .vlg-cat-link {
    min-height: 46px !important;
  }
}

@media (max-width: 430px) {
  body.vlg-theme .vlg-nav.is-open,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    left: max(6px, env(safe-area-inset-left)) !important;
    right: max(6px, env(safe-area-inset-right)) !important;
    top: max(6px, env(safe-area-inset-top)) !important;
    bottom: max(6px, env(safe-area-inset-bottom)) !important;
  }

  body.admin-bar.vlg-theme .vlg-nav.is-open,
  body.admin-bar.vlg-theme.vlg-menu-open .vlg-nav.is-open {
    top: calc(var(--wp-admin--admin-bar--height, 46px) + max(6px, env(safe-area-inset-top))) !important;
  }

  body.vlg-theme .vlg-nav.is-open .vlg-nav-inner,
  body.vlg-theme.vlg-menu-open .vlg-nav.is-open .vlg-nav-inner {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* Checkout: keep section chrome stable while company invoice fields appear/disappear. */
.woocommerce-checkout .vlg-company-invoice-field.vlg-company-invoice-hidden,
.woocommerce-checkout .vlg-company-invoice-hidden {
  display: none !important;
}

.woocommerce-checkout .vlg-company-invoice-field:not(.vlg-company-invoice-hidden) {
  display: block !important;
}

.woocommerce-checkout .woocommerce-billing-fields,
.woocommerce-checkout .woocommerce-shipping-fields,
.woocommerce-checkout .woocommerce-additional-fields,
.woocommerce-checkout .woocommerce-billing-fields h3,
.woocommerce-checkout .woocommerce-shipping-fields h3,
.woocommerce-checkout .woocommerce-additional-fields h3,
.woocommerce-checkout .fs-checkout-card,
.woocommerce-checkout .fs-checkout-card__head {
  visibility: visible !important;
  opacity: 1 !important;
}

.woocommerce-checkout .woocommerce-billing-fields h3,
.woocommerce-checkout .woocommerce-shipping-fields h3,
.woocommerce-checkout .woocommerce-additional-fields h3 {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100% !important;
}

.woocommerce-checkout .woocommerce-billing-fields h3::after,
.woocommerce-checkout .woocommerce-shipping-fields h3::after,
.woocommerce-checkout .woocommerce-additional-fields h3::after {
  content: "" !important;
  display: block !important;
  flex: 1 1 auto !important;
  height: 2px !important;
  min-width: 32px !important;
  border-radius: 999px !important;
  background: linear-gradient(90deg, var(--vlg-primary, #f28a00), rgba(242, 138, 0, .22)) !important;
}

body.admin-bar.woocommerce-checkout .fs-payment-column,
body.admin-bar.woocommerce-checkout .fs-payment-column #payment,
body.admin-bar.woocommerce-checkout .fs-payment-column .woocommerce-checkout-payment {
  scroll-margin-top: calc(var(--wp-admin--admin-bar--height, 46px) + 18px) !important;
}

@media (min-width: 1180px) {
  body.admin-bar.woocommerce-checkout .fs-payment-column {
    position: relative !important;
    top: auto !important;
  }
}
