/* ============================================
   MoshpitGallery — Frontend Styles
   ============================================ */

/* Thumbnail Grid */
.mg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-width: 960px;
    margin: 0 auto;
}

.mg-gallery-grid[data-columns="2"] { grid-template-columns: repeat(2, 1fr); }
.mg-gallery-grid[data-columns="4"] { grid-template-columns: repeat(4, 1fr); }

.mg-gallery-item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 3 / 2;
    background: #1a1a1a;
    cursor: pointer;
}

.mg-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.mg-gallery-item:hover img {
    transform: scale(1.05);
    opacity: 0.85;
}

/* Image Protection Overlay */
.mg-gallery-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Pagination */
.mg-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 20px auto;
    max-width: 960px;
}

.mg-pagination button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 14px;
    transition: background 0.2s;
}

.mg-pagination button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mg-pagination button.active {
    background: rgba(255, 255, 255, 0.4);
    font-weight: bold;
}

.mg-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Loading Spinner */
.mg-loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.mg-loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mg-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}

@keyframes mg-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Lightbox
   ============================================ */
.mg-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mg-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mg-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mg-lightbox-content img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.mg-lightbox-caption {
    color: #ccc;
    text-align: center;
    padding: 12px 20px;
    font-size: 14px;
    max-width: 600px;
    line-height: 1.5;
}

.mg-lightbox-close {
    position: fixed;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    z-index: 100001;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.mg-lightbox-close:hover { opacity: 1; }

.mg-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    font-size: 48px;
    cursor: pointer;
    z-index: 100001;
    padding: 20px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.mg-lightbox-nav:hover { opacity: 1; }
.mg-lightbox-prev { left: 10px; }
.mg-lightbox-next { right: 10px; }

/* ============================================
   Slideshow
   ============================================ */
.mg-slideshow {
    position: relative;
    max-width: 800px;
    margin: 0 auto 30px;
    overflow: hidden;
}

.mg-slideshow-track {
    display: flex;
    transition: transform 0.4s ease;
}

.mg-slideshow-slide {
    min-width: 100%;
    position: relative;
    cursor: pointer;
}

.mg-slideshow-slide img {
    width: 100%;
    height: auto;
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.mg-slideshow-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 15px 12px;
    z-index: 10;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.mg-slideshow-nav:hover { opacity: 1; }
.mg-slideshow-prev { left: 0; }
.mg-slideshow-next { right: 0; }

/* Gallery Title (Album-Ansicht) */
.mg-gallery-title {
    text-align: center;
    margin: 30px 0 15px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .mg-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }

    .mg-lightbox-nav { font-size: 32px; padding: 10px; }
    .mg-lightbox-prev { left: 0; }
    .mg-lightbox-next { right: 0; }
}

@media (max-width: 480px) {
    .mg-gallery-grid {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}
