/* ── Widoczność sekcji #grupy-tkaninowe ──────────────────────────────────────── */
/* Ukryj sekcję gdy shortcode nie zwrócił żadnej treści                          */
/* Warunek: brak .tkaniny-grid (tryb grupowy) ORAZ brak .tkaniny-proste (tryb prosty) */
#grupy-tkaninowe:not(:has(.tkaniny-grid)):not(:has(.tkaniny-proste)) {
    display: none !important;
}
/* Ukryj też gdy siatka grupowa jest w DOM ale pusta */
#grupy-tkaninowe:has(.tkaniny-grid:empty):not(:has(.tkaniny-proste)) {
    display: none !important;
}

/* ── Widoczność sekcji #grupy-drewna / #grupy-nog ───────────────────────────── */
/* Ten sam wzorzec co #grupy-tkaninowe: ukryj gdy shortcode nie zwrócił treści   */
#grupy-drewna:not(:has(.drewno-grid)) {
    display: none !important;
}
#grupy-drewna:has(.drewno-grid:empty) {
    display: none !important;
}

#grupy-nog:not(:has(.nog-grid)) {
    display: none !important;
}
#grupy-nog:has(.nog-grid:empty) {
    display: none !important;
}

/* Ukryj link "Zobacz..." gdy brak obu trybów */
body:not(:has(.tkaniny-grid)):not(:has(.tkaniny-proste)) .zobacz-tkaniny-link {
    display: none !important;
}

/* ── Główna siatka grup ──────────────────────────────────────────────────────── */
.tkaniny-grid {
    display: grid;
    gap: 25px;
    width: 100%;
}

/* ── Karta grupy ─────────────────────────────────────────────────────────────── */
.tkanina-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}

/* ── Nagłówek karty ──────────────────────────────────────────────────────────── */
.tkanina-header {
    background-color: rgb(245, 154, 87);
    padding: 12px 15px;
    text-align: center;
    transition: background-color .3s ease;
}

.tkanina-card.wt-wybrana .tkanina-header {
    background-color: #2a7a2a;
}
.tkanina-header h4 {
    margin: 0;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* ── Treść karty ─────────────────────────────────────────────────────────────── */
.tkanina-body {
    padding: 15px;
}

.kolekcja-wrapper {
    margin-bottom: 20px;
}
.kolekcja-wrapper:last-child {
    margin-bottom: 0;
}

.kolekcja-tytul {
    margin: 0 0 10px;
    font-size: .95rem;
    color: #555;
    font-weight: bold;
    border-left: 3px solid rgb(245, 154, 87);
    padding-left: 8px;
}

/* ── Siatka próbek ───────────────────────────────────────────────────────────── */
.galeria-miniatures {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Wrapper przejmuje wszystkie wymiary po starym .tkanina-link */
.galeria-miniatures .tkanina-thumb-wrapper {
    position: relative;
    width: calc(20% - 7px);
    min-width: 60px;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 4px;
    border: 2px solid #ddd;
    transition: border-color .15s ease;
}

.galeria-miniatures .tkanina-link {
    display: block;
    width: 100%;
    height: 100%;
    line-height: 0;
    cursor: zoom-in;
    cursor: -webkit-zoom-in;
}

.galeria-miniatures .galeria-thumb-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    transition: transform .2s ease;
}

.galeria-miniatures .tkanina-thumb-wrapper:hover .galeria-thumb-img {
    transform: scale(1.1);
}

/* ── Przycisk "Wybierz" ──────────────────────────────────────────────────────── */
/* !important niezbędne — motyw nadpisuje wszystkie button globalnymi regułami   */
.wt-wybierz-btn {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    display: block !important;
    min-height: unset !important;
    height: auto !important;
    padding: 5px 2px !important;
    margin: 0 !important;
    background: rgba(0, 0, 0, .55) !important;
    background-color: rgba(0, 0, 0, .55) !important;
    color: #fff !important;
    font-size: .68rem !important;
    font-weight: 600 !important;
    letter-spacing: .02em !important;
    text-align: center !important;
    line-height: 1.3 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    text-shadow: none !important;
    text-transform: none !important;
    cursor: pointer !important;
    transform: translateY(100%) !important;
    transition: transform .2s ease, background-color .15s ease !important;
    z-index: 2 !important;
    pointer-events: auto !important;
}

.tkanina-thumb-wrapper:hover .wt-wybierz-btn {
    transform: translateY(0) !important;
}

/* ── Próbka niedostępna (brak w atrybucie produktu) ─────────────────────────── */
.tkanina-thumb-wrapper.wt-niedostepna {
    opacity: .3;
}

.tkanina-thumb-wrapper.wt-niedostepna .tkanina-link {
    cursor: not-allowed;
}

/* Przycisk Wybierz niewidoczny nawet po hoverce */
.tkanina-thumb-wrapper.wt-niedostepna .wt-wybierz-btn {
    display: none !important;
}

/* Adnotacja: stały pasek "Niedostępna" zawsze widoczny na dole */
.tkanina-thumb-wrapper.wt-niedostepna::after {
    content: 'Niedostępna';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 2px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: .6rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    pointer-events: none;
    z-index: 3;
}

/* ── Stan wybranej próbki ────────────────────────────────────────────────────── */
.tkanina-thumb-wrapper.selected {
    border-color: #2a7a2a;
    box-shadow: 0 0 0 2px rgba(42, 122, 42, .25);
}

/* Przycisk zostaje widoczny i zmienia się na zielony */
.tkanina-thumb-wrapper.selected .wt-wybierz-btn {
    transform: translateY(0) !important;
    background: #2a7a2a !important;
    background-color: #2a7a2a !important;
}

/* ── Pasek potwierdzenia wyboru ──────────────────────────────────────────────── */
.wt-wybor-info {
    display: none; /* pokazywany przez JS po pierwszym wyborze */
    margin-top: 16px;
    padding: 10px 16px;
    background: #fdf3f4;
    border: 1px solid #c0687a;
    border-left: 4px solid #7a1a2a;
    border-radius: 4px;
    color: #333;
    font-size: .9rem;
    line-height: 1.5;
}
.wt-wybor-info .wt-ptaszek {
    color: #7a1a2a;
    font-weight: 700;
    margin-right: 4px;
}

/* ── Tryb prosty: 4 próbki w rzędzie ────────────────────────────────────────── */
.tkaniny-proste .tkanina-thumb-wrapper {
    width: calc(25% - 6px);
}

@media (max-width: 480px) {
    .tkaniny-proste .tkanina-thumb-wrapper {
        width: calc(33.333% - 6px);
    }
}

/* ── Responsywność siatki grupowej ──────────────────────────────────────────── */
@media (min-width: 0px)    { .tkaniny-grid { grid-template-columns: 1fr; } }
@media (min-width: 768px)  { .tkaniny-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1025px) { .tkaniny-grid { grid-template-columns: repeat(3, 1fr); } }

/* ── Tryb drewna: 2 kolumny kart + 3 kafelki w rzędzie ──────────────────────── */
@media (min-width: 768px)  { .drewno-grid { grid-template-columns: repeat(2, 1fr) !important; } }
@media (min-width: 1025px) { .drewno-grid { grid-template-columns: repeat(2, 1fr) !important; } }

/* ── Tryb nóg: 1 kolumna (pełna szerokość) ───────────────────────────────────── */
.nog-grid { grid-template-columns: 1fr !important; }

.drewno-grid .tkanina-thumb-wrapper {
    width: calc(33.333% - 6px);
}

@media (max-width: 480px) {
    .drewno-grid .tkanina-thumb-wrapper {
        width: calc(50% - 4px);
    }
}

@media (max-width: 480px) {
    .galeria-miniatures .tkanina-thumb-wrapper {
        width: calc(25% - 6px);
    }
}

/* ── Lightbox ────────────────────────────────────────────────────────────────── */
body.wt-lb-open {
    overflow: hidden;
}

.wt-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wt-lightbox[hidden] {
    display: none;
}

.wt-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    cursor: pointer;
}

