/* Custom Player Controls */

/* Settings dropdown overrides */
#rp-player .item-setup .player-dm .cs-list .cs-item {
    display: flex !important;
    cursor: pointer;
}

#rp-player .item-setup .player-dm .cs-list .cs-item .csi-current {
    display: inline-flex !important;
}

/* Override: .p_b-right .item-btn .line-center span { display:none } */
.p_b-right .item-btn .player-dm span,
.p_b-right .item-btn .player-dm .line-center span {
    display: inline !important;
    opacity: 0.7;
    color: #fff;
}

#rp-player .item-setup .player-dm .dropdown-title {
    font-size: 14px !important;
}


#rp-player {
    position: relative;
    width: 100%;
    max-width: 100%;
    display: block !important;
    height: auto !important;
    overflow: hidden;
    margin: 0 auto;
    cursor: none;
}

#rp-player.cp-show {
    cursor: default;
}

#rp-player:fullscreen,
#rp-player.cp-fullscreen {
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #000;
}

/* Force player_top to overlay instead of taking flow space */
#rp-player #player_top {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 25;
}

#rp-player .main-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #08080A;
    border-radius: .75rem .75rem 0 0;
}

#rp-player:fullscreen .main-player,
#rp-player.cp-fullscreen .main-player {
    height: 100vh;
    width: 100vw;
    max-height: 100vh;
    aspect-ratio: unset;
    border-radius: 0;
}

#rp-player:fullscreen .cp-controls,
#rp-player.cp-fullscreen .cp-controls {
    z-index: 30;
}

#rp-player:fullscreen.cp-show .cp-controls,
#rp-player.cp-fullscreen.cp-show .cp-controls {
    opacity: 1 !important;
    pointer-events: auto !important;
}

#rp-player:fullscreen .main-player video,
#rp-player.cp-fullscreen .main-player video {
    object-fit: contain !important;
}

#rp-player .main-player video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    z-index: 2;
    display: block;
}

#rp-player .main-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 2;
}

/* Controls wrapper */
.cp-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: linear-gradient(to top, rgba(0, 0, 0, .85) 0%, rgba(0, 0, 0, .4) 60%, transparent 100%);
    padding: 0 0 0;
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}

/* Show controls only via JS-managed cp-show class (auto-hides after 3s) */
#rp-player.cp-show .cp-controls {
    opacity: 1;
    pointer-events: auto;
}

/* Hide custom controls when iframe is used (iframe has its own controls) */
#rp-player.has-iframe .cp-controls,
#rp-player.has-iframe #player_top {
    display: none !important;
}

/* Seek bar */
.cp-seek-wrap {
    padding: 0 16px;
    height: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.cp-seek-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, .2);
    border-radius: 2px;
    position: relative;
    overflow: visible;
}

.cp-seek-track:hover {
    height: 6px;
}

.cp-seek-buffer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, .3);
    border-radius: 2px;
    pointer-events: none;
}

.cp-seek-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #e74c3c;
    border-radius: 2px;
    pointer-events: none;
}

.cp-seek-knob {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: #e74c3c;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity .15s;
    pointer-events: none;
}

.cp-seek-wrap:hover .cp-seek-knob {
    opacity: 1;
}

.cp-seek-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .85);
    color: #fff;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    display: none;
    margin-bottom: 8px;
}

.cp-seek-wrap:hover .cp-seek-tooltip {
    display: block;
}

/* Bottom function bar */
.cp-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px 10px;
    gap: 8px;
}

