/* ═══════════════════════════════════════════════════════════════════ */
/* RUNACY — VIEWER (полноэкранный просмотр медиа) */
/* ═══════════════════════════════════════════════════════════════════ */

.rv-viewer {
    position: fixed;
    inset: 0;
    z-index: 300;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    background: var(--overlay);
}

.rv-viewer.rv-hidden { display: none !important; }

.rv-viewer.rv-hide-cursor { cursor: none; }

/* ─── Фон ─── */

.rv-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* ─── Сцена (медиа) ─── */

.rv-stage {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.rv-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Медиа занимает всю область — панели плавают поверх */
    padding: 0;
    will-change: transform;
    pointer-events: none;
}

.rv-slide.rv-fade {
    animation: rv-fade-in 0.15s ease-out;
}

@keyframes rv-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.rv-slide > img,
.rv-slide > video {
    max-width: 100%;
    max-height: 100%;
    display: block;
    border-radius: 0;
    object-fit: contain;
    pointer-events: auto;
    transform-origin: center center;
    transition: transform 0.2s ease-out;
}

/* Видео заполняет контейнер по максимуму, сохраняя пропорции.
   Если видео меньше окна — оно растянется до размеров окна. */
.rv-slide > video {
    width: 100%;
    height: 100%;
}

/* Картинки оставляем в натуральном размере, но не больше экрана.
   Маленькие превью не будут растягиваться на весь монитор. */
.rv-slide > img {
    width: auto;
    height: auto;
}

.rv-slide.rv-no-transition > img {
    transition: none;
}

.rv-slide .rv-file-view {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 60px 80px;
    text-align: center;
    color: var(--fg-dim);
    pointer-events: auto;
    margin: 40px;
}

.rv-slide .rv-file-view .icon { font-size: 84px; margin-bottom: 16px; }
.rv-slide .rv-file-view .icon > .ico { width: 84px; height: 84px; }
.rv-slide .rv-file-view .name { color: var(--fg); font-size: 16px; margin-bottom: 8px; }
.rv-slide .rv-file-view .size { font-size: 13px; }

/* ─── Оверлей (панели поверх медиа) ─── */

.rv-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.25s ease-out;
}

.rv-overlay > * {
    pointer-events: auto;
}

.rv-viewer.rv-hidden-overlay .rv-overlay {
    opacity: 0;
    pointer-events: none;
}

.rv-viewer.rv-hidden-overlay .rv-overlay > * {
    pointer-events: none;
}

/* ─── Верхняя панель ─── */

.rv-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
    color: white;
}

.rv-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 12px;
}

.rv-top-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ─── Кнопки ─── */

.rv-btn {
    background: rgba(0, 0, 0, 0.55);
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0;
    line-height: 1;
    font-family: inherit;
    flex-shrink: 0;
}

.rv-btn:hover { background: rgba(0, 0, 0, 0.85); }
.rv-btn:active { transform: scale(0.94); }
.rv-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.rv-btn.rv-btn-danger { color: #ff8888; }
.rv-btn.rv-btn-danger:hover { background: rgba(200, 40, 40, 0.85); color: white; }

.rv-btn.rv-active { color: #ffc940; }

/* ─── Стрелки ─── */

.rv-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    font-size: 32px;
    line-height: 1;
    padding-bottom: 6px;
}

.rv-prev { left: 20px; }
.rv-next { right: 20px; }

.rv-viewer.rv-single .rv-prev,
.rv-viewer.rv-single .rv-next {
    display: none;
}

/* ─── Нижняя панель ─── */

.rv-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 14px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    pointer-events: none;
}

.rv-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    pointer-events: auto;
}

/* ─── Видео-контролы ─── */

.rv-video-bar {
    position: absolute;
    bottom: 78px;
    left: 0;
    right: 0;
    padding: 0 30px;
    display: flex;
    align-items: center;
    gap: 14px;
    pointer-events: auto;
}

.rv-video-bar.rv-hidden { display: none; }

.rv-video-play {
    width: 40px;
    height: 40px;
    font-size: 16px;
}

.rv-video-seek {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    position: relative;
}

.rv-video-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.rv-video-seek::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.rv-video-time {
    color: white;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    min-width: 100px;
    text-align: right;
    opacity: 0.9;
}

/* ─── Инфо-панель ─── */

.rv-info-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    width: 340px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    padding: 18px 20px;
    color: var(--fg);
    font-size: 13px;
    pointer-events: auto;
    z-index: 6;
}

.rv-info-panel.rv-hidden { display: none; }

.rv-info-panel h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    word-break: break-word;
    padding-right: 24px;
}

.rv-info-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--fg-dim);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 3px;
}

.rv-info-close:hover { background: var(--bg-3); color: var(--fg); }

.rv-info-row {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

.rv-info-row:last-child { border-bottom: none; }

.rv-info-label {
    color: var(--fg-dim);
    min-width: 96px;
    flex-shrink: 0;
}

.rv-info-value {
    color: var(--fg);
    word-break: break-word;
    flex: 1;
}

.rv-info-value a {
    color: var(--accent);
    text-decoration: none;
}

.rv-info-value a:hover { text-decoration: underline; }

/* ─── Мобильные ─── */

@media (max-width: 768px) {
    .rv-nav {
        width: 42px;
        height: 42px;
        font-size: 26px;
        padding-bottom: 4px;
    }

    .rv-prev { left: 8px; }
    .rv-next { right: 8px; }

    .rv-top { padding: 10px 12px; }
    .rv-title { font-size: 12px; }

    .rv-btn { width: 38px; height: 38px; font-size: 16px; }

    .rv-bottom { padding: 10px 12px; }

    .rv-video-bar { padding: 0 12px; bottom: 70px; gap: 8px; }
    .rv-video-time { min-width: 80px; font-size: 11px; }

    .rv-info-panel {
        top: auto;
        bottom: 80px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: 60vh;
    }
}