/**
 * Mediagrid Lightbox / Gallery Viewer Styles
 */

body.mgb-locked {
    overflow: hidden !important;
    touch-action: none !important;
}

.mgb-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: var(--mgb-overlay-bg, rgba(8, 9, 13, 0.94));
    backdrop-filter: blur(var(--mgb-overlay-blur, 14px));
    -webkit-backdrop-filter: blur(var(--mgb-overlay-blur, 14px));
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    user-select: none;
    outline: none;
}

.mgb-overlay.mgb-open {
    opacity: 1;
    visibility: visible;
}

/* Верхняя панель */
.mgb-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
}

.mgb-counter {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    padding: 0;
    border: none;
    letter-spacing: 0.5px;
}

.mgb-title {
    font-size: 15px;
    font-weight: 500;
    color: #ffffff;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.mgb-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mgb-btn-close {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
    padding: 0;
}

.mgb-btn-close:hover {
    background: transparent;
    color: #ffffff;
    transform: scale(1.15);
}

/* Сцена просмотра */
.mgb-stage {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 40px 20px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.mgb-content {
    max-width: 94vw;
    max-height: 86vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.24s ease;
}

.mgb-media-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 92vw;
    max-height: 80vh;
    border-radius: 8px;
    overflow: hidden;
    user-select: none;
}

.mgb-triggers {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 8;
    pointer-events: auto;
}

.mgb-trigger {
    flex: 1;
    height: 100%;
    cursor: pointer;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
}

.mgb-image {
    max-width: 92vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: none;
    display: block;
    user-select: none;
}

/* Видеоплеер */
.mgb-video-wrapper {
    width: min(94vw, 1080px);
    aspect-ratio: 16 / 9;
    background: #000000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: none;
    position: relative;
}

.mgb-video-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 1;
}

.mgb-video-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #000000;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    z-index: 2;
    pointer-events: none;
}

.mgb-video-loader .mgb-spinner {
    display: block;
    position: static;
    transform: none;
}

/* Стрелки навигации (без фона и бордера) */
.mgb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
    z-index: 20;
}

.mgb-nav:hover {
    background: transparent;
    border: none;
    color: #ffffff;
    transform: translateY(-50%) scale(1.18);
}

.mgb-prev {
    left: 16px;
}

.mgb-next {
    right: 16px;
}

.mgb-nav.mgb-disabled {
    opacity: 0.15;
    pointer-events: none;
}

/* Нижняя панель с миниатюрами */
.mgb-bottombar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    padding: 8px 20px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 100%);
    box-sizing: border-box;
}

.mgb-thumbs-track {
    display: flex;
    gap: 8px;
    max-width: 92vw;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.mgb-thumbs-track::-webkit-scrollbar {
    display: none;
}

.mgb-thumb-item {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: #14151b;
    padding: 0;
    margin: 0;
    outline: none;
    display: block;
}

.mgb-thumb-item:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

.mgb-thumb-item.mgb-thumb-active {
    opacity: 1;
    border-color: #3b82f6;
    transform: scale(1.08);
    box-shadow: none;
}

.mgb-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mgb-thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-size: 11px;
}

/* Спиннер загрузки */
.mgb-spinner {
    position: absolute;
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #0077ff;
    border-radius: 50%;
    animation: mgb-spin 0.8s linear infinite;
    display: none;
}

.mgb-loading .mgb-spinner {
    display: block;
}

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

/* Мобильная адаптивность */
@media (max-width: 640px) {
    .mgb-topbar {
        padding: 0 12px;
        height: 50px;
    }
    .mgb-stage {
        padding: 50px 10px 76px;
    }
    .mgb-nav {
        width: 40px;
        height: 40px;
    }
    .mgb-prev { left: 4px; }
    .mgb-next { right: 4px; }
    .mgb-title { display: none; }
    .mgb-thumb-item {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
}
