/* 
 * PPF-VARIOPOOL CUSTOM GALLERY & LIGHTBOX SYSTEM
 * Optimized for speed, security, and white-label branding.
 */

/* 1. About Us Gallery (Elementor-style structure) */
.elementor-gallery__container {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 15px !important;
    width: 100% !important;
    margin: 20px 0 !important;
}

@media (max-width: 921px) {
    .elementor-gallery__container {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 544px) {
    .elementor-gallery__container {
        grid-template-columns: 1fr !important;
    }
}

.elementor-gallery-item {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    padding-bottom: 66.66% !important; /* 16:9 Aspect Ratio */
    overflow: hidden !important;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.e-gallery-image {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

.elementor-gallery-item:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    z-index: 10;
}

/* 2. Homepage Gallery (Basic WordPress structure) */
.gallery {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px !important;
    width: 100% !important;
    margin: 20px 0 !important;
}

@media (max-width: 921px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 544px) {
    .gallery {
        grid-template-columns: 1fr !important;
    }
}

.gallery-item {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

.gallery-icon, .gallery-icon a {
    display: block !important;
    width: 100% !important;
    height: auto !important;
}

.gallery-icon img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
    object-fit: cover !important;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.gallery-item:hover img {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.gallery-caption {
    display: none !important;
}

/* 3. Global Lightbox Styling */
#custom-lightbox {
    display: none;
    position: fixed;
    z-index: 2147483640; /* Maximum safe z-index */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.lightbox-content-container {
    position: relative;
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2147483641;
}

.lightbox-img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,1);
    z-index: 2147483642;
}

.lightbox-close {
    position: fixed;
    top: 30px;
    right: 30px;
    color: #ffffff !important;
    background: rgba(0,0,0,0.5);
    width: 50px;
    height: 50px;
    line-height: 46px;
    text-align: center;
    font-family: Arial, sans-serif;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    z-index: 2147483647;
    border-radius: 50%;
    transition: all 0.2s ease;
    border: 2px solid rgba(255,255,255,0.2);
}

.lightbox-close:hover {
    background: #bf0202;
    border-color: #ffffff;
    transform: rotate(90deg);
}

.lightbox-prev, .lightbox-next {
    cursor: pointer;
    position: fixed;
    top: 50%;
    color: white !important;
    font-weight: bold;
    font-size: 24px;
    transition: 0.3s ease;
    user-select: none;
    background-color: rgba(0,0,0,0.6);
    border-radius: 50%;
    z-index: 2147483647;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.2);
    transform: translateY(-50%);
}

.lightbox-prev {
    left: 40px;
}

.lightbox-next {
    right: 40px;
}

.lightbox-prev:hover, .lightbox-next:hover {
    background-color: #bf0202;
    border-color: #ffffff;
    width: 70px;
    height: 70px;
}

@media (max-width: 768px) {
    .lightbox-prev, .lightbox-next {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
    .lightbox-close { top: 15px; right: 15px; width: 40px; height: 40px; font-size: 30px; line-height: 38px; }
}
