/* =============================================
   BONY CUSTOM VIDEO PLAYER - Premium HLS Player
   ============================================= */

/* === PLAYER CONTAINER === */
.bony-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.bony-player video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Hide native controls */
.bony-player video::-webkit-media-controls {
    display: none !important;
}

.bony-player video::-webkit-media-controls-enclosure {
    display: none !important;
}

/* === LOADING SPINNER === */
.bony-player-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.bony-player-loader.active {
    opacity: 1;
}

.bony-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: bony-spin 0.8s linear infinite;
}

@keyframes bony-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideRight {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.animate-spin-slow {
    animation: bony-spin 3s linear infinite;
}

.animate-\[slideRight_2s_infinite\] {
    animation: slideRight 2s infinite;
}

/* === BIG CENTER PLAY BUTTON === */
.bony-big-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.9);
    border: none;
    color: #000;
    cursor: pointer;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 40px rgba(34, 197, 94, 0.3);
}

.bony-big-play .material-icons-round {
    font-size: 40px;
}

.bony-big-play:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 60px rgba(34, 197, 94, 0.5);
}

.bony-big-play:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.bony-big-play.bony-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.5);
}

/* Ocultar el botón Play gigante y su brillo cuando los modales de Watch Party están visibles */
.movie-iframe-wrapper:has(#movie-room-join-lock:not(.hidden)) .bony-big-play,
.movie-iframe-wrapper:has(#movie-room-host-lock:not(.hidden)) .bony-big-play {
    opacity: 0 !important;
    pointer-events: none !important;
    box-shadow: none !important;
}


/* === TAP ZONES (Double tap gestures) === */
.bony-tap-zones {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 3;
}

.bony-tap-zone {
    flex: 1;
}

/* Ripple on double tap */
.bony-tap-zone.bony-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%) scale(0);
    animation: bony-ripple 0.6s ease-out forwards;
}

.bony-tap-left.bony-ripple::after {
    left: 25%;
}

.bony-tap-right.bony-ripple::after {
    right: 25%;
    left: auto;
    transform: translate(50%, -50%) scale(0);
}

@keyframes bony-ripple {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* === SEEK INDICATORS (-10s / +10s) === */
.bony-seek-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: white;
    font-size: 13px;
    font-weight: 700;
    z-index: 6;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.bony-seek-indicator.active {
    opacity: 1;
}

.bony-seek-left {
    left: 15%;
}

.bony-seek-right {
    right: 15%;
}

.bony-seek-indicator .material-icons-round {
    font-size: 40px;
    animation: bony-seek-bounce 0.4s ease;
}

@keyframes bony-seek-bounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* === VOLUME GESTURE INDICATOR === */
.bony-volume-indicator {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 6;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    background: rgba(0, 0, 0, 0.85);
    /* solid bg instead of backdrop-filter blur for mobile GPU performance */
    border-radius: 20px;
    padding: 16px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.bony-volume-indicator.active {
    opacity: 1;
}

.bony-volume-indicator .material-icons-round {
    color: #22c55e;
    font-size: 24px;
}

.bony-vol-bar-bg {
    width: 4px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bony-vol-bar-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: #22c55e;
    border-radius: 4px;
    transition: height 0.1s;
}

/* === CONTROLS OVERLAY === */
.bony-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 0 16px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.3) 15%, rgba(0, 0, 0, 0.85));
    opacity: 1;
    transition: opacity 0.35s ease;
}

/* Top gradient for title area */
.bony-controls::before {
    content: '';
    position: absolute;
    top: -80px;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.2));
    pointer-events: none;
}

.bony-player.controls-hidden {
    cursor: none;
}

.bony-player.controls-hidden .bony-controls {
    opacity: 0;
    pointer-events: none;
}

.bony-player.controls-hidden .bony-big-play:not(.bony-hidden) {
    opacity: 0;
}

/* === PROGRESS BAR === */
.bony-progress-container {
    position: relative;
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 2px;
}

.bony-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    transition: height 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.bony-progress-container:hover .bony-progress-bar,
.bony-progress-container.dragging .bony-progress-bar {
    height: 6px;
}

.bony-progress-buffered {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 3px;
    /* no transition — buffer updates constantly, animating wastes GPU */
}

.bony-progress-played {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: #22c55e;
    border-radius: 3px;
}

.bony-progress-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 2;
}

.bony-progress-container:hover .bony-progress-thumb,
.bony-progress-container.dragging .bony-progress-thumb {
    transform: translate(-50%, -50%) scale(1);
}

.bony-progress-tooltip {
    position: absolute;
    bottom: 28px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.bony-progress-container:hover .bony-progress-tooltip {
    opacity: 1;
}

/* === CONTROLS ROW === */
.bony-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
}

.bony-controls-left,
.bony-controls-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === CONTROL BUTTONS === */
.bony-ctrl-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.bony-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.bony-ctrl-btn:active {
    transform: scale(0.88);
}

.bony-ctrl-btn .material-icons-round {
    font-size: 24px;
}

