:root {
    --brand-color: #8b5cf6;
    --brand-color-light: #a78bfa;
    --op-color: #fbbf24;
    --ed-color: #38bdf8;
    --overlay-gradient-top: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    --overlay-gradient-bottom: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 40%, transparent 100%);
}

body.stop-scrolling {
    overflow: hidden !important;
    height: 100vh;
}

.player-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: none;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #fff;
}

.player-wrapper * {
    box-sizing: border-box;
}

.player-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;

    margin: 0;
    padding: 0;
}
.video-frame {

    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-frame video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-frame .plyr {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.player-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
    pointer-events: none; /* Permite clickear el video a través del header vacío */
    transition: opacity 0.3s ease;
}

.header-left, .header-right {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-icon-glass {
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 10px;
    border-radius: 20%;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}

.btn-icon-glass:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-1px) scale(1.05);
}

.player-container:hover .player-header,
.player-container.paused .player-header {
    opacity: 1;
    pointer-events: all;
}

.player-meta {
    display: flex; flex-direction: column; gap: 0.5rem;
}

.btn-close-player {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    display: flex; align-items: center; gap: 10px;
    font-size: 1.1rem; font-weight: 500;
    cursor: pointer; padding: 0;
    transition: color 0.2s;
}
.btn-close-player:hover { color: #fff; }
.btn-close-player svg { width: 28px; height: 28px; }

.episode-info {
    display: flex;
    flex-direction: column;
}
.ep-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.7);
    letter-spacing: 1px;
}
.ep-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.nav-capsule {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px; /* Forma de pastilla */
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.nav-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.nav-capsule .divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
}

#skip-overlay-btn {
    position: absolute;
    bottom: 80px; /* Encima de la barra de Plyr */
    right: 30px;
    background: white;
    color: black;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    z-index: 2147483647 !important; /* Siempre encima de todo */
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);

    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s;
    pointer-events: none;

}

#skip-overlay-btn.visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    visibility: visible !important;
    display: flex !important;
}

#skip-overlay-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

#skip-overlay-btn.is-next {
    background: #8b5cf6;
    color: white;
}
#skip-overlay-btn.is-next:hover {
    background: #7c3aed;
}


/* --- BOTONES DE NAVEGACIÓN LATERALES (Side Chevrons) --- */
.side-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.8);
    border: none;
    width: 60px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 30; /* Encima del video */
    transition: all 0.3s ease;
    opacity: 0; /* Invisibles por defecto */
}

/* Bordes redondeados según el lado */
.side-nav-btn.left {
    left: 0;
    border-radius: 0 10px 10px 0;
}

.side-nav-btn.right {
    right: 0;
    border-radius: 10px 0 0 10px;
}

/* Mostrar solo cuando el mouse está sobre el reproductor */
.player-container:hover .side-nav-btn {
    opacity: 1;
}

/* Efecto Hover sobre el botón */
.side-nav-btn:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.6); /* Tu color brand morado pero transparente */
    color: white;
    width: 70px; /* Crecen un poco */
}

/* Estado deshabilitado (Primer/Último episodio) */
.side-nav-btn:disabled {
    cursor: default;
    opacity: 0 !important; /* Totalmente oculto si no se puede usar */
    pointer-events: none;
}
#player-episode-title {
    font-size: 1.5rem; font-weight: 700;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    margin-left: 2px;
}

.player-controls-top {
    display: flex; gap: 1rem; align-items: center;
}

