:root {
    --fmum-accent: #2c1810;
    --fmum-accent-light: #5c3a2e;
    --fmum-accent-yellow: #fecc00;        /* JCB-żółty z fmu-martin.pl */
    --fmum-accent-yellow-soft: #fff3b0;
    --fmum-bg: #faf8f6;
    --fmum-bg-overlay: rgba(8, 8, 10, 0.96);
    --fmum-arrow-size: 56px;
    --fmum-radius: 6px;
    --fmum-radius-sm: 4px;
    --fmum-thumb-gap: 8px;
    --fmum-transition-speed: 0.45s;
    --fmum-shadow: 0 4px 24px rgba(44, 24, 16, 0.08);
    --fmum-shadow-hover: 0 8px 32px rgba(44, 24, 16, 0.14);
    --fmum-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===========================
   1. Wrapper & main container
   =========================== */

.fmum-slider-wrap {
    position: relative;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    font-family: var(--fmum-font);
    -webkit-user-select: none;
    user-select: none;
}

.fmum-slider-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--fmum-bg);
    border-radius: var(--fmum-radius);
    box-shadow: var(--fmum-shadow);
    cursor: zoom-in;
    transition: box-shadow 0.3s ease;
}

.fmum-slider-container:hover {
    box-shadow: var(--fmum-shadow-hover);
}

.fmum-slider-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform var(--fmum-transition-speed) cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.fmum-slider-wrap[data-transition="fade"] .fmum-slider-track {
    display: block;
    transition: none;
}

.fmum-slider-wrap[data-transition="fade"] .fmum-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--fmum-transition-speed) ease;
    pointer-events: none;
}

.fmum-slider-wrap[data-transition="fade"] .fmum-slide--active {
    opacity: 1;
    pointer-events: auto;
}

.fmum-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.fmum-slide__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -webkit-user-drag: none;
}

.fmum-slider-container:hover .fmum-slide--active .fmum-slide__image {
    transform: scale(1.02);
}

/* ===========================
   2. Strzałki na głównym widoku
   =========================== */

.fmum-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: var(--fmum-arrow-size);
    height: var(--fmum-arrow-size);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(44, 24, 16, 0.08);
    border-radius: 50%;
    cursor: pointer;
    color: var(--fmum-accent);
    transition: opacity 0.25s ease, background 0.25s ease, color 0.25s ease,
                transform 0.25s ease, box-shadow 0.25s ease;
    opacity: 0.85;
    padding: 0;
    outline: none;
    box-shadow: 0 2px 12px rgba(44, 24, 16, 0.1);
}

.fmum-slider-container:hover .fmum-arrow,
.fmum-slider-container:focus-within .fmum-arrow {
    opacity: 1;
}

/* Na urządzeniach bez hovera (telefony, tablety) — pełna widoczność zawsze */
@media (hover: none) {
    .fmum-arrow {
        opacity: 1;
    }
}

.fmum-arrow:hover {
    background: var(--fmum-accent);
    color: #fff;
    border-color: var(--fmum-accent);
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 4px 16px rgba(44, 24, 16, 0.2);
}

.fmum-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.fmum-arrow--prev { left: 16px; }
.fmum-arrow--next { right: 16px; }

.fmum-arrow svg {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.fmum-arrow:focus-visible {
    opacity: 1;
    outline: 2px solid var(--fmum-accent-yellow);
    outline-offset: 2px;
}

/* ===========================
   3. Ikona "powiększ" w rogu
   =========================== */

.fmum-zoom-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(44, 24, 16, 0.08);
    border-radius: var(--fmum-radius-sm);
    cursor: pointer;
    color: var(--fmum-accent);
    padding: 0;
    outline: none;
    box-shadow: 0 2px 8px rgba(44, 24, 16, 0.12);
    transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.fmum-zoom-hint:hover {
    background: var(--fmum-accent);
    color: #fff;
    transform: scale(1.05);
}

.fmum-zoom-hint:focus-visible {
    outline: 2px solid var(--fmum-accent-yellow);
    outline-offset: 2px;
}

.fmum-zoom-hint svg {
    width: 20px;
    height: 20px;
}

/* ===========================
   4. Pasek miniaturek (główny)
   ===========================
   Mobile: 4 kolumny (3 thumby + opcjonalny "+N")
   Desktop: 5 kolumn (4 thumby + opcjonalny "+N")
*/

.fmum-thumbnails {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--fmum-thumb-gap);
    margin-top: 12px;
}

/* Mobile edge-cases: gdy total ≤ 3 nie ma "+N", więc dopasowujemy liczbę kolumn */
.fmum-thumbnails[data-total="2"] {
    grid-template-columns: repeat(2, minmax(0, calc(25% - var(--fmum-thumb-gap) * 0.75)));
}
.fmum-thumbnails[data-total="3"] {
    grid-template-columns: repeat(3, minmax(0, calc(25% - var(--fmum-thumb-gap) * 0.75)));
}

.fmum-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    width: 100%;
    border-radius: var(--fmum-radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    background: var(--fmum-bg);
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    outline: none;
    opacity: 0.75;
}

