/************************************************
 * PRODUCT CARD — CORE
 * Jedno źródło prawdy dla kafelka produktu
 ************************************************/


/* =================================================
   01. ROOT / CARD BASE
================================================= */

.fc-product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 100%;
    cursor: default;
    text-align: left;
    gap: 0;
    overflow: visible !important;
    z-index: 5;
}

.fc-product-card * {
    text-align: left;
}

.fc-card {
    display: contents;
}


/* =================================================
   02. NATIVE LOOP ORDER
================================================= */

.fc-product-card > figure {
    order: 1;
}

.fc-product-card > .fc-card-rating {
    order: 2;
}

.fc-product-card > .fc-card-body {
    order: 3;
}

.fc-product-card > .ct-woo-card-actions {
    order: 4;
}


/* =================================================
   03. LISTS / GRID / CAROUSEL EQUAL HEIGHT
================================================= */

ul.products {
    align-items: stretch;
}

ul.products > li {
    display: flex;
    height: 100%;
}

/* Stackable / shortcode — kolumny mają się rozciągać */
.stk-block-carousel .stk-block-carousel__slider,
.stk-block-carousel [role="listitem"],
.stk-block-carousel .stk-block-column,
.stk-block-carousel .wp-block-stackable-column,
.stk-block-carousel .stk-column-wrapper,
.stk-block-carousel .stk-inner-blocks {
    align-items: stretch;
}

/* Shortcode WooCommerce wewnątrz Stackable */
.stk-block-carousel .paese-shortcode-single-product,
.stk-block-carousel .paese-shortcode-single-product .woocommerce,
.stk-block-carousel .paese-shortcode-single-product ul.products,
.stk-block-carousel .paese-shortcode-single-product ul.products > li {
    height: 100%;
}

/* UL shortcode bez marginesów, żeby nie rozbijał wysokości */
.paese-shortcode-single-product ul.products {
    display: flex;
    align-items: stretch;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Pojedynczy produkt jako pełna kolumna */
.paese-shortcode-single-product ul.products > li.fc-product-card,
.stk-block-carousel li.fc-product-card,
.fc-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
}


/* =================================================
   04. IMAGE
================================================= */

.fc-product-card > figure {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 1 / 1;
    margin-bottom: 4px;
    overflow: hidden;
    background-color: #f7f4ef;
}

.fc-product-card > figure img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: none !important;
    scale: 1 !important;
    transition: none !important;
}

.fc-product-card > figure .ct-media-container {
    display: block;
    width: 100%;
    height: 100%;
    transform: none !important;
    transition: none !important;
}

.fc-product-card > figure .ct-media-container img,
.fc-product-card > figure .ct-media-container picture,
.fc-product-card > figure .ct-media-container video,
.fc-product-card > figure .has-hover-effect,
.fc-product-card > figure .ct-media-container.has-hover-effect {
    transform: none !important;
    scale: 1 !important;
    transition: none !important;
}

.fc-product-card > figure:hover .ct-media-container,
.fc-product-card > figure:hover .ct-media-container img,
.fc-product-card > figure:hover img,
.fc-product-card:hover .ct-media-container,
.fc-product-card:hover .ct-media-container img,
.fc-product-card:hover img {
    transform: none !important;
    scale: 1 !important;
    transition: none !important;
}

.is-visible {
    background-color: #f7f4ef;
}


/* =================================================
   05. BADGES
================================================= */

.fc-product-card > figure .ct-woo-badges {
    position: absolute;
    top: 0;
    left: 0;
    right: auto;
    z-index: 5;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

.ct-woo-badges span {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 400;
}

.ct-woo-badge-new {
    border: 1px solid var(--theme-palette-color-6);
    background-color: var(--theme-palette-color-3);
}

/* =================================================
   06. WISHLIST
================================================= */

/* Ukryj pusty kontener YITH przed figurą */
.fc-product-card > .yith-add-to-wishlist-button-block {
    display: none !important;
}

/*
   YITH w trybie "before_image" renderuje wishlistę jako bezpośrednie dziecko
   kafelka, przed <figure>. Pozycjonujemy tylko ten wariant po prawej stronie;
   badge pozostaje niezależnie po lewej.
*/
.fc-product-card > .yith-wcwl-add-to-wishlist {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    z-index: 20;
    width: 40px;
    height: 40px;
    margin: 0 !important;
}

/*
   Oryginalny H2 z loopa Woo/Blocksy zostaje tylko jako nośnik wishlisty.
   Customowy tytuł znajduje się w .fc-card-header-slot.
*/

.fc-product-card > h2.woocommerce-loop-product__title {
    position: absolute !important;
    top: 12px;
    right: 12px;
    left: auto !important;
    z-index: 20;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    pointer-events: none;
}

/* Ukryj tekst/link oryginalnego tytułu, ale zachowaj wishlist */
.fc-product-card > h2.woocommerce-loop-product__title > a {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    width: auto;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-decoration: none !important;
    pointer-events: none;
}

/* Wishlist po prawej, klikalna */
.fc-product-card > h2.woocommerce-loop-product__title .yith-wcwl-add-to-wishlist-button {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    font-size: initial !important;
    line-height: 1 !important;
    margin: 0 !important;
}

.yith-wcwl-add-to-wishlist-button.yith-wcwl-add-to-wishlist-button-over-image--top-left {
    left: 20px;
    top: -18px;
}

.yith-wcwl-add-to-wishlist-button:is(button) {
    background-color: transparent;
}

.fc-card-wishlist {
    position: relative;
    z-index: 20;
}

.fc-card-wishlist .yith-wcwl-add-to-wishlist-button__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* YITH PHP renderer: no initial REST calls, same compact card control. */
.fc-product-card > h2.woocommerce-loop-product__title .yith-wcwl-add-to-wishlist,
.fc-card-wishlist .yith-wcwl-add-to-wishlist {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    pointer-events: auto;
}

.fc-product-card .yith-wcwl-add-to-wishlist a,
.fc-card-wishlist .yith-wcwl-add-to-wishlist a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 0;
    line-height: 0;
    border: 0;
    background: transparent;
}