.glass-select {
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}
.glass-select:hover { background: rgba(255, 255, 255, 0.2); }
.glass-select option { background: #111; color: #ccc; }

.sd-toggle {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    display: flex;
    padding: 2px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
}
.sd-option {
    padding: 4px 12px;
    font-size: 0.75rem; font-weight: 700;
    color: rgba(255,255,255,0.5);
    border-radius: 2px;
    transition: all 0.2s;
}
.sd-option.active {
    background: #fff;
    color: #000;
}

.btn-skip-intro {
    position: absolute;
    bottom: 120px; right: 40px;
    background: #fff;
    color: #000;
    border: none;
    padding: 10px 24px;
    font-weight: 700; font-size: 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    z-index: 50;
    display: flex; align-items: center; gap: 8px;
    opacity: 0; transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.btn-skip-intro.visible {
    opacity: 1; transform: translateY(0);
}
.btn-skip-intro:hover {
    background: #e6e6e6;
    transform: scale(1.02);
}

:root {
    --plyr-color-main: var(--brand-color);
    --plyr-video-control-color: #fff;
    --plyr-video-control-background-hover: transparent;
    --plyr-control-icon-size: 20px;
    --plyr-range-track-height: 4px;
    --plyr-range-thumb-height: 14px;
    --plyr-range-thumb-background: #fff;
    --plyr-menu-background: rgba(20, 20, 20, 0.95);
    --plyr-menu-color: #fff;
    --plyr-tooltip-background: rgba(255,255,255,0.9);
    --plyr-tooltip-color: #000;
}

.plyr--video .plyr__controls {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.plyr__progress__container:hover .plyr__progress input[type=range],
.plyr__progress__container:hover .plyr__progress__buffer {
    height: 8px;
    transition: height 0.1s ease;
}

.plyr__progress {
    position: relative;
    cursor: pointer;
}

.skip-marker {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    z-index: 3;
    pointer-events: none;
    transition: height 0.1s ease;

    background-color: rgba(255, 255, 255, 0.3);

    border-left: 2px solid rgba(0,0,0,0);
    border-right: 2px solid rgba(0,0,0,0);
    background-clip: padding-box;
}

.plyr__progress__container:hover .skip-marker {
    height: 8px;
}

.skip-marker.op {
    background-color: var(--op-color);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.skip-marker.ed {
    background-color: var(--ed-color);
}

.player-loading-overlay {
    background: #000;
}
.spinner {
    border-width: 2px;
    width: 50px; height: 50px;
    border-top-color: #fff;
    border-right-color: rgba(255,255,255,0.1);
    border-bottom-color: rgba(255,255,255,0.1);
    border-left-color: rgba(255,255,255,0.1);
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 12px; /* Espacio entre los elementos */
}

/* Opcional: Ajuste para pantallas móviles muy pequeñas */
@media (max-width: 600px) {
    .settings-group {
        gap: 8px;
    }
    .glass-select {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

.player-container:fullscreen,
.player-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #000;
    position: fixed;
    inset: 0;
    z-index: 99999;
}

/* Controles custom SIEMPRE visibles encima */
.player-container:fullscreen .player-header,
.player-container:fullscreen .side-nav-btn,
.player-container:fullscreen #skip-overlay-btn,
.player-container:-webkit-full-screen .player-header,
.player-container:-webkit-full-screen .side-nav-btn,
.player-container:-webkit-full-screen #skip-overlay-btn {
    z-index: 2147483647 !important;
    visibility: visible;
}

/* Posición correcta del botón Skip en fullscreen */
.player-container:fullscreen #skip-overlay-btn,
.player-container:-webkit-full-screen #skip-overlay-btn {
    bottom: 100px;
    right: 50px;
}

/* ================= UI HIDDEN (UNA SOLA FUENTE DE VERDAD) ================= */

.player-container.ui-hidden .player-header,
.player-container.ui-hidden .side-nav-btn {
    opacity: 0;
    pointer-events: none;
    cursor: none;
}
#skip-overlay-btn {
    opacity: 0;
    pointer-events: none;
}

#skip-overlay-btn.visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.player-container.ui-hidden #skip-overlay-btn.visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    visibility: visible !important;
}
.player-header,
.side-nav-btn,
#skip-overlay-btn {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.player-container:fullscreen #skip-overlay-btn,
.player-container:-webkit-full-screen #skip-overlay-btn {
    z-index: 2147483647 !important;
    pointer-events: auto !important;
}
.player-container:fullscreen #skip-overlay-btn.visible,
.player-container:-webkit-full-screen #skip-overlay-btn.visible {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.glass-btn-mpv {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    height: 36px;
}

.glass-btn-mpv:hover {
    background: white;
    color: black;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.glass-btn-mpv svg {
    margin-top: -1px;
}

.glass-btn-mpv:active {
    transform: scale(0.95);
}

.plyr__custom-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

/* El select real: invisible pero clickable */
.plyr__custom-select-wrapper select {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2; /* Encima del botón visual */
    appearance: none;
    -webkit-appearance: none;
}

/* El botón visual que imita a Plyr */
.plyr__custom-control-btn {
    position: relative;
    background: transparent;
    border: none;
    color: #fff; /* Plyr default white */
    padding: 7px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.plyr__custom-control-btn:hover {
    background: rgba(255, 255, 255, 0.15); /* Plyr hover effect */
    color: #fff;
}

.plyr__custom-control-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    pointer-events: none;
}

/* Badge pequeño para indicar calidad actual (opcional) */
.quality-badge {
    background: var(--brand-color);
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}