/* ======= Galeria produktu - Wspólne style ======= */
.ct-stacked-gallery-container .ct-media-container {
    background-color: var(--drevko-bg-surface);
}

.woocommerce-product-gallery__trigger {
    opacity: 0 !important;
    pointer-events: none;
}

/* ======= Galeria produktu - Desktop (PC) ======= */
@media (min-width: 1000px) {
    .ct-stacked-gallery-container figure:first-child img {
        object-fit: contain;
        max-height: calc(100vh - 205px);
        min-height: 500px;
        background: var(--drevko-bg-surface);
    }

    .ct-stacked-gallery .ct-stacked-gallery-container {
        display: grid;
        grid-column-gap: 4px;
        grid-row-gap: 4px;
    }

    .ct-stacked-gallery .ct-stacked-gallery-container a {
        grid-area: auto; /* Zresetuj obszar siatki dla wszystkich obrazów */
    }

    /* Ustaw pierwszy obraz na pełną szerokość */
    .ct-stacked-gallery .ct-stacked-gallery-container > *:first-child {
        grid-column: 1 / span 2;
    }

    /* Rozciągnij ostatni obraz w obu kolumnach tylko wtedy, gdy jest to obraz z indeksem parzystym */
    .ct-stacked-gallery .ct-stacked-gallery-container *:nth-child(even):last-child {
        grid-column: 1 / span 2;
    }

    .ct-stacked-gallery-container .ct-media-container img {
        aspect-ratio: 1/1 !important;
    }
}

/* ======= Galeria produktu - Tablet ======= */
@media (min-width: 690px) and (max-width: 999.98px) {
    .ct-stacked-gallery .woocommerce-product-gallery {
        width: unset;
    }
}

/* ======= Galeria produktu - Mobile ======= */
@media (max-width: 999.98px) {
    .ct-stacked-gallery .woocommerce-product-gallery {
        margin: 0 -5vw 2em;
        overflow: hidden;
    }

    .ct-stacked-gallery .ct-stacked-gallery-container {
        flex-wrap: nowrap;
        display: flex;
        overflow-x: auto;
        grid-column-gap: 0;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .ct-stacked-gallery-container .ct-media-container {
        aspect-ratio: 7/8;
        -webkit-box-flex: 0;
        flex-grow: 0;
        flex-shrink: 0;
        display: inline-flex;
        width: calc(100vw - 24px);
        height: auto;
        align-items: center;
        scroll-snap-align: start;
    }

    .ct-stacked-gallery-container .ct-media-container:first-child:last-child {
        width: 100%;
    }
    
    .ct-stacked-gallery-container .ct-media-container:not(:last-child) {
        margin-right: 4px;
    }

    .ct-stacked-gallery-container .ct-media-container:first-child img {
        aspect-ratio: 7/8 !important;
    }

    /* Scrollbar dla galerii */
    .ct-stacked-gallery .ct-stacked-gallery-container::-webkit-scrollbar {
        height: 3px;
    }

    .ct-stacked-gallery .ct-stacked-gallery-container::-webkit-scrollbar-track {
        background-color: var(--drevko-bg-subtle);
    }

    .ct-stacked-gallery .ct-stacked-gallery-container::-webkit-scrollbar-thumb {
        background-color: var(--drevko-border-default);
    }

    .ct-stacked-gallery .ct-media-container:hover [class*="gallery__trigger"], 
    .ct-columns-top-gallery .ct-media-container:hover [class*="gallery__trigger"] {
        display: none;
    }
}

/* ======= Galeria produktu - Pseudo scrollbar ======= */
@media (max-width: 999.98px) {
    .ct-stacked-gallery-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .ct-stacked-gallery-container::-webkit-scrollbar {
        display: none;
    }

    .bullet-container {
        display: flex;
        justify-content: space-between;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        pointer-events: none;
    }

    .bullet {
        flex: 1;
        height: 2px;
        background-color: var(--drevko-border-subtle);
        margin: 0;
        pointer-events: auto;
    }

    .bullet.active {
        background-color: var(--drevko-neutral-500);
    }

    .ct-stacked-gallery-container .bullet-container {
        display: flex;
    }
    
    .ct-stacked-gallery-container .bullet-container:empty {
        display: none;
    }
}

/* ======= Informacje o produkcie ======= */
/* Odstęp między podsumowaniem produktu a opisem */
.product-entry-wrapper {
    margin-bottom: 50px;
    z-index: 2;
}

@media (max-width: 689.98px) {
    .product-entry-wrapper {
        margin-bottom: 36px;
    }
}

/* Modyfikacja wyglądu formularza koszyka w galerii */
.ct-default-gallery .entry-summary > form.cart,
.ct-stacked-gallery .entry-summary > form.cart {
    padding-top: 0;
    border-top: 0;
}

/* Ukrycie linku po dodaniu produktu do koszyka */
a.added_to_cart.wc-forward {
    display: none;
}

/* Dostosowanie marginesu dla ceny produktu */
p.price {
    margin-bottom: 0;
}

/* Wyświetlenie ceny promocyjnej jako elementu inline-flex */
.summary.entry-summary .sale-price, 
.ct-floating-bar .sale-price {
    display: inline-flex;
}

/* Ukrycie sekcji ilości produktu na stronie produktu */
.single-product .ct-cart-actions .quantity {
    display: none;
}

/* ======= Krótki opis produktu ======= */
.product-short-desc:not(:empty) {
    font-size: 17px;
}

@media (max-width: 999.98px) {
    .product-short-desc:not(:empty) {
        font-size: 15px;
    }
}

/* ======= Przyciski akcji koszyka ======= */
.ct-cart-actions {
    margin-top: 20px;
}

@media (min-width: 480px) {
    .ct-cart-actions {
        --theme-button-min-height: 60px;
    }
}

/* ======= Pływający panel - "Dodaj do koszyka" (mobile) ======= */
@media (max-width: 689.98px) {
    .ct-floating-bar {
        height: 70px;
        --theme-box-shadow: 0px 5px 20px -4px rgba(44,62,80,0.3);
    }

    .has-floating-cart #main-container {
        --floating-cart-spacer: 70px;
    }

    .ct-floating-bar > div {
        grid-template-columns: 1fr 1fr;
        margin-bottom: 2px;
    }

    .ct-floating-bar form.cart {
        display: grid;
        width: 100%;
    }

    .ct-floating-bar .price {
        font-weight: 600;
        font-size: 15px;
    }

    .ct-floating-bar .sale-price {
        flex-direction: column;
        font-size: .9em;
        line-height: 1.5;
    }

    .ct-floating-bar .ct-media-container {
        max-width: 48px;
        margin-inline-end: 15px;
    }
    
    .ct-floating-bar .pwp-omnibus-price__info {
        display: none;
    }

    .floating-bar-actions .single_add_to_cart_button:not(.loading):after {
        font-size: 0;
    }

    .floating-bar-actions .added_to_cart,
    .floating-bar-actions .single_add_to_cart_button {
        font-size: 0 !important;
        min-width: 100%;
        max-width: 100%;
        height: 43px;
        padding: 12px 24px;
        display: flex;
        justify-content: center;
        white-space: nowrap;
        border-radius: 0;
    }

    .floating-bar-actions .added_to_cart:not(.loading),
    .floating-bar-actions .single_add_to_cart_button:not(.loading) {
        font-size: 15px !important;
    }
    
    .floating-bar-actions .added_to_cart {
        display: none;
    }
}

