/*
 * Przyklejony pasek „Dodaj do koszyka" na karcie produktu — wersja desktopowa.
 *
 * To ten sam element co pasek mobilny (.box-cart-mobile w
 * woocommerce/single-product/add-to-cart/simple.php), więc miniatura podglądu
 * lustra (wtyczka mirror-preview wstrzykuje .mp-mini-wrap w .box-cart-mobile)
 * i podpięcie ceny z WC Kalkulatora (#wckalkulator-price_bar) działają w obu
 * widokach bez dublowania kodu.
 *
 * Plik ładowany na kartach produktu PO dist/css/theme.css (patrz header.php) —
 * theme.css jest ręcznie łatany i rozjechany ze źródłami SCSS, więc poprawek
 * nie wnosimy do dist/ ani nie przebudowujemy gulpem.
 */

/* ------------------------------------------------------------------ *
 * Telefon — pasek zostaje dokładnie taki jak był.
 * ------------------------------------------------------------------ */
@media screen and (max-width: 650px) {

  /* Opakowanie ceny nie może zmienić układu istniejącego paska: znika ze
     struktury flexa i #wckalkulator-price_bar dalej jest bezpośrednim
     elementem rzędu .box-cart-mobile__action. */
  .box-cart-bar .box-cart-bar__price {
    display: contents;
  }

  .box-cart-bar .box-cart-bar__label,
  .box-cart-bar .box-cart-bar__qty,
  .box-cart-bar .box-cart-bar__cta-long {
    display: none;
  }
}

/* ------------------------------------------------------------------ *
 * Desktop i tablet — pasek pojawia się po przewinięciu poza blok z ceną.
 * Klasę .is-visible dokłada assets/sticky-atc.js.
 * ------------------------------------------------------------------ */
@media screen and (min-width: 651px) {

  .product-main .product-info .box-cart .box-cart__add.box-cart-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999999;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    /* Treść wyrównana do kontenera motywu (max 1240px, padding 40px). */
    padding: 10px max(40px, calc((100% - 1160px) / 2));
    background-color: #fff;
    border-top: 1px solid rgb(221, 221, 221);
    box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.12);
    /* Ukryty do czasu przewinięcia — bez visibility łapałby kliknięcia. */
    visibility: hidden;
    opacity: 0;
    transform: translateY(110%);
    transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s;
  }

  .product-main .product-info .box-cart .box-cart__add.box-cart-bar.is-visible {
    visibility: visible;
    opacity: 1;
    transform: none;
  }

  /* Nazwa produktu tylko w wersji mobilnej — na desktopie tytuł i tak jest
     w zasięgu wzroku, a rząd ma być jednoliniowy. */
  .product-main .product-info .box-cart .box-cart-bar .box-cart-mobile__info {
    display: none;
  }

  /* Miniatura podglądu lustra: na telefonie leży absolutnie w rogu paska,
     tutaj wchodzi normalnie w rząd. */
  .product-main .product-info .box-cart .box-cart-bar .mp-mini-wrap {
    position: static;
    flex: 0 0 auto;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-mobile__action {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: none;
    margin: 0;
  }

  /* Cena ------------------------------------------------------------ */
  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__price {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 46px;
    padding: 6px 20px;
    border: 1px solid rgb(221, 221, 221);
    border-radius: 8px;
    background-color: #fafafa;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__label {
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgb(122, 122, 122);
    white-space: nowrap;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__price .price {
    font-size: 24px;
    line-height: 32px;
    font-weight: 500;
    color: rgb(26, 26, 26);
    white-space: nowrap;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__price .price * {
    text-decoration: none;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__price .old-price {
    font-size: 16px;
    line-height: 24px;
    margin-left: 8px;
    color: rgb(122, 122, 122);
    text-decoration: line-through;
  }

  /* Ilość ----------------------------------------------------------- */
  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__qty {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    height: 46px;
    border: 1px solid rgb(204, 204, 204);
    border-radius: 30px;
    background-color: #fff;
    overflow: hidden;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__qty-btn {
    width: 40px;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: rgb(26, 26, 26);
    transition: 0.2s;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__qty-btn:hover {
    background-color: rgb(240, 240, 240);
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__qty-input {
    width: 44px;
    height: 100%;
    padding: 0;
    border: 0;
    outline: none;
    text-align: center;
    font-size: 16px;
    line-height: 20px;
    color: rgb(26, 26, 26);
    background-color: transparent;
    -moz-appearance: textfield;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__qty-input::-webkit-outer-spin-button,
  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  /* Przycisk -------------------------------------------------------- */
  .product-main .product-info .box-cart .box-cart-bar .btn-add-to-cart {
    flex: 0 0 auto;
    width: auto;
    min-width: 260px;
    height: 46px;
    padding: 8px 28px;
  }

  .product-main .product-info .box-cart .box-cart-bar .box-cart-bar__cta-short {
    display: none;
  }
}

/* Pasek nie ma sensu na wydruku. */
@media print {
  .box-cart-bar {
    display: none !important;
  }
}
