/* CSS dla bloku galeria */
.galeria {
	/* Style tutaj */
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 15px; 
    margin-top: 20px;
}

.gallery-item.full-width {
    grid-column: span 3;
}

.gallery-item.small-width {
    grid-column: span 2; 
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

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

.gallery-item img {
    width: 100%;
    height: 30vh;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
    cursor: pointer;
}

.gallery-item img:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.3) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.gallery-item:hover::before {
    opacity: 1;
}

/* Lazy loading styles */
.gallery-item img.lazy-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
    filter: blur(2px);
}

.gallery-item img.lazy-loaded {
    animation: fade-in 0.5s ease;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
        filter: blur(2px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* Lightbox styles */
.custom-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.custom-lightbox.active {
    visibility: visible;
    opacity: 1;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: lightbox-zoom-in 0.3s ease;
}

.custom-lightbox.active .lightbox-content {
    animation: lightbox-zoom-in 0.3s ease;
}

@keyframes lightbox-zoom-in {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

.lightbox-caption {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    margin-top: 15px;
    font-size: 14px;
    max-width: 80%;
    text-align: center;
}

.lightbox-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    backdrop-filter: blur(10px);
}

/* Lightbox controls - używamy Bootstrap Icons poprzez tekst */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-family: 'Bootstrap Icons', sans-serif;
}

.lightbox-close::before {
    content: '\f62a'; /* Bootstrap x-lg icon */
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-family: 'Bootstrap Icons', sans-serif;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-prev::before {
    content: '\f285'; /* Bootstrap chevron-left icon */
}

.lightbox-next {
    right: 20px;
}

.lightbox-next::before {
    content: '\f286'; /* Bootstrap chevron-right icon */
}

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

/* Advanced lightbox controls */
.lightbox-advanced-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.lightbox-advanced-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-family: 'Bootstrap Icons', sans-serif;
    font-size: 16px;
}

/* Bootstrap Icons dla zaawansowanych kontrolek */
.lightbox-fullscreen::before {
    content: '\f2a0'; /* Bootstrap fullscreen icon */
}

.lightbox-slideshow::before {
    content: '\f4f4'; /* Bootstrap play icon */
}

.lightbox-slideshow.playing::before {
    content: '\f4c4'; /* Bootstrap pause icon */
}

.lightbox-download::before {
    content: '\f1c1'; /* Bootstrap download icon */
}

.lightbox-share::before {
    content: '\f52d'; /* Bootstrap share icon */
}

.lightbox-advanced-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Prevent body scroll when lightbox is open */
body.lightbox-open {
    overflow: hidden;
}

.gallery-grid .gallery-item.small-width:nth-child(2n+1){
	grid-column: span 1;
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr); 
    }
    
    .gallery-item.full-width,
    .gallery-item.small-width {
        grid-column: span 2;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .lightbox-close {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .lightbox-counter {
        top: 15px;
        left: 15px;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .lightbox-advanced-controls {
        bottom: 15px;
        padding: 8px;
    }
    
    .lightbox-advanced-controls button {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .lightbox-shortcuts {
        top: 60px;
        left: 15px;
        right: 15px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr; 
    }
    
    .gallery-item.full-width,
    .gallery-item.small-width {
        grid-column: span 1;
    }
    
    .gallery-item img {
        height: 25vh;
    }
    
    .lightbox-content {
        padding: 10px;
    }
    
    .lightbox-image {
        max-height: 70vh;
    }
    
    .lightbox-advanced-controls {
        bottom: 10px;
        gap: 8px;
    }
    
    .lightbox-shortcuts {
        font-size: 10px;
        padding: 8px 12px;
    }
}

@media screen and (max-width: 992px) {
    .gallery-grid{
        display: flex !important;
        flex-direction: column !important;
    }
    
    .gallery-item {
        margin-bottom: 15px;
    }
}

/* Focus styles for accessibility */
.gallery-item img:focus,
.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus,
.lightbox-advanced-controls button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Performance optimizations */
.gallery-item img[loading="lazy"] {
    content-visibility: auto;
    contain-intrinsic-size: 1px 200px;
}

/* Print styles */
@media print {
    .custom-lightbox,
    .lightbox-advanced-controls {
        display: none !important;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-item img,
    .gallery-item::before,
    .custom-lightbox,
    .lightbox-content,
    .lightbox-image {
        animation: none !important;
        transition: none !important;
    }
    
    .gallery-item:hover {
        transform: none;
    }
    
    .gallery-item img:hover {
        transform: none;
        filter: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .gallery-item {
        border: 2px solid;
    }
    
    .lightbox-backdrop {
        background: #000;
    }
    
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next,
    .lightbox-advanced-controls button {
        border: 1px solid #fff;
    }
}

/* Loading indicator */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10000;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}