/**
 * Gallery Realizations - Professional lightbox gallery with thumbnails
 * Optimized for performance and UX
 */

/* Gallery Section */
.pgm-realizations-gallery {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.pgm-gallery-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    color: #1a1a1a;
    display: none; /* Hidden by default - can be shown if needed */
}

/* Main Image */
.pgm-gallery-main-wrapper {
    margin-bottom: 20px;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}

.pgm-gallery-main-image {
    position: relative;
    width: 100%;
    height: 600px; /* STAŁA wysokość - zapobiega przeskakiwaniu */
    background: #f5f5f5; /* Neutralne tło */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pgm-gallery-main-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* Contain - pokazuje całe zdjęcie */
    cursor: zoom-in;
    transition: opacity 0.3s ease;
}

.pgm-gallery-main-image img:hover {
    opacity: 0.95;
}

/* Fullscreen Button - widoczny na każdym tle */
.pgm-fullscreen-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(0, 0, 0, 0.15);
    color: #1f2937;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pgm-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pgm-fullscreen-btn svg {
    stroke-width: 2.5; /* Grubsza linia dla lepszej widoczności */
}

/* Thumbnails Wrapper */
.pgm-gallery-thumbnails-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pgm-gallery-thumbnails {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
    padding: 8px 0;
    flex: 1;
}

.pgm-gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.pgm-gallery-thumbnails::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.pgm-gallery-thumbnails::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.pgm-gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Thumbnail Item */
.pgm-thumbnail {
    flex-shrink: 0;
    width: 120px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.pgm-thumbnail::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
}

.pgm-thumbnail:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

.pgm-thumbnail.active {
    border-color: #3b82f6;
    transform: scale(1.05);
}

.pgm-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Navigation Buttons */
.pgm-thumb-nav {
    flex-shrink: 0;
    background: #fff;
    border: 2px solid #e5e7eb;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #374151;
}

.pgm-thumb-nav:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: scale(1.1);
}

.pgm-thumb-nav:active {
    transform: scale(0.95);
}

.pgm-thumb-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Lightbox */
.pgm-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    animation: pgm-fadeIn 0.3s ease;
}

@keyframes pgm-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.pgm-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
}

.pgm-lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Usunięty padding - pełne centrowanie */
}

/* Lightbox Close Button */
.pgm-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px; /* Symetrycznie jak lewy przycisk */
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.pgm-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1) rotate(90deg);
}

/* Lightbox Image */
.pgm-lightbox-image-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 85vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Wrapper nie blokuje przycisków */
    z-index: 5; /* Poniżej przycisków */
}

.pgm-lightbox-image-wrapper img {
    max-width: 85vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    animation: pgm-zoomIn 0.3s ease;
    pointer-events: auto;
    display: block;
}

@keyframes pgm-zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Lightbox Navigation */
.pgm-lightbox-prev,
.pgm-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    z-index: 15; /* Nad zdjęciem */
}

.pgm-lightbox-prev {
    left: 20px;
}

.pgm-lightbox-next {
    right: 20px; /* Symetrycznie jak lewy przycisk */
}

.pgm-lightbox-prev:hover,
.pgm-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.pgm-lightbox-prev:active,
.pgm-lightbox-next:active {
    transform: translateY(-50%) scale(0.95);
}

/* Lightbox Counter */
.pgm-lightbox-counter {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    z-index: 20;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .pgm-gallery-title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .pgm-gallery-main-image {
        height: 400px; /* Mniejsza stała wysokość na mobile */
    }

    .pgm-thumbnail {
        width: 100px;
        height: 67px;
    }

    .pgm-thumb-nav {
        width: 36px;
        height: 36px;
    }

    .pgm-thumb-nav svg {
        width: 16px;
        height: 16px;
    }

    .pgm-fullscreen-btn {
        width: 40px;
        height: 40px;
        top: 12px;
        right: 12px;
    }

    .pgm-fullscreen-btn svg {
        width: 20px;
        height: 20px;
    }

    .pgm-lightbox-prev,
    .pgm-lightbox-next {
        width: 50px;
        height: 50px;
    }

    .pgm-lightbox-prev {
        left: 10px;
    }

    .pgm-lightbox-next {
        right: 10px; /* Symetrycznie jak lewy przycisk */
    }

    .pgm-lightbox-close {
        width: 44px;
        height: 44px;
        top: 10px;
        right: 10px; /* Symetrycznie jak lewy przycisk */
    }

    .pgm-lightbox-content {
        padding: 0;
    }

    .pgm-lightbox-image-wrapper {
        max-width: 90vw;
        max-height: 80vh;
    }

    .pgm-lightbox-image-wrapper img {
        max-width: 90vw;
        max-height: 80vh;
    }

    .pgm-lightbox-counter {
        bottom: 30px;
        font-size: 14px;
        padding: 8px 16px;
    }
}

@media screen and (max-width: 480px) {
    .pgm-gallery-main-image {
        height: 300px; /* Jeszcze mniejsza na bardzo małych ekranach */
    }

    .pgm-thumbnail {
        width: 80px;
        height: 53px;
    }

    .pgm-gallery-thumbnails-wrapper {
        gap: 8px;
    }

    .pgm-gallery-thumbnails {
        gap: 8px;
    }
}

/* Accessibility */
.pgm-lightbox:focus-visible,
.pgm-lightbox-close:focus-visible,
.pgm-lightbox-prev:focus-visible,
.pgm-lightbox-next:focus-visible,
.pgm-fullscreen-btn:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* Smooth transitions */
* {
    -webkit-tap-highlight-color: transparent;
}
