/* ================================== */
/* MEDIA PREVIEW MODAL (кастомная версия) */
/* ================================== */

.media-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.1s ease;
    will-change: opacity;
}

.media-preview-overlay.light-theme {
    background: rgba(255, 255, 255, 0.7);
}

.modal-custom-container {
    transition: transform 0.1s ease, opacity 0.1s ease;
    will-change: transform, opacity;
    background: transparent !important;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    max-width: 100%;
    max-height: 100%;
    position: relative;
    padding: 0;
}

.media-preview-modal {
    width: auto;
    max-width: 90%;
    padding: 0;
    overflow: hidden;
}

/* Верхняя панель – только кнопка закрытия */
.media-preview-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 16px 24px;
    flex-shrink: 0;
    background: transparent;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.media-preview-header > * {
    pointer-events: auto;
}

/* Кнопка закрытия – единый стиль для обеих тем */
.media-preview-close {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    /* добавляем лёгкую тень для контраста на светлом фоне */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.media-preview-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Светлая тема – делаем фон чуть темнее, цвет остаётся белым */
.light-theme .media-preview-close {
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.light-theme .media-preview-close:hover {
    background: rgba(0, 0, 0, 0.55);
}

/* Тело – идеальное центрирование */
.media-preview-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent !important;
    overflow: auto;
    position: relative;
}

/* Контейнер с медиа – небольшое смещение вверх для компенсации верхней панели */
.media-preview-body > div {
    transform: translateY(-5%);
}

.media-preview-body img,
.media-preview-body video {
    max-width: 90vw;
    max-height: 70vh;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* Нижняя панель с миниатюрами – абсолютно внизу */
.media-preview-thumbnails {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    z-index: 5;
    flex-shrink: 0;
}

.light-theme .media-preview-thumbnails {
    background: linear-gradient(to top, rgba(255, 255, 255, 0.9) 0%, transparent 100%);
}

.thumbnail-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    align-items: center;
}

.light-theme .thumbnail-strip {
    scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

.thumbnail-item {
    flex: 0 0 auto;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border 0.2s, transform 0.2s;
    position: relative;
}

.thumbnail-item.active {
    border-color: #4a9eff;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(74, 158, 255, 0.5);
}

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

.thumbnail-item .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 24px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Кнопки навигации – абсолютно по центру */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.light-theme .nav-btn {
    background: rgba(0, 0, 0, 0.3);
}

.light-theme .nav-btn:hover {
    background: rgba(0, 0, 0, 0.5);
}

.nav-btn.prev {
    left: 20px;
}

.nav-btn.next {
    right: 20px;
}

@media (prefers-reduced-motion: reduce) {
    .media-preview-overlay,
    .modal-custom-container,
    .media-preview-close,
    .thumbnail-item,
    .nav-btn {
        transition: none !important;
    }
}