/* =========================================================
   GALLERY CUSTOM – PRODUCTION HARDENING
   Desktop: pionowe miniaturki po lewej + duże zdjęcie
   Modal: dopasowany układ + własny close button
   Mobile: custom slider bez miniaturek + licznik + swipe + własny modal
========================================================= */

/* =========================================================
   DESKTOP / TABLET
========================================================= */
@media (min-width: 992px) {
  body#product #main {
    width: 100%;
    max-width: 100% !important;
  }

  body#product #content {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }

  body#product .product-container {
    display: flex;
    gap: 28px;
  }

  body#product .product-container > .col-md-6:first-child {
    flex: 0 0 60%;
    max-width: 60%;
    min-width: 0;
  }

  body#product .product-container > .col-md-6:last-child {
    flex: 0 0 40%;
    max-width: 40%;
    min-width: 0;
  }

  body#product #main .images-container.js-images-container {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    width: 100%;
    min-width: 0;
  }

  body#product #main .product-cover {
    order: 2;
    flex: 1 1 auto;
    max-width: calc(100% - 106px);
    margin: 0;
    min-width: 0;
  }

  body#product #main .product-cover picture,
  body#product #main .product-cover img {
    display: block;
    width: 100%;
    height: auto;
  }

  body#product #main .product-cover img {
    border-radius: 14px;
  }

  body#product #main .js-qv-mask.mask.scroll {
    order: 1;
    flex: 0 0 88px;
    width: 88px;
    max-width: 88px;
    max-height: 760px;
    margin: 0;
    padding: 4px 8px 4px 4px;
    overflow-x: visible !important;
    overflow-y: auto !important;
    white-space: normal !important;
  }

  body#product #main .js-qv-mask.mask.scroll::-webkit-scrollbar {
    width: 6px;
  }

  body#product #main .js-qv-mask.mask.scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 999px;
  }

  body#product #main ul.product-images.js-qv-product-images {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch;
    gap: 14px;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    white-space: normal !important;
  }

  body#product #main .product-images > li.thumb-container,
  body#product #main .product-images > li.js-thumb-container {
    width: 100% !important;
    margin: 0 !important;
    float: none !important;
    border-radius: 14px !important;
    overflow: visible !important;
    background: transparent;
    transition: background-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
  }

  body#product #main .product-images img {
    display: block;
    width: 100% !important;
    height: auto !important;
    border-radius: 12px;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    opacity: 0.72;
    transform: scale(1);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  }

  body#product #main .product-images a:hover img {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.07);
    opacity: 0.9;
  }

  /* reset zaznaczenia */
  body#product #main .product-images > li,
  body#product #main .product-images > li a,
  body#product #main .product-images > li img,
  body#product #main .product-images .js-thumb,
  body#product #main .product-images .js-thumb a,
  body#product #main .product-images .js-thumb img {
    border: 0 !important;
    outline: none !important;
  }

  /* wariant A – aktywna miniaturka */
  body#product #main .product-images > li.selected,
  body#product #main .product-images .js-thumb.selected {
    border-radius: 14px !important;
    background: rgba(36, 185, 215, 0.14) !important;
    box-shadow: inset 0 0 0 1px rgba(36, 185, 215, 0.22) !important;
    overflow: visible !important;
  }

  body#product #main .product-images > li.selected img,
  body#product #main .product-images .js-thumb.selected img,
  body#product #main .product-images a.selected img,
  body#product #main .product-images img.selected {
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
    transform: scale(1.035) !important;
  }

  body#product #main .scroll-box-arrows {
    display: none !important;
  }
}

/* =========================================================
   DUŻE DESKTOPY
========================================================= */
@media (min-width: 1400px) {
  body#product .product-container > .col-md-6:first-child {
    flex: 0 0 61%;
    max-width: 61%;
  }

  body#product .product-container > .col-md-6:last-child {
    flex: 0 0 39%;
    max-width: 39%;
  }

  body#product #main .js-qv-mask.mask.scroll {
    flex: 0 0 92px;
    width: 92px;
    max-width: 92px;
  }

  body#product #main .product-cover {
    max-width: calc(100% - 110px);
  }
}

