/* Główny kontener wyszukiwania - WAŻNE: position relative */
#swc-search-container {
    width: 100%;
    display: flex;
    margin: 0 auto;
    position: relative; /* DODANE - potrzebne dla absolute positioning wyników */
}
#swc-search-results::-webkit-scrollbar {
    width: 8px;
}

#swc-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#swc-search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
    transition: background 0.3s ease;
}

#swc-search-results::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Dodatkowa izolacja dla scroll container */
#swc-search-container {
    /* Tworzy nowy stacking context */
    isolation: isolate;
}

/* Upewnij się że backdrop nie przeszkadza */
.swc-search-backdrop {
    pointer-events: none;
    z-index: 99;
}

.swc-search-backdrop.active {
    pointer-events: auto;
    z-index: 99;
}
/* Pasek wyszukiwania */
.swc-search-bar {
    display: flex;
    align-items: center;
    gap: 0px;
    width:100%;
    position: relative; /* DODANE - dla z-index */
    z-index: 1000; /* DODANE - pasek nad wynikami */
}

/* NOWY UKŁAD - wrapper dla input + ikona jako jeden element */
.swc-search-input-wrapper {
    display: flex;

    white-space: nowrap;
    min-width: 0;
    align-items: center;
    background: white;
    border-radius: 6px 0 0 6px;
    border: 2px solid #ddd;
    
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    
    /* Zajmuje przestrzeń minus przycisk zaawansowane */
    flex: 1;
    
}

.swc-search-input-wrapper:focus-within {
    border-color: #0073aa;
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.2);
    
}

/* Input wyszukiwania - BEZ PRAWEGO BORDERA */
#swc-search-input {
    flex: 1;
    margin-bottom:0px;
    width: 100%;
    min-width: 0; /* Pozwala na zmniejszenie bez obcinania */
    padding: 12px 16px;
    border: none; /* Usunięte wszystkie bordery */
    outline: none;
    font-size: 16px;
    background: transparent;
    border-radius: 6px 0 0 6px; /* Zaokrąglone tylko lewe rogi */
}

/* NOWA IKONA SVG - przyklejona do inputu */
.swc-search-icon {
    display: flex;
    flex-shrink: 1;
    white-space: nowrap;
    min-width: 0;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 46px;
    background: #ddd;
    border: 2px solid #ddd;
    border-left:0;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    border-radius: 0 6px 6px 0; /* Zaokrąglone tylko prawe rogi */
}

.swc-search-icon svg {
    width: 20px;
    height: 20px;
    fill: #666;
    transition: fill 0.3s ease;
}

.swc-search-icon:hover {
    background: #e9ecef;
}

.swc-search-icon:hover svg {
    fill: #0073aa;
}

.swc-search-icon:active {
    
    background: #dee2e6;
}
/* Gdy wrapper ma focus, zmień też ikonę */
.swc-search-input-wrapper:focus-within .swc-search-icon {
    border-left-color: #0073aa;
    background: #f0f8ff;
}

.swc-search-input-wrapper:focus-within .swc-search-icon svg {
    fill: #0073aa;
}
/* Przycisk zaawansowane - ZAWSZE WIDOCZNY */
#swc-advanced-btn {

    /* Reset stylów */
    all: initial;
    font-family: inherit;
    flex-shrink: 1;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    min-width: 0;
    /* Style przycisku */
    margin-left:10px !important;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    
    /* Stała szerokość - zawsze widoczny */
    width: 140px;
    min-width: 140px;
    padding: 0 20px;
    flex: 0 0 140px;
    
    /* Tylko hover/focus transitions */
    transition: background-color 0.3s ease, transform 0.2s ease;
}

/* Hover effect na przycisk */
#swc-advanced-btn:hover {
    background: #005a87;
    transform: translateY(-2px);
}

#swc-advanced-btn:active {
    transform: translateY(1px);
}

/* Focus state dla przycisku */
#swc-advanced-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Ikona lupy */
.swc-search-icon {
    font-size: 24px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.swc-search-icon:hover {
    color: #0073aa;
    
}
#swc-row-pierwszy {
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
    overflow:hidden;
}


