/**
 * LIGHTBOX.CSS - Galeria ze powiększaniem
 * Wersja: 2.0 (Premium Rebrand)
 */

/* ============================================
   GALERIA GRID
   ============================================ */

.gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
    width: 100%;
    max-width: 100%;
}

@media (min-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-6);
    }
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: var(--space-8);
    }
}

@media (min-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    aspect-ratio: 4 / 3;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 100%;
}

/* Suwak w galerii - bez cursor pointer */
.gallery-item--slider {
    cursor: default;
}

.gallery-item--slider .before-after-container {
    height: 100%;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--brand);
}

/* Suwak nie podnosi się na hover */
.gallery-item--slider:hover {
    transform: none;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-base);
}

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

/* Overlay z lupą */
.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(43, 89, 166, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-base);
}

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

.gallery-overlay i {
    color: var(--bg);
    font-size: 48px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ============================================
   LIGHTBOX
   ============================================ */

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.97);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    padding: var(--space-4);
    overflow: hidden;
}

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

.lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: var(--shadow-xl);
    animation: zoomIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--radius-md);
}

@media (min-width: 768px) {
    .lightbox img {
        max-width: 90%;
        max-height: calc(100vh - 80px);
    }
}

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

/* ============================================
   PRZYCISKI NAWIGACJI
   ============================================ */

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: fixed;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: var(--bg);
    font-size: 24px;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
    z-index: 10000;
    user-select: none;
}

@media (min-width: 768px) {
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }
}

@media (min-width: 1024px) {
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 64px;
        height: 64px;
        font-size: 32px;
    }
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: var(--brand);
    border-color: var(--brand-hover);
    transform: scale(1.1);
}

.lightbox-close {
    top: var(--space-4);
    right: var(--space-4);
}

@media (min-width: 768px) {
    .lightbox-close {
        top: var(--space-8);
        right: var(--space-8);
    }
}

.lightbox-prev {
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
}

@media (min-width: 768px) {
    .lightbox-prev {
        left: var(--space-8);
    }
}

.lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.lightbox-next {
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
}

@media (min-width: 768px) {
    .lightbox-next {
        right: var(--space-8);
    }
}

.lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Ikony Bootstrap Icons */
.lightbox-close i,
.lightbox-prev i,
.lightbox-next i {
    font-size: inherit;
    line-height: 1;
}

/* ============================================
   LICZNIK
   ============================================ */

.lightbox-counter {
    position: fixed;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(17, 24, 39, 0.85);
    color: var(--bg);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    font-size: var(--font-sm);
    font-weight: var(--font-semibold);
    backdrop-filter: blur(10px);
    z-index: 10000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
}

@media (min-width: 768px) {
    .lightbox-counter {
        bottom: var(--space-8);
        padding: var(--space-4) var(--space-8);
        font-size: var(--font-base);
    }
}

/* ============================================
   MOBILE TOUCH OPTIMIZATIONS
   ============================================ */

/* Większe obszary dotykowe na mobile */
@media (max-width: 767px) {
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Swipe gestures support */
.lightbox {
    touch-action: pan-y pinch-zoom;
}

/* Zapobieganie poziomemu scrollowi */
.lightbox,
.lightbox * {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Screen reader text */
.lightbox-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   LOADING STATE
   ============================================ */

.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--brand);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   ANIMATIONS
   ============================================ */

/* Fade in dla overlay */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Slide in dla przycisków */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.lightbox.active .lightbox-prev {
    animation: slideInLeft 0.3s ease-out;
}

.lightbox.active .lightbox-next {
    animation: slideInRight 0.3s ease-out;
}

.lightbox.active .lightbox-close {
    animation: fadeIn 0.3s ease-out;
}

.lightbox.active .lightbox-counter {
    animation: fadeIn 0.5s ease-out 0.2s both;
}