/* =========================================================
   TABLET SZEROKI
========================================================= */
@media (min-width: 992px) and (max-width: 1200px) {
  body#product .product-container > .col-md-6:first-child {
    flex: 0 0 58%;
    max-width: 58%;
  }

  body#product .product-container > .col-md-6:last-child {
    flex: 0 0 42%;
    max-width: 42%;
  }

  body#product #main .js-qv-mask.mask.scroll {
    flex: 0 0 82px;
    width: 82px;
    max-width: 82px;
  }

  body#product #main .product-cover {
    max-width: calc(100% - 100px);
  }
}

/* =========================================================
   MODAL PRODUKTU
========================================================= */
#product-modal.modal,
#product-modal.modal.fade,
#product-modal.modal.fade.in {
  padding: 0 !important;
}

#product-modal .modal-dialog {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
}

#product-modal .modal-content {
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.94) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

#product-modal .modal-body {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 20px 24px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* =========================================================
   DESKTOP / TABLET MODAL
========================================================= */
@media (min-width: 768px) {
  #product-modal {
    --gc-modal-thumbs-width: 84px;
    --gc-modal-thumbs-gap: 18px;
    --gc-modal-caption-gap: 10px;
    --gc-modal-image-max-height: calc(100vh - 100px);
    --gc-modal-stage-width: min(1200px, calc(100vw - 48px - 84px - 18px));
  }

  #product-modal .gc-modal-stage {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--gc-modal-stage-width) !important;
    min-width: var(--gc-modal-stage-width) !important;
    max-width: var(--gc-modal-stage-width) !important;
    margin: 0 auto !important;
    min-height: 0;
  }

  #product-modal figure {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    align-self: center !important;
    width: var(--gc-modal-stage-width) !important;
    min-width: var(--gc-modal-stage-width) !important;
    max-width: var(--gc-modal-stage-width) !important;
    min-height: 0 !important;
    margin: 0 !important;
  }

  #product-modal .gc-image-inner {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--gc-modal-stage-width) !important;
    min-width: var(--gc-modal-stage-width) !important;
    max-width: var(--gc-modal-stage-width) !important;
    min-height: 0;
    line-height: 0 !important;
  }

  #product-modal picture {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }

  #product-modal img.js-modal-product-cover,
  #product-modal .product-cover-modal {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: var(--gc-modal-image-max-height) !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    border-radius: 10px !important;
    transition: opacity 0.18s ease !important;
    backface-visibility: hidden;
  }

  #product-modal img.js-modal-product-cover.gc-is-switching,
  #product-modal .product-cover-modal.gc-is-switching {
    opacity: 0.08;
  }

  #product-modal figcaption.image-caption {
    align-self: center !important;
    width: auto !important;
    max-width: min(var(--gc-modal-stage-width), calc(100vw - 180px)) !important;
    margin-top: var(--gc-modal-caption-gap) !important;
    padding: 8px 12px !important;
    overflow: hidden !important;
    color: #111 !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    background: rgba(255, 255, 255, 0.96) !important;
    border-radius: 8px !important;
  }

  #product-modal aside#thumbnails,
  #product-modal .thumbnails.js-thumbnails {
    position: absolute !important;
    top: 50% !important;
    left: calc(100% + var(--gc-modal-thumbs-gap)) !important;
    right: auto !important;
    z-index: 25 !important;
    width: var(--gc-modal-thumbs-width) !important;
    min-width: var(--gc-modal-thumbs-width) !important;
    max-width: var(--gc-modal-thumbs-width) !important;
    margin: 0 !important;
    overflow: visible !important;
    transform: translateY(-50%) !important;
  }

  #product-modal .js-modal-mask.mask.nopadding {
    position: static !important;
    width: var(--gc-modal-thumbs-width) !important;
    max-width: var(--gc-modal-thumbs-width) !important;
    max-height: calc(100vh - 140px) !important;
    margin: 0 !important;
    padding: 4px 8px 4px 4px !important;
    overflow-x: visible !important;
    overflow-y: auto !important;
    transform: none !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
  }

  #product-modal .js-modal-mask.mask.nopadding::-webkit-scrollbar {
    width: 6px;
  }

  #product-modal .js-modal-mask.mask.nopadding::-webkit-scrollbar-track {
    background: transparent;
  }

  #product-modal .js-modal-mask.mask.nopadding::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
  }

  #product-modal .arrows.js-modal-arrows,
  #product-modal .js-modal-arrows,
  #product-modal .js-modal-arrow-up,
  #product-modal .js-modal-arrow-down,
  #product-modal .arrow-up.js-modal-arrow-up,
  #product-modal .arrow-down.js-modal-arrow-down,
  #product-modal i.js-modal-arrow-up,
  #product-modal i.js-modal-arrow-down,
  #product-modal .material-icons.arrow-up.js-modal-arrow-up,
  #product-modal .material-icons.arrow-down.js-modal-arrow-down,
  #product-modal .scroll-box-arrows,
  #product-modal .scroll-box-arrows i,
  #product-modal .scroll-box-arrows .material-icons,
  #product-modal .scroll-box-arrows .left,
  #product-modal .scroll-box-arrows .right,
  #product-modal .scroll-box-arrows .up,
  #product-modal .scroll-box-arrows .down,
  #product-modal .js-modal-mask + .scroll-box-arrows,
  #product-modal #thumbnails .scroll-box-arrows {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
  }

  #product-modal ul.product-images.js-modal-product-images {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: var(--gc-modal-thumbs-width) !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
  }

  #product-modal ul.product-images.js-modal-product-images > li {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    float: none !important;
    border-radius: 12px !important;
    overflow: visible !important;
    background: transparent;
    transition: background-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
  }

  #product-modal ul.product-images.js-modal-product-images img {
    display: block !important;
    width: 100% !important;
    max-width: var(--gc-modal-thumbs-width) !important;
    height: auto !important;
    border-radius: 10px !important;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    opacity: 0.72;
    transform: scale(1);
    cursor: pointer !important;
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease !important;
    backface-visibility: hidden;
  }

  #product-modal ul.product-images.js-modal-product-images img:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
    opacity: 0.9;
  }

  /* reset zaznaczenia w modalu */
  #product-modal ul.product-images.js-modal-product-images > li,
  #product-modal ul.product-images.js-modal-product-images > li a,
  #product-modal ul.product-images.js-modal-product-images > li img,
  #product-modal ul.product-images.js-modal-product-images .js-thumb,
  #product-modal ul.product-images.js-modal-product-images .js-thumb a,
  #product-modal ul.product-images.js-modal-product-images .js-thumb img {
    border: 0 !important;
    outline: none !important;
  }

  /* wariant A – aktywna miniaturka w modalu */
  #product-modal ul.product-images.js-modal-product-images > li.selected,
  #product-modal ul.product-images.js-modal-product-images .js-thumb.selected {
    border-radius: 12px !important;
    background: rgba(36, 185, 215, 0.14) !important;
    box-shadow: inset 0 0 0 1px rgba(36, 185, 215, 0.22) !important;
    overflow: visible !important;
  }

  #product-modal ul.product-images.js-modal-product-images > li.selected img,
  #product-modal ul.product-images.js-modal-product-images .js-thumb.selected img,
  #product-modal ul.product-images.js-modal-product-images a.selected img,
  #product-modal ul.product-images.js-modal-product-images img.selected {
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
    transform: scale(1.035) !important;
  }

  #product-modal .gc-modal-close {
    position: fixed !important;
    top: 18px !important;
    right: 18px !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.10) !important;
    color: #fff !important;
    font-size: 26px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28) !important;
    opacity: 0.96 !important;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease !important;
  }

  #product-modal .gc-modal-close:hover {
    background: rgba(36, 185, 215, 0.18) !important;
    border-color: rgba(36, 185, 215, 0.45) !important;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34) !important;
    transform: scale(1.05) !important;
    opacity: 1 !important;
  }

  #product-modal .gc-modal-close:focus,
  #product-modal .gc-modal-close:focus-visible {
    outline: 2px solid rgba(36, 185, 215, 0.9) !important;
    outline-offset: 2px !important;
  }
}