.fc-product-card .yith-wcwl-add-to-wishlist i,
.fc-card-wishlist .yith-wcwl-add-to-wishlist i {
    font-size: 26px;
    line-height: 1;
}

.fc-product-card .yith-wcwl-add-to-wishlist .feedback,
.fc-card-wishlist .yith-wcwl-add-to-wishlist .feedback {
    display: none;
}


/* =================================================
   07. HIDE ORIGINAL LOOP ELEMENTS
================================================= */

.fc-product-card > .price,
.fc-product-card > .star-rating,
.fc-product-card > .ct-woo-card-rating {
    display: none !important;
}


/* =================================================
   08. CUSTOM RATING
   Wygląd ratingu siedzi w global.css
================================================= */

.fc-card-rating,
.fc-card-rating.woocommerce-loop-product__rating,
.fc-product-card > .fc-card-rating {
    flex: 0 0 auto;
    order: 2;
    width: 100%;
    min-height: 18px;
    margin-bottom: 10px;
}


/* =================================================
   09. BODY
================================================= */

.fc-card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 4px;
    width: 100%;
    min-width: 0;
}


/* =================================================
   10. HEADER / TITLE / CAPACITY
   Jedno źródło prawdy dla tytułu i pojemności
================================================= */

.fc-card-header-slot {
    flex: 0 0 auto;
    width: 100%;
    min-height: 58px;
    margin-bottom: 0;
}

/* Nagłówek: tytuł po lewej, pojemność po prawej */
.fc-product-card .fc-card-header-slot > .card-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) max-content !important;
    align-items: start !important;
    column-gap: 10px !important;
    row-gap: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    text-align: left;
}

