/**
 * Multi Mode Gallery - Frontend Styles
 */

/* Base Gallery Styles */
.mmg-gallery {
    position: relative;
    width: 100%;
    margin: 20px 0;
}

.mmg-gallery * {
    box-sizing: border-box;
}

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

.mmg-gallery a {
    display: block;
    text-decoration: none;
    width: 100%;
    height: 100%;
}

/* Grid Mode */
.mmg-grid {
    display: grid;
    width: 100%;
}

.mmg-grid-item {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    aspect-ratio: 1;
}

.mmg-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Pinterest/Masonry Mode */
.mmg-pinterest {
    position: relative;
    width: 100%;
    min-height: 300px;
}

.mmg-pinterest-item {
    position: absolute;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.mmg-pinterest-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.mmg-pinterest-item img {
    width: 100%;
    height: auto;
    display: block;
}

/* Carousel Mode - Splide Styles */
.mmg-carousel .splide__slide {
    border-radius: 8px;
    overflow: hidden;
}

.mmg-carousel-item {
    width: 100%;
    height: 300px;
    position: relative;
}

.mmg-carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Slideshow Mode - Splide Styles */
.mmg-slideshow {
    max-width: 100%;
    margin: 0 auto;
}

.mmg-slideshow .splide__slide {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 400px;
}

.mmg-slideshow-item {
    width: 100%;
    height: 100%;
}

.mmg-slideshow-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Mosaic Mode */
.mmg-mosaic {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 150px;
    width: 100%;
}

.mmg-mosaic-item {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 8px;
}

.mmg-mosaic-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Justified Mode */
.mmg-justified {
    position: relative;
    width: 100%;
    min-height: 200px;
}

.mmg-justified > div {
    position: absolute;
    overflow: hidden;
    background: #f5f5f5;
}

.mmg-justified img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Tiles Mode */
.mmg-tiles {
    position: relative;
    width: 100%;
    min-height: 300px;
}

.mmg-tiles-item {
    position: absolute;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.mmg-tiles-item:hover {
    z-index: 10;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.mmg-tiles-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Caption Styles */
.mmg-caption,
.caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    font-size: 14px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mmg-gallery [class*="-item"]:hover .mmg-caption,
.mmg-gallery [class*="-item"]:hover .caption {
    transform: translateY(0);
}

/* Hover Effects */
.mmg-gallery [class*="-item"] {
    cursor: pointer;
    transition: all 0.3s ease;
}

.mmg-gallery [class*="-item"]:hover img {
    transform: scale(1.05);
}

/* Splide Custom Styles */
.splide__arrows {
    position: absolute;
    top: 50%;
    width: 100%;
}

.splide__arrow {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.splide__arrow:hover {
    opacity: 1;
}

.splide__arrow svg {
    fill: #333;
}

.splide__pagination {
    bottom: 1em;
}

.splide__pagination__page {
    background: rgba(255, 255, 255, 0.5);
    width: 10px;
    height: 10px;
    margin: 0 4px;
    transition: all 0.3s;
}

.splide__pagination__page.is-active {
    background: #fff;
    transform: scale(1.2);
}

/* Simple Media Popup */
.mmg-media-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mmg-media-popup.active {
    opacity: 1;
}

.mmg-media-popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.mmg-media-popup-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.mmg-media-popup-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.mmg-media-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 60px; /* Space for toggle button */
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.mmg-media-caption.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.mmg-media-caption-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.mmg-media-caption-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.mmg-media-popup-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 10px;
    transition: transform 0.3s ease;
}

.mmg-media-popup-close:hover {
    transform: scale(1.2);
}

.mmg-media-popup-close svg {
    width: 30px;
    height: 30px;
}

/* Custom Lightbox with Glass Effect */
.mmg-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mmg-lightbox-overlay.active {
    opacity: 1;
}

.mmg-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mmg-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mmg-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
}

/* Lightbox Caption */
.mmg-lightbox-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 80px; /* Space for counter and toggle */
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    max-width: calc(100% - 120px);
    max-height: 120px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.mmg-lightbox-caption.empty {
    display: none;
}

.mmg-lightbox-caption.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

/* Caption Toggle Button - Bottom Right Corner */
.mmg-lightbox-caption-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    z-index: 10;
}

.mmg-lightbox-caption-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Loading Animation */
.mmg-lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mmg-lightbox-loading.active {
    opacity: 1;
}

.mmg-spinner {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}

.mmg-spinner div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 64px;
    height: 64px;
    margin: 8px;
    border: 8px solid #fff;
    border-radius: 50%;
    animation: mmg-spinner 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: #fff transparent transparent transparent;
}

