/**
 * 媒体查看器样式
 * 包含图片查看器和视频预览样式
 */

/* ============ 图片查看器 ============ */
.image-viewer-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    flex-direction: column;
}

.image-viewer-modal.show {
    display: flex;
}

/* 顶部栏 */
.image-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.5);
}

.image-viewer-counter {
    color: white;
    font-size: 14px;
}

.image-viewer-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 图片容器 */
.image-viewer-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.image-viewer-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#image-viewer-img {
    max-width: 90%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.1s ease-out;
    user-select: none;
    -webkit-user-drag: none;
}

/* 导航按钮 */
.image-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 48px;
    width: 60px;
    height: 80px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    z-index: 10;
}

.image-viewer-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.image-viewer-nav:disabled {
    cursor: not-allowed;
}

.image-viewer-prev {
    left: 10px;
    border-radius: 0 8px 8px 0;
}

.image-viewer-next {
    right: 10px;
    border-radius: 8px 0 0 8px;
}

/* 底部工具栏 */
.image-viewer-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
}

.image-viewer-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 16px;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 40px;
}

.image-viewer-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.image-viewer-zoom-level {
    color: white;
    font-size: 14px;
    min-width: 50px;
    text-align: center;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
    .image-viewer-nav {
        width: 50px;
        height: 60px;
        font-size: 36px;
    }
    
    .image-viewer-prev {
        left: 5px;
    }
    
    .image-viewer-next {
        right: 5px;
    }
    
    .image-viewer-footer {
        gap: 10px;
        padding: 12px 15px;
    }
    
    .image-viewer-btn {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    #image-viewer-img {
        max-width: 95%;
    }
}

/* ============ 视频预览样式 ============ */

/* 视频消息悬停效果 */
.video-message {
    position: relative;
}

.video-message.video-previewing {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
}

.video-message.video-previewing .video-thumbnail {
    border-radius: 6px 6px 0 0;
}

/* 视频预览进度条 */
.video-preview-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.3);
    display: none;
}

.video-preview-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #00a1d6, #00d4ff);
    width: 0%;
    transition: width 0.1s linear;
}

/* 预览时的播放动画 */
.video-previewing .video-thumbnail::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #ff4757;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* 视频播放器弹窗 */
.video-player-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    flex-direction: column;
}

.video-player-modal.show {
    display: flex;
}

.video-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.5);
}

.video-player-title {
    color: white;
    font-size: 16px;
    font-weight: 500;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-player-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.video-player-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.video-player-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#video-player {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    background: #000;
}

/* 移动端视频播放器适配 */
@media screen and (max-width: 768px) {
    .video-player-container {
        padding: 10px;
    }
    
    .video-player-title {
        font-size: 14px;
    }
    
    #video-player {
        width: 100%;
    }
}

/* 视频缩略图播放中指示器 */
.video-message:hover .video-play-overlay {
    transform: translate(-50%, -50%) scale(1.1);
}

/* 优化视频消息在聊天中的显示 */
.video-thumbnail {
    position: relative;
    overflow: hidden;
    background: #1a1a1a;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-thumbnail video {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 200px;
    object-fit: contain;
    background: #000;
}

/* 视频播放按钮 */
.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 5;
}

.video-play-overlay:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}