/* OVERLAY WYNIKÓW WYSZUKIWANIA - GŁÓWNA ZMIANA */
#swc-search-results {
    
    position: absolute; /* ZMIENIONE z relative na absolute */
    top: 100%; /* Pozycjonuj pod paskiem wyszukiwania */
    left: 0;
    right: 0;
    width: 100%; /* Pełna szerokość kontenera */
    
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); /* ZWIĘKSZONY cień dla overlay */
    max-height: 400px;
    overflow-y: scroll;
    
    z-index: 9999; /* DODANE - nad paskiem wyszukiwania */
    
    /* Animacja pojawiania się */
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    
    /* DODANE - domyślnie ukryty */
    display: none;
}

#swc-search-results:not(:empty) {
    overflow-y: scroll;
    
    -webkit-overflow-scrolling: touch;
    contain: style layout;
    opacity: 1;
    transform: translateY(0);
    padding: 15px;
    display: block; /* DODANE - pokaż gdy ma zawartość */
}

/* DODANE - gdy wyniki są puste, ukryj całkowicie */
#swc-search-results:empty {
    opacity: 0;
    pointer-events: none;
}

/* Input zaawansowanego wyszukiwania */
#swc-advanced-search {
    width: 85%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    
    transition: border-color 0.3s ease;
    background: white;
}

#swc-advanced-search:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* Overlay zaawansowanego wyszukiwania */
.swc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Zawartość overlay */
.swc-overlay-content {
    position: relative;
    background: white;
    padding: 30px;
    width: 95%;
    height: 90%;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Przycisk zamknij */
.swc-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    cursor: pointer;
    color: #999;
    transition: all 0.3s ease;
    line-height: 1;
}

.swc-close:hover {
    color: #333;
    transform: rotate(90deg);
}

/* Wiersze w overlay */
.swc-row {
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 2px solid #f1f3f4;
}

.swc-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.swc-row h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.swc-row h3:before {
    content: "";
    width: 4px;
    height: 20px;
    background: #0073aa;
    margin-right: 10px;
    border-radius: 2px;
}

/* UKŁAD DWUKOLUMNOWY - dla "Ostatnio wyszukiwane" i "Najczęściej wyszukiwane" */
.swc-two-columns {
    display: flex !important;
    gap: 200px;
    align-items: flex-start;
    flex-direction: row !important;
}

.swc-column {
    flex: 1 1 50%; /* Każda kolumna zajmuje 50% */
    min-width: 0; /* Pozwala na zmniejszanie kolumn */
    width: 50%;
    box-sizing: border-box;
}

.swc-column h3 {
    margin-bottom: 15px !important;
    font-size: 16px !important;
    color: #333;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.swc-column h3:before {
    content: "";
    width: 3px;
    height: 16px;
    background: #0073aa;
    margin-right: 10px;
    border-radius: 2px;
}

/* Pierwszy wiersz - wyszukiwanie i kategorie */
.swc-row:first-child {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.swc-row:first-child #swc-advanced-search {
    flex: 0 0 60%; /* Zmniejszony input - 60% szerokości */
    margin-bottom: 0;
}



/* Select kategorii */
#swc-category-select {
    flex-shrink: 1;           /* Pozwala przyciskowi się zmniejszać */
    min-width: 0;             /* Pozwala się zmniejszać */

    white-space: nowrap; 
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

#swc-category-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* Kontener z przewijaniem i strzałkami */
.swc-products-scroll-container {
    position: relative;
    margin-top: 15px;
    width: 100%; /* DODANE - pełna szerokość w kolumnie */
}


/* Strzałki scroll - style domyślne */
.swc-scroll-arrow {
    padding: 0 0 0 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(112, 112, 112, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    z-index: 10;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.swc-scroll-arrow:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
    background: rgba(70, 70, 70, 0.9);
}

.swc-scroll-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.swc-scroll-arrow.left {
    left: -20px;
}

.swc-scroll-arrow.right {
    right: -20px;
}

.swc-scroll-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(128, 128, 128, 0.5);
}

.swc-scroll-arrow:disabled:hover {
    transform: translateY(-50%);
    background: rgba(128, 128, 128, 0.5);
}

/* Siatka produktów - horizontal scroll */
.swc-product-grid {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 5px;
    scroll-behavior: smooth;
    
    /* Ukryj scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.swc-product-grid::-webkit-scrollbar {
    display: none;
}

.swc-product-grid .swc-product-item {
    flex: 0 0 160px; /* Stała szerokość, nie rozciąganie */
    width: 160px;
    min-width: 160px;
}

