/* Optimized Player CSS - Responsive & Modern with Mobile Control Bar */
body {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-size: 15px;
    background: #000;
}

/* Player Container */
.jw-blogger-container {
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    background: var(--jw-control-bg, #0a0a0a);
}

/* Video Container */
#videoContainer {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2;
}

/* Embed Container */
.embed-container {
    text-align: center;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    background: #000;
    position: absolute;
    color: #fff;
    z-index: 3;
    line-height: 1.4;
}

.embed-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
}

/* Loading Animation */
.lds-ellipsis {
    display: block;
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.lds-ellipsis div {
    position: absolute;
    top: 33px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #e83636;
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.lds-ellipsis div:nth-child(1) { left: 8px; animation: lds-ellipsis1 0.6s infinite; }
.lds-ellipsis div:nth-child(2) { left: 8px; animation: lds-ellipsis2 0.6s infinite; }
.lds-ellipsis div:nth-child(3) { left: 32px; animation: lds-ellipsis2 0.6s infinite; }
.lds-ellipsis div:nth-child(4) { left: 56px; animation: lds-ellipsis3 0.6s infinite; }

@keyframes lds-ellipsis1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes lds-ellipsis3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

@keyframes lds-ellipsis2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

/* Ads Overlay */
#directAds, #resume {
    width: 100%;
    height: 100%;
    position: absolute;
}

#resume { z-index: 12; }
#directAds { z-index: 1024; background: #000; }

#closeAds {
    font-size: 1.2rem;
    font-weight: 700;
    position: absolute;
    color: #fff;
    background: #a00000;
    border: 2px solid #fff;
    border-radius: 5px;
    right: 5px;
    top: 5px;
    cursor: pointer;
}

/* Server List */
#server-list {
    position: fixed;
    right: 5px;
    top: 5px;
    z-index: 4;
    left: auto;
    bottom: auto;
}

#btnServer {
    position: relative;
    display: inline-block;
    background-color: #673ab7;
    border: 1px solid #673ab7;
    padding: 0;
    border-radius: 0.25rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    width: 42px;
    height: 42px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

#btnServer:hover {
    background-color: #3f51b5;
    border-color: #3f51b5;
}

#servers {
    list-style: none;
    padding: 0;
    display: none;
    background-color: #1a1a1a;
    position: absolute;
    width: 200px;
    max-width: 300px;
    right: 45px;
    top: 0;
    margin: 0;
    border-radius: 8px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    max-height: calc(100vh - 65px);
    overflow-y: auto;
}

#servers li a {
    color: #fff;
    padding: 10px 15px;
    display: block;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.15s ease;
}

#servers li a:hover,
#servers li a.active {
    color: #fff;
    background-color: #673ab7;
}

/* ========================================
   JW PLAYER MOBILE CONTROL BAR OPTIMIZATION
   ======================================== */

/* Ensure control bar is always visible and properly sized */
.jw-controlbar {
    /* background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0.7)) !important;
    backdrop-filter: blur(10px) !important; */
    -webkit-backdrop-filter: blur(10px) !important;
    padding: 8px 12px !important;
    z-index: 10 !important;
}

