/* --- Reset CSS --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Globalne Style --- */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

ul {
    list-style: none;
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.5em;
    color: #333;
}

/* --- Układ Główny (Dla desktopu w rzędzie) --- */
.main-wrapper {
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
    display: flex;
    flex-direction: row; /* Wymuś układ w rzędzie */
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 20px;
    flex-grow: 1;
}

/* --- Nagłówek (Header) --- */
header {
    background: #333;
    color: #fff;
    padding: 1rem 0;
    border-bottom: 3px solid #007bff;
}

.header-content {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo img {
    height: 50px;
}

.main-nav ul {
    display: flex;
}

.main-nav ul li {
    margin-left: 20px;
}

.main-nav ul li a {
    color: #fff;
    padding: 5px 10px;
    transition: background-color 0.3s ease;
}

.main-nav ul li a:hover {
    background-color: #0056b3;
    border-radius: 4px;
    text-decoration: none;
}

.lang-selector img {
    width: 24px;
    height: 24px;
    margin-left: 10px;
    border: 1px solid #ddd;
    border-radius: 2px;
}

/* --- Sidebar --- */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    align-self: flex-start;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease-in-out;
}

.sidebar.hidden {
    display: none;
}

.sidebar-content {
    position: sticky;
    top: 20px;
}

/* Style for the show sidebar toggle button */
.show-sidebar-toggle-button {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background-color: #28a745;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.3s ease;
}

.show-sidebar-toggle-button:hover {
    background-color: #218838;
}

.sidebar-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.sidebar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.sidebar-section h3 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #007bff;
}

.sidebar input[type="text"] {
    width: calc(100% - 60px);
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    vertical-align: middle;
}

.sidebar button {
    padding: 8px 12px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    vertical-align: middle;
}

.sidebar button:hover {
    background-color: #0056b3;
}

.sidebar ul {
    padding-left: 15px;
}

.sidebar ul li a {
    display: block;
    padding: 5px 0;
    color: #555;
}

.sidebar ul li a:hover {
    color: #007bff;
    text-decoration: none;
}

.sidebar ul ul {
    padding-left: 25px;
    border-left: 1px dashed #eee;
    margin-top: 5px;
}

.sidebar .filters-section label {
    display: block;
    margin-bottom: 5px;
}

/* --- Główna Zawartość (Content Area) --- */
.main-content {
    flex-grow: 1;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease-in-out;
}

/* --- Stopka (Footer) --- */
footer {
    background: #333;
    color: #fff;
    padding: 1.5rem 0;
    margin-top: 30px;
    text-align: center;
}

.footer-content {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.9em;
}

.footer-content p {
    margin: 5px 0;
}

.footer-nav ul {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.footer-nav ul li {
    margin: 0 10px;
}

.footer-nav ul li a {
    color: #fff;
    transition: color 0.3s ease;
}

.footer-nav ul li a:hover {
    color: #007bff;
    text-decoration: none;
}

.copyright {
    text-align: right;
}

/* --- Sekcje strony głównej --- */
.featured-products-section {
    padding: 20px 0;
    text-align: center;
}

.featured-products-section h2 {
    margin-bottom: 30px;
    font-size: 2em;
    color: #333;
}

/* --- Układ produktów (za pomocą flexboxa) --- */
.product-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: flex-start;
}

/* Domyślnie 3 kolumny, gdy sidebar jest widoczny */
.product-grid .product-card {
    flex: 1 1 calc(33.333% - 13.333px);
    min-width: 280px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: left;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Przełączenie na 4 kolumny, gdy sidebar jest ukryty */
.main-wrapper > .sidebar.hidden + .main-content .product-grid .product-card {
    flex: 1 1 calc(25% - 15px);
}

.product-card img {
    max-width: 100%;
    height: 200px;
    object-fit: contain;
    display: block;
    margin: 0 auto 15px auto;
    border: 1px solid #eee;
    border-radius: 4px;
}

.product-card h3 {
    font-size: 1.5em;
    margin-top: 0;
    margin-bottom: 10px;
    color: #0056b3;
    min-height: 50px;
}

.product-card .catalog-number {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 10px;
}

.product-card p {
    font-size: 1em;
    color: #444;
    line-height: 1.5;
    flex-grow: 1;
}

.product-card .button {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    align-self: flex-start;
}

.product-card .button:hover {
    background-color: #0056b3;
}

/* --- Responsywność: Media Queries --- */

/* Dla dużych tabletów i małych desktopów */
@media (min-width: 769px) and (max-width: 1024px) {
    .product-grid .product-card {
        flex: 1 1 calc(50% - 10px); /* 2 kolumny */
    }
    .main-wrapper > .sidebar.hidden + .main-content .product-grid .product-card {
        flex: 1 1 calc(33.333% - 13.333px); /* 3 kolumny bez sidebara */
    }
}

/* Dla tabletów i telefonów */
@media (max-width: 768px) {
    .header-content, .footer-content, .main-wrapper {
        flex-direction: column;
        text-align: center;
    }

    .main-nav ul {
        flex-direction: column;
        margin-top: 15px;
    }

    .main-nav ul li {
        margin: 5px 0;
    }

    .lang-selector {
        margin-top: 15px;
    }

    /* Na małych ekranach sidebar na całą szerokość */
    .sidebar {
        width: 100%;
        padding: 15px;
        margin: 0;
    }

    .sidebar.hidden {
        display: none;
    }

    .main-wrapper {
        gap: 0;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 15px;
    }

    .footer-nav ul {
        margin-top: 10px;
    }

    /* Na mobile zawsze 1 kolumna */
    .product-grid .product-card {
        flex: 1 1 100%;
        min-width: unset;
    }
}

/* --- Style dla lightboxa --- */
#lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#lightbox-overlay img {
    max-width: 90%;
    max-height: 90%;
    border: 3px solid #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.lightbox-close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
}

.lightbox-close-btn:hover {
    color: #ccc;
}

.product-details .product-image img {
    max-width: 500px;
    height: auto;
    cursor: pointer;
}
/* Style dla sidebara i kategorii */
.sidebar .category-list h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    color: var(--text-color-dark);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.categories-root,
.subcategories {
    list-style-type: none;
    padding-left: 0;
    margin-top: 0.5rem;
}

.subcategories {
    padding-left: 1.25rem;
    max-height: 0; /* Domyślnie podkategorie są ukryte */
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

.subcategories.open {
    max-height: 500px; /* Wartość wystarczająco duża, aby pomieścić wszystkie podkategorie */
}

.category-item {
    position: relative;
    padding: 0.25rem 0;
    color: var(--text-color-medium);
}

.category-item a {
    text-decoration: none;
    color: inherit;
    display: block;
    padding-right: 2rem;
}

.category-item a:hover {
    color: var(--primary-color);
}

.category-item.has-children {
    font-weight: bold;
}

.expand-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
}

.expand-toggle.open {
    transform: translateY(-50%) rotate(45deg);
}

.category-item.has-children > a {
    font-weight: bold; /* Pogrubienie tylko rodziców */
}