/* =========================================================
   MOBILE – PRODUCT GALLERY
========================================================= */
@media (max-width: 767.98px) {
  body#product .js-qv-mask,
  body#product .scroll-box-arrows,
  body#product .product-cover.gc-mobile-slider-ready .layer[data-target="#product-modal"],
  body#product .product-cover.gc-mobile-slider-ready [data-target="#product-modal"] {
    display: none !important;
  }

  html,
  body,
  body#product,
  body#product #wrapper,
  body#product #content,
  body#product .images-container.js-images-container,
  body#product .product-cover {
    overflow-x: hidden !important;
  }

  body#product .product-cover.gc-mobile-slider-ready {
    position: relative;
    overflow: hidden !important;
    touch-action: pan-y pinch-zoom;
    -webkit-user-select: none;
    user-select: none;
    cursor: grab;
  }

  body#product .product-cover.gc-mobile-slider-ready picture,
  body#product .product-cover.gc-mobile-slider-ready img {
    display: block;
    width: 100%;
    height: auto;
  }

  body#product .product-cover.gc-mobile-slider-ready img {
    margin: 0 auto;
    transition: opacity 0.18s ease;
    -webkit-user-drag: none;
    user-select: none;
    backface-visibility: hidden;
  }

  body#product .gc-mobile-counter {
    position: absolute;
    left: 50%;
    bottom: 10px;
    z-index: 6;
    min-width: 58px;
    padding: 5px 10px;
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    background: rgba(0, 0, 0, 0.60);
    border-radius: 999px;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .gc-mobile-gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    overscroll-behavior: contain;
  }

  .gc-mobile-gallery-modal.is-open {
    display: block;
  }

  .gc-mobile-gallery-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
  }

  .gc-mobile-gallery-dialog {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 12px 24px;
    box-sizing: border-box;
  }

  .gc-mobile-gallery-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .gc-mobile-gallery-counter {
    position: absolute;
    top: 14px;
    left: 50%;
    z-index: 3;
    min-width: 62px;
    padding: 6px 10px;
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    transform: translateX(-50%);
  }

  .gc-mobile-gallery-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    touch-action: pan-y pinch-zoom;
  }

  .gc-mobile-gallery-image {
    display: block;
    width: auto;
    max-width: calc(100vw - 24px);
    height: auto;
    max-height: calc(100vh - 72px);
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
    backface-visibility: hidden;
  }

  html.gc-mobile-gallery-modal-open,
  body.gc-mobile-gallery-modal-open {
    overflow: hidden !important;
  }

  #product-modal .modal-body {
    padding: 14px 12px !important;
  }

  #product-modal .gc-image-inner {
    max-width: calc(100vw - 100px) !important;
  }

  #product-modal img.js-modal-product-cover,
  #product-modal .product-cover-modal {
    max-width: calc(100vw - 100px) !important;
    max-height: calc(100vh - 60px) !important;
    border-radius: 8px !important;
  }

  #product-modal figcaption.image-caption {
    display: none !important;
  }

  #product-modal aside#thumbnails,
  #product-modal .thumbnails.js-thumbnails {
    left: calc(100% + 10px) !important;
    width: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
  }

  #product-modal .js-modal-mask.mask.nopadding {
    width: 64px !important;
    max-width: 64px !important;
    max-height: calc(100vh - 90px) !important;
  }

  #product-modal ul.product-images.js-modal-product-images {
    width: 64px !important;
    gap: 10px !important;
  }

  #product-modal ul.product-images.js-modal-product-images img {
    max-width: 64px !important;
    border-radius: 8px !important;
  }

  #product-modal .gc-modal-close {
    top: 10px !important;
    right: 10px !important;
    width: 38px !important;
    height: 38px !important;
    font-size: 24px !important;
  }
}

