/* Gallery Lightbox Styles */
.ps-gallery-item {
    position: relative;
    margin-bottom: 30px;
    overflow: hidden;
    display: block !important;
    visibility: visible !important;
}

.ps-gallery-item__link {
    display: block;
    position: relative;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.ps-gallery-item__image {
    position: relative;
    overflow: hidden;
    transition: all 0.4s ease;
    /* Fixed aspect ratio container */
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* Default 1:1 Aspect Ratio (will be overridden by inline style if width/height are set) */
    background-color: #f5f5f5; /* Light background for empty spaces */
}

.ps-gallery-item__image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover the container while maintaining aspect ratio */
    object-position: center; /* Center the image within the container */
    transition: all 0.4s ease;
    display: block !important;
}

/* Custom aspect ratio support */
.ps-gallery-item__image[style*="padding-bottom"] {
    /* This will be used when inline style with custom padding-bottom is applied */
    /* The inline style will override the default padding-bottom: 100% */
}

.ps-gallery-item__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.4s ease;
}

.ps-gallery-item__overlay i {
    color: #fff;
    font-size: 24px;
}

.ps-gallery-item:hover .ps-gallery-item__overlay {
    opacity: 1;
}

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

/* Gallery section layouts */
.ps-section--gallery {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
    overflow: hidden !important;
}

/* Container layout - centered with max width */
.ps-section--container {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

/* Fullwidth layout - spans entire viewport width */
.ps-section--fullwidth {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
}

/* Force display for gallery carousel */
.ps-section--gallery .owl-slider,
.ps-section--gallery .gallery-carousel {
    display: block !important;
    visibility: visible !important;
}

/* Magnific Popup Customizations */
.mfp-with-zoom .mfp-container,
.mfp-with-zoom.mfp-bg {
    opacity: 0;
    transition: all 0.3s ease-out;
}

.mfp-with-zoom.mfp-ready .mfp-container {
    opacity: 1;
}

.mfp-with-zoom.mfp-ready.mfp-bg {
    opacity: 0.8;
}

.mfp-with-zoom.mfp-removing .mfp-container,
.mfp-with-zoom.mfp-removing.mfp-bg {
    opacity: 0;
}

.mfp-arrow {
    opacity: 0.7;
    transition: all 0.3s ease;
}

.mfp-arrow:hover {
    opacity: 1;
}

.mfp-counter {
    color: #f7f7f7;
}

/* Responsive styles */
@media (max-width: 1199px) {
    .ps-gallery-item {
        margin-bottom: 20px;
    }
}

@media (max-width: 991px) {
    .ps-gallery-item {
        margin-bottom: 15px;
    }
    
    .ps-gallery-item__overlay i {
        font-size: 20px;
    }
    
    /* Ensure gallery is visible on tablets */
    .ps-section--gallery {
        display: block !important;
        visibility: visible !important;
    }
    
    .ps-section--gallery .owl-carousel {
        display: block !important;
        visibility: visible !important;
    }
}

@media (max-width: 767px) {
    .ps-gallery-item {
        margin-bottom: 10px;
    }
    
    .ps-section--gallery .owl-slider {
        margin-left: -5px;
        margin-right: -5px;
    }
    
    .ps-section--gallery .owl-slider .owl-item {
        padding-left: 5px;
        padding-right: 5px;
    }
    
    .ps-gallery-item__overlay i {
        font-size: 18px;
    }
    
    /* Ensure gallery is visible on mobile */
    .ps-section--gallery {
        display: block !important;
        visibility: visible !important;
        width: 100% !important;
        overflow: hidden !important;
    }
    
    .ps-section--gallery .owl-carousel,
    .ps-section--gallery .owl-stage-outer,
    .ps-section--gallery .owl-stage,
    .ps-section--gallery .owl-item {
        display: block !important;
        visibility: visible !important;
    }
    
    /* Fallback for mobile if carousel doesn't initialize */
    .ps-section--gallery .owl-carousel:not(.owl-loaded) {
        display: flex !important;
        flex-wrap: wrap;
        margin: 0 -5px;
    }
    
    .ps-section--gallery .owl-carousel:not(.owl-loaded) .ps-gallery-item {
        width: 50%;
        padding: 0 5px;
        margin-bottom: 10px;
    }
}

@media (max-width: 479px) {
    .ps-gallery-item__overlay i {
        font-size: 16px;
    }
    
    .ps-section--gallery .ps-section__header {
        margin-bottom: 15px;
    }
    
    .ps-section--gallery .ps-section__title {
        font-size: 18px;
    }
    
    /* Adjust fallback for very small screens */
    .ps-section--gallery .owl-carousel:not(.owl-loaded) .ps-gallery-item {
        width: 100%;
    }
}

/* Fix for owl carousel initialization issues */
.owl-carousel {
    display: block;
}

.owl-carousel.owl-loaded {
    display: block;
}

/* Ensure images are visible */
.ps-gallery-item img {
    display: block !important;
    max-width: 100% !important;
}