.cp-bar-left,
.cp-bar-right {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.cp-bar .item-btn {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.cp-bar .item-btn:hover {
    color: var(--primary-color, #e74c3c);
}

.cp-bar .item-btn .inc-icon.icon-large {
    width: 48px !important;
    height: 48px !important;
}

.cp-bar .item-btn .inc-icon.icon-large svg {
    width: 100% !important;
    height: 100% !important;
}

/* Buttons */
.cp-btn {
    cursor: pointer;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: .85;
    transition: opacity .15s;
    padding: 4px;
    user-select: none;
}

.cp-btn:hover {
    opacity: 1;
}

.cp-btn .cp-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cp-btn .cp-icon svg {
    width: 100%;
    height: 100%;
}

.cp-btn .cp-icon.cp-icon-lg {
    width: 26px;
    height: 26px;
}

.cp-btn span {
    font-size: 13px;
    white-space: nowrap;
}

/* Time display */
.cp-time {
    color: rgba(255, 255, 255, .8);
    font-size: 13px;
    white-space: nowrap;
    user-select: none;
    padding: 0 4px;
}

/* Volume */
.cp-volume {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-left: 8px;
}

.cp-volume-bar {
    width: 70px;
    height: 4px;
    background: rgba(255, 255, 255, .25);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.cp-volume-level {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    pointer-events: none;
}

/* Speed dropdown */
.cp-dropdown {
    position: relative;
}

.cp-dropdown-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(20, 22, 30, .96);
    backdrop-filter: blur(12px);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 140px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
    margin-bottom: 8px;
    z-index: 30;
    max-height: 320px;
    overflow-y: auto;
}

.cp-dropdown.open .cp-dropdown-menu {
    display: block;
}

.cp-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    color: rgba(255, 255, 255, .8);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.cp-dropdown-item:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.cp-dropdown-item.active {
    color: #e74c3c;
}

.cp-dropdown-item.active::after {
    content: '✓';
    margin-left: 8px;
}

.cp-dropdown-title {
    padding: 8px 16px 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, .5);
    text-transform: uppercase;
}

/* Fullscreen */
#rp-player.cp-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

#rp-player.cp-fullscreen .main-player {
    height: 100vh !important;
    max-height: 100vh !important;
    aspect-ratio: unset !important;
    padding-top: 0 !important;
    border-radius: 0 !important;
}

/* Loading spinner */
.cp-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    pointer-events: none;
}

.cp-loading .spinner-border {
    width: 40px;
    height: 40px;
}

/* Big play button center */
.cp-big-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    cursor: pointer;
    opacity: .8;
    transition: opacity .2s;
}

.cp-big-play:hover {
    opacity: 1;
}

.cp-big-play svg {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .5));
}

/* Player top bar */
#player_top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .7) 0%, transparent 100%);
    pointer-events: auto;
    opacity: 0;
    transition: opacity .3s ease;
}

#rp-player.cp-show #player_top {
    opacity: 1;
}

/* Hide player_top when episode panel is open (panel has its own header) */
.main-player:has(#video_eps.active) #player_top {
    opacity: 0 !important;
    pointer-events: none !important;
}

#player_top .video-info .name {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

#player_top .video-info .info {
    color: rgba(255, 255, 255, .7);
    font-size: 12px;
}

/* Settings Menu */
.cp-settings-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: rgba(20, 22, 30, .96);
    backdrop-filter: blur(12px);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
    z-index: 30;
    max-height: 320px;
    overflow-y: auto;
}

.cp-settings-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: rgba(255, 255, 255, .8);
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    margin-bottom: 4px;
}

.cp-settings-header:hover {
    background: rgba(255, 255, 255, .05);
}

.cp-settings-header i {
    font-size: 12px;
}

.cp-settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    color: rgba(255, 255, 255, .8);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.cp-settings-item:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.cp-settings-item.active {
    color: #e74c3c;
}

.cp-settings-item i {
    font-size: 12px;
    margin-left: 8px;
}

