/* Frontend Styles */
.advanced-gallery-block {
    position: relative;
    margin: 0 auto;
    max-width: 100%;
}

.advanced-gallery-grid {
    display: grid;
    width: 100%;
}

.gallery-item {
    position: relative;
    padding-bottom: 100%;
    height: 0;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

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

.gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-item.hidden {
    display: none;
}

.load-more-container {
    text-align: center;
    margin-top: 20px;
}

.load-more-button {
    background-color: #0073aa;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s ease;
}

.load-more-button:hover {
    background-color: #005d8c;
}

/* Lightbox Styles */
.gallery-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
}

.lightbox-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 10000;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    touch-action: pan-y;
    overflow: hidden;
}

.lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    margin: 0 auto;
    will-change: transform;
}

.lightbox-caption {
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 14px;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: -40px;
    background: transparent;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 10px;
    line-height: 1;
    z-index: 10001;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 24px;
    padding: 15px 10px;
    cursor: pointer;
    border-radius: 4px;
    z-index: 10001;
}

.lightbox-prev {
    left: -60px;
}

.lightbox-next {
    right: -60px;
}

/* Mobile View Styles */
.gallery-mobile-view {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: white;
    z-index: 9998;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.mobile-view-header {
    position: sticky;
    top: 0;
    background-color: white;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    z-index: 1;
    text-align: left;
}

.back-to-grid-button {
    background-color: #0073aa;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.mobile-view-content {
    padding: 10px;
}

.mobile-gallery-item {
    margin-bottom: 20px;
}

.mobile-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}

.mobile-image-caption {
    padding: 10px;
    background-color: #f5f5f5;
    text-align: center;
    font-size: 14px;
    color: #333;
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
    }
    
    /* Ensure grid layout works on mobile without inline styles */
    .advanced-gallery-grid {
        width: 100% !important;
    }
    
    .gallery-item {
        width: auto !important; /* Override any inline width styles */
    }
    
    /* Improve mobile lightbox */
    .lightbox-container {
        max-width: 100%;
        max-height: 100%;
    }
    
    .lightbox-image {
        max-height: 70vh;
    }
}
