/* Lightbox Overlay */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

/* Lightbox Content */
.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    margin: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox-overlay.active .lightbox-content {
    transform: scale(1);
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: block;
    margin: 0 auto;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

/* Close Button */
.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease;
    z-index: 10000;
}

.lightbox-close:hover {
    transform: rotate(90deg);
}

/* Navigation Buttons */
.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

.lightbox-prev:disabled,
.lightbox-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Counter */
.lightbox-counter {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
}

/* Loading Spinner */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lightbox-spin 0.8s linear infinite;
}

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

/* Gallery Grid Container */
.instalacia-gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 40px;
}

/* Gallery Item Wrapper */
.instalacia-gallery-item {
    flex: 0 0 calc(25% - 15px);
    max-width: calc(25% - 15px);
}

/* Gallery Link */
.lightbox-gallery,
a[data-fancybox="galeria"] {
    display: block;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 4px;
    background: #f0f0f0;
    aspect-ratio: 1 / 1;
    width: 100%;
}

/* Gallery Images */
.lightbox-gallery img,
a[data-fancybox="galeria"] img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.3s ease;
}

/* Hover Effects */
.lightbox-gallery:hover,
a[data-fancybox="galeria"]:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.lightbox-gallery:hover img,
a[data-fancybox="galeria"]:hover img {
    transform: scale(1.1);
}

/* Overlay on Hover */
.lightbox-gallery::after,
a[data-fancybox="galeria"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    pointer-events: none;
}

.lightbox-gallery:hover::after,
a[data-fancybox="galeria"]:hover::after {
    background: rgba(0, 0, 0, 0.2);
}

/* Zoom Icon on Hover */
.lightbox-gallery::before,
a[data-fancybox="galeria"]::before {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 32px;
    color: white;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.lightbox-gallery:hover::before,
a[data-fancybox="galeria"]:hover::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Responsive Gallery Grid */
@media (min-width: 1200px) {
    /* 4 columns on large desktop */
    .instalacia-gallery-item {
        flex: 0 0 calc(25% - 15px);
        max-width: calc(25% - 15px);
    }
}

@media (min-width: 769px) and (max-width: 1199px) {
    /* 3 columns on desktop/tablet */
    .instalacia-gallery-item {
        flex: 0 0 calc(33.333% - 14px);
        max-width: calc(33.333% - 14px);
    }
    .instalacia-gallery-grid {
        gap: 15px;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    /* 2 columns on small tablet */
    .instalacia-gallery-item {
        flex: 0 0 calc(50% - 10px);
        max-width: calc(50% - 10px);
    }
    .instalacia-gallery-grid {
        gap: 12px;
    }
}

@media (max-width: 576px) {
    /* 2 columns on mobile */
    .instalacia-gallery-item {
        flex: 0 0 calc(50% - 8px);
        max-width: calc(50% - 8px);
    }
    .instalacia-gallery-grid {
        gap: 10px;
    }
}

/* Responsive Lightbox */
@media (max-width: 768px) {
    .lightbox-content {
        max-width: 95%;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        width: 35px;
        height: 35px;
        font-size: 24px;
    }

    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-counter {
        bottom: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }

    .lightbox-gallery::before,
    a[data-fancybox="galeria"]::before {
        font-size: 24px;
    }

    .instalacia-gallery-grid {
        gap: 10px;
    }
}

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