.fmum-thumb:hover:not(.fmum-thumb--active):not(.fmum-thumb--more) {
    opacity: 1;
    border-color: rgba(254, 204, 0, 0.45);
}

.fmum-thumb--active {
    border-color: var(--fmum-accent-yellow);
    opacity: 1;
    box-shadow: 0 0 0 1px var(--fmum-accent-yellow), 0 4px 12px rgba(254, 204, 0, 0.25);
}

.fmum-thumb:focus-visible {
    outline: 2px solid var(--fmum-accent-yellow);
    outline-offset: 2px;
    opacity: 1;
}

.fmum-thumb:active {
    transform: scale(0.96);
}

.fmum-thumb__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Ukrywanie thumbów wykraczających poza limit (mobile = 3 widoczne) */
.fmum-thumbnails .fmum-thumb:not(.fmum-thumb--more):nth-child(n+4) {
    display: none;
}

/* Kafelek "+N" — różny licznik dla mobile/desktop, sterowany przez attr() */
.fmum-thumb--more {
    background: var(--fmum-accent);
    color: #fff;
    opacity: 1;
    border-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: var(--fmum-font);
}

.fmum-thumb--more::before {
    content: "+" attr(data-count-mobile);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.fmum-thumb__more-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.fmum-thumb--more:hover {
    background: var(--fmum-accent-light);
    transform: scale(1.02);
}

.fmum-thumb--more:hover .fmum-thumb__more-icon {
    opacity: 1;
}

/* ===========================
   5. Lightbox
   =========================== */

.fmum-lightbox {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 999999 !important;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

/* Druga warstwa ochrony: jeśli motyw/Elementor nadpisze position, 
   to chociaż display:none wyłączy renderowanie w flow strony. */
.fmum-lightbox:not(.fmum-lightbox--open) {
    display: none !important;
}

.fmum-lightbox--open {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.fmum-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: var(--fmum-bg-overlay);
    cursor: pointer;
}

.fmum-lightbox__content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 16px;
    box-sizing: border-box;
}

.fmum-lightbox__stage {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;          /* pozwala flex-childowi się skurczyć */
    overflow: hidden;
    touch-action: pan-y;
}

.fmum-lightbox__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--fmum-radius);
    transform: scale(0.94);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.25s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    -webkit-user-drag: none;
    will-change: transform;
}

.fmum-lightbox--open .fmum-lightbox__image {
    transform: scale(1);
    opacity: 1;
}

/* Przycisk zamknięcia */

.fmum-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    transition: background 0.25s ease, transform 0.3s ease, border-color 0.25s ease;
    padding: 0;
    outline: none;
}

.fmum-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
    border-color: rgba(255, 255, 255, 0.3);
}

.fmum-lightbox__close:focus-visible {
    outline: 2px solid var(--fmum-accent-yellow);
    outline-offset: 2px;
}

/* Licznik 1/12 */

.fmum-lightbox__counter {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    pointer-events: none;
    font-feature-settings: "tnum";       /* tabular nums = brak skoków */
}

.fmum-lightbox__counter-separator {
    margin: 0 4px;
    opacity: 0.5;
}

/* Strzałki w lightboxie */

.fmum-lightbox__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    transition: background 0.25s ease, transform 0.25s ease;
    padding: 0;
    outline: none;
}

.fmum-lightbox__arrow:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-50%) scale(1.06);
}

.fmum-lightbox__arrow:focus-visible {
    outline: 2px solid var(--fmum-accent-yellow);
    outline-offset: 2px;
}

.fmum-lightbox__arrow--prev { left: 20px; }
.fmum-lightbox__arrow--next { right: 20px; }

/* Pasek miniaturek w lightboxie */

