/* Video Player Styles */
.custom-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s;
}

.custom-popup-overlay.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.custom-popup-box {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 10px 50px rgba(0,0,0,.9);
}

#bsvPopupVideo {
    display: block;
    cursor: pointer;
    border-radius: 12px;
}

.modern-player {
    position: relative;
    width: 100%;
    height: 100%;
}

.modern-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    padding: 0 24px;
    background: linear-gradient(180deg,transparent 0%,rgba(0,0,0,.7) 50%,rgba(0,0,0,.95) 100%);
    display: flex;
    align-items: center;
    gap: 15px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
    z-index: 20;
    border-radius: 0 0 12px 12px;
}

.custom-popup-box:hover .modern-controls,
.custom-popup-box.mouse-moving .modern-controls,
.modern-controls.active {
    opacity: 1;
    pointer-events: auto;
}

.modern-btn {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,.1);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modern-btn:hover {
    background: rgba(255,255,255,.2);
    transform: translateY(-2px);
}

.modern-btn svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.youtube-progress-container {
    flex-grow: 1;
    height: 4px;
    background: rgba(255,255,255,.2);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: height .2s;
    min-width: 60px;
}

.youtube-progress-container:hover {
    height: 6px;
}

.youtube-progress-bar {
    height: 100%;
    width: 0%;
    background: #f00;
    border-radius: 2px;
}

.youtube-progress-bar::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: #f00;
    border-radius: 50%;
    opacity: 0;
    transition: opacity .2s;
}

.youtube-progress-container:hover .youtube-progress-bar::after {
    opacity: 1;
}

.modern-time {
    min-width: 120px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    color: rgba(255,255,255,.9);
    flex-shrink: 0;
}

.speed-control {
    position: relative;
}

.speed-btn {
    width: auto;
    padding: 0 16px;
    font-size: 14px;
    color: #fff;
}

.speed-options {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(28,28,28,.95);
    border-radius: 8px;
    padding: 8px;
    min-width: 100px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all .3s;
    backdrop-filter: blur(10px);
    z-index: 30;
}

.speed-control:hover .speed-options {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.speed-option {
    padding: 8px 16px;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    transition: background .2s;
    text-align: center;
}

.speed-option:hover {
    background: rgba(255,255,255,.1);
}

.speed-option.active {
    color: #f00;
}

.custom-popup-box:fullscreen,
.custom-popup-box:-webkit-full-screen {
    border-radius: 0;
    width: 100vw!important;
    height: 100vh!important;
    background: #000;
    display: flex!important;
    justify-content: center!important;
    align-items: center!important;
}

.custom-popup-box:fullscreen video,
.custom-popup-box:-webkit-full-screen video {
    width: 100%!important;
    height: 100%!important;
    object-fit: contain!important;
}

.custom-popup-box:fullscreen .modern-player,
.custom-popup-box:-webkit-full-screen .modern-player {
    width: 100%!important;
    height: 100%!important;
    display: flex!important;
    justify-content: center!important;
    align-items: center!important;
}

.custom-popup-box:fullscreen .modern-controls,
.custom-popup-box:-webkit-full-screen .modern-controls {
    opacity: 0!important;
    pointer-events: none!important;
    background: linear-gradient(180deg,transparent 0%,rgba(0,0,0,.8) 50%,rgba(0,0,0,.95) 100%)!important;
}

.custom-popup-box:fullscreen.mouse-moving .modern-controls,
.custom-popup-box:-webkit-full-screen.mouse-moving .modern-controls {
    opacity: 1!important;
    pointer-events: auto!important;
}

.custom-popup-box:fullscreen .close-btn,
.custom-popup-box:-webkit-full-screen .close-btn {
    display: none!important;
}

.video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,.1);
    border-top: 4px solid #f00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
}

.video-loading.active {
    opacity: 1;
}

@keyframes spin {
    0% { transform: translate(-50%,-50%) rotate(0); }
    100% { transform: translate(-50%,-50%) rotate(360deg); }
}

