/**
 * Powerful Media Gallery - Main Stylesheet
 * Includes: Masonry Grid, Hover Effects, Zoom Effects, Smooth Animations
 */

/* Gallery Container */
.pmg-gallery-container {
    width: 100%;
    margin: 30px 0;
    padding: 0;
}

/* Masonry Grid Layout */
.pmg-masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.pmg-gallery-container[data-columns="1"] .pmg-masonry-grid {
    grid-template-columns: 1fr;
}

.pmg-gallery-container[data-columns="2"] .pmg-masonry-grid {
    grid-template-columns: repeat(2, 1fr);
}

.pmg-gallery-container[data-columns="3"] .pmg-masonry-grid {
    grid-template-columns: repeat(3, 1fr);
}

.pmg-gallery-container[data-columns="4"] .pmg-masonry-grid {
    grid-template-columns: repeat(4, 1fr);
}

.pmg-gallery-container[data-columns="5"] .pmg-masonry-grid {
    grid-template-columns: repeat(5, 1fr);
}

.pmg-gallery-container[data-columns="6"] .pmg-masonry-grid {
    grid-template-columns: repeat(6, 1fr);
}

/* Gallery Item */
.pmg-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    opacity: 1; /* Always visible by default */
    visibility: visible; /* Ensure visibility */
    display: block; /* Ensure display */
    animation: pmgFadeIn 0.6s ease forwards;
}

/* Fallback: If animation doesn't work, items are still visible */
.pmg-gallery-item.pmg-loaded {
    opacity: 1 !important;
    visibility: visible !important;
}

.pmg-gallery-item:nth-child(1) { animation-delay: 0.1s; }
.pmg-gallery-item:nth-child(2) { animation-delay: 0.2s; }
.pmg-gallery-item:nth-child(3) { animation-delay: 0.3s; }
.pmg-gallery-item:nth-child(4) { animation-delay: 0.4s; }
.pmg-gallery-item:nth-child(n+5) { animation-delay: 0.5s; }

@keyframes pmgFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure images are always visible */
.pmg-gallery-image {
    display: block;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure grid is always visible */
.pmg-masonry-grid {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.pmg-gallery-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Image Wrapper */
.pmg-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Square aspect ratio */
    overflow: hidden;
    background: #f5f5f5;
}

.pmg-gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(1);
}

/* Hover Effect - Zoom In */
.pmg-gallery-item:hover .pmg-gallery-image {
    transform: scale(1.15);
}

/* Hover Effect - Lift Card */
.pmg-gallery-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Overlay */
.pmg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.7) 100%);
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: flex-end;
    padding: 20px;
    box-sizing: border-box;
}

.pmg-gallery-item:hover .pmg-overlay {
    opacity: 1;
}

/* Overlay Content */
.pmg-overlay-content {
    width: 100%;
    color: #fff;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pmg-gallery-item:hover .pmg-overlay-content {
    transform: translateY(0);
}

/* Image Category */
.pmg-image-category {
    margin: 0 0 12px 0;
    padding: 6px 12px;
    background: rgba(102, 126, 234, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.pmg-category-label {
    opacity: 0.9;
    margin-right: 5px;
}

.pmg-category-name {
    color: #fff;
    font-weight: 700;
}

.pmg-image-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.pmg-image-caption {
    margin: 0 0 15px 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.4;
}

/* Overlay Buttons */
.pmg-overlay-buttons {
    display: flex;
    gap: 10px;
}

.pmg-popup-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.pmg-popup-trigger:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) rotate(90deg);
    border-color: rgba(255, 255, 255, 0.5);
}

.pmg-icon-zoom {
    display: inline-block;
    width: 20px;
    height: 20px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg>') no-repeat center;
    background-size: contain;
}

/* Lightbox/Popup Styles */
.pmg-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.pmg-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.pmg-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    margin: auto;
    animation: pmgZoomIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pmgZoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.pmg-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pmg-lightbox-info {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    text-align: center;
    width: 100%;
}

.pmg-lightbox-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 5px 0;
}

.pmg-lightbox-caption {
    font-size: 14px;
    opacity: 0.8;
    margin: 0;
}

/* Lightbox Controls */
.pmg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pmg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.pmg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pmg-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.pmg-lightbox-prev {
    left: 20px;
}

.pmg-lightbox-next {
    right: 20px;
}

/* Pagination */
.pmg-pagination-wrapper {
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
}

.pmg-load-more-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 15px 40px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pmg-load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.pmg-load-more-btn:active {
    transform: translateY(0);
}

.pmg-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading Spinner */
.pmg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: #667eea;
    font-size: 16px;
    margin-top: 20px;
}

.pmg-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: pmgSpin 0.8s linear infinite;
}

@keyframes pmgSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .pmg-gallery-container[data-columns="6"] .pmg-masonry-grid,
    .pmg-gallery-container[data-columns="5"] .pmg-masonry-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .pmg-gallery-container[data-columns="4"] .pmg-masonry-grid,
    .pmg-gallery-container[data-columns="6"] .pmg-masonry-grid,
    .pmg-gallery-container[data-columns="5"] .pmg-masonry-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .pmg-masonry-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
    
    .pmg-image-wrapper {
        padding-top: 100%;
    }
    
    .pmg-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .pmg-lightbox-prev {
        left: 10px;
    }
    
    .pmg-lightbox-next {
        right: 10px;
    }
    
    .pmg-lightbox-close {
        width: 40px;
        height: 40px;
        top: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .pmg-masonry-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .pmg-overlay {
        padding: 15px;
    }
    
    .pmg-image-title {
        font-size: 16px;
    }
    
    .pmg-image-caption {
        font-size: 12px;
    }
}

/* Smooth Scroll Behavior */
html {
    scroll-behavior: smooth;
}

/* Accessibility */
.pmg-gallery-item:focus {
    outline: 3px solid #667eea;
    outline-offset: 3px;
}

.pmg-popup-trigger:focus,
.pmg-load-more-btn:focus,
.pmg-lightbox-close:focus,
.pmg-lightbox-nav:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