/* Label buttons (speed, quality) */
.bony-ctrl-label {
    width: auto;
    min-height: 40px;
    padding: 0 10px;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* === TIME DISPLAY === */
.bony-time {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-left: 6px;
    white-space: nowrap;
}

/* === VOLUME CONTROL === */
.bony-volume-control {
    display: flex;
    align-items: center;
    gap: 0;
}

.bony-volume-slider {
    width: 0;
    opacity: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.bony-volume-control:hover .bony-volume-slider,
.bony-volume-control.volume-active .bony-volume-slider,
.bony-volume-slider:focus {
    width: 70px;
    opacity: 1;
}

.bony-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.bony-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* === POPUP MENUS (Speed, Quality) === */
.bony-popup {
    position: absolute;
    bottom: 60px;
    right: 16px;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 6px;
    z-index: 20;
    min-width: 150px;
    max-height: calc(100% - 70px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
    animation: bony-popup-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar del popup */
.bony-popup::-webkit-scrollbar {
    width: 4px;
}

.bony-popup::-webkit-scrollbar-track {
    background: transparent;
}

.bony-popup::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.bony-popup::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

@keyframes bony-popup-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.bony-popup-title {
    color: rgba(255, 255, 255, 0.35);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 10px 14px 6px;
}

.bony-popup-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.15s;
    gap: 8px;
}

.bony-popup-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.bony-popup-item.active {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

/* === WATCH PARTY WAITING ROOM ANIMATIONS === */
.bony-animated-dots::after {
    content: " ";
    animation: bonyLoadingDots 1.5s steps(4, end) infinite;
}

@keyframes bonyLoadingDots {

    0%,
    20% {
        content: "";
    }

    40% {
        content: ".";
    }

    60% {
        content: "..";
    }

    80%,
    100% {
        content: "...";
    }
}

@keyframes bonyLoadingLine {
    0% {
        transform: translateX(-100%) scaleX(0.5);
    }

    50% {
        transform: translateX(0) scaleX(1);
        opacity: 1;
    }

    100% {
        transform: translateX(100%) scaleX(0.5);
        opacity: 0;
    }
}

.animate-bony-loading-line {
    animation: bonyLoadingLine 2s ease-in-out infinite;
    transform-origin: center left;
}

.bony-popup-item.active {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}

.bony-popup-item.active::before {
    content: '✓';
    font-weight: 800;
    font-size: 12px;
}

/* === FULLSCREEN === */
.bony-player.bony-fullscreen {
    border-radius: 0;
}

/* When using Fullscreen API, the element becomes fullscreen */
.bony-player:fullscreen,
.bony-player:-webkit-full-screen {
    border-radius: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
}

.bony-player:fullscreen video,
.bony-player:-webkit-full-screen video {
    width: 100%;
    height: 100%;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 640px) {
    .bony-controls {
        padding: 0 10px 8px;
    }

    .bony-ctrl-btn {
        width: 36px;
        height: 36px;
    }

    .bony-ctrl-btn .material-icons-round {
        font-size: 20px;
    }

    .bony-time {
        font-size: 10px;
        margin-left: 2px;
    }

    .bony-ctrl-label {
        width: auto;
        font-size: 10px;
        padding: 0 8px;
        flex-shrink: 0;
    }

    /* On mobile, don't auto-show slider on hover - only via click (.volume-active) */
    .bony-volume-control:hover .bony-volume-slider {
        width: 0;
        opacity: 0;
    }

    .bony-volume-control.volume-active .bony-volume-slider {
        width: 70px;
        opacity: 1;
    }

    .bony-big-play {
        width: 60px;
        height: 60px;
    }

    .bony-big-play .material-icons-round {
        font-size: 32px;
    }

    /* Hide rewind/forward buttons on mobile - use double tap */
    #bony-btn-rewind,
    #bony-btn-forward {
        display: none;
    }

    .bony-popup {
        min-width: 130px;
        right: 8px;
        bottom: 54px;
    }
}

/* Landscape mobile */
@media (max-height: 450px) and (orientation: landscape) {
    .bony-controls {
        padding: 0 16px 6px;
    }

    .bony-ctrl-btn {
        width: 32px;
        height: 32px;
    }

    .bony-progress-container {
        height: 18px;
    }
}

/* === HIDE QUALITY/SPEED/PIP IN NON-FULLSCREEN ===
   Only show inside the player when in fullscreen mode.
   Uses .bony-fullscreen class as fallback for iOS (webkitEnterFullscreen). */
#bony-btn-quality,
#bony-btn-speed,
#bony-btn-pip {
    display: none !important;
}

.bony-player:fullscreen #bony-btn-quality,
.bony-player:-webkit-full-screen #bony-btn-quality,
.bony-player.bony-fullscreen #bony-btn-quality,
.bony-player:fullscreen #bony-btn-speed,
.bony-player:-webkit-full-screen #bony-btn-speed,
.bony-player.bony-fullscreen #bony-btn-speed,
.bony-player:fullscreen #bony-btn-pip,
.bony-player:-webkit-full-screen #bony-btn-pip,
.bony-player.bony-fullscreen #bony-btn-pip {
    display: flex !important;
}

/* === EXTERNAL ACTION BUTTONS (below title) === */
.bony-ext-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 90px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.bony-ext-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(34, 197, 94, 0.3);
    color: #fff;
    transform: translateY(-2px);
}

.bony-ext-btn:active {
    transform: scale(0.95);
}

.bony-ext-btn .material-icons-round {
    font-size: 26px;
    color: #22c55e;
}

.bony-ext-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* === EXTERNAL POPUP PANELS === */
.bony-ext-popup {
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 24px;
    padding: 0;
    margin-bottom: 12px;
    overflow: hidden;
    animation: bony-ext-popup-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes bony-ext-popup-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bony-ext-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: white;
    font-size: 14px;
    font-weight: 700;
}

.bony-ext-popup-header .material-icons-round {
    font-size: 22px;
}

.bony-ext-popup-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.bony-ext-popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.bony-ext-popup-close .material-icons-round {
    font-size: 18px;
}

.bony-ext-popup-list {
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.bony-ext-popup-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    border-radius: 14px;
    transition: all 0.15s;
    gap: 10px;
}

.bony-ext-popup-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.bony-ext-popup-item.active {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}

.bony-ext-popup-item.active::before {
    content: '✓';
    font-weight: 800;
    font-size: 12px;
}