/* Make buttons larger and more touch-friendly on mobile */
@media (max-width: 768px) {
    .jw-controlbar .jw-icon {
        width: 44px !important;
        height: 44px !important;
        /* display: inline-flex !important; */
        align-items: center !important;
        justify-content: center !important;
    }
    
    .jw-controlbar .jw-icon svg {
        width: 24px !important;
        height: 24px !important;
    }
    
    /* Make time slider easier to tap */
    .jw-slider-time {
        padding: 0 8px !important;
        /* min-height: 40px !important; */
        display: flex !important;
        align-items: center !important;
    }
    
    .jw-slider-time .jw-slider-container {
        height: 6px !important;
    }
    
    /* Volume slider for mobile */
    .jw-volume-tip {
        width: 60px !important;
        padding: 12px 0 !important;
    }
    
    /* Settings menu on mobile */
    .jw-settings-menu {
        /* max-width: 280px !important;
        width: 100% !important; */
        border-radius: 12px !important;
    }
    
    .jw-settings-content-item {
        font-size: 12px !important;
        /* padding: 12px 16px !important; */
    }
    
    /* Control bar button container */
    .jw-button-container {
        gap: 2px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    
    .jw-button-container::-webkit-scrollbar {
        display: none !important;
    }
    
    /* Make all control bar elements visible
    .jw-icon-playback,
    .jw-icon-rewind,
    .jw-icon-forward,
    .jw-icon-volume,
    .jw-icon-settings,
    .jw-icon-fullscreen,
    .jw-icon-pip,
    .jw-icon-cast,
    .jw-icon-cc,
    .jw-icon-next {
        display: inline-flex !important;
    } */
    
    /* Duration text */
    .jw-text-duration,
    .jw-text-elapsed {
        font-size: 13px !important;
        padding: 0 8px !important;
        min-width: 45px !important;
    }
    
    /* Control bar height
    .jw-controlbar {
        min-height: 60px !important;
    } */
    
    /* Display controls (center play button) */
    .jw-display-icon-container {
        width: 70px !important;
        height: 70px !important;
    }
    
    .jw-display-icon-container .jw-icon {
        width: 70px !important;
        height: 70px !important;
    }
    
    .jw-display-icon-container svg {
        width: 48px !important;
        height: 48px !important;
    }
}

/* For very small screens (under 480px) */
@media (max-width: 480px) {
    .jw-controlbar .jw-icon {
        width: 38px !important;
        height: 38px !important;
    }
    
    .jw-controlbar .jw-icon svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    .jw-text-duration,
    .jw-text-elapsed {
        font-size: 11px !important;
        min-width: 38px !important;
    }
    
    .jw-slider-time {
        padding: 0 4px !important;
    }
    
    .jw-button-container {
        gap: 0px !important;
    }
    
    .jw-controlbar {
        padding: 6px 8px !important;
    }
}

/* Tablet screens (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .jw-controlbar .jw-icon {
        width: 42px !important;
        height: 42px !important;
    }
    
    .jw-controlbar .jw-icon svg {
        width: 22px !important;
        height: 22px !important;
    }
}

/* Ensure control bar shows on touch devices */
.jw-flag-touch .jw-controlbar {
    /* display: flex !important; */
    opacity: 1 !important;
    visibility: visible !important;
}

/* Keep control bar visible during playback on mobile */
.jw-flag-user-inactive.jw-flag-touch .jw-controlbar {
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

.jw-flag-user-inactive.jw-flag-touch .jw-controlbar.jw-controlbar-visible {
    opacity: 1 !important;
}

/* Make the control bar stay visible when controls are enabled */
.jw-flag-controls .jw-controlbar {
    display: flex !important;
}

/* Mobile control bar background gradient */
@media (max-width: 768px) {
    /* .jw-controlbar {
        background: linear-gradient(to top, rgba(0,0,0,0.95), rgba(0,0,0,0.8)) !important;
        border-top: 1px solid rgba(255,255,255,0.1) !important;
    } */
}

/* Improve slider knob visibility on mobile */
@media (max-width: 768px) {
    .jw-knob {
        width: 14px !important;
        height: 14px !important;
        box-shadow: 0 0 0 2px rgba(255,255,255,0.3) !important;
    }
    
    .jw-knob:hover {
        transform: scale(1.2) !important;
    }
}

/* Time tooltip on mobile */
.jw-time-tip {
    background: rgba(0,0,0,0.8) !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
}

/* Mobile settings menu improvements */
@media (max-width: 768px) {
    .jw-settings-menu {
            position: absolute;
    bottom: 57px;
    right: 12px;
    align-items: flex-start;
    background-color: #333;
    display: none;
    flex-flow: column nowrap;
    max-width: 284px;
    pointer-events: auto;
    }
    
    .jw-settings-submenu {
        max-height: 60vh !important;
    }
    
    .jw-settings-submenu .jw-submenu-topbar {
        /* padding: 12px !important; */
    }
}

/* Volume overlay on mobile */
@media (max-width: 768px) {
    .jw-overlay {
        bottom: 100% !important;
        margin-bottom: 10px !important;
    }
    
    .jw-overlay .jw-volume-tip {
        width: 50px !important;
    }
    
    .jw-slider-volume {
        height: 120px !important;
    }
}

/* Captions text size on mobile */
@media (max-width: 768px) {
    .jw-text-track-cue {
        font-size: 14px !important;
        padding: 4px 8px !important;
        border-radius: 6px !important;
    }
}

/* Loading indicator visibility */
@media (max-width: 768px) {
    .jw-loading {
        width: 40px !important;
        height: 40px !important;
    }
}

/* Keep all buttons functional on mobile */
.jw-icon {
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Active state feedback for mobile */
.jw-icon:active {
    opacity: 0.7 !important;
    transform: scale(0.95) !important;
    transition: all 0.05s ease !important;
}

/* JW Player Customizations */
.jwplayer video { pointer-events: none !important; }
.jwplayer .jw-rightclick .jw-rightclick-list { display: none !important; }

.jw-knob {
    width: 13px !important;
    height: 13px !important;
}

.jw-settings-menu,
.jw-button-container { z-index: 2; }

/* Volume Slider */
.jw-horizontal-volume-container .jw-buffer,
.jw-slider-time .jw-buffer {
    background-color: #ffffff !important;
}

/* Small Player Adjustments */
.jw-breakpoint-1:not(.jw-flag-audio-player) .jw-slider-time { padding: 0 12px !important; }
.jw-breakpoint--1:not(.jw-flag-audio-player) .jw-slider-time { height: auto !important; padding: 0 !important; }

/* Captions Styling */
::cue,
video::cue,
video::-webkit-media-text-track-display {
    color: #ffff00;
    text-shadow: #000 -2px 0 1px, #000 2px 0 1px, #000 0 -2px 1px, #000 0 2px 1px;
}

.jw-text-track-cue {
    padding: 3px 8px !important;
    border-radius: 8px !important;
}

/* Preview Container */
#preview-container {
    position: absolute;
    bottom: 105%;
    width: 180px;
    display: none;
    z-index: 1000;
    pointer-events: none;
}

#preview-video {
    width: 100%;
    height: 101px;
    border-radius: 6px;
    object-fit: cover;
    overflow: hidden;
    border: 3px solid #000000a9;
}

#preview-time {
    color: #fff;
    text-align: center;
    padding: 5px 10px;
    font-size: 12px;
    background-color: #000000a9;
    width: max-content;
    margin: auto;
    margin-top: 6px;
    border-radius: 6px;
}

/* Responsive Preview */
@media (max-width: 900px) {
    #preview-container { width: 140px; }
    #preview-video { height: 78px; }
}

@media (max-width: 420px) {
    #preview-container { width: 100px; }
    #preview-video { height: 60px; }
    #preview-time { margin-top: 0; }
}