/* ================================== */
/*    МОДАЛКА ПРЕДПРОСМОТРА ФАЙЛА     */
/* ================================== */

.file-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview-container {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    height: auto;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.file-preview-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-base);
    backdrop-filter: blur(8px);
    transition: background var(--transition-fast);
}

.file-preview-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.file-preview-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 300px;
    margin-bottom: 24px;
    position: relative;
}

.file-preview-video {
    max-width: 100%;
    max-height: calc(90vh - 160px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: block;
}

.file-preview-image {
    max-width: 100%;
    max-height: calc(90vh - 160px);
    border-radius: var(--radius-md);
    object-fit: contain;
}

.file-preview-video-wrapper {
    position: relative;
    display: inline-block;
}

.file-preview-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    font-size: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: var(--z-base);
}

.file-preview-play-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.file-preview-panel {
    width: 80%;
    max-width: 600px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-md);
}

.file-preview-caption {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 15px;
    padding: 10px 0;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 80px;
    overflow-y: auto;
}

.file-preview-caption:focus {
    outline: none;
}

.file-preview-send-btn {
    background: var(--primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
    flex-shrink: 0;
}

.file-preview-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.file-preview-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.file-preview-error {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 68, 68, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    white-space: nowrap;
}

/* ================================== */
/*   ЭЛЕМЕНТЫ УПРАВЛЕНИЯ ВИДЕО       */
/* ================================== */

.file-preview-video-controls {
    width: 80%;
    max-width: 600px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    padding: 12px 16px;
}

.video-progress-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.video-progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.video-progress-slider::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

.video-time-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-family: monospace;
}

.trim-badge {
    background: var(--primary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
}

/* ================================== */
/*   ТАЙМЛАЙН С КАДРАМИ (rc-slider)   */
/* ================================== */

.video-timeline-wrapper {
    width: 100%;
    position: relative;
}

.video-timeline-frames {
    display: flex;
    width: 100%;
    background: #1a1a1a;
    border-radius: var(--radius-md);
    cursor: pointer;
    height: 48px;
    overflow: hidden;
    margin-bottom: 12px;
    user-select: none;
    -webkit-user-select: none;
}

.video-timeline-frame {
    flex: 1 1 0;
    height: 48px;
}

.video-timeline-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.video-timeline-placeholder {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    padding: 12px;
}

/* Слайдер обрезки (rc-slider) */
.video-trim-slider {
    margin-top: 8px;
    padding: 0 4px;
}

.video-trim-slider .rc-slider-rail {
    background-color: rgba(255, 255, 255, 0.3);
    height: 4px;
    border-radius: 2px;
}

.video-trim-slider .rc-slider-track {
    background-color: var(--primary);
    height: 4px;
}

.video-trim-slider .rc-slider-handle {
    background-color: var(--primary);
    border: 2px solid white;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    opacity: 1;
    box-shadow: var(--shadow-sm);
}

.video-trim-slider .rc-slider-handle:active {
    box-shadow: 0 0 0 2px var(--primary-glow);
    transform: scale(1.1);
}

.video-trim-slider .rc-slider-handle-dragging {
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ================================== */
/* МОДАЛКА ПРЕДПРОСМОТРА (MEDIA PREVIEW) */
/* ================================== */
.media-preview-overlay {
    z-index: var(--z-max) !important;
}

.media-preview-modal {
    width: auto;
    max-width: 90vw;
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    border-radius: var(--radius-xl);
    overflow: hidden;
    padding: 0;
}

.media-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.media-preview-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.media-preview-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    transition: color var(--transition-fast);
}

.media-preview-close:hover {
    color: var(--text);
}

.media-preview-body {
    padding: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.media-preview-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

.media-preview-body .custom-video-player {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
}

.media-preview-body .custom-video-player .video-controls {
    backdrop-filter: blur(12px);
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .file-preview-container {
        width: 95vw;
        padding: 10px 0;
    }
    .file-preview-close {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
    .file-preview-panel,
    .file-preview-video-controls {
        width: 95%;
    }
    .file-preview-play-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    .video-timeline-frames {
        height: 36px;
    }
    .video-timeline-frame {
        height: 36px;
    }
    .media-preview-modal {
        max-width: 100vw;
        border-radius: 0;
    }
    .media-preview-header {
        padding: 12px 16px;
    }
    .media-preview-title {
        font-size: 16px;
    }
}

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .file-preview-close,
    .file-preview-play-btn,
    .file-preview-send-btn,
    .video-progress-slider::-webkit-slider-thumb:active {
        transition: none;
    }
    .file-preview-play-btn:hover {
        transform: translate(-50%, -50%) scale(1);
    }
    .file-preview-send-btn:hover:not(:disabled) {
        transform: none;
    }
}