.property-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    width: 100%;
    margin: 20px auto 0;
    border-radius: 0px;
    overflow: hidden;
}

.gallery-main-image {
    grid-column: 1 / 2;
    position: relative;
    height: 0;
    padding-bottom: 75%; /* 4:3 aspect ratio (min) */
    max-height: 745px;
    overflow: hidden;
    border-radius: 0px;
}

.gallery-main-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 4 / 3;
    max-height: 745px;
}

.gallery-thumbnails {
    grid-column: 2 / 3;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 1fr;
    gap: 25px;
    border-radius: 0px;
    overflow: hidden;
    max-height: 745px;
}

.thumbnail-item {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 745px;
    overflow: hidden;
    border-radius: 0px;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    aspect-ratio: 4 / 3;
}

/* Ensure no img tag styling for thumbnail items, as they are now background images */
.thumbnail-item > img {
    display: none;
}

.empty-thumbnail-slot {
    display: none;
}

.gallery-more-photos-overlay {
    position: relative;
}

.gallery-more-photos {
    position: absolute;
    top: 15px;
    right: 15px;
    width: auto;
    height: auto;
    background-color: white;
    color: black;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 10;
    border-radius: 0;
    padding: 7px 16px;
}

/* Responsive Adjustments (Simplified for consistent 2x2 square thumbnails) */
/* Tablet: 768px to 1024px */
@media (max-width: 1024px) and (min-width: 768px) {
    .property-gallery {
        min-height: 200px;
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .gallery-main-image {
        grid-column: auto;
        padding-bottom: 56.25%;
    }

    .gallery-thumbnails {
        grid-column: auto;
        grid-template-columns: repeat(4, 1fr);
    }

    .thumbnail-item {
        padding-bottom: 56.25%;
    }

    .gallery-more-photos {
        grid-column: auto;
        text-align: center;
        font-size: 14px;
        line-height: 1.35em;
    }
}

/* Mobile: 767px and lower */
@media (max-width: 767px) {
    .property-gallery {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        min-height: unset;
        width: 100%;
        gap: 10px;
    }
    .gallery-main-image {
        height: 200px;
        padding-bottom: 0;
        min-width: 0;
        width: 100%;
    }
    .gallery-main-image img {
        position: static;
        width: 100%;
        height: 100% !important;
        object-fit: cover;
        object-position: center center;
    }
    .gallery-thumbnails {
        display: flex;
        flex-direction: row;
        gap: 8px;
        width: 100%;
        grid-template-columns: none;
        grid-auto-rows: unset;
        border-radius: 0;
        overflow: visible;
        margin-top: 0;
        justify-content: space-between;
    }
    .thumbnail-item {
        flex: 1 1 0;
        height: 70px;
        min-width: 0;
        padding-bottom: 0;
        border-radius: 0px;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
    }
}

/* Lightbox Styles */
.lightbox-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); /* Dark overlay */
    z-index: 9999; /* High z-index to be on top */
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    display: block;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    z-index: 10000; /* Higher than other lightbox elements */
}

.elementor-kit-10 .lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    padding: 0px;
    line-height: 44px;
    cursor: pointer;
    font-size: 24px;
    border-radius: 100%;
    z-index: 9999;
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

.lightbox-caption {
    color: #fff;
    margin-top: 10px;
    font-size: 1rem;
}

.lightbox-counter {
    color: #fff;
    margin-top: 5px;
    font-size: 0.8rem;
}

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

/* Clearfix for .property-gallery in case of floating/absolute children */
/* .property-gallery::after {
    content: "";
    display: table;
    clear: both;
}  */