:root {
    --brand-color: #8b5cf6;
    --brand-color-light: #a78bfa;
    --brand-gradient: linear-gradient(90deg, #7c3aed 0%, #a78bfa 100%);
    --op-color: rgba(251, 191, 36, 0.3); /* Ámbar sutil */
    --ed-color: rgba(56, 189, 248, 0.3); /* Azul cielo sutil */

    --glass-bg: rgba(10, 10, 10, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(20px);
    --player-bg: #000;
}

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

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

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

.player-container.show-cursor {
    cursor: default;
}

/* Video Frame */
.video-frame {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--player-bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Subtitles Canvas Overlay */
#subtitles-canvas {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
}

/* Header Controls */
.player-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 60;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.player-container.show-cursor .player-header {
    opacity: 1;
    pointer-events: auto;
}

.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: 6px;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.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);
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.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: 8px;
    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: 8px;
    display: flex;
    padding: 2px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

.sd-bg {
    position: absolute;
    height: calc(100% - 4px);
    width: calc(50% - 2px);
    background: #fff;
    border-radius: 6px;
    transition: transform 0.2s ease;
    top: 2px;
    left: 2px;
}

.sd-toggle[data-state="dub"] .sd-bg {
    transform: translateX(100%);
}

.sd-option {
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    border-radius: 6px;
    transition: color 0.2s;
    z-index: 1;
    position: relative;
}

.sd-option.active {
    color: #000;
}

.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: 8px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.glass-btn-mpv:hover {
    background: white;
    color: black;
    transform: translateY(-2px);
}

/* Side Navigation Buttons */
.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: 50;
    transition: all 0.3s ease;
    opacity: 0;
}

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

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

.player-container.show-cursor .side-nav-btn {
    opacity: 1;
}

.side-nav-btn:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.6);
    color: white;
    width: 70px;
}

.side-nav-btn:disabled {
    cursor: default;
    opacity: 0 !important;
    pointer-events: none;
}

.glass-panel {
    background: rgba(20, 20, 20, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Skip Overlay Button */
#skip-overlay-btn {
    position: absolute;
    bottom: 100px;
    right: 30px;
    background: white;
    color: black;
    padding: 12px 28px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    z-index: 70;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s;
    pointer-events: none;
}

#skip-overlay-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

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

#skip-overlay-btn.is-next {
    background: var(--brand-color);
    color: white;
}

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

/* Custom Controls */
.custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0;
    z-index: 60;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.player-container.show-cursor .custom-controls {
    opacity: 1;
    pointer-events: auto;
}

.controls-gradient {
    display: none;
}

/* Progress Bar */
.progress-container {
    width: calc(100% - 48px);
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    margin: 0 auto 10px auto;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 70;
}

.progress-container:hover {
    height: 6px;
    transform: scaleY(1);
}

.progress-buffer {
    position: absolute;
    height: 100%;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    pointer-events: none;
    transition: width 0.2s linear;
}

.progress-played {
    background: var(--brand-color);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.6);
    position: absolute;
    height: 100%;
    border-radius: 2px;
}

.progress-handle {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s ease;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.2);
    z-index: 71;
}

.progress-container:hover .progress-handle {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
}

/* Skip Markers on Progress */
.skip-range {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

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

.skip-cut {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 3px;
    background-color: #000;
    z-index: 5;
    pointer-events: none;
    border-radius: 2px;
    box-shadow: 0 0 2px rgba(0,0,0,1);
}

/* Controls Row */
.controls-row {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;

    width: 100%;
    padding: 5px 24px 20px 24px;
    margin: 0;
    border-radius: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-left,
.controls-center,
.controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls-center {
    flex: 1;
    justify-content: center;
}

.control-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    padding: 10px;
    margin: 0 2px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: none;
    box-shadow: none;
}

.control-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    stroke: none;
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn.play-pause svg {
    width: 32px;
    height: 32px;
}

.time-display {
    font-family: 'Inter', monospace;
    font-variant-numeric: tabular-nums; /* Evita que los números "bailen" */
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.9;
    margin-left: 16px;
}

/* Volume Control */
.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-slider-container {
    width: 0;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 5px;
}

.volume-control:hover .volume-slider-container {
    width: 100px;
    margin-left: 10px;
}

.volume-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
    transition: transform 0.1s;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.settings-panel {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 300px;
    max-height: 400px;
    border-radius: 16px;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 100;

    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-panel.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.settings-back-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s;
}

.settings-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.settings-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}

/* Lista de opciones */
.settings-content {
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Item del menú */
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    color: #eee;
    font-size: 0.9rem;
    margin: 0 4px;
}

.settings-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Estilos específicos para la vista principal */
.settings-item-main {
    justify-content: space-between;
}

.settings-label-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.settings-label-icon {
    opacity: 0.7;
}

.settings-value-right {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

/* Item activo (seleccionado en submenú) */
.settings-item.selected {
    color: var(--brand-color-light);
}

.settings-item .check-icon {
    width: 16px;
    height: 16px;
    opacity: 0;
    margin-left: 10px;
}

.settings-item.selected .check-icon {
    opacity: 1;
}

/* Scrollbar bonito para listas largas */
.settings-content {
    max-height: 300px;
    overflow-y: auto;
}

.settings-content::-webkit-scrollbar {
    width: 4px;
}
.settings-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.settings-section {
    margin-bottom: 16px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
    font-weight: 600;
}

.settings-option {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}

.settings-option:hover {
    background: rgba(255,255,255,0.1);
}

.settings-option.active {
    background: var(--brand-color);
    font-weight: 600;
}

.settings-option .check-icon {
    width: 16px;
    height: 16px;
    opacity: 0;
}

.settings-option.active .check-icon {
    opacity: 1;
}

/* Loading Overlay */
.player-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: var(--player-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.spinner {
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#player-loading-text {
    margin-top: 20px;
    font-size: 1rem;
    color: rgba(255,255,255,0.7);
}

/* Fullscreen Adjustments */
.player-container:fullscreen,
.player-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
}

.player-container:fullscreen #skip-overlay-btn,
.player-container:-webkit-full-screen #skip-overlay-btn {
    bottom: 120px;
    right: 50px;
}

/* Download Modal - Matching your existing style */
#download-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(8px);
    z-index: 99999;

    display: flex;
    align-items: center;
    justify-content: center;

    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease;
}

#download-modal.show {
    opacity: 1;
    visibility: visible;
}


.download-settings-content {
    background: rgba(20, 20, 20, 0.95);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    color: #fff;
}

#download-modal.show .download-settings-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-title {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    font-weight: 800;
}

.download-sections-wrapper {
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 20px;
    flex: 1;
}

.dl-section {
    margin-bottom: 1.5rem;
}

.dl-section h3 {
    font-size: 0.75rem;
    color: var(--brand-color-light);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.dl-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dl-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.dl-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.dl-item input[type="radio"],
.dl-item input[type="checkbox"] {
    accent-color: var(--brand-color);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.dl-item span {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
    flex: 1;
    font-weight: 500;
}

.dl-item .tag-info {
    font-size: 0.7rem;
    color: #ccc;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.dl-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-cancel {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-confirm {
    background: var(--brand-color);
    border: none;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-confirm:hover {
    background: #7c3aed;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    .player-header {
        padding: 15px 20px;
    }

    .settings-group {
        gap: 8px;
    }

    .glass-select,
    .glass-btn-mpv {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .custom-controls {
        padding: 0 15px 15px;
    }

    .side-nav-btn {
        width: 50px;
        height: 70px;
    }
}