/* ============================================
   Taxonomy Filter Widget (TFW) — Frontend CSS
   Version: 1.6.0
   Author: The Salt
   ============================================ */

/* Wrapper */
.tfw-wrapper {
    position: relative;
}

/* ── Filter bar — wiersz 1 ─────────────────── */

.tfw-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tfw-layout-horizontal {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tfw-layout-horizontal::-webkit-scrollbar { display: none; }

.tfw-layout-vertical {
    flex-direction: column;
    align-items: flex-start;
}

.tfw-layout-wrap {
    flex-wrap: wrap;
}

/* ── Subfilter row — wiersz 2 (dynamiczne podkategorie) ─────── */
/*
 * Pojawia się pod wierszem 1 po kliknięciu kategorii z dziećmi.
 * Gap synchronizowany przez JS z wartością computed z .tfw-filter.
 * Padding-left obliczany w JS = szerokość pierwszego buttona + gap,
 * dzięki czemu podkategorie zaczynają się dokładnie pod drugim buttonem.
 * Przyciski używają klasy .tfw-btn — dziedziczą cały styl z Elementor Panel.
 */
.tfw-subfilter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;           /* wartość nadpisywana przez JS z computed .tfw-filter gap */
    align-items: center;
    margin-top: 8px;    /* nadpisywane przez kontrolkę subfilter_row_gap w Elementorze */
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;   /* zapobiega przesunięciu layoutu podczas slideDown */
}

/* ── Buttons — wszystkie (wiersz 1 i wiersz 2) ─ */
/*
 * .tfw-sub-btn dziedziczy .tfw-btn — jeden selektor pokrywa oba wiersze.
 * Dzięki temu Panel Elementor → Styl → Przyciski kontroluje oba jednocześnie.
 */
.tfw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid currentColor;
    background: transparent;
    padding: 8px 20px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    letter-spacing: inherit;
    transition: all 250ms ease;
    white-space: nowrap;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.tfw-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.tfw-btn.is-active {
    background-color: #000;
    color: #fff;
    border-color: #000;
}

/* ── Inline child buttons (stary tryb show_children = yes) ─────── */

.tfw-btn.tfw-child {
    margin-left: 20px;
    font-size: 0.9em;
    opacity: 0.85;
}

.tfw-btn.tfw-child.is-active {
    opacity: 1;
}

/* ── Loading state — pulsowanie ──────────── */

@keyframes tfw-pulse {
    0%   { opacity: 1; }
    50%  { opacity: 0.35; }
    100% { opacity: 1; }
}

.tfw-loading [class*="elementor-widget-loop-grid"],
.tfw-loading .e-loop-inner,
.tfw-loading ul.products,
.tfw-loading .products {
    animation: tfw-pulse 1.2s ease-in-out infinite;
    pointer-events: none;
}

.tfw-loading .tfw-filter,
.tfw-loading .tfw-subfilter-row,
.tfw-loading .tfw-sort-inner {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 150ms ease;
}

.tfw-loader {
    display: none !important;
}

/* ── Przycisk Reset ────────────────────── */

.tfw-reset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    color: #666;
    transition: all 200ms ease;
    white-space: nowrap;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    animation: tfw-fadein 200ms ease forwards;
}

.tfw-reset-btn:hover {
    opacity: 0.7;
}

.tfw-reset-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.tfw-wrapper > .tfw-reset-btn,
.tfw-sort-wrapper > .tfw-reset-btn {
    display: block;
    width: 100%;
    text-align: center;
}

/* ── Loop Grid alignment ─────────────────── */

.elementor-loop-container.elementor-grid {
    align-items: stretch !important;
}

.e-loop-item {
    display: flex !important;
    flex-direction: column;
}

.e-loop-item > [class*="elementor-"] {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.e-loop-item > [class*="elementor-"] > .elementor-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* No results */
.tfw-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    opacity: 0.6;
}

/* ── Animacja wejścia items ──────────────── */

@keyframes tfw-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tfw-animated-in {
    animation: tfw-fadein 300ms ease forwards;
}

/* ============================================
   Sort Widget (TFW)
   ============================================ */

.tfw-sort-wrapper {
    position: relative;
}

.tfw-sort-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: stretch;
}

.tfw-sort-layout-horizontal {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tfw-sort-layout-horizontal::-webkit-scrollbar { display: none; }

.tfw-sort-layout-vertical {
    flex-direction: column;
    align-items: flex-start;
}

.tfw-sort-layout-wrap {
    flex-wrap: wrap;
}

.tfw-sort-label {
    font-size: 0.875em;
    opacity: 0.7;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.tfw-sort-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid currentColor;
    background: transparent;
    padding: 7px 16px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    transition: all 250ms ease;
    white-space: nowrap;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.tfw-sort-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.tfw-sort-btn.is-active {
    background-color: #000;
    color: #fff;
    border-color: #000;
}

.tfw-sort-select-wrap {
    position: relative;
    display: inline-flex;
    align-self: stretch;
}

.tfw-sort-select-wrap::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #333;
    pointer-events: none;
}

.tfw-sort-select {
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    border: 1px solid #ccc;
    background: #fff;
    padding: 8px 36px 8px 12px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    outline: none !important;
    box-shadow: none !important;
    min-width: 160px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.tfw-sort-select:focus,
.tfw-sort-select:focus-visible,
.tfw-sort-select:focus-within {
    outline: none !important;
    box-shadow: none !important;
}

/* ── Mobile dropdown ───────────────────── */

.tfw-mobile-select-wrap {
    position: relative;
    width: 100%;
}

.tfw-mobile-select-wrap::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    pointer-events: none;
}

.tfw-mobile-select {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    cursor: pointer;
    border: 1px solid currentColor;
    background: transparent;
    padding: 10px 40px 10px 16px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    letter-spacing: inherit;
    color: inherit;
    outline: none !important;
    box-shadow: none !important;
    box-sizing: border-box;
}

.tfw-mobile-select:focus,
.tfw-mobile-select:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}
