/* ============================================
   Drishya - Video Player Styles
   Apple TV+ Inspired (Glass & Minimal)
   ============================================ */

/* Player Overlay */
.hidden {
    display: none !important;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.rotating {
    animation: rotate 1s linear infinite;
}

/* Change Source Button - Icon only style */
.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.control-btn:hover {
    transform: scale(1.1);
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

/* Hide tooltip text by default, show on hover */
.control-btn .tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(28, 28, 30, 0.95);
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 8px;
}

.control-btn:hover .tooltip {
    display: block;
}

.player-overlay {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #000;
    z-index: var(--z-player);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    overflow: hidden;
    box-sizing: border-box;
}

.player-overlay.active {
    opacity: 1;
    visibility: visible;
}

.player-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
    box-sizing: border-box;
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Player Controls Gradient - Subtle Apple Vibe */
.player-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(180deg,
            rgba(0, 0, 0, 0.75) 0%,
            rgba(0, 0, 0, 0.35) 15%,
            transparent 30%,
            transparent 70%,
            rgba(0, 0, 0, 0.45) 85%,
            rgba(0, 0, 0, 0.85) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    cursor: none;
    z-index: 30;
    box-sizing: border-box;
    overflow: hidden;
}

.player-controls.visible {
    opacity: 1;
    pointer-events: auto;
    cursor: default;
}

/* Top Controls */
.player-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(16px, env(safe-area-inset-top, 16px)) var(--content-padding) 8px !important;
    box-sizing: border-box;
    width: 100%;
    z-index: 35;
}

.player-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: -0.5px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.player-top-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Center Controls - Big Play Button */
.player-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
    position: relative;
    z-index: 20;
}

.player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    border-radius: 50%;
    background: transparent;
}

.player-btn:hover {
    transform: scale(1.1);
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.play-btn {
    width: 80px;
    height: 80px;
    background: rgba(15, 16, 20, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
}

.play-btn:hover {
    background: rgba(15, 16, 20, 0.85);
    border-color: #00b5f8;
    box-shadow: 0 0 24px rgba(0, 181, 248, 0.5);
    transform: scale(1.06);
}

.seek-btn {
    width: 60px;
    height: 60px;
    opacity: 0.8;
}

.seek-btn:hover {
    opacity: 1;
}

.back-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Bottom Controls */
.player-bottom {
    padding: 8px var(--content-padding) max(16px, calc(10px + env(safe-area-inset-bottom, 10px))) !important;
    box-sizing: border-box;
    width: 100%;
    z-index: 35;
}

/* Progress Bar - Minimal Line */
.progress-container {
    position: relative;
    margin-bottom: 14px;
    padding: 8px 0;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-full);
    transition: height var(--transition-fast);
}

.progress-container:hover .progress-bar {
    height: 8px;
    /* Slight expand */
}

.progress-buffered {
    position: absolute;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    pointer-events: none;
}

.progress-played {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, #0088cc 0%, #00b5f8 100%);
    border-radius: var(--radius-full);
    pointer-events: none;
    box-shadow: 0 0 12px rgba(0, 181, 248, 0.6);
}

.progress-thumb {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border: 2.5px solid #00b5f8;
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%) scale(0);
    transition: transform var(--transition-fast);
    pointer-events: none;
    box-shadow: 0 0 10px rgba(0, 181, 248, 0.8), 0 2px 8px rgba(0, 0, 0, 0.6);
}

.progress-container:hover .progress-thumb {
    transform: translate(-50%, -50%) scale(1);
}

