/**
 * Product page CRO – mobile optimization
 * Imagine mică, sticky add to cart la scroll
 */

/* ====== Mobile: imagine mai mică → Add to cart above the fold ====== */
@media (max-width: 767px) {
  /* Imaginea rămâne sus, dar mai mică – ca titlu + preț + Add to cart să fie vizibile fără scroll */

  /* Galerie standard WooCommerce (flex-viewport) */
  .woocommerce div.product .woocommerce-product-gallery .flex-viewport,
  .woocommerce div.product .woocommerce-product-gallery__wrapper {
    max-height: 35vh !important;
  }
  .woocommerce div.product .woocommerce-product-gallery .flex-viewport img,
  .woocommerce div.product .woocommerce-product-gallery__image img,
  .woocommerce div.product .woocommerce-product-gallery__wrapper img {
    max-height: 35vh !important;
    width: auto !important;
    object-fit: contain !important;
  }

  /* Galerie Kadence (Splide) – .product_image, .kadence-product-gallery-main */
  .woocommerce div.product .woocommerce-product-gallery .product_image,
  .woocommerce div.product .ksk-gallery .product_image {
    max-height: 35vh !important;
    overflow: hidden !important;
  }
  .woocommerce div.product .kadence-product-gallery-main,
  .woocommerce div.product .kadence-product-gallery-main .splide__track,
  .woocommerce div.product .kadence-product-gallery-main .splide__list {
    max-height: 35vh !important;
  }
  .woocommerce div.product .kadence-product-gallery-main .splide__slide,
  .woocommerce div.product .kadence-product-gallery-main img,
  .woocommerce div.product .product_image img {
    max-height: 35vh !important;
    object-fit: contain !important;
  }
}

/* Sticky bar – ascuns pe desktop */
.dipimacu-sticky-atc-bar {
  display: none;
}
/* ====== Mobile: doar butonul Add to cart sticky (minimal) ====== */
@media (max-width: 767px) {
  .dipimacu-sticky-atc-bar {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .dipimacu-sticky-atc-bar.dipimacu-sticky-atc-bar--hidden {
    pointer-events: none;
    opacity: 0;
    transform: translateY(100%);
  }
  .dipimacu-sticky-atc-btn {
    width: 100%;
    height: 48px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: 6px;
    background: var(--global-palette-btn-bg, #b32d2e);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s;
  }
  .dipimacu-sticky-atc-btn:hover:not(:disabled) {
    opacity: 0.9;
  }
  .dipimacu-sticky-atc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  /* Spațiu la final ca conținutul să nu fie ascuns sub bară */
  .woocommerce.single-product .product {
    padding-bottom: 90px;
  }
  /* scroll-margin pentru scroll din sticky – lasă spațiu pentru header fix */
  .woocommerce.single-product .summary.entry-summary {
    scroll-margin-top: 80px;
  }
}

/* ====== Add to cart + Vezi coșul – UX îmbunătățit ====== */
@media (max-width: 767px) {
  /* Form cart: quantity + add to cart pe o linie, full width */
  .woocommerce.single-product form.cart {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Rând 1: quantity + Add to cart (aliniate) */
  .woocommerce.single-product form.cart .woocommerce-variation-add-to-cart,
  .woocommerce.single-product form.cart:not(.variations_form) {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  /* Buton Add to cart – flex grow pe mobile */
  .woocommerce.single-product form.cart .single_add_to_cart_button {
    flex: 1 1 auto !important;
    min-width: 140px !important;
    height: 48px !important;
    min-height: 48px !important;
  }

  /* Vezi coșul – full width, proeminent, sub Add to cart */
  .woocommerce.single-product form.cart a.added_to_cart.wc-forward {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    margin-top: 0.25rem !important;
    padding: 0.75rem 1rem !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    background: #4b382a !important;
    color: #fff !important;
    text-decoration: none !important;
    transition: background 0.2s ease !important;
  }
  .woocommerce.single-product form.cart a.added_to_cart.wc-forward:hover {
    background: #3d2e23 !important;
    color: #fff !important;
  }
}