/* Element produktu */
.swc-product-item {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    position: relative;
    overflow: hidden;
}

.swc-product-item:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
    border-color: #0073aa;
}

.swc-product-item:active {
    transform: translateY(-1px);
}

/* Zdjęcie produktu */
.swc-product-image {
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
    transition: transform 0.3s ease;
}

.swc-product-item:hover .swc-product-image {
    transform: scale(1.05);
}

/* Tytuł produktu */
.swc-product-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
    font-size: 12px;
    line-height: 1.3;
    height: 32px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Opis produktu */
.swc-product-description {
    font-size: 10px;
    color: #666;
    line-height: 1.3;
    height: 39px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Wyniki prostego wyszukiwania - lista */
#swc-search-results .swc-product-item {
    display: flex;
    align-items: center;
    text-align: left;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 6px;
}

#swc-search-results .swc-product-item {
    border-left: 4px solid transparent; /* DODANE - wskaźnik hover */
    transition: all 0.3s ease, border-left-color 0.3s ease; /* ROZSZERZONE transition */
}

#swc-search-results .swc-product-item:hover {
    border-left-color: #0073aa; /* DODANE - kolorowy wskaźnik przy hover */
    background: #f8f9fa; /* DODANE - lekkie tło przy hover */
}

#swc-search-results .swc-product-image {
    width: 70px;
    height: 70px;
    margin-right: 15px;
    margin-bottom: 0;
    flex-shrink: 0;
}

#swc-search-results .swc-product-title {
    margin-bottom: 5px;
    height: auto;
    font-size: 16px;
}

#swc-search-results .swc-product-description {
    height: auto;
    margin-bottom: 0;
}

/* Brak wyników */
.swc-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* Loader - dostosowany do horizontal scroll */
.swc-loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

/* Loader w kontenerze horizontal scroll */
.swc-products-scroll-container .swc-loader {
    display: block;
    margin: 40px auto;
    width: 30px;
    height: 30px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Placeholder dla pustego inputa */
#swc-search-input::placeholder {
    color: #999;
    font-style: italic;
    transition: color 0.3s ease;
}

#swc-search-input:focus::placeholder {
    color: #ccc;
}

/* DODANE - kliknięcie poza wynikami zamyka overlay */
.swc-search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    background: transparent;
    display: none;
}

.swc-search-backdrop.active {
    display: block;
}

/* RESPONSYWNOŚĆ */
@media (max-width: 768px) {
    
    
    .swc-search-input-wrapper {
        width: 100%;
        flex: 1;
    }
    
    #swc-advanced-btn {
        width: 120px;
        min-width: 120px;
        padding: 0 15px;
        font-size: 12px;
        flex: 0 0 120px;
    }
    
    /* DODANE - wyniki wyszukiwania na mobile */
    #swc-search-results {
        left: -15px; /* Rozszerz poza kontener */
        right: -15px;
        border-radius: 0; /* Usuń zaokrąglenia na mobile */
        border-left: none;
        border-right: none;
        max-height: 60vh; /* Ogranicz wysokość na mobile */
    }
    
    .swc-overlay-content {
        width: 95%;
        max-width: 95vw;
        padding: 20px;
        margin: 10px;
    }
    
    .swc-row:first-child {
        flex-direction: column;
    }
    
    .swc-row:first-child #swc-category-select {
        flex: none;
        width: 100%;
    }
    
    /* RESPONSYWNOŚĆ DLA DWUKOLUMNOWEGO UKŁADU */