/* H2 / title */
.fc-product-card .fc-card-header-slot > .card-header > .woocommerce-loop-product__title {
    grid-column: 1;
    grid-row: 1;
    display: block;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

/* Link tytułu — pełny tytuł bez skracania */
.fc-product-card .fc-card-header-slot > .card-header > .woocommerce-loop-product__title > a {
    display: block;
    overflow: visible;
    max-width: 100%;
    max-height: none;
    line-height: 1.22;
    font-size: 1.125rem;
    font-weight: 400;
    text-decoration: none;
    text-align: left;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
    text-overflow: unset;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    -webkit-box-orient: unset;
}

/* Pierwsza część tytułu */
.fc-product-card .fc-card-header-slot .paese-title-lead {
    display: block !important;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 1px;
}

/* Druga część tytułu */
.fc-product-card .fc-card-header-slot .paese-title-rest {
    display: block !important;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.22;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
}

/* Zabezpieczenie przed wymuszonym przełamaniem */
.fc-product-card .fc-card-header-slot .paese-title-rest::before {
    content: none;
    display: none;
}

/* Capacity — prawa kolumna, góra */
.fc-product-card .fc-card-header-slot > .card-header > .fc-card-capacity {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;

    margin: 0;
    padding: 0;

    white-space: nowrap;
    font-size: 1rem;
    line-height: 1.15;
    font-weight: 700;
    color: var(--theme-text-color, #777);
    text-align: right;
}

/* Fallback, gdy capacity pojawi się poza .card-header */
.fc-card-capacity {
    font-size: 12px;
    line-height: 1.15;
}


/* =================================================
   11. SWATCHES
   Ograniczenie szerokości w kafelku + bez psucia overlay
================================================= */

.fc-card-swatches-slot {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    min-height: 28px;
    margin-top: 0;
    margin-bottom: 0;

    /*
     * Slot musi pozwalać wyjść overlayowi nad kartę.
     * Nie może jednak odpowiadać za poziome "rozlewanie" zwykłej linii swatchy.
     */
    overflow: visible !important;
}

.fc-card-swatches,
.fc-swatches {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: flex-start;

    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/*
 * Główna linia swatchy na karcie:
 * - jedna linia,
 * - nic nie wychodzi poza kafelek,
 * - szerokość ograniczona do kolumny produktu.
 */
.fc-swatches--card {
    position: relative;
    z-index: 50;

    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    min-width: 0;

    overflow: hidden !important;
}

.fc-swatches--card > .fc-swatch[hidden] {
    display: none !important;
}

@media (max-width: 767px) {
    .fc-swatches--card {
        gap: 6px;
        padding-inline: 2px;
    }

    .fc-swatches--card > .fc-swatch--color {
        width: 16px;
        height: 16px;
    }

    .fc-swatches--card > .fc-swatch--text {
        max-width: calc(100% - 40px);
    }

    .fc-swatches--card > .fc-swatch--more {
        min-width: 22px;
        padding-inline: 5px;
    }
}

/*
 * Gdy otwiera się overlay z pełną paletą,
 * przywracamy overflow: visible tylko na czas widocznego panelu.
 * Dzięki temu sam overlay nie zostanie przycięty.
 */
.fc-swatches--card:has(.fc-swatches-overlay.is-visible) {
    overflow: visible !important;
}

/* baza swatcha */
.fc-swatch {
    position: relative;
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 50%;
    cursor: pointer;
}

/*
 * Swatch tekstowy:
 * - nie może rozpychać kafelka,
 * - dłuższe nazwy są skracane wielokropkiem.
 */
.fc-swatch--text {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 1 auto;
    width: auto;
    min-width: 24px;
    max-width: 92px;
    height: 18px;

    padding: 0 5px;
    border-radius: 10px;
    font-size: 10px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* +X */
.fc-swatch--more {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;
    min-width: 16px;
    height: 16px;

    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 50%;

    font-size: 11px;
    line-height: 1;
    color: var(--theme-text-color, #777);
    white-space: nowrap;
}

/* overlay z pełną paletą */
.fc-swatches-overlay {
    position: absolute;
    bottom: 100%;
    left: 0;
    z-index: 9999;

    display: none;
    flex-wrap: wrap;
    gap: 8px;

    width: max-content;
    max-width: 260px;
    padding: 10px;

    background: #fff;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}

.fc-swatches-overlay.is-visible {
    display: flex;
}

/* tooltip */
.fc-swatch::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    z-index: 10000;
    transform: translateX(-50%) scale(.95);

    padding: 4px 8px;
    border-radius: 4px;

    background: rgba(0, 0, 0, .85);
    color: #fff;

    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;

    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}

/* =================================================
   12. PRICE
================================================= */

.fc-card-price-slot {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    min-height: 66px;
    margin-top: 0;
    text-align: left;
}

.price,
.fc-price {
    display: flex;
    flex-direction: column;
    gap: 1px;
    align-items: flex-start;
    text-align: left;
}

.fc-price-dynamic-notice,
.iworks-omnibus,
.fc-price-main .iworks-omnibus,
.fc-omnibus-notice {
    min-height: 14px;
    margin: 0;
    font-size: 11px;
    line-height: 1.25;
    color: var(--theme-text-color, #777);
    font-weight: 400;
}

.iworks-omnibus .woocommerce-Price-amount {
    font-weight: 600;
}

.fc-card-unit-price {
    margin-top: auto;
    font-size: 11px;
    color: var(--theme-text-color, #777);
}

.fc-price-main ins,
.fc-price-main ins .woocommerce-Price-amount {
    font-weight: 600;
    font-size: clamp(17px, 1.5vw, 20px);
    color: var(--theme-palette-color-6);
    text-decoration: none;
}

.fc-price-main del,
.fc-price-main del .woocommerce-Price-amount {
    font-size: 0.85rem;
    color: #9a9a9a;
}

.fc-price-main:not(:has(del)) .woocommerce-Price-amount {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--theme-palette-color-5);
}


/* =================================================
   13. CTA
================================================= */

.fc-product-card > .ct-woo-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: auto;
    padding-top: 8px;
    text-align: left;
}

.fc-product-card > .ct-woo-card-actions .button,
.fc-product-card > .ct-woo-card-actions a.button,
.fc-product-card > .ct-woo-card-actions .add_to_cart_button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
    text-align: center !important;
}


/* =================================================
   14. CTA AFTER AJAX ADD TO CART
   Po dodaniu do koszyka zostaw tylko "Zobacz koszyk"
================================================= */

/* Ukryj pierwotny przycisk po AJAX add to cart */
.fc-product-card .ct-woo-card-actions .add_to_cart_button.fc-is-hidden-after-add,
.fc-product-card .ct-woo-card-actions .add_to_cart_button.added,
.fc-product-card .ct-woo-card-actions .button.fc-is-hidden-after-add {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Ukryj pierwotny przycisk, jeśli pojawił się link "Zobacz koszyk" */
.fc-product-card .ct-woo-card-actions:has(.added_to_cart.wc-forward) .add_to_cart_button,
.fc-product-card .ct-woo-card-actions:has(.added_to_cart.wc-forward) .fc-variable-archive-cta,
.fc-product-card .ct-woo-card-actions:has(.added_to_cart.fc-cart-forward-visible) .add_to_cart_button,
.fc-product-card .ct-woo-card-actions:has(.added_to_cart.fc-cart-forward-visible) .fc-variable-archive-cta {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Link "Zobacz koszyk" jako pełny button */
.fc-product-card .ct-woo-card-actions .added_to_cart.wc-forward,
.fc-product-card .ct-woo-card-actions .added_to_cart.fc-cart-forward-visible {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-height: 40px;
    padding: 8px 12px;
    text-align: center !important;
    text-decoration: none;
}


/* =================================================
   15. OUT OF STOCK
================================================= */

li.fc-product-card:has(.out-of-stock-badge) {
    opacity: 1;
}

li.fc-product-card:has(.out-of-stock-badge) figure {
    position: relative;
}

li.fc-product-card:has(.out-of-stock-badge) figure::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

li.fc-product-card:has(.out-of-stock-badge) .ct-woo-badges,
li.fc-product-card:has(.out-of-stock-badge) .ct-woo-badges * {
    opacity: 1 !important;
    filter: none !important;
}

li.fc-product-card:has(.out-of-stock-badge) .ct-woo-card-actions,
li.fc-product-card:has(.out-of-stock-badge) .ct-woo-card-actions .button {
    opacity: 1;
    pointer-events: auto;
    filter: none;
}

li.fc-product-card:has(.out-of-stock-badge) .onsale {
    display: none;
}


/* =================================================
   16. RESPONSIVE — TABLET / SMALL DESKTOP
================================================= */

@media (max-width: 1440px) {
    .fc-card-header-slot {
        min-height: 52px;
    }

    .fc-product-card .fc-card-header-slot > .card-header > .woocommerce-loop-product__title > a {
        -webkit-line-clamp: 2;
    }
}


/* =================================================
   17. RESPONSIVE — MOBILE
================================================= */

@media (max-width: 768px) {
    .fc-card-body {
        gap: 4px;
    }

    .fc-card-header-slot {
        min-height: 50px;
    }

    .fc-product-card .fc-card-header-slot > .card-header {
        column-gap: 8px !important;
    }

    .fc-product-card .fc-card-header-slot > .card-header > .woocommerce-loop-product__title > a {
        font-size: 1rem;
        line-height: 1.2;
    }

    .fc-product-card .fc-card-header-slot > .card-header > .fc-card-capacity {
        font-size: 0.875rem;
    }

    /*
     * Tytuły mogą mieć różną liczbę wierszy. Slot ceny jest
     * zakotwiczony przy dole elastycznego body, dzięki czemu
     * ceny w sąsiednich kafelkach zaczynają się na jednej linii.
     */
    .fc-product-card .fc-card-price-slot {
        flex: 0 0 72px;
        min-height: 72px;
        margin-top: auto;
    }

    .fc-card-unit-price {
        display: none;
    }

    .fc-product-card > .ct-woo-card-actions .button,
    .fc-product-card > .ct-woo-card-actions a.button,
    .fc-product-card > .ct-woo-card-actions .add_to_cart_button {
        min-height: 38px;
        padding: 8px 12px;
        font-size: 12px;
        line-height: 1.2;
    }

    [data-products] .fc-product-card.product {
        height: auto !important;
        min-height: unset !important;
        align-self: stretch;
        isolation: auto;
    }

    li.fc-product-card:has(.out-of-stock-badge) figure::after {
        background: rgba(255, 255, 255, 0.6);
    }
}
/* Mobile: kompaktowe badge'e nad górną częścią zdjęcia, po dwa w wierszu. */
@media (max-width: 689px) {
    .fc-product-card > figure .ct-woo-badges {
        top: 6px;
        left: 6px;
        right: 6px;
        width: auto;
        max-width: calc(100% - 12px);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 4px;
        pointer-events: none;
    }

    .fc-product-card > figure .ct-woo-badges > span {
        position: static;
        flex: 0 1 auto;
        width: auto;
        min-width: 0;
        min-height: 22px;
        height: auto;
        padding: 4px 7px;
        font-size: 9px;
        line-height: 1.15;
        letter-spacing: 0.35px;
        white-space: nowrap;
    }
}
