/* Gallery Section Styles */
.genz-gallery-section {
    background: #ffffff;
    padding: 40px 0;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Loading Placeholder Styles */
.genz-gallery-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6c757d;
    text-align: center;
}

.genz-gallery-loading-placeholder .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Modal Loading Styles */
.genz-modal-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1002;
    display: none;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    padding: 20px;
}

.genz-modal-loading.show {
    display: block;
}

.genz-modal-loading .spinner-border {
    width: 4rem;
    height: 4rem;
    color: white;
}

/* Image Counter */
.genz-modal-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 1001;
}

/* Optimized Modal Image Container */
.genz-modal-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

/* Modal image optimization */
.genz-modal-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.genz-modal-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.genz-modal-image.loaded {
    opacity: 1 !important;
}

/* Progressive Image Loading with Lazy Loading */
.genz-gallery-grid-item {
    position: relative;
    overflow: hidden;
    min-height: 220px;
}

.genz-gallery-grid-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
}

.genz-gallery-grid-item.loaded::before {
    display: none;
}

/* Lazy Loading Placeholder */
.genz-gallery-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    z-index: 2;
    border-radius: 12px;
}

.genz-placeholder-content {
    text-align: center;
    color: #6c757d;
}

.genz-gallery-grid-item.loaded .genz-gallery-placeholder {
    display: none;
}

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

/* Gallery Item Styling */
.genz-gallery-grid-item {
    margin-bottom: 0;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0, 1);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    background: #fff;
    position: relative;
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.genz-gallery-grid-item.loading {
    opacity: 0;
    transform: translateY(15px);
}

.genz-gallery-grid-item.loaded {
    opacity: 1 !important;
    transform: translateY(0);
}

.genz-gallery-grid-item.loaded .genz-gallery-grid-img {
    opacity: 1 !important;
}

.genz-gallery-grid-item.loaded .genz-gallery-placeholder {
    display: none !important;
}

.genz-gallery-grid-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.15);
}

.genz-gallery-grid-item:focus {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

.genz-gallery-grid-item:active {
    transform: translateY(-4px) scale(0.98);
}

.genz-gallery-grid-item img,
.genz-gallery-grid-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: all 0.5s ease;
    display: block;
    border-radius: 12px;
    background: #f8f9fa;
    will-change: opacity, transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.genz-gallery-grid-item:hover img,
.genz-gallery-grid-item:hover .genz-gallery-grid-img {
    transform: scale(1.01);
}

/* Clean gallery grid styling */
.genz-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Desktop: 4 columns */
    gap: 20px;
    padding: 20px 0;
    background: #ffffff;
    min-height: 200px;
}

/* Tablets (≤992px): 3 columns */
@media (max-width: 992px) {
    .genz-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        padding: 16px 0;
    }
}

/* Mobile (≤576px): 2 columns */
@media (max-width: 576px) {
    .genz-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px 0;
    }
}


.genz-gallery-grid-item {
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-bottom: 0;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
}

.genz-gallery-grid-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.genz-gallery-grid-item:active {
    transform: scale(0.98);
}

.genz-gallery-grid-item img,
.genz-gallery-grid-img {
    width: 100%;
    height: 220px;
    border-radius: 12px;
    object-fit: cover;
    background: #f8f9fa;
    transition: transform 0.3s ease;
    display: block;
}

.genz-gallery-grid-item:hover img,
.genz-gallery-grid-item:hover .genz-gallery-grid-img {
    transform: scale(1.02);
}

@media (max-width: 992px) {
    .genz-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        padding: 15px 0;
    }
    .genz-gallery-grid-item img,
    .genz-gallery-grid-img {
        height: 200px;
    }
}

@media (max-width: 768px) {
    .genz-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 15px 0;
    }
    .genz-gallery-grid-item img,
    .genz-gallery-grid-img {
        height: 180px;
    }
}