.progress-preview {
    position: absolute;
    bottom: 25px;
    left: 0;
    padding: 6px 12px;
    background: rgba(28, 28, 30, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity var(--transition-fast);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-container:hover .progress-preview {
    opacity: 1;
}

/* Bottom Controls Row */
.player-bottom-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
    gap: 12px;
}

.player-left-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.player-right-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 1;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.time-display {
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* Volume */
.volume-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.volume-slider {
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Quality & Speed - Glass Chip style */
/* Quality & Speed - Glass Chip style */
.quality-selector {
    padding: 6px 12px;
    background: #1e2330 !important;
    border: 1px solid #252b3b !important;
    border-radius: 6px;
    color: #ffffff !important;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-selector {
    padding: 6px 4px;
    width: 50px;
    text-align: center;
    background: #1e2330 !important;
    border: 1px solid #252b3b !important;
    border-radius: 6px;
    color: #ffffff !important;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.quality-selector:hover,
.speed-selector:hover {
    border-color: #00b5f8 !important;
}

.quality-selector:hover,
.speed-selector:hover {
    background: rgba(255, 255, 255, 0.2);
}

.quality-selector option,
.speed-selector option {
    background: #1c1c1e;
    /* Standard dark dropdown */
    color: #fff;
}

/* Settings Panel - Glass Sidebar */
/* Using previously defined Track Modal for settings content */

/* Netflix-style Audio/Subtitle Modal but Glass */
.track-modal {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.track-modal.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.track-modal-content {
    display: flex;
    flex-direction: row;
    gap: 24px;
    background: rgba(15, 16, 20, 0.96);
    backdrop-filter: blur(40px) saturate(190%);
    -webkit-backdrop-filter: blur(40px) saturate(190%);
    padding: 28px 30px 24px;
    border-radius: 16px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    max-width: 980px;
    width: min(980px, 95vw);
    max-height: min(85vh, 680px);
    height: auto;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.track-section {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.track-section h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    color: var(--text-primary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
}

.track-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.track-list::-webkit-scrollbar {
    width: 6px;
}

.track-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

.track-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 4px;
}

.track-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.38);
}

.track-item {
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.18s ease;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.track-item:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    transform: translateX(2px);
}

.track-item.selected {
    color: #ffffff;
    font-weight: 600;
    background: rgba(0, 181, 248, 0.15);
    border-color: rgba(0, 181, 248, 0.4);
}

.track-item.selected::before {
    content: '✓';
    margin-right: 10px;
    font-weight: bold;
    color: #00b5f8;
}

.track-divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
    flex-shrink: 0;
}

.upload-section {
    flex-shrink: 0;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.08);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 20;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    transform: scale(1.08);
}

/* Suppress native browser/system subtitle cue rendering completely across all platforms 
   (macOS, iOS, Android, Windows, Web) to prevent dual/duplicate subtitles with Drishya's custom overlay */
video::cue,
video::-webkit-media-text-track-display,
video::-webkit-media-text-track-container,
video::-webkit-media-text-track-display-backdrop,
video::-webkit-media-text-track-region,
video::-webkit-media-text-track-region-container {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    background: transparent !important;
    border: none !important;
    text-shadow: none !important;
    height: 0 !important;
    width: 0 !important;
    pointer-events: none !important;
}

/* Loading Spinner */
.player-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.player-loading.active {
    opacity: 1;
    visibility: visible;
}

/* Loading Status (Centered Below Play Button) */
.player-loading-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 90px;
    /* Clear the 90px play button (45px half + 45px gap) */
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 60;
    max-width: 300px;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.player-brand-emblem-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}

.player-brand-emblem {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    filter: drop-shadow(0 0 16px rgba(0, 240, 255, 0.45));
    animation: liquidEmblemPulse 2.4s ease-in-out infinite;
}

@keyframes liquidEmblemPulse {
    0%, 100% {
        transform: scale(0.97);
        filter: drop-shadow(0 0 12px rgba(0, 240, 255, 0.35));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 24px rgba(112, 0, 255, 0.65)) drop-shadow(0 0 8px rgba(0, 240, 255, 0.8));
    }
}

.player-loading-status .loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

.player-loading-status .loading-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    max-width: 100%;
}

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

/* Server Selector Drawer (Vega Style) */
.server-selector {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 90vw;
    z-index: 90;
    display: none;
    flex-direction: column;
    background: rgba(10, 14, 24, 0.90);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: -15px 0 50px rgba(0, 0, 0, 0.7);
    padding: 28px 22px;
    box-sizing: border-box;
    overflow-y: auto;
    animation: serverDrawerSlide 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes serverDrawerSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.server-selector.active,
.server-selector[style*="display: flex"] {
    display: flex !important;
}

.server-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 18px;
}

