/* Gallery Grid Layout */
.gallery-grid-template {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto;
    grid-auto-rows: 1fr;
    gap: 20px;
    max-width: 1140px;
    margin: 0 auto;
}

.gallery-item {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: var(--item-border-radius,12px);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Media preview common styles */
img.media-preview,
video.media-preview {
    border-radius: var(--item-border-radius,12px);
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}


/* Image Preview Modal */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
}

.preview-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 40px;
    box-sizing: border-box;
}

/* Close Button */
.preview-close-btn {
    position: absolute;
    top: 25px;
    right: 25px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 24px;
    font-weight: 300;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.preview-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

/* Navigation Buttons */
.preview-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 32px;
    font-weight: 300;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.preview-nav-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
}

.preview-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%) scale(1);
}

.preview-nav-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.preview-prev-btn {
    left: 25px;
}

.preview-next-btn {
    right: 25px;
}

/* Media Container */
.image-container {
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.preview-item {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--item-border-radius,12px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: none;
    transition: opacity 0.3s ease;
}

/* Specific media type styles */
img.preview-item {
    object-fit: contain;
}

video.preview-item {
    background: #000;
    object-fit: contain;
}

iframe.preview-item {
    width: 80vw;
    height: 80vh;
    max-width: 1200px;
    border-radius: var(--item-border-radius,12px);
    background: #fff;
}

/* Counter */
.preview-counter {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 25px;
    font-family: var(--font-primary, Arial, sans-serif);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Media Type Indicator */
.media-type-badge {
    position: absolute;
    top: 25px;
    left: 25px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .gallery-grid-template {
        grid-template-columns: repeat(2, 1fr);
        max-width: 992px;
    }
}

@media (max-width: 992px) {
    .gallery-grid-template {
        grid-template-columns: repeat(2, 1fr);
        max-width: 768px;
    }
    
    .preview-container {
        padding: 30px;
    }
    
    iframe.preview-item {
        width: 90vw;
        height: 70vh;
    }
}

@media (max-width: 768px) {
    
    .gallery-grid-template {
        grid-template-columns: 1fr;
        max-width: 576px;
    }

    .preview-nav-btn {
        width: 50px;
        height: 50px;
        font-size: 24px;
        top: unset;
        bottom: 50px;
    }
    
    .preview-prev-btn {
        left : unset;
        right : 55%;
    }
    
    .preview-next-btn {
        right : unset;
        left : 55%;
    }
    
    .preview-close-btn {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .preview-container {
        padding: 20px;
    }
    
    .image-container {
        max-width: 95%;
        max-height: 80vh;
    }
    
    iframe.preview-item {
        width: 95vw;
        height: 60vh;
    }
    
    .preview-counter {
        bottom: 15px;
        font-size: 14px;
        padding: 8px 16px;
    }
    
    .media-type-badge {
        top: 15px;
        left: 15px;
        font-size: 11px;
        padding: 5px 10px;
    }
}

@media (max-width: 576px) {

    .gallery-grid-template {
        max-width: 360px;
    }
    .preview-container {
        padding: 15px;
    }
    
    .preview-nav-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .preview-close-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    iframe.preview-item {
        height: 50vh;
    }
    
    .preview-counter {
        font-size: 13px;
        padding: 6px 14px;
    }
}
