.gallery-outer-container {
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    background-color: #f8f9fa;
    padding: 0;
    margin-bottom: 2rem;
    margin-top: 100px;
}

.gallery-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    height: 500px;
    gap: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    background: #fff;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.main-image-container {
    grid-column: span 3;
    grid-row: span 2;
}

/* Responsive adjustments */
@media (min-width: 992px) and (max-width: 1487px) {
    .gallery-container {
        height: 500px;
        max-width: 100%;
        margin-left: 30px;
        margin-right: 30px;
    }
}

@media (max-width: 992px) {
    .gallery-container {
        height: 400px;
    }
    .gallery-outer-container {
        margin-top: 118px !important;
    }
    .property-gallery {
        height: 100%;
    }
}

@media (max-width: 768px) {
    .gallery-container {
        grid-template-columns: 1fr;
        height: auto;
        aspect-ratio: 1;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
    .main-image-container {
        grid-column: span 2;
        grid-row: span 2;
        /* Ensure proper touch interaction on mobile */
        -webkit-tap-highlight-color: transparent;
    }

    .thumbnail-item:nth-last-child(1),
    .thumbnail-item:nth-last-child(2) {
        display: none;
    }
}

.main-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #fff;
    /* Ensure proper stacking context for absolute positioning */
    isolation: isolate;
}

.thumbnails-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 100%;
    box-sizing: border-box;
}

.thumbnail-item {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #fff;
    transition: transform 0.2s ease;
}

.thumbnail-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.zoom-on-click {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    cursor: pointer;
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
    will-change: transform;
}

.zoom-on-click:hover .gallery-img {
    transform: scale(1.05);
}

.photo-count {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    z-index: 90;
    pointer-events: none;
    gap: 6px;
}

/* Ensure the photo count text is visible */
.photo-count span {
    pointer-events: none;
    display: flex;
    align-items: center;
    line-height: 1;
}

.photo-count .camera-icon {
    width: 20px;
    height: 20px;
    fill: white;
    display: flex;
    align-items: center;
}

.no-image {
    width: 100%;
    height: 600px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    max-width: 1400px;
    margin: 0 auto;
}

.no-image img {
    max-width: 100%;
    max-height: 100%;
}

/* Image Zoom Modal */
#image-zoom-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    transition: opacity 0.3s ease;
    justify-content: center;
    align-items: center;
    opacity: 0;
}

#image-zoom-modal.show {
    display: flex;
    opacity: 1;
}

#image-zoom-modal .modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#image-zoom-modal-img {
    max-width: 100%;
    max-height: 90vh;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    background: #000;
    display: block;
    object-fit: contain;
    transition: transform 0.3s ease;
}

/* Navigation Arrows */
.nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 100px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    z-index: 2001;
    border-radius: 4px;
}

.property-gallery {
    margin-top: 40px;
}

.nav-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
}

#prev-image {
    left: 20px;
}

#next-image {
    right: 20px;
}


/* Image Counter */
#image-counter {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .nav-arrow {
        width: 40px;
        height: 80px;
        font-size: 20px;
    }
    
    #prev-image {
        left: 5px;
    }
    
    #next-image {
        right: 5px;
    }
}

@media (max-width: 767.98px) {
    .d-mobile-only {
        display: block !important;
    }
    .d-desktop-only {
        display: none !important;
    }
}
@media (min-width: 768px) {
    .d-mobile-only {
        display: none !important;
    }
    .d-desktop-only {
        display: block !important;
    }
}