/* Animacja wejścia */
@keyframes wt-lb-in {
    from { opacity: 0; transform: scale(.94); }
    to   { opacity: 1; transform: scale(1); }
}

.wt-lb-box {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    max-width: min(92vw, 680px);
    max-height: 92vh;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
    animation: wt-lb-in .2s ease;
}

.wt-lb-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(92vh - 72px);
    object-fit: contain;
    flex-shrink: 1;
    min-height: 0;
}

/* Stopka z info i przyciskiem */
.wt-lb-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;
    background: #f7f7f7;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.wt-lb-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.wt-lb-kolekcja {
    display: none;
}

.wt-lb-bottom {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.wt-lb-grupa {
    font-size: .8rem;
    font-weight: 700;
    color: rgb(245, 154, 87);
    white-space: nowrap;
    flex-shrink: 0;
}

.wt-lb-tkanina {
    font-size: .95rem;
    font-weight: 700;
    color: #2a2a2a;
    white-space: normal;
    line-height: 1.3;
}

/* Przycisk "Wybierz" wewnątrz lightboksu */
.wt-lb-wybierz {
    flex-shrink: 0 !important;
    padding: 9px 22px !important;
    background: rgb(245, 154, 87) !important;
    background-color: rgb(245, 154, 87) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 5px !important;
    font-size: .9rem !important;
    font-weight: 700 !important;
    letter-spacing: .02em !important;
    line-height: 1.3 !important;
    cursor: pointer !important;
    transition: background-color .15s ease !important;
    white-space: nowrap !important;
    min-height: unset !important;
    box-shadow: none !important;
    text-transform: none !important;
    text-shadow: none !important;
}

.wt-lb-wybierz:hover {
    background: rgb(220, 130, 60) !important;
    background-color: rgb(220, 130, 60) !important;
}

.wt-lb-wybierz.wt-lb-wybrano {
    background: #2a7a2a !important;
    background-color: #2a7a2a !important;
}

/* Przycisk zamknięcia */
.wt-lb-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 3 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    min-height: unset !important;
    background: rgba(0, 0, 0, .45) !important;
    background-color: rgba(0, 0, 0, .45) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    transition: background-color .15s ease !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.wt-lb-close:hover {
    background: rgba(0, 0, 0, .75) !important;
    background-color: rgba(0, 0, 0, .75) !important;
}

/* Strzałki nawigacji (w ramach kolekcji) */
.wt-lb-prev,
.wt-lb-next {
    position: absolute !important;
    top: 50% !important;
    z-index: 2 !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 48px !important;
    height: 48px !important;
    padding: 0 !important;
    min-height: unset !important;
    background: rgba(255, 255, 255, .15) !important;
    background-color: rgba(255, 255, 255, .15) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 30px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    transition: background-color .15s ease !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.wt-lb-prev { left: 12px !important; }
.wt-lb-next { right: 12px !important; }

.wt-lb-prev:hover,
.wt-lb-next:hover {
    background: rgba(255, 255, 255, .3) !important;
    background-color: rgba(255, 255, 255, .3) !important;
}

.wt-lb-prev[hidden],
.wt-lb-next[hidden] {
    display: none !important;
}
