.wtwh-cloudflare-gallery {
    width: 100%;
}

.wtwh-gallery-grid {
    display: grid;
    grid-gap: 10px;
}

/* Apply alternating row heights only to styles 1-4 */
.style-1, .style-2, .style-3, .style-4 {
    grid-auto-rows: 250px 150px;
}

.wtwh-gallery-item {
    overflow: hidden;
    border-radius: 4px;
    break-inside: avoid;
    cursor: pointer;
}

.style-1 {
    grid-template-columns: repeat(5, 1fr);
}

.style-1 .wtwh-gallery-item:nth-child(3n) {
    grid-row: span 2;
}

.style-2, .style-3, .style-4 {
    grid-template-columns: repeat(6, 1fr);
}

.style-2 .wtwh-gallery-item:nth-child(3n), .style-3 .wtwh-gallery-item:nth-child(3n) {
    grid-column: span 2;
}

.style-3 .wtwh-gallery-item:nth-child(6n) {
    grid-row: span 2;
}

.style-4 .wtwh-gallery-item:nth-child(4n) {
    grid-column: span 2;
}

.style-5 {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

@media (max-width: 480px) {
    .style-5 {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

.style-5 .wtwh-gallery-item {
    position: relative;
    width: 100%;
}

/* Fallback for browsers without aspect-ratio support */
.style-5 .wtwh-gallery-item::before {
    content: '';
    display: block;
    padding-top: 100%; /* 1:1 aspect ratio */
}

.style-5 .wtwh-gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Modern browsers with aspect-ratio support */
@supports (aspect-ratio: 1 / 1) {
    .style-5 .wtwh-gallery-item {
        aspect-ratio: 1 / 1;
    }
    
    .style-5 .wtwh-gallery-item::before {
        display: none;
    }
    
    .style-5 .wtwh-gallery-item img {
        position: static;
    }
}

/* Square image alignment options */
.style-5[data-square-alignment="top"] .wtwh-gallery-item img {
    object-position: top;
}

.style-5[data-square-alignment="bottom"] .wtwh-gallery-item img {
    object-position: bottom;
}

.style-5[data-square-alignment="left"] .wtwh-gallery-item img {
    object-position: left;
}

.style-5[data-square-alignment="right"] .wtwh-gallery-item img {
    object-position: right;
}

.style-5[data-square-alignment="top-left"] .wtwh-gallery-item img {
    object-position: top left;
}

.style-5[data-square-alignment="top-right"] .wtwh-gallery-item img {
    object-position: top right;
}

.style-5[data-square-alignment="bottom-left"] .wtwh-gallery-item img {
    object-position: bottom left;
}

.style-5[data-square-alignment="bottom-right"] .wtwh-gallery-item img {
    object-position: bottom right;
}

.style-5[data-square-alignment="center"] .wtwh-gallery-item img {
    object-position: center;
}

.wtwh-gallery-item img {
    width: 100%;
    height: 100% !important;
    object-fit: cover;
}

.wtwh-gallery-empty {
    color: #666;
    text-align: center;
    padding: 20px;
}

/* Category Filter Buttons */
.wtwh-gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.wtwh-gallery-filters[data-alignment="left"] {
    justify-content: flex-start;
}

.wtwh-gallery-filters[data-alignment="center"] {
    justify-content: center;
}

.wtwh-gallery-filters[data-alignment="right"] {
    justify-content: flex-end;
}

.wtwh-filter-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    color: #495057;
    padding: 8px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    outline: none;
}

.wtwh-filter-btn:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: translateY(-1px);
}

.wtwh-filter-btn.active {
    background: var(--e-global-color-primary, #007cba);
    border-color: var(--e-global-color-primary, #007cba);
    color: white;
}

.wtwh-filter-btn.active:hover {
    background: var(--e-global-color-primary, #005a87);
    border-color: var(--e-global-color-primary, #005a87);
}

@media (max-width: 768px) {
    .wtwh-gallery-filters {
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .wtwh-filter-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

.wtwh-gallery-overlay{
    width:100%;
    height:100vh;
    position:fixed;
    top:0;
    left:0;
    z-index:9999;
    background-color:rgba(0,0,0,0.8);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wtwh-gallery-overlay.visible{
    opacity: 1;
}

.wtwh-gallery-overlay.fade-out{
    opacity: 0;
}

.wtwh-gallery-lightbox{
    width:100%;
    height:100vh;
    display:flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position:relative;
    z-index:10000;
    padding:6rem;
}

.wtwh-gallery-lightbox img{
    max-width:100%;
    max-height:100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wtwh-gallery-lightbox img.visible{
    opacity: 1;
}

.wtwh-gallery-lightbox .image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 1;
}

.wtwh-gallery-lightbox .image-loader.hidden {
    display: none;
}

.wtwh-gallery-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.wtwh-gallery-loader-text {
    color: #fff;
    font-size: 14px;
    opacity: 0.8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.wtwh-gallery-lightbox .image-skeleton {
    width: 80%;
    height: 60%;
    background: linear-gradient(90deg, rgba(255,255,255,0.1) 25%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.1) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
    position: relative;
}

.wtwh-gallery-lightbox .image-skeleton.hidden {
    display: none;
}

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

.wtwh-gallery-close{
    position:absolute;
    top:20px;
    right:20px;
    z-index:10000;
    cursor:pointer;
    font-size: 18px;
    color: #fff;
    border: none;
    background: grey;
    padding: 3px 9px !important;
    border-radius: 25px !important;
}

.wtwh-gallery-share-links{
    display: flex;
    justify-content: center;
    margin-top: 20px;
    gap: 10px;
}

.wtwh-gallery-share-links button{
    background-color:transparent;
    border:none;
    cursor:pointer;
    padding: 0;
}

.wtwh-gallery-share-links svg{
    width:24px;
    fill:#fff;
}

.wtwh-gallery-share-links svg:hover{
    fill:var(--e-a-color-primary);
}

.wtwh-gallery-copied-notification{
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10001;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.wtwh-gallery-copied-notification.fade-out{
    opacity: 0;
}

.wtwh-gallery-arrows{
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 2rem;
}

.wtwh-gallery-arrows .wtwh-gallery-arrow{
    background: grey;
    color: white;
    border: none;
    font-weight: bold;
    padding: 17px 12px !important;
    border-radius: 25px !important;
    line-height: 0;
}