/* Close button */
.close-btn {
    position: absolute;
    top: -60px;
    right: -10px;
    width: 56px;
    height: 56px;
    background: transparent !important;
    color: #fff !important;
    border: none !important;
    outline: none !important;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover,
.close-btn:focus,
.close-btn:active {
    background: transparent !important;
    color: #fff !important;
    transform: none !important;
}

/* Control style */
.youtube-controls {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 16px;
}

.youtube-left-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.youtube-right-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ====== Required modifications ====== */

/* Update progress bar (Timeline) to be similar to YouTube */
.youtube-progress {
    position: absolute !important;
    bottom: 60px !important;
    left: 5% !important;
    right: 5% !important;
    width: 90% !important;
    padding: 0 !important;
    z-index: 10 !important;
}

.youtube-progress-container {
    width: 100% !important;
    background: rgba(255,255,255,.3) !important;
    height: 5px !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    position: relative !important;
    overflow: visible !important;
}

.youtube-progress-bar {
    background: #f00 !important;
    height: 100% !important;
    border-radius: 3px !important;
    position: relative !important;
    transition: width 0.1s linear !important;
}

/* Spherical indicator */
.youtube-progress-bar::after {
    content: '' !important;
    position: absolute !important;
    right: -10px !important;
    top: 50% !important;
    transform: translateY(-50%) scale(0) !important;
    width: 20px !important;
    height: 20px !important;
    background: #f00 !important;
    border-radius: 50% !important;
    opacity: 0 !important;
    transition: transform 0.2s ease, opacity 0.2s ease !important;
    box-shadow: 0 0 10px rgba(255,0,0,0.8) !important;
    cursor: pointer !important;
    z-index: 5 !important;
    pointer-events: none !important;
}

/* Preload bar (Buffer) */
.youtube-buffer-bar {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 100% !important;
    background: rgba(255,255,255,.5) !important;
    border-radius: 3px !important;
    z-index: 1 !important;
    pointer-events: none !important;
}

/* Hover effect on container */
.youtube-progress-container:hover {
    height: 6px !important;
}

.youtube-progress-container:hover .youtube-progress-bar::after {
    opacity: 1 !important;
    transform: translateY(-50%) scale(1) !important;
}

/* Click/drag effect */
.youtube-progress-container.dragging .youtube-progress-bar::after {
    opacity: 1 !important;
    transform: translateY(-50%) scale(1.2) !important;
    box-shadow: 0 0 15px rgba(255,0,0,1) !important;
}

.youtube-progress-container.dragging {
    cursor: grabbing !important;
}

/* 2. Reorder control elements */
.modern-controls {
    padding: 0 5% !important;
    height: 60px !important;
}

.youtube-left-controls {
    width: 50% !important;
    justify-content: flex-start !important;
    gap: 10px !important;
}

.youtube-right-controls {
    width: 50% !important;
    justify-content: flex-end !important;
    gap: 10px !important;
}

/* 3. Play button and timing on the left */
.play-time-container {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.modern-time {
    margin: 0 !important;
    min-width: 80px !important;
    text-align: left !important;
}

/* 4. Volume control system - Large screens */
.volume-control-container {
    display: flex !important;
    align-items: center !important;
    position: relative !important;
}

.volume-button {
    width: 44px !important;
    height: 44px !important;
    background: rgba(255,255,255,.1) !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    transition: all 0.2s !important;
    z-index: 2 !important;
    padding: 0 !important;
}

.volume-button:hover {
    background: rgba(255,255,255,.2) !important;
    transform: translateY(-2px) !important;
}

.volume-button.muted::after {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) rotate(45deg) !important;
    width: 30px !important;
    height: 3px !important;
    background: #f00 !important;
    border-radius: 2px !important;
    z-index: 3 !important;
}

.volume-button svg {
    width: 24px !important;
    height: 24px !important;
    fill: #fff !important;
    z-index: 2 !important;
    position: relative !important;
}

/* 5. Vertical volume slider for large screens - without ball */
.volume-vertical-slider {
    position: absolute !important;
    bottom: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 44px !important;
    height: 0 !important;
    background: rgba(28,28,28,0.95) !important;
    border-radius: 8px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: flex-end !important;
    overflow: hidden !important;
    transition: height 0.3s ease, opacity 0.3s ease !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: 100 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.7) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    padding: 10px 0 !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

.volume-vertical-slider.expanded {
    height: 140px !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    bottom: 120% !important;
}

.volume-vertical-track {
    width: 6px !important;
    height: 100px !important;
    background: linear-gradient(to top, #f00 0%, #ff6666 100%) !important;
    border-radius: 3px !important;
    position: relative !important;
    cursor: pointer !important;
    overflow: hidden !important;
}

.volume-vertical-fill {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    background: rgba(255,255,255,0.9) !important;
    border-radius: 3px !important;
    transition: height 0.15s ease !important;
    height: 0%;
}

/* Remove ball cursor completely */
.volume-vertical-handle {
    display: none !important;
}

/* 6. Horizontal volume bar for small screens - without ball */
.volume-horizontal-container {
    display: none !important;
    align-items: center !important;
    gap: 8px !important;
}

.volume-horizontal-slider {
    width: 80px !important;
    height: 4px !important;
    background: linear-gradient(to right, #f00 0%, #ff6666 100%) !important;
    border-radius: 2px !important;
    position: relative !important;
    cursor: pointer !important;
    overflow: hidden !important;
}

.volume-horizontal-fill {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 100% !important;
    background: rgba(255,255,255,0.9) !important;
    border-radius: 2px !important;
    transition: width 0.15s ease !important;
    width: 0%;
}

.volume-horizontal-display {
    position: absolute !important;
    top: -22px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    pointer-events: none !important;
}

/* Remove ball cursor completely */
.volume-horizontal-handle {
    display: none !important;
}

/* Update for small screens */
@media (max-width: 768px) {
    .youtube-progress {
        bottom: 50px !important;
    }
    
    .youtube-progress-bar::after {
        width: 18px !important;
        height: 18px !important;
        right: -9px !important;
    }
    
    .volume-vertical-slider {
        display: none !important;
    }
    
    .volume-horizontal-container {
        display: flex !important;
    }
    
    .volume-control-container:hover .volume-vertical-slider {
        height: 0 !important;
        opacity: 0 !important;
    }
    
    .modern-controls {
        height: 50px !important;
        padding: 0 3% !important;
    }
    
    .modern-btn {
        width: 36px !important;
        height: 36px !important;
    }
    
    .modern-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
    
    .volume-button {
        width: 36px !important;
        height: 36px !important;
        background: rgba(255,255,255,.1) !important;
    }
    
    .volume-button svg {
        width: 18px !important;
        height: 18px !important;
    }
    
    .volume-button.muted::after {
        width: 24px !important;
        height: 3px !important;
    }
    
    .modern-time {
        font-size: 12px !important;
        min-width: 70px !important;
    }
    
    .volume-horizontal-slider {
        width: 60px !important;
    }
}

/* Support for very small screens */
@media (max-width: 480px) {
    .youtube-progress {
        bottom: 45px !important;
        left: 2% !important;
        right: 2% !important;
        width: 96% !important;
    }
    
    .youtube-progress-bar::after {
        width: 16px !important;
        height: 16px !important;
        right: -8px !important;
    }
    
    .modern-controls {
        height: 45px !important;
    }
    
    .modern-btn {
        width: 32px !important;
        height: 32px !important;
    }
    
    .volume-button {
        width: 32px !important;
        height: 32px !important;
        background: rgba(255,255,255,.1) !important;
    }
    
    .volume-button svg {
        width: 16px !important;
        height: 16px !important;
    }
    
    .volume-button.muted::after {
        width: 22px !important;
        height: 3px !important;
    }
    
    .modern-time {
        font-size: 11px !important;
        min-width: 60px !important;
    }
    
    .volume-horizontal-slider {
        width: 50px !important;
    }
}

/* 9. Previous fixes */
@media (max-width:1024px) {
    .custom-popup-box.vertical-video {
        max-height:75vh!important;
    }
    .custom-popup-box.vertical-video video {
        max-height:75vh!important;
        max-width:85vw!important;
    }
}

@media (max-width:768px) {
    .custom-popup-box.vertical-video {
        max-height:70vh!important;
    }
    .custom-popup-box.vertical-video video {
        max-height:70vh!important;
        max-width:80vw!important;
    }
}

@media (max-width:480px) {
    .custom-popup-box.vertical-video {
        max-height:65vh!important;
        max-width:85vw!important;
    }
    .custom-popup-box.vertical-video video {
        max-height:65vh!important;
        max-width:85vw!important;
    }
}

@media (max-width:360px) {
    .custom-popup-box.vertical-video {
        max-height:60vh!important;
        max-width:90vw!important;
    }
    .custom-popup-box.vertical-video video {
        max-height:60vh!important;
        max-width:90vw!important;
    }
}

/* 10. Improvements for touch screens */
@media (hover: none) and (pointer: coarse) {
    .modern-btn,
    .volume-button,
    .youtube-progress-container,
    .volume-vertical-track,
    .volume-horizontal-slider {
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
    }
    
    .volume-button:active {
        background-color: rgba(255,255,255,0.2) !important;
    }
}

/* 11. Top numeric gradient */
.volume-display {
    position: absolute !important;
    top: 8px !important;
    left: 0 !important;
    width: 100% !important;
    text-align: center !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5) !important;
}

/* 12. Improve appearance of volume bars when filled */
.volume-vertical-track {
    background: rgba(255,255,255,0.2) !important;
}

.volume-vertical-fill {
    background: #f00 !important;
    box-shadow: 0 0 10px rgba(255,0,0,0.5) !important;
}

.volume-horizontal-slider {
    background: rgba(255,255,255,0.2) !important;
}

.volume-horizontal-fill {
    background: #f00 !important;
    box-shadow: 0 0 8px rgba(255,0,0,0.5) !important;
}