.mmg-spinner div:nth-child(1) {
    animation-delay: -0.45s;
}

.mmg-spinner div:nth-child(2) {
    animation-delay: -0.3s;
}

.mmg-spinner div:nth-child(3) {
    animation-delay: -0.15s;
}

@keyframes mmg-spinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.mmg-lightbox-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.mmg-lightbox-nav button {
    pointer-events: all;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.mmg-lightbox-nav button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.mmg-lightbox-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mmg-lightbox-nav button svg {
    width: 24px;
    height: 24px;
}

.mmg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.mmg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg) scale(1.1);
}

.mmg-lightbox-close svg {
    width: 20px;
    height: 20px;
}

.mmg-lightbox-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .mmg-media-popup-close {
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        padding: 8px;
    }
    
    .mmg-media-caption {
        font-size: 13px;
        padding: 10px 14px;
        bottom: 15px;
        left: 15px;
        right: 55px;
        max-height: 100px;
    }
    
    .mmg-media-caption-toggle,
    .mmg-lightbox-caption-toggle {
        bottom: 15px;
        right: 15px;
        width: 32px;
        height: 32px;
    }
    
    .mmg-lightbox-caption {
        bottom: 15px;
        left: 15px;
        right: 60px;
        font-size: 13px;
        padding: 10px 14px;
        max-height: 100px;
    }
    
    .mmg-lightbox-counter {
        top: 10px;
        left: 10px;
        font-size: 12px;
        padding: 5px 10px;
    }
    
    .mmg-lightbox-nav {
        padding: 0 10px;
    }
    
    .mmg-lightbox-nav button {
        width: 40px;
        height: 40px;
    }
    
    .mmg-lightbox-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
    }
    
    .mmg-lightbox-content img {
        border-radius: 0;
    }
    
    .mmg-spinner {
        width: 60px;
        height: 60px;
    }
    
    .mmg-spinner div {
        width: 48px;
        height: 48px;
        margin: 6px;
        border-width: 6px;
    }
}

/* Loading State */
.mmg-gallery.loading {
    opacity: 0.5;
    pointer-events: none;
}

.mmg-gallery.loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
}

/* Responsive Styles */
@media (max-width: 1200px) {
    .mmg-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    }
    
    .mmg-mosaic {
        grid-template-columns: repeat(5, 1fr);
        grid-auto-rows: 140px;
    }
}

@media (max-width: 1024px) {
    .mmg-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .mmg-mosaic {
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: 120px;
    }
    
    .mmg-tiles-item {
        border-radius: 6px;
    }
}

@media (max-width: 768px) {
    .mmg-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .mmg-mosaic {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 100px;
    }
    
    .mmg-slideshow .splide__slide {
        min-height: 300px;
    }
    
    .mmg-carousel-item {
        height: 200px;
    }
    
    /* Pinterest responsive columns handled by JS */
    
    /* Justified - smaller target height on mobile */
    .mmg-justified {
        /* JS will adjust row height */
    }
    
    /* Tiles - simpler patterns on mobile */
    .mmg-tiles {
        /* JS will adjust layout */
    }
}

@media (max-width: 480px) {
    .mmg-grid {
        grid-template-columns: 1fr !important;
    }
    
    .mmg-grid-item {
        aspect-ratio: 16/9; /* Wider aspect on mobile */
    }
    
    .mmg-mosaic {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 100px;
    }
    
    .mmg-slideshow .splide__slide {
        min-height: 200px;
    }
    
    .mmg-pinterest-item,
    .mmg-tiles-item {
        border-radius: 4px;
    }
    
    /* Smaller gaps on mobile */
    .mmg-gallery[data-gap="10"] > * {
        gap: 5px !important;
    }
    
    .mmg-gallery[data-gap="20"] > * {
        gap: 10px !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    .mmg-gallery [class*="-item"]:hover img {
        transform: none;
    }
    
    /* Show captions by default on touch devices */
    .mmg-caption,
    .caption {
        transform: translateY(0);
        background: rgba(0, 0, 0, 0.6);
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Print Styles */
@media print {
    .splide__arrows,
    .splide__pagination {
        display: none !important;
    }
}