/* 影片預覽模態框樣式 - 參考 post-detail.css 的設計 */

/* ===== 全版模態框佈局 ===== */
.video-preview-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000; /* 黑色背景，適合影片觀看 */
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: auto;
    isolation: isolate;
}

.video-preview-modal-content {
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: relative;
    z-index: 10001;
    pointer-events: auto;
}

/* ===== 頁面佈局 ===== */
.video-preview-modal-content .video-preview-container {
    max-width: 100%;
    margin: 0;
    background: #000000;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 模態框標題 */
.video-preview-page-header {
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10002;
    padding: 1rem;
    flex-shrink: 0;
    pointer-events: auto;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.video-preview-modal-overlay .title-section h1 {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.header-spacer {
    width: 40px; /* 與返回按鈕同寬，保持對稱 */
}

/* ===== 影片播放器區域 ===== */
.video-preview-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: hidden;
}

.video-preview-content {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.video-player-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.preview-video {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    background: #000;
}

/* ===== 自定義影片控制項 ===== */
.custom-video-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    z-index: 1;
    background: transparent;
}

.controls-overlay {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.custom-play-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 107, 107, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.custom-play-btn:hover {
    background: rgba(255, 107, 107, 1);
    transform: scale(1.1);
}

.controls-bar {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    pointer-events: auto;
}

.video-preview-modal-overlay .control-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-preview-modal-overlay .control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.time-display {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 80px;
    text-align: center;
}

.time-separator {
    margin: 0 2px;
    opacity: 0.7;
}

.progress-container {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-bar {
    width: 100%;
    height: 100%;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: #ff6b6b;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s ease;
}

/* 控制項顯示/隱藏 */
.custom-video-controls.hidden .controls-overlay {
    opacity: 0;
    pointer-events: none;
}

.custom-video-controls.hidden .controls-bar {
    opacity: 0;
    pointer-events: none;
}

/* 當影片播放時，隱藏大播放按鈕 */
.custom-video-controls.playing .controls-overlay {
    opacity: 0;
    pointer-events: none;
}

/* 當影片暫停時，顯示大播放按鈕 */
.custom-video-controls.paused .controls-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .custom-play-btn {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .video-preview-modal-overlay .control-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .controls-bar {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .time-display {
        font-size: 0.8rem;
        min-width: 70px;
    }
}

/* 確保影片控制項容器正確顯示 */
.preview-video::-webkit-media-controls-overlay-enclosure {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border-radius: 8px !important;
    padding: 8px !important;
}

/* 修正播放按鈕的圖標 */
.preview-video::-webkit-media-controls-play-button::before {
    content: '' !important;
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 12px solid white !important;
    border-top: 8px solid transparent !important;
    border-bottom: 8px solid transparent !important;
    margin: auto !important;
}

.preview-video::-webkit-media-controls-pause-button::before {
    content: '' !important;
    display: block !important;
    width: 4px !important;
    height: 16px !important;
    background: white !important;
    margin: 0 2px !important;
    border-radius: 1px !important;
}

.preview-video::-webkit-media-controls-pause-button::after {
    content: '' !important;
    display: block !important;
    width: 4px !important;
    height: 16px !important;
    background: white !important;
    margin: 0 2px !important;
    border-radius: 1px !important;
    position: absolute !important;
    right: 50% !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* ===== 影片資訊區域 ===== */
.video-info-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.video-meta {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.video-filename {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
}

.video-filename i {
    color: #ff6b6b;
    font-size: 1.2rem;
}

.video-details {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.video-duration,
.video-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.video-duration i,
.video-size i {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

/* ===== 響應式設計 ===== */
@media (max-width: 768px) {
    .video-preview-wrapper {
        padding: 1rem;
    }
    
    .video-preview-content {
        gap: 1.5rem;
    }
    
    .video-info-section {
        padding: 1rem;
    }
    
    .video-details {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .preview-video {
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .video-preview-page-header {
        padding: 0.75rem;
    }
    
    .video-preview-wrapper {
        padding: 0.75rem;
    }
    
    .video-preview-content {
        gap: 1rem;
    }
    
    .video-info-section {
        padding: 0.75rem;
    }
    
    .preview-video {
        max-height: 50vh;
    }
}

/* ===== 載入狀態 ===== */
.video-preview-wrapper.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-preview-wrapper.loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== 確保模態框完全覆蓋 ===== */
.video-preview-modal-overlay {
    contain: layout style paint;
    transform: translateZ(0);
}

.video-preview-modal-overlay * {
    pointer-events: auto;
}

body.video-modal-open {
    overflow: hidden;
}

/* ===== 影片控制項樣式優化 ===== */
.preview-video::-webkit-media-controls-panel {
    background: transparent;
}

.preview-video::-webkit-media-controls-play-button,
.preview-video::-webkit-media-controls-pause-button {
    background: rgba(255, 107, 107, 0.9) !important;
    border-radius: 50% !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    position: relative !important;
    z-index: 10 !important;
}

.preview-video::-webkit-media-controls-play-button:hover,
.preview-video::-webkit-media-controls-pause-button:hover {
    background: rgba(255, 107, 107, 1) !important;
    transform: scale(1.05);
}

.preview-video::-webkit-media-controls-timeline {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.preview-video::-webkit-media-controls-current-time-display,
.preview-video::-webkit-media-controls-time-remaining-display {
    color: white;
    font-weight: 500;
}

/* 修正播放按鈕的跑版問題 */
.preview-video::-webkit-media-controls {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.preview-video::-webkit-media-controls-enclosure {
    background: transparent !important;
    border-radius: 8px !important;
    padding: 8px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* 確保播放按鈕不會被其他元素覆蓋 */
.preview-video::-webkit-media-controls-play-button {
    width: 48px !important;
    height: 48px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

/* 修正時間顯示 */
.preview-video::-webkit-media-controls-current-time-display,
.preview-video::-webkit-media-controls-time-remaining-display {
    font-size: 14px !important;
    line-height: 1 !important;
    margin: 0 4px !important;
}

/* 修正進度條 */
.preview-video::-webkit-media-controls-timeline {
    flex: 1 !important;
    height: 4px !important;
    margin: 0 8px !important;
}

/* 修正音量和其他控制項 */
.preview-video::-webkit-media-controls-volume-slider,
.preview-video::-webkit-media-controls-mute-button,
.preview-video::-webkit-media-controls-fullscreen-button {
    margin: 0 4px !important;
}