/* ======= Sekcja - Podobne produkty ======= */
.related.products {
    margin-left: auto;
    margin-right: auto;
    width: var(--theme-container-width);
    max-width: var(--theme-block-max-width);
    margin-bottom: 36px;
}

.related.products [class*="flexy-arrow"] {
    top: var(--flexy-nav-arrow-top-offset, calc(50% - 50px));
}

.related.products .woocommerce-loop-product__title {
    overflow: hidden;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@media (max-width: 999.98px) {
    .related > h2, 
    .up-sells > h2 {
        --theme-font-size: 17px;
    }

    .related.products .flexy-container {
        width: 100vw;
        margin: 0 -5vw;
    }

    .related [data-products], 
    .upsells [data-products] {
        --grid-columns-width: calc(100% / 2.5);
    }

    .related.products [class*="flexy-arrow"] {
        display: none;
    }
}

/* Style dla Omnibus */
.product[class*="gallery"] .entry-summary-items > .pwp-omnibus-price__info {
    margin-bottom: 24px;
    margin-top: -20px;
    line-height: 1;
}

/* ======= Okruszki nawigacyjne ======= */
@media (max-width: 999.98px) {
    .entry-header > *:not(:first-child) {
        margin-top: 12px;
    }

    [data-prefix="product"] .hero-section[data-type="type-1"] {
        margin-bottom: 12px;
    }

    .breadcrumbs-product {
        font-size: 13px;
        font-weight: 500;
    }

    .breadcrumbs-product a {
        color: var(--drevko-text-primary);
        padding-left: 10px;
    }
}

/* ======= PhotoSwipe - Galeria ======= */
.pswp__bg {
    background: #fff;
}

button.pswp__button {
    -webkit-filter: invert(90%);
    filter: invert(90%);
}

.woocommerce .pswp__bg, .woocommerce-page .pswp__bg {
    opacity: 1 !important;
}

.pswp__ui--idle .pswp__top-bar {
    opacity: 1;
}

.pswp--zoom-allowed .pswp__button--zoom {
    display: none;
}

.pswp--supports-fs .pswp__button--fs {
    display: none;
}

.pswp__preloader {
    display: none;
}

.pswp__ui--idle .pswp__button--arrow--left, .pswp__ui--idle .pswp__button--arrow--right {
    opacity: 1;
}

.pswp--touch .pswp__button--arrow--left, .pswp--touch .pswp__button--arrow--right {
    visibility: visible !important;
}

.pswp__ui--fit .pswp__top-bar, .pswp__top-bar {
    background-color: #fff !important;
    border-bottom: 1px solid var(--drevko-bg-surface);
}

.pswp__counter {
    color: var(--drevko-text-primary);
}

button.pswp__button--arrow--left::before, button.pswp__button--arrow--right::before {
    opacity: 0.7;
}

.pswp .ct-lightbox-video-container video {
    position: relative;
}
