.jo-property-gallery {
    margin: 2rem 0;
    width: 100%;
}

.property-gallery-title {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
    font-weight: 600;
    font-size: 1.5rem;
}

.jo-gallery-error {
    background: #ffeaa7;
    border: 1px solid #fdcb6e;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    color: #2d3436;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    align-items: start;
    gap: var(--image-gap, 15px);
}

.gallery-item {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.gallery-thumb {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    text-decoration: none;
    cursor: zoom-in;
    overflow: hidden;
}

.property-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-thumb:hover .property-image {
    transform: scale(1.05);
}

.image-caption {
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
    padding: 0 0.5rem;
}

.gallery-item.rect-wide {
    aspect-ratio: 16/9;
}

.gallery-item.rect-tall {
    aspect-ratio: 3/4;
}

.gallery-item.rect-square {
    aspect-ratio: 1/1;
}

.gallery-item.rect-portrait {
    aspect-ratio: 2/3;
}

.gallery-grid[data-thumb-count="1"] .gallery-item:nth-child(1) {
    grid-column: 1 / span 12;
    aspect-ratio: 4/3;
    grid-row: 1;
}

.gallery-grid[data-thumb-count="2"] .gallery-item:nth-child(1) {
    grid-column: 1 / span 6;
    aspect-ratio: 4/3;
	grid-row: 1;
}

.gallery-grid[data-thumb-count="2"] .gallery-item:nth-child(2) {
    grid-column: 7 / span 6;
    aspect-ratio: 4/3;
	grid-row: 1;
}

.gallery-grid[data-thumb-count="3"] .gallery-item:nth-child(1) {
    grid-column: 1 / span 8;
    aspect-ratio: 4/3;
    grid-row: 1 / span 2;
}

.gallery-grid[data-thumb-count="3"] .gallery-item:nth-child(2) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 1;
}

.gallery-grid[data-thumb-count="3"] .gallery-item:nth-child(3) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 2;
}

.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(1) {
    grid-column: 1 / span 8;
    aspect-ratio: 4/3;
    grid-row: 1 / span 2;
}

.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(2) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 1;
}

.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(3) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 2;
}

.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(4) {
    grid-column: 1 / span 12;
    aspect-ratio: 4/3;
    grid-row: 3;
}

.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(1) {
    grid-column: 1 / span 8;
    aspect-ratio: 4/3;
    grid-row: 1 / span 2;
}

.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(2) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 1;
}

.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(3) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 2;
}

.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(4) {
    grid-column: 1 / span 6;
    aspect-ratio: 4/3;
	grid-row: 3;
}

.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(5) {
    grid-column: 7 / span 6;
    aspect-ratio: 4/3;
	grid-row: 3;
}

.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(1) {
    grid-column: 1 / span 8;
    aspect-ratio: 4/3;
    grid-row: 1 / span 2;
}

.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(2) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 1;
}

.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(3) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 2;
}

.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(4) {
    grid-column: 1 / span 8;
    aspect-ratio: 4/3;
    grid-row: 3 / span 2;
}

.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(5) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 3;
}

.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(6) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 4;
}

.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(1) {
    grid-column: 1 / span 8;
    aspect-ratio: 4/3;
    grid-row: 1 / span 2;
}

.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(2) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 1;
}

.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(3) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 2;
}

.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(4) {
    grid-column: 1 / span 8;
    aspect-ratio: 4/3;
    grid-row: 3 / span 2;
}

.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(5) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 3;
}

.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(6) {
    grid-column: 9 / span 4;
    aspect-ratio: 4/3;
    grid-row: 4;
}

.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(7) {
    grid-column: 1 / span 12;
    aspect-ratio: 4/3;
    grid-row: 5;
}

.view-all-container {
    padding: 1rem 0;
}

.view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 1rem;
    color: #007cba !important;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid #007cba;
    width: fit-content;
}

.view-all-link:hover {
    border-color: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
}

.view-all-text {
    font-size: 1rem;
}

.image-count {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: normal;
}

.pswp__counter {
    font-weight: 600;
    font-size: 14px;
}

.pswp__caption__center {
    text-align: center;
    font-size: 14px;
    padding: 10px;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: auto;
        gap: 10px;
    }
    
    .gallery-grid .gallery-item {
        grid-column: 1 / span 12 !important;
        aspect-ratio: 4/3 !important;
    }
	
	.gallery-grid[data-thumb-count="2"] .gallery-item:nth-child(1) {
		grid-row: 1;
	}

	.gallery-grid[data-thumb-count="2"] .gallery-item:nth-child(2) {
		grid-row: 2;
	}

	.gallery-grid[data-thumb-count="3"] .gallery-item:nth-child(1) {
		grid-row: 1;
	}

	.gallery-grid[data-thumb-count="3"] .gallery-item:nth-child(2) {
		grid-row: 2;
	}

	.gallery-grid[data-thumb-count="3"] .gallery-item:nth-child(3) {
		grid-row: 3;
	}

	.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(1) {
		grid-row: 1;
	}

	.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(2) {
		grid-row: 2;
	}

	.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(3) {
		grid-row: 3;
	}

	.gallery-grid[data-thumb-count="4"] .gallery-item:nth-child(4) {
		grid-row: 4;
	}

	.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(1) {
		grid-row: 1;
	}

	.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(2) {
		grid-row: 2;
	}

	.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(3) {
		grid-row: 3;
	}

	.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(4) {
		grid-row: 4;
	}

	.gallery-grid[data-thumb-count="5"] .gallery-item:nth-child(5) {
		grid-row: 5;
	}

	.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(1) {
		grid-row: 1;
	}

	.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(2) {
		grid-row: 2;
	}

	.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(3) {
		grid-row: 3;
	}

	.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(4) {
		grid-row: 4;
	}

	.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(5) {
		grid-row: 5;
	}

	.gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(6) {
		grid-row: 6;
	}

	.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(1) {
		grid-row: 1;
	}

	.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(2) {
		grid-row: 2;
	}

	.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(3) {
		grid-row: 3;
	}

	.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(4) {
		grid-row: 4;
	}

	.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(5) {
		grid-row: 5;
	}

	.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(6) {
		grid-row: 6;
	}

	.gallery-grid[data-thumb-count="7"] .gallery-item:nth-child(7) {
		grid-row: 7;
	}
    
    .property-gallery-title {
        font-size: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .view-all-link {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .view-all-text {
        font-size: 0.9rem;
    }
}

@media (min-width: 769px) and (max-width: 1399px) {
    .gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(1) {
        grid-column: 1 / span 8;
        aspect-ratio: 4/3;
        grid-row: 1 / span 2;
    }

    .gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(2) {
        grid-column: 9 / span 4;
        aspect-ratio: 4/3;
        /*! grid-row: 1; */
    }

    .gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(3) {
        grid-column: 9 / span 4;
        aspect-ratio: 4/3;
        /*! grid-row: 2; */
    }

    .gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(4) {
        grid-column: 1 / span 8;
        aspect-ratio: 16/9;
    }

    .gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(5) {
        grid-column: 9 / span 4;
        aspect-ratio: 16/9;
    }

    .gallery-grid[data-thumb-count="6"] .gallery-item:nth-child(6) {
        grid-column: 9 / span 4;
        aspect-ratio: 16/9;
    }
}

@supports not (aspect-ratio: 1/1) {
    .gallery-item::before {
        float: left;
        padding-top: 75%;
        content: '';
    }
    
    .gallery-item::after {
        content: '';
        display: block;
        clear: both;
    }
    
    .property-image {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}