/* v5.1.29 — mobile visual refresh: cleaner product imagery, tighter layout and refined energy modal */

@media (max-width: 782px) {
  /* General mobile product spacing */
  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: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    align-items: start !important;
  }

  /* Single product gallery — reduce empty area and let image use the card properly */
  html body.vlg-theme.single-product .vlg-product-gallery-card {
    padding: 10px !important;
    margin: 0 0 10px !important;
    min-height: 0 !important;
    border-radius: 22px !important;
    background: linear-gradient(180deg, #fdfdfd 0%, #f7f8fa 100%) !important;
    box-shadow: 0 10px 24px rgba(18, 33, 56, .06) !important;
    overflow: hidden !important;
  }

  html body.vlg-theme.single-product .vlg-product-gallery-media {
    display: grid !important;
    gap: 10px !important;
  }

  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;
    display: block !important;
    overflow: hidden !important;
    transform: none !important;
    left: auto !important;
  }

  html body.vlg-theme.single-product .flex-viewport {
    aspect-ratio: 1 / 1 !important;
    min-height: clamp(250px, 74vw, 390px) !important;
    border-radius: 18px !important;
    background: #ffffff !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,
  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 {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: clamp(250px, 74vw, 390px) !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !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: auto !important;
    height: auto !important;
    max-width: min(100%, calc(100vw - 40px)) !important;
    max-height: clamp(230px, 68vw, 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;
    align-items: stretch !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 2px 4px !important;
    overflow-x: auto !important;
    scrollbar-width: thin !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs li {
    flex: 0 0 60px !important;
    width: 60px !important;
    height: 60px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    background: #fff !important;
    border: 1px solid rgba(24, 38, 61, .09) !important;
    box-shadow: 0 6px 14px rgba(17, 32, 55, .05) !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs li img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    padding: 6px !important;
  }

  html body.vlg-theme.single-product .vlg-single-image-energy {
    right: 8px !important;
    bottom: 8px !important;
    transform: scale(.72) !important;
    transform-origin: right bottom !important;
    z-index: 3 !important;
  }

  /* Summary card */
  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 .vlg-pill {
    display: inline-flex !important;
    max-width: 100% !important;
    padding: 7px 12px !important;
    font-size: 12px !important;
    line-height: 1.1 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  html body.vlg-theme.single-product .product_title,
  html body.vlg-theme.single-product div.product .product_title {
    margin: 8px 0 10px !important;
    font-size: clamp(19px, 6vw, 30px) !important;
    line-height: 1.12 !important;
    letter-spacing: -.03em !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    hyphens: auto !important;
  }

  html body.vlg-theme.single-product .vlg-product-price,
  html body.vlg-theme.single-product div.product p.price,
  html body.vlg-theme.single-product div.product span.price {
    font-size: clamp(18px, 5vw, 26px) !important;
    line-height: 1.14 !important;
    margin: 0 0 10px !important;
  }

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

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

  /* Buybox */
  html body.vlg-theme.single-product .vlg-product-buybox {
    display: grid !important;
    gap: 10px !important;
    margin: 14px 0 0 !important;
    padding: 12px !important;
    min-height: 0 !important;
    border-radius: 18px !important;
    overflow: hidden !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 {
    display: grid !important;
    grid-template-columns: 80px minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: center !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: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    margin: 0 !important;
  }

  html body.vlg-theme.single-product form.cart .quantity .qty {
    width: 100% !important;
    min-height: 50px !important;
    max-width: 100% !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: nowrap !important;
  }

  /* Product cards in mobile product listings — image should fill card better */
  body.vlg-theme ul.products li.product.vlg-product-card,
  body.vlg-theme .vlg-products-grid .vlg-product-card,
  body.vlg-theme .vlg-home-product-section .vlg-product-card {
    border-radius: 18px !important;
    overflow: hidden !important;
  }

  body.vlg-theme ul.products li.product.vlg-product-card .vlg-card-image-wrap,
  body.vlg-theme .vlg-products-grid .vlg-product-card .vlg-card-image-wrap,
  body.vlg-theme .vlg-home-product-section .vlg-product-card .vlg-card-image-wrap {
    min-height: 0 !important;
    aspect-ratio: 1 / .9 !important;
    padding: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(180deg, #fbfbfc 0%, #f3f4f7 100%) !important;
  }

  body.vlg-theme ul.products li.product.vlg-product-card .vlg-card-image-wrap img,
  body.vlg-theme .vlg-products-grid .vlg-product-card .vlg-card-image-wrap img,
  body.vlg-theme .vlg-home-product-section .vlg-product-card .vlg-card-image-wrap img,
  body.vlg-theme ul.products li.product.vlg-product-card .wp-post-image,
  body.vlg-theme .vlg-products-grid .vlg-product-card .wp-post-image,
  body.vlg-theme .vlg-home-product-section .vlg-product-card .wp-post-image {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: clamp(132px, 34vw, 188px) !important;
    object-fit: contain !important;
    margin: 0 auto !important;
  }

  body.vlg-theme ul.products li.product.vlg-product-card .vlg-card-content,
  body.vlg-theme .vlg-products-grid .vlg-product-card .vlg-card-content,
  body.vlg-theme .vlg-home-product-section .vlg-product-card .vlg-card-content {
    padding-top: 10px !important;
  }

  body.vlg-theme ul.products li.product.vlg-product-card h2,
  body.vlg-theme .vlg-products-grid .vlg-product-card h2,
  body.vlg-theme .vlg-home-product-section .vlg-product-card h2 {
    font-size: 14px !important;
    line-height: 1.22 !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  /* Energy label modal — fit fully on screen and use less empty 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(92vw, 350px) !important;
    max-width: 92vw !important;
    max-height: calc(100svh - 16px) !important;
    padding: 10px !important;
    border-radius: 20px !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    align-content: start !important;
    justify-items: center !important;
    gap: 10px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  .valgusallikad-energiasildid-modal-title,
  .fs-euel-modal-title {
    width: 100% !important;
    margin: 0 !important;
    padding-right: 44px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    text-align: left !important;
    overflow-wrap: anywhere !important;
  }

  .valgusallikad-energiasildid-modal-close,
  .fs-euel-modal-close {
    top: 10px !important;
    right: 10px !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
  }

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

  .valgusallikad-energiasildid-modal-filter,
  .fs-euel-modal-filter {
    width: 100% !important;
    min-height: 48px !important;
    margin: 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;
    justify-content: center !important;
  }

  /* Footer contact values should stay readable on one logical line */
  .vlg-footer-mini-card a,
  .vlg-footer-contact-row a,
  .vlg-footer-contact-row span,
  .vlg-footer-mini-card span {
    word-break: normal !important;
    overflow-wrap: normal !important;
  }

  .vlg-footer-mini-card a,
  .vlg-footer-contact-row a {
    white-space: nowrap !important;
  }
}

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

  html body.vlg-theme.single-product .flex-viewport,
  html body.vlg-theme.single-product .woocommerce-product-gallery__image,
  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 {
    min-height: clamp(232px, 72vw, 330px) !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 {
    max-height: clamp(214px, 64vw, 300px) !important;
  }

  html body.vlg-theme.single-product .flex-control-thumbs li {
    flex-basis: 56px !important;
    width: 56px !important;
    height: 56px !important;
  }

  html body.vlg-theme.single-product .vlg-single-image-energy {
    transform: scale(.68) !important;
  }

  html body.vlg-theme.single-product .product_title,
  html body.vlg-theme.single-product div.product .product_title {
    font-size: clamp(18px, 5.7vw, 24px) !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: 74px 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: 74px !important;
    min-width: 74px !important;
    max-width: 74px !important;
  }

  .valgusallikad-energiasildid-modal-dialog,
  .fs-euel-modal-dialog {
    width: calc(100vw - 14px) !important;
    max-width: calc(100vw - 14px) !important;
    padding: 10px 10px 12px !important;
  }

  .valgusallikad-energiasildid-modal-image,
  .fs-euel-modal-image {
    max-height: calc(100svh - 198px) !important;
  }
}
