/**
 * Video Background Styles
 * 视频背景样式
 * @version 2.0.0
 */

/* 视频容器 */
.video-background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 视频元素 */
.background-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
    opacity: 0;
    display: none;
    transition: opacity 1s ease-in-out;
}

/* 当前播放的视频 */
.background-video.active {
    opacity: 1;
    display: block;
}

/* 视频加载动画 */
.video-background-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 1;
}

.video-background-container.loading::before {
    opacity: 1;
}

/* 视频遮罩（增强内容可读性） */
.video-background-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 2;
}

/* 模糊效果（可选） */
.video-background-container.blur .background-video {
    filter: blur(8px);
}

/* 降低饱和度（可选） */
.video-background-container.desaturate .background-video {
    filter: saturate(0.7);
}

/* 组合效果 */
.video-background-container.blur.desaturate .background-video {
    filter: blur(8px) saturate(0.7);
}

/* 视频控制面板（调试用） */
.video-control-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    color: white;
    font-size: 12px;
    z-index: 9999;
    backdrop-filter: blur(10px);
    display: none; /* 默认隐藏，开发时可显示 */
}

.video-control-panel.show {
    display: block;
}

.video-control-panel h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: bold;
}

.video-control-panel button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    margin: 2px;
    font-size: 11px;
    transition: background 0.3s;
}

.video-control-panel button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.video-control-panel .status {
    margin: 5px 0;
    padding: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.video-control-panel .status.success {
    background: rgba(34, 197, 94, 0.2);
    border-left: 3px solid #22c55e;
}

.video-control-panel .status.error {
    background: rgba(239, 68, 68, 0.2);
    border-left: 3px solid #ef4444;
}

.video-control-panel .status.info {
    background: rgba(59, 130, 246, 0.2);
    border-left: 3px solid #3b82f6;
}

/* 性能指标显示 */
.video-performance-metrics {
    font-size: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.video-performance-metrics div {
    margin: 3px 0;
    display: flex;
    justify-content: space-between;
}

.video-performance-metrics span {
    color: #a0aec0;
}

.video-performance-metrics strong {
    color: white;
}

/* 移动端优化 */
@media (max-width: 768px) {
    /* 移动端视频适配 */
    .background-video {
        min-width: 100%;
        min-height: 100%;
        width: auto;
        height: auto;
    }

    /* 移动端增强遮罩（提高可读性） */
    .video-background-container::after {
        background: rgba(0, 0, 0, 0.4);
    }

    /* 移动端控制面板位置调整 */
    .video-control-panel {
        bottom: 10px;
        right: 10px;
        padding: 10px;
        font-size: 11px;
        max-width: calc(100% - 40px);
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .background-video {
        width: 100%;
        height: auto;
        min-height: 100%;
    }
}

/* 高性能模式（降低视频质量以节省资源） */
.video-background-container.performance-mode .background-video {
    filter: blur(2px);
}

/* 省电模式（暂停视频） */
.video-background-container.power-saving .background-video {
    display: none;
}

/* 暗色主题适配 */
[data-theme="dark"] .video-background-container::after {
    background: rgba(0, 0, 0, 0.5);
}

/* 亮色主题适配 */
[data-theme="light"] .video-background-container::after {
    background: rgba(255, 255, 255, 0.2);
}

/* 视频加载占位符 */
.video-loading-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.video-background-container.loading .video-loading-placeholder {
    opacity: 1;
}

.video-loading-placeholder .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.video-loading-placeholder p {
    font-size: 14px;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 视频错误提示 */
.video-error-message {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
    display: none;
}

.video-error-message.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 无障碍支持 - 减少动画 */
@media (prefers-reduced-motion: reduce) {
    .background-video,
    .video-background-container::before,
    .video-background-container::after {
        transition: none;
    }

    .video-loading-placeholder .spinner {
        animation: none;
        border: 4px solid white;
    }
}

/* 打印模式 - 隐藏视频背景 */
@media print {
    .video-background-container {
        display: none;
    }
}