.server-label {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
}

.drawer-close-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.05);
}

.server-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.server-btn {
    width: 100%;
    padding: 13px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    text-align: left;
}

.server-btn:hover {
    background: rgba(0, 240, 255, 0.12);
    border-color: rgba(0, 240, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.12);
}

.server-btn.active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.18) 0%, rgba(112, 0, 255, 0.18) 100%);
    border: 1px solid #00f0ff;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.25);
}

/* Responsive */
@media (max-width: 768px) {
    .player-center {
        gap: 32px;
        width: 100%;
        justify-content: center;
    }

    .play-btn {
        width: 64px;
        height: 64px;
    }

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

    .seek-btn {
        width: 44px;
        height: 44px;
    }

    .seek-btn svg {
        width: 24px;
        height: 24px;
    }

    /* Hide less important controls on mobile */
    .volume-container {
        display: none;
    }

    .player-title {
        display: block;
        font-size: 1rem;
        max-width: 60%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .player-bottom {
        padding: 10px 16px max(20px, calc(12px + env(safe-area-inset-bottom, 12px)));
    }

    .player-bottom-controls {
        gap: 8px;
    }

    .player-left-controls,
    .player-right-controls {
        gap: 10px;
    }

    .time-display {
        font-size: 0.78rem;
    }

    /* Ensure icons don't get too small */
    .player-btn svg {
        width: 20px;
        height: 20px;
    }

    .player-btn {
        padding: 4px;
    }

    .track-modal {
        padding: 10px;
        align-items: flex-end;
    }

    .track-modal-content {
        flex-direction: column;
        padding: 22px 18px 18px;
        border-radius: 20px 20px 0 0;
        width: 100%;
        max-width: 100%;
        max-height: 88vh;
        gap: 16px;
    }

    .track-divider {
        display: none;
    }

    .track-section {
        max-height: calc(44vh - 24px);
        min-height: 140px;
    }

    .track-section h3 {
        font-size: 1.15rem;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .track-item {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

@media (max-height: 560px) {
    .track-modal {
        padding: 8px;
        align-items: center;
    }

    .track-modal-content {
        flex-direction: row;
        max-height: 94vh;
        padding: 16px 22px;
        gap: 16px;
        border-radius: 18px;
    }

    .track-section {
        max-height: 100%;
    }

    .track-section h3 {
        font-size: 1.05rem;
        margin-bottom: 6px;
        padding-bottom: 6px;
    }

    .track-item {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

/* ============================================
   Drishya Dedicated Subtitle Overlay
   ============================================ */
.drishya-subtitle-overlay {
    position: absolute;
    bottom: 85px;
    left: 4%;
    right: 4%;
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    pointer-events: none;
    z-index: 25;
    transition: bottom 0.25s ease;
}

.player-controls:not(.active) ~ .drishya-subtitle-overlay,
.player-container:not(.show-controls) .drishya-subtitle-overlay {
    bottom: 45px;
}

.drishya-subtitle-text {
    display: inline-block;
    max-width: 88%;
    color: #ffffff;
    font-size: clamp(17px, 2.6vw, 29px);
    font-weight: 600;
    line-height: 1.4;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.9);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 6px 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    letter-spacing: 0.2px;
}

/* ============================================
   Real-Time Video Enhancer & FidelityFX CAS
   ============================================ */
#upscaleCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none !important;
    z-index: 2;
    transition: opacity 0.25s ease;
}

#upscaleCanvas.hidden,
#upscaleCanvas[style*="display: none"] {
    opacity: 0;
}

/* Hardware-composited Clarity Matrix (Eco) - Cinematic Smooth Tone Mapping */
.clarity-vivid-eco {
    filter: contrast(1.03) brightness(1.01) saturate(1.03) !important;
    image-rendering: auto !important;
    transition: filter 0.2s ease;
}

/* Enhancer Off / Passthrough */
.clarity-off {
    filter: none !important;
    image-rendering: auto;
    transition: filter 0.2s ease;
}

/* Upscale Subpanel Selected Highlighting */
#upscalePanel .settings-item.selected {
    color: var(--accent-primary, #6366f1);
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
}