@media (max-width: 576px) {
    .genz-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px 0;
    }
    .genz-gallery-grid-item {
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        min-height: 160px;
    }
    .genz-gallery-grid-item img,
    .genz-gallery-grid-img {
        height: 160px;
        border-radius: 8px;
    }
    
    /* Optimize modal for mobile */
    .genz-modal-image-container {
        padding: 10px;
    }
    
    .genz-gallery-nav-btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    
    .genz-gallery-nav-btn-prev {
        left: 16px;
    }
    
    .genz-gallery-nav-btn-next {
        right: 16px;
    }
}

/* Modal Styles */
.lm-gallery-modal-content {
    border-radius: 16px;
    overflow: hidden;
    border: none;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.lm-gallery-modal-header {
    background-color: #212529;
    color: white;
    border-bottom: none;
    padding: 16px 24px;
}

.lm-gallery-modal-img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    background-color: #000;
    display: block;
}

@media (max-width: 576px) {
    .modal-img {
        max-height: 60vh;
    }
}

.lm-gallery-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background-color: #212529;
    color: white;
}

.modal-fullscreen .lm-gallery-modal-content {
    border-radius: 0;
    background-color: #000;
}

.modal-fullscreen .lm-gallery-modal-header {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-fullscreen .lm-gallery-modal-footer {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Reduced height modal body for gallery popover */
.genz-gallery-modal-body {
    width: 100% !important;
    height: 75vh !important;
    max-height: 75vh !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #000;
    padding: 0;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Centered navigation buttons on left/right */
.genz-gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    background: rgba(0,0,0,0.7) !important;
    border: none;
    border-radius: 50%;
    font-size: 2rem;
    transition: background 0.2s, opacity 0.2s;
}
.genz-gallery-nav-btn:hover, .genz-gallery-nav-btn:focus {
    opacity: 1;
    background: rgba(0,0,0,0.95) !important;
}
.genz-gallery-nav-btn-prev {
    left: 32px;
    right: auto;
}
.genz-gallery-nav-btn-next {
    right: 32px;
    left: auto;
}

/* Tab Styles */
.genz-gallery-tabs {
    border-bottom: 2px solid #f1f3f5;
    margin-bottom: 0px;
}

.genz-gallery-tabs .nav-link {
    margin-bottom: -2px;
    border: none;
    color: #6c757d;
    font-weight: 600;
    padding: 14px 24px;
    border-radius: 0;
    transition: all 0.3s ease;
}

.genz-gallery-tabs .nav-link:hover {
    border-color: transparent;
    color: #495057;
}

.genz-gallery-tabs .nav-link.active {
    color: #0d6efd;
    background-color: transparent;
    border-bottom: 3px solid #0d6efd;
}

/* Gallery tab content styling */
.genz-gallery-section .genz-gallery-tab-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    padding: 20px 0;
    min-height: 400px;
}

/* Ensure tab content is always visible */
#genz-gallery-tab-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.genz-gallery-section .genz-gallery-tab-pane {
    display: none !important;
    transition: all 0.3s ease;
}

.genz-gallery-section .genz-gallery-tab-pane.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure active tab pane is always visible */
.tab-pane.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Fix Bootstrap fade class conflicts */
.genz-gallery-section .genz-gallery-tab-pane.fade {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.genz-gallery-section .genz-gallery-tab-pane.fade.show {
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
}

.genz-gallery-section .genz-gallery-tab-pane.fade.active.show {
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
}

/* Override Bootstrap fade behavior */
.tab-pane.fade.active.show {
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
}

.tab-pane.fade.show {
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
}

/* Ensure tab content is always visible */
.genz-gallery-tab-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.genz-gallery-tab-pane {
    display: none;
}

.genz-gallery-tab-pane.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.genz-gallery-tab-pane.fade.active.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.genz-gallery-badge-tab {
    margin-left: 8px;
    background-color: #e9ecef;
    color: #6c757d;
    font-weight: 500;
    font-size: 0.75rem;
    padding: 5px 8px;
}

.genz-gallery-tabs .nav-link.active .genz-gallery-badge-tab {
    background-color: #0d6efd;
    color: white;
}

.genz-gallery-tab-icon {
    margin-right: 8px;
}

/* Image Modal Styles */
#genz-image-modal .modal-content {
    width: 100%;
    height: 80vh;
    max-height: 80vh;
    background-color: rgba(0, 0, 0, 0.9);
    border: none;
    border-radius: 12px;
}