/* RESPONSYWNOŚĆ DLA DWUKOLUMNOWEGO UKŁADU - ZACHOWAJ KOLUMNY */
    .swc-two-columns {
        gap: 50px; /* Zmniejsz gap na mobile */
    }

    .swc-column {
        min-width: 100px; /* Minimalna szerokość kolumny */
        width: 50%;
        flex: 1 1 45%; /* Elastyczne kolumny ale zachowaj proporcje */
    }
    
    .swc-column h3 {
        font-size: 16px !important;
        margin-bottom: 15px !important;
    }
    
    /* Przywróć normalne rozmiary produktów na mobile */
    .swc-column .swc-product-grid .swc-product-item {
        flex: 0 0 140px;
        width: 140px;
        min-width: 140px;
        padding: 12px;
    }
    
    .swc-column .swc-product-image {
        height: 100px;
    }
    
    .swc-column .swc-product-title {
        font-size: 11px;
        height: 28px;
    }
    
    .swc-column .swc-product-description {
        font-size: 9px;
        height: 32px;
    }
    
    .swc-column .swc-scroll-arrow {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .swc-column .swc-scroll-arrow.left {
        left: -17px;
    }
    
    .swc-column .swc-scroll-arrow.right {
        right: -17px;
    }
    
    /* Dostosowania dla horizontal scroll na mobile */
    .swc-product-grid .swc-product-item {
        flex: 0 0 140px;
        width: 140px;
        min-width: 140px;
    }
    
    .swc-product-image {
        height: 100px;
    }
    
    .swc-product-title {
        font-size: 11px;
        height: 28px;
    }
    
    .swc-product-description {
        font-size: 9px;
        height: 32px;
    }
    
    .swc-scroll-arrow {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .swc-scroll-arrow.left {
        left: -17px;
    }
    
    .swc-scroll-arrow.right {
        right: -17px;
    }
    
    #swc-search-results .swc-product-item {
        flex-direction: column;
        text-align: center;
    }
    
    #swc-search-results .swc-product-image {
        margin-right: 0;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .swc-search-bar {
        padding: 12px;
    }
    
    #swc-advanced-btn {
        width: 100px;
        min-width: 100px;
        padding: 0 12px;
        font-size: 11px;
        flex: 0 0 100px;
    }
    
    .swc-overlay-content {
        padding: 15px;
        max-width: 98vw;
    }
    
    .swc-row h3 {
        font-size: 16px;
    }
    
    /* Jeszcze mniejsze produkty na bardzo małych ekranach */
    .swc-product-grid .swc-product-item {
        flex: 0 0 120px;
        width: 120px;
        min-width: 120px;
        padding: 10px;
    }
    
    .swc-product-image {
        height: 80px;
    }
    
    .swc-product-title {
        font-size: 10px;
        height: 24px;
    }
    
    .swc-product-description {
        font-size: 8px;
        height: 24px;
        -webkit-line-clamp: 2;
    }
    
    .swc-scroll-arrow {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .swc-scroll-arrow.left {
        left: -15px;
    }
    
    .swc-scroll-arrow.right {
        right: -15px;
    }
    
    /* DODANE - jeszcze bardziej rozszerz na bardzo małych ekranach */
    #swc-search-results {
        left: -12px;
        right: -12px;
    }
    /* Jeszcze mniejszy gap dla bardzo małych ekranów */
.swc-two-columns {
    gap: 20px;
}

.swc-column {
    min-width: 0px;
    flex: 1 1 48%;
}

/* Mniejsze produkty w kolumnach na bardzo małych ekranach */
.swc-column .swc-product-grid .swc-product-item {
    flex: 0 0 100px;
    width: 100px;
    min-width: 100px;
    padding: 6px;
}

.swc-column .swc-product-image {
    height: 60px;
}

.swc-column .swc-product-title {
    font-size: 9px;
    height: 20px;
}

.swc-column .swc-product-description {
    font-size: 8px;
    height: 16px;
    -webkit-line-clamp: 2;
}
}

/* ANIMACJE */
.swc-product-item {
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

.swc-visible {
    opacity: 1;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* DODATKOWE STYLE HELPER */
.swc-clicked { 
    transform: scale(0.95) !important; 
}

.swc-hover { 
    z-index: 10; 
}

.swc-no-image { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: #f8f9fa; 
    color: #6c757d; 
    font-size: 24px; 
}

body.swc-overlay-open { 
    overflow: hidden; 
}

.swc-product-item:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    z-index: 11;
}

/* TOUCH SUPPORT IMPROVEMENTS */
@media (hover: none) and (pointer: coarse) {
    .swc-product-item:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .swc-scroll-arrow:hover {
        transform: translateY(-50%);
        background: rgb(88, 88, 88, 0.9);
    }
    
    .swc-product-item:active {
        transform: scale(0.98);
        background: #f8f9fa;
    }
}

/* ACCESSIBILITY IMPROVEMENTS */
.swc-scroll-arrow:focus {
    outline: 2px solid #535353;
    outline-offset: 2px;
}

.swc-product-grid:focus {
    outline: 2px solid #535353;
    outline-offset: 2px;
}