/* Right side controls */
.p_b-right {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.item-setup,
.item-pip,
.item-fullscreen {
    position: relative;
}

/* Hide control labels on mobile/tablet, show on PC */
.cp-label {
    display: none !important;
}

@media (min-width: 1200px) {
    .cp-label {
        display: inline !important;
    }
}

/* Responsive adjustments */
@media (max-width: 1199px) {
    .cp-bar {
        padding: 2px 6px 6px;
        gap: 4px;
    }

    .cp-bar-left,
    .cp-bar-right {
        gap: 4px;
        min-width: 0;
    }

    .cp-bar-left {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .cp-btn .cp-icon {
        width: 18px;
        height: 18px;
    }

    .cp-time {
        font-size: 11px;
        padding: 0 2px;
        white-space: nowrap;
    }

    .cp-settings-menu {
        min-width: 160px;
    }

    /* === W2G (live-status-play) mobile fixes === */

    /* Hide text labels in control buttons - only show icons (exclude dropdown menus) */
    .live-status-play .cp-bar .item-btn>.line-center>span,
    .live-status-play .cp-bar .jw-audio-label>span,
    .live-status-play .cp-bar .icon-quality .q-play {
        display: none !important;
    }

    /* Ensure dropdown menu text stays visible */
    .live-status-play .cp-bar .player-dm span {
        display: inline !important;
    }

    /* Shrink play/pause icon */
    .live-status-play .cp-bar .item-play .icon-large {
        width: 28px !important;
        height: 28px !important;
    }

    /* Right side: override Bootstrap gap-4 and shrink */
    .live-status-play .cp-bar .p_b-right {
        gap: 10px !important;
        flex-shrink: 0;
    }

    .live-status-play .cp-bar .p_b-right .inc-icon {
        width: 18px !important;
        height: 18px !important;
    }

    .live-status-play .cp-bar .p_b-right .item-btn .line-center {
        gap: 0 !important;
    }

    /* Shrink volume icon */
    .live-status-play .cp-bar .cp-volume .cp-btn i {
        font-size: 14px !important;
    }

    /* Player top bar compact */
    #player_top {
        padding: 6px 10px;
    }

    #player_top .video-info .name {
        font-size: 12px;
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #player_top .video-info .info {
        color: rgba(255, 255, 255, .7);
        font-size: 11px;
    }

    #player_top .p_t-right .cp-btn span {
        font-size: 11px !important;
    }

    #player_top .p_t-right .cp-icon {
        width: 16px !important;
        height: 16px !important;
    }

    /* Big play button smaller on mobile */
    .cp-big-play svg {
        width: 44px;
        height: 44px;
    }

    /* Episode list - ensure proper mobile coverage */
    .live-status-play #video_eps {
        z-index: 50 !important;
    }

    .live-status-play #video_eps .eps-list {
        width: 300px;
        max-width: 85%;
    }

    /* Dropdown menus positioning */
    .live-status-play .player-dm {
        max-height: 60vh;
        overflow-y: auto;
    }
}

@media (max-width: 480px) {

    /* Hide PiP on very small screens */
    .live-status-play .cp-bar .item-pip {
        display: none !important;
    }

    /* Even smaller controls */
    .live-status-play .cp-bar .item-play .icon-large {
        width: 36px !important;
        height: 38px !important;
    }

    .live-status-play .cp-bar .p_b-right {
        gap: 15px !important;
    }

    .live-status-play .cp-bar .p_b-right .inc-icon {
        width: 16px !important;
        height: 16px !important;
    }

    .cp-volume {
        padding-left: 4px !important;
    }

    .cp-time {
        font-size: 10px;
    }

    #player_top .video-info .name {
        max-width: 140px;
        font-size: 11px;
    }

    #player_top .p_t-right .cp-btn span {
        display: none !important;
    }

    .cp-big-play svg {
        width: 36px;
        height: 36px;
    }

    /* Seek bar tighter */
    .cp-seek-wrap {
        padding: 0 8px;
        height: 16px;
    }

    .live-status-play #video_eps .eps-list {
        width: 100%;
        max-width: 100%;
    }
}

/* W2G specific adjustments */
.live-status-play #rp-player .main-player {
    border-radius: 0;
}

.live-status-play #rp-player {
    border-radius: 0;
    height: 100%;
    width: 100%;
}

/* Import necessary styles from style.min.css for W2G only */
.live-status-play .inc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.live-status-play .icon-large {
    height: 48px;
    width: 48px;
}

.live-status-play .line-center {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Dropdown menu styles for W2G */
.live-status-play .player-dm {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background-color: rgba(20, 22, 30, 0.96);
    border-radius: 8px;
    padding: 0.6rem 0;
    color: #fff;
}

.live-status-play .player-dm::-webkit-scrollbar {
    display: none;
}

.live-status-play .player-dm .dropdown-title {
    font-size: 1em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    padding: 0.2rem 1rem 0.6rem;
}

.live-status-play .player-dm .dropdown-item {
    align-items: center;
    background-color: initial !important;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    cursor: pointer;
}

.live-status-play .player-dm .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #fff;
}

