/* v5.1.28 — mobile single-product fit: gallery, buybox and energy modal */

@media (max-width: 782px) {
  html body.vlg-theme.single-product .vlg-single-product-page {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  html body.vlg-theme.single-product .vlg-product-main-grid,
  html body.vlg-theme.single-product .vlg-product-detail .vlg-product-main-grid {
    display: block !important;
    gap: 0 !important;
  }

  html body.vlg-theme.single-product .vlg-product-gallery-card {
    min-height: 0 !important;
    height: auto !important;
    padding: 8px !important;
    margin: 0 0 12px !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    background: #fff !important;
  }

  html body.vlg-theme.single-product .vlg-product-gallery-card::before {
    display: none !important;
  }

  html body.vlg-theme.single-product .vlg-product-gallery-media,
  html body.vlg-theme.single-product .woocommerce-product-gallery,
  html body.vlg-theme.single-product .flex-viewport,
  html body.vlg-theme.single-product .woocommerce-product-gallery__wrapper,
  html body.vlg-theme.single-product .woocommerce-product-gallery__image,
  html body.vlg-theme.single-product .flex-viewport .slides,
  html body.vlg-theme.single-product .flex-viewport .slides > li {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    left: auto !important;
    transform: none !important;
    display: block !important;
    overflow: hidden !important;
  }

  html body.vlg-theme.single-product .flex-viewport {
    aspect-ratio: 1 / 1 !important;
    border-radius: 18px !important;
    background: linear-gradient(180deg, #fbfbfc 0%, #f4f5f7 100%) !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__wrapper > *:not(:first-child):not(.flex-active-slide),
  html body.vlg-theme.single-product .flex-viewport .slides > li:not(:first-child):not(.flex-active-slide) {
    display: none !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__image a,
  html body.vlg-theme.single-product .flex-viewport .slides > li > a,
  html body.vlg-theme.single-product .flex-viewport .slides > li > div,
  html body.vlg-theme.single-product .woocommerce-product-gallery__image {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    min-height: clamp(240px, 72vw, 360px) !important;
    background: transparent !important;
  }

  html body.vlg-theme.single-product .woocommerce-product-gallery__image img,
  html body.vlg-theme.single-product .woocommerce-product-gallery img.wp-post-image,
  html body.vlg-theme.single-product .vlg-product-gallery-card img,
  html body.vlg-theme.single-product .flex-viewport .slides img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: clamp(240px, 72vw, 360px) !important;
    object-fit: contain !important;
    object-position: center center !important;
    margin: 0 auto !important;
    padding: 0 !important;
    background: transparent !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs {
    display: flex !important;
    gap: 8px !important;
    margin: 8px 0 0 !important;
    padding: 0 0 4px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs li {
    flex: 0 0 58px !important;
    width: 58px !important;
    height: 58px !important;
    border-radius: 12px !important;
  }

  html body.vlg-theme.single-product .vlg-single-image-energy {
    right: 8px !important;
    bottom: 8px !important;
    left: auto !important;
    top: auto !important;
    transform: scale(.76) !important;
    transform-origin: right bottom !important;
  }

  html body.vlg-theme.single-product .vlg-product-summary-card,
  html body.vlg-theme.single-product div.product .summary {
    padding: 14px !important;
    border-radius: 20px !important;
    overflow: hidden !important;
  }

  html body.vlg-theme.single-product .product_title,
  html body.vlg-theme.single-product div.product .product_title {
    font-size: clamp(18px, 5.3vw, 28px) !important;
    line-height: 1.14 !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  html body.vlg-theme.single-product .vlg-product-meta-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  html body.vlg-theme.single-product .vlg-product-meta-grid > * {
    min-width: 0 !important;
  }

  html body.vlg-theme.single-product .vlg-product-buybox {
    display: grid !important;
    gap: 12px !important;
    min-height: 0 !important;
    margin: 16px 0 !important;
    padding: 12px !important;
    border-radius: 16px !important;
  }

  html body.vlg-theme.single-product .vlg-product-buybox > p,
  html body.vlg-theme.single-product .vlg-product-buybox .stock,
  html body.vlg-theme.single-product .vlg-product-buybox .woocommerce-variation-availability,
  html body.vlg-theme.single-product .vlg-product-buybox .woocommerce-variation-price {
    margin: 0 !important;
  }

  html body.vlg-theme.single-product .vlg-product-buybox form.cart,
  html body.vlg-theme.single-product div.product form.cart,
  html body.vlg-theme.single-product form.cart {
    position: relative !important;
    display: grid !important;
    grid-template-columns: 82px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  html body.vlg-theme.single-product form.cart .quantity,
  html body.vlg-theme.single-product .vlg-product-buybox form.cart .quantity {
    width: 82px !important;
    min-width: 82px !important;
    max-width: 82px !important;
    margin: 0 !important;
  }

  html body.vlg-theme.single-product form.cart .quantity .qty {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 50px !important;
  }

  html body.vlg-theme.single-product form.cart .single_add_to_cart_button,
  html body.vlg-theme.single-product .vlg-product-buybox form.cart .single_add_to_cart_button {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 50px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    font-size: 15px !important;
    line-height: 1.15 !important;
    white-space: normal !important;
  }

  /* Energy label modal should fit without excessive white area. */
  .valgusallikad-energiasildid-modal,
  .fs-euel-modal {
    padding: 8px !important;
    align-items: center !important;
  }

  .valgusallikad-energiasildid-modal-dialog,
  .fs-euel-modal-dialog {
    width: min(94vw, 360px) !important;
    max-width: 94vw !important;
    max-height: calc(100dvh - 16px) !important;
    padding: 12px !important;
    border-radius: 20px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    align-content: start !important;
    justify-items: center !important;
    gap: 10px !important;
  }

  .valgusallikad-energiasildid-modal-title,
  .fs-euel-modal-title {
    width: 100% !important;
    margin: 0 !important;
    padding-right: 48px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
  }

  .valgusallikad-energiasildid-modal-image,
  .fs-euel-modal-image {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 210px) !important;
    margin: 0 auto !important;
    object-fit: contain !important;
  }

  .valgusallikad-energiasildid-modal-filter,
  .fs-euel-modal-filter {
    width: 100% !important;
    min-height: 50px !important;
    margin-top: 0 !important;
    padding: 12px 14px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    text-align: center !important;
    white-space: normal !important;
    border-radius: 999px !important;
  }
}

@media (max-width: 390px) {
  html body.vlg-theme.single-product .vlg-product-gallery-card {
    padding: 6px !important;
  }

  html body.vlg-theme.single-product .vlg-product-buybox form.cart,
  html body.vlg-theme.single-product div.product form.cart,
  html body.vlg-theme.single-product form.cart {
    grid-template-columns: 76px minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  html body.vlg-theme.single-product form.cart .quantity,
  html body.vlg-theme.single-product .vlg-product-buybox form.cart .quantity {
    width: 76px !important;
    min-width: 76px !important;
    max-width: 76px !important;
  }
}
