.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    justify-content: flex-start;
    align-items: flex-start;
}

/* Kafelek: stała wysokość miniatury, bez przycinania */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform .3s ease, box-shadow .3s ease;
    cursor: pointer;
    height: 200px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Najważniejsze: obrazek NIE jest przycinany (contain) i ma auto-szerokość */
.gdlr-core-page-builder-body .gallery-grid .gallery-item img,
.gallery-grid .gallery-item img {
    height: 200px;
    width: auto;
    object-fit: contain;
    object-position: center;
    display: block;
    background-color: #f8f9fa;
    max-width: none;
    min-width: auto;
}

/* Podpis (jeśli używany) */
.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: #fff;
    padding: 20px 15px 15px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0;
    transition: opacity .3s ease, transform .3s ease;
    transform: translateY(10px);
}

.gallery-item:hover .gallery-caption {
    opacity: 1;
    transform: translateY(0);
}


.lightbox {
    display: none;
    position: fixed;
    z-index: 99999;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    overflow-y: auto;
    padding: 20px 0;
}

.lightbox-content {
    position: relative;
    margin: 0 auto;
    width: 90%;
    max-width: 900px;
    min-height: 60vh;

    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.lightbox img {
    width: 100%;
    height: auto;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.lightbox-caption {
    margin: 20px auto 0;
    width: 90%;
    max-width: 900px;
    text-align: center;
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 8px;
    min-height: 20px;
    position: relative;
    z-index: 10001;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Mobile */
@media (max-width: 768px) {
    .lightbox {
        padding: 10px 0;
    }

    .lightbox-content {
        min-height: 50vh;
        margin-bottom: 20px;
    }

    .lightbox img {
        max-height: 50vh;
    }

    .lightbox-caption {
        margin: 15px auto 20px;
        font-size: 16px;
        padding: 12px;
    }

    .close {
        top: 10px;
        right: 20px;
        font-size: 30px;
    }

    .prev-lightbox,
    .next-lightbox {
        padding: 12px;
        font-size: 24px;
    }
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.close:hover,
.close:focus {
    color: #bbb;
    text-decoration: none;
}

.prev-lightbox,
.next-lightbox {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: #fff;
    font-weight: bold;
    font-size: 30px;
    transition: .6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    z-index: 10000;
}

.next-lightbox {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.prev-lightbox:hover,
.next-lightbox:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Loading */
.loading {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 20px;
}

/* Hint */
.gallery-overlay::after {
    content: "Use ← → arrow keys to navigate, ESC or click outside to close";
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 1000002;
    pointer-events: none;
}