.live-status-play .player-dm .dropdown-item.active {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: var(--primary-color, #e74c3c);
}

.live-status-play .player-dm .dropdown-item .w-check {
    opacity: 0;
}

.live-status-play .player-dm .dropdown-item.active .w-check {
    opacity: 1;
}

.live-status-play .player-dm .dropdown-item.active .s-title {
    font-weight: 600;
}

.live-status-play .dropdown-menu {
    background-color: rgba(20, 22, 30, 0.96);
    border: none;
    color: #fff;
}

.live-status-play .dropdown-menu.show {
    display: block;
}

/* Settings menu specific styles */
.live-status-play .player-dm .cs-list {
    display: flex;
    flex-direction: column;
}

.live-status-play .player-dm .cs-item {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
}

.live-status-play .player-dm .cs-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.live-status-play .player-dm .cs-item.active {
    color: var(--primary-color, #e74c3c);
}

.live-status-play .player-dm .cs-item .csi-current {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.7;
}

.live-status-play .player-dm .cs-item .csi-title {
    flex-grow: 1;
}

.live-status-play .player-dm .cs-item .csi-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.live-status-play .player-dm .cs-item .csi-font {
    font-size: 13px;
}

.live-status-play .player-dm .sub-back {
    cursor: pointer;
}

.live-status-play .player-dm .sub-back:hover {
    color: #fff;
}

/* Override style.min.css hiding controls on W2G pages - desktop only */
@media (min-width: 1200px) {
    .live-status-play #rp-player .item-btn .line-center span {
        display: inline !important;
    }
}

.live-status-play #rp-player .item-btn {
    font-size: 14px !important;
}

/* Use icon sizes from style.min.css */
.live-status-play #rp-player .inc-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.live-status-play #rp-player .inc-icon svg {
    width: 100% !important;
    height: 100% !important;
}

.live-status-play #rp-player .cp-controls {
    display: block !important;
}

.live-status-play #rp-player .cp-bar {
    display: flex !important;
}

.live-status-play #rp-player .cp-btn {
    display: inline-flex !important;
}

.live-status-play #rp-player .cp-time {
    display: block !important;
}

/* Ensure player fills the container */
.live-status-play .lw-player #rp-player {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

.live-status-play .lw-player #rp-player .main-player {
    height: 100%;
    padding-top: 0;
}

/* Episode list panel styles for W2G */
.live-status-play #video_eps {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s;
}

.live-status-play #video_eps.active {
    opacity: 1;
    pointer-events: auto;
}

.live-status-play #video_eps .eps-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #08080a;
    opacity: 0;
    z-index: 2;
    pointer-events: none;
}

.live-status-play #video_eps.active .eps-mask {
    opacity: 0.8;
    pointer-events: auto;
}

.live-status-play #video_eps .eps-list {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 90%;
    background-color: #1e1f28;
    z-index: 3;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(100%);
    transition: transform 0.35s;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.live-status-play #video_eps .eps-list::-webkit-scrollbar {
    display: none;
}

.live-status-play #video_eps.active .eps-list {
    transform: translateX(0);
}

.live-status-play #video_eps .eps-list .eps-header {
    padding: 0.5rem 3.5rem 0.5rem 1.2rem;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.live-status-play #video_eps .eps-list .eps-header .name {
    font-size: 1.2em;
    font-weight: 600;
    color: #fff;
}

.live-status-play #video_eps .eps-list .eps-header .season-eps {
    margin-top: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.live-status-play #video_eps .eps-list .eps-header #eps-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    cursor: pointer;
    color: #fff;
}

.live-status-play #video_eps .eps-list .eps-header #eps-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.live-status-play #video_eps .eps-list .eps-list-menu {
    display: flex;
    flex-direction: column;
}

.live-status-play #video_eps .eps-list .item-ep {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    transition: background-color 0.2s;
}

.live-status-play #video_eps .eps-list .item-ep:hover {
    background-color: rgba(255, 255, 255, 0.08);
    opacity: 1 !important;
}

.live-status-play #video_eps .eps-list .item-ep.active {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: var(--primary-color, #e74c3c);
}

.live-status-play #video_eps .eps-list .item-ep .v-thumbnail {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    height: 56px;
    min-height: 56px;
    max-height: 56px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    background-color: rgba(255, 255, 255, 0.05);
}

.live-status-play #video_eps .eps-list .item-ep.active .v-thumbnail {
    box-shadow: 0 0 0 2px var(--primary-color, #e74c3c);
}

.live-status-play #video_eps .eps-list .item-ep .v-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.live-status-play #video_eps .eps-list .item-ep .v-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.live-status-play #video_eps .eps-list .item-ep .v-title {
    font-size: 14px;
    font-weight: 500;
}