.fmum-lightbox__thumbs {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 4px 4px;
    margin-top: 12px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.fmum-lightbox__thumbs::-webkit-scrollbar {
    display: none;
}

.fmum-lightbox__thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: var(--fmum-radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s ease, opacity 0.2s ease, transform 0.15s ease;
    outline: none;
    opacity: 0.55;
}

.fmum-lightbox__thumb:hover:not(.fmum-lightbox__thumb--active) {
    opacity: 0.85;
}

.fmum-lightbox__thumb--active {
    border-color: var(--fmum-accent-yellow);
    opacity: 1;
}

.fmum-lightbox__thumb:focus-visible {
    outline: 2px solid var(--fmum-accent-yellow);
    outline-offset: 2px;
    opacity: 1;
}

.fmum-lightbox__thumb:active {
    transform: scale(0.95);
}

.fmum-lightbox__thumb-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Drag-state visualization */

.fmum-slider-track--dragging {
    transition: none !important;
    cursor: grabbing;
}

.fmum-slider-container--dragging .fmum-slide__image {
    pointer-events: none;
}

.fmum-lightbox__image--dragging {
    transition: none !important;
}

/* ===========================
   6. Responsive
   =========================== */

@media (min-width: 769px) {
    /* Desktop: 5 kolumn miniaturek (4 thumby + "+N") */
    .fmum-thumbnails {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 10px;
        margin-top: 14px;
    }

    /* Edge-cases dla małej liczby zdjęć — desktop */
    .fmum-thumbnails[data-total="2"] {
        grid-template-columns: repeat(2, minmax(0, calc(20% - 8px)));
    }
    .fmum-thumbnails[data-total="3"] {
        grid-template-columns: repeat(3, minmax(0, calc(20% - 8px)));
    }
    .fmum-thumbnails[data-total="4"] {
        grid-template-columns: repeat(4, minmax(0, calc(20% - 8px)));
    }

    /* Re-show thumb #4, hide od #5 wzwyż */
    .fmum-thumbnails .fmum-thumb:not(.fmum-thumb--more):nth-child(4) {
        display: block;
    }
    .fmum-thumbnails .fmum-thumb:not(.fmum-thumb--more):nth-child(n+5) {
        display: none;
    }

    /* Licznik "+N" — desktopowa wartość */
    .fmum-thumb--more::before {
        content: "+" attr(data-count-desktop);
    }

    /* Jeśli na desktopie nie ma overflow (total ≤ 4), chowamy "+N" */
    .fmum-thumbnails[data-total="4"] .fmum-thumb--more {
        display: none;
    }

    /* Lightbox większe miniaturki */
    .fmum-lightbox__thumb {
        flex: 0 0 72px;
        width: 72px;
        height: 72px;
    }

    .fmum-lightbox__content {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .fmum-arrow {
        opacity: 1;
        width: 44px;
        height: 44px;
    }

    .fmum-arrow--prev { left: 8px; }
    .fmum-arrow--next { right: 8px; }

    .fmum-arrow svg {
        width: 22px;
        height: 22px;
    }

    .fmum-zoom-hint {
        bottom: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
    }

    .fmum-zoom-hint svg {
        width: 18px;
        height: 18px;
    }

    .fmum-lightbox__arrow {
        width: 44px;
        height: 44px;
    }

    .fmum-lightbox__arrow--prev { left: 8px; }
    .fmum-lightbox__arrow--next { right: 8px; }

    .fmum-lightbox__close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }

    .fmum-lightbox__counter {
        top: 16px;
        font-size: 12px;
        padding: 5px 12px;
    }

    .fmum-thumb--more::before {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .fmum-slider-container {
        border-radius: var(--fmum-radius-sm);
    }

    .fmum-thumbnails {
        gap: 6px;
        margin-top: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fmum-slider-track,
    .fmum-slide,
    .fmum-slide__image,
    .fmum-arrow,
    .fmum-zoom-hint,
    .fmum-thumb,
    .fmum-lightbox,
    .fmum-lightbox__image,
    .fmum-lightbox__close,
    .fmum-lightbox__arrow,
    .fmum-lightbox__thumb {
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .fmum-arrow,
    .fmum-zoom-hint,
    .fmum-lightbox,
    .fmum-thumbnails {
        display: none !important;
    }

    .fmum-slider-container {
        box-shadow: none;
    }
}

/* ===========================================================
   12. Layout: opis produktu jako osobna sekcja na pełną szerokość
   ===========================================================
   Motywy oparte na flex/grid (WoodMart, Astra, Storefront, Flatsome)
   często wpychają długi opis produktu do lewej kolumny pod galerią.
   Te reguły wymuszają, żeby pełny opis był osobną sekcją na całą
   szerokość pod galerią + summary, przed sekcją "Podobne produkty".

   Targetowane elementy:
   - .qrwc-product-description (plugin Quote Request for WooCommerce)
   - .woocommerce-product-description (standardowy WC w niektórych motywach)
   - .product .description (alternatywne klasy)
   =========================================================== */

.product .qrwc-product-description,
.product > .woocommerce-product-description,
.product > .product-description,
.single-product .product .qrwc-product-description,
.single-product .qrwc-product-description {
    clear: both !important;
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-basis: 100% !important;
    flex-grow: 1 !important;
    grid-column: 1 / -1 !important;
    margin: 0 0 32px 0 !important;
    padding: 50px 0 0 0 !important;
    box-sizing: border-box;
}

/* Tytuł "Opis" — niech wyróżnia się jako sekcja */
.product .qrwc-product-description > h2,
.product .qrwc-product-description > h3,
.product > .woocommerce-product-description > h2,
.product > .woocommerce-product-description > h3 {
    margin: 0 0 20px 0 !important;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--fmum-accent-yellow, #fecc00);
    font-size: 1.5rem;
    font-weight: 600;
    text-align: left;
}

/* Treść opisu — czytelna typografia */
.product .qrwc-product-description p,
.product > .woocommerce-product-description p {
    margin: 0 0 12px 0;
    line-height: 1.65;
}

/* Sekcja "Podobne produkty" też na pełnej szerokości (gdyby motyw wpychał) */
.product > .related.products,
.product > section.related.products {
    clear: both !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-basis: 100% !important;
    grid-column: 1 / -1 !important;
    margin-top: 64px !important;
}