#genz-image-modal .modal-header {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;
    border: none;
}

#genz-image-modal .modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border: none;
    background: transparent;
}

#genz-image-modal .modal-header .btn {
    opacity: 0.7;
    transition: all 0.3s;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    padding: 0.7rem;
    border-radius: 4px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#genz-image-modal .modal-header .btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.8);
}

#genz-image-modal .modal-header .btn i {
    color: white;
    font-size: 1.2rem;
}

#genz-modal-image {
    transition: transform 0.3s ease, opacity 0.3s ease;
    cursor: zoom-in;
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

#genz-modal-image.zoomed {
    transform: scale(1.5);
    cursor: zoom-out;
}

#genz-modal-image:focus {
    outline: none;
}

/* Loading state for modal image */
#genz-modal-image[style*="opacity: 0.5"] {
    filter: blur(2px);
}

/* Modal navigation buttons */
#genz-prev-image, #genz-next-image {
    opacity: 0.7;
    transition: all 0.3s ease;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 1rem 0.8rem;
    border-radius: 4px;
    backdrop-filter: blur(5px);
    color: white;
    font-size: 1.2rem;
    min-width: 50px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#genz-prev-image:hover, #genz-next-image:hover,
#genz-prev-image:focus, #genz-next-image:focus {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

#genz-prev-image:active, #genz-next-image:active {
    transform: scale(0.95);
}

#genz-prev-image i, #genz-next-image i {
    color: white;
    pointer-events: none;
}

/* Gallery tab buttons with 2 per row mobile layout */
@media (max-width: 576px) {
    .nav-tabs {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        font-size: 0.9rem;
        margin: 0 0 16px 0;
        border-bottom: none;
        padding: 8px;
        background: #f8f9fa;
        width: 100%;
    }
    .nav-tabs .nav-item {
        width: 100%;
        margin: 0;
    }
    .nav-tabs .nav-link {
        padding: 10px 8px;
        text-align: center;
        font-size: 0.9rem;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        margin: 0;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: white;
        color: #495057;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        width: 100%;
    }
    .nav-tabs .nav-link:hover {
        background: #f8f9fa;
        border-color: #dee2e6;
    }
    .nav-tabs .nav-link.active {
        background: #0d6efd;
        color: white;
        border-color: #0d6efd;
        box-shadow: 0 2px 5px rgba(13, 110, 253, 0.2);
    }
    .nav-tabs .nav-link.active .badge-tab {
        background: white;
        color: #0d6efd;
    }
    .badge-tab {
        font-size: 0.75rem;
        padding: 4px 6px;
        margin-left: 6px;
        border-radius: 6px;
        background: #e9ecef;
        font-weight: 600;
    }
    .tab-icon {
        font-size: 0.9rem;
        margin-right: 4px;
    }
    #prevImage, #nextImage {
        padding: 0.8rem 0.6rem;
    }
}

/* Modal: full width, no cropping */
@media (max-width: 576px) {
    .modal-content,
    #imageModal .modal-content {
        border-radius: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-height: 85vh !important;
        padding: 0;
    }
    #imageModal .modal-header, #imageModal .modal-footer {
        padding-left: 8px;
        padding-right: 8px;
    }
    #modalImage {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 55vh !important;
        object-fit: contain;
        margin: 0 auto;
    }
    .gallery-img,
    .gallery-item-container {
        height: 200px;
    }
    .nav-tabs .nav-link {
        padding: 16px 4px;
    }
}