/* =========================================================
   DESKTOP – wyłączenie overlay lupy / zaciemnienia
========================================================= */
@media (min-width: 992px) {
  body#product .product-cover .layer,
  body#product .product-cover .zoom-in,
  body#product .product-cover .easyzoom-flyout,
  body#product .product-cover .easyzoom-notice,
  body#product .product-cover .easyzoom .zoom,
  body#product .product-cover [data-target="#product-modal"]::before,
  body#product .product-cover [data-target="#product-modal"]::after {
    background: transparent !important;
    box-shadow: none !important;
    opacity: 0 !important;
  }

  body#product .product-cover [data-target="#product-modal"],
  body#product .product-cover picture,
  body#product .product-cover img.js-qv-product-cover,
  body#product .product-cover img {
    cursor: pointer !important;
  }
}

/* =========================================================
   REDUCED MOTION
========================================================= */
@media (prefers-reduced-motion: reduce) {
  body#product .product-images img,
  #product-modal img.js-modal-product-cover,
  #product-modal .product-cover-modal,
  #product-modal ul.product-images.js-modal-product-images img,
  #product-modal .gc-modal-close,
  body#product .product-cover.gc-mobile-slider-ready img,
  .gc-mobile-gallery-image {
    transition: none !important;
  }

  #product-modal .gc-modal-close:hover,
  body#product #main .product-images a:hover img,
  #product-modal ul.product-images.js-modal-product-images img:hover {
    transform: none !important;
  }
}