/* ============================================================
   CUSTOM ZERO-BRANDING VIDEO PLAYER (YouTube + HTML5 + Drive)
   Udemy & Modern EdTech Grade Custom Player Engine
   ============================================================ */

:root {
    --player-primary: #a435f0;
    --player-primary-hover: #b958f8;
    --player-bg: #000000;
    --player-shield-h: 40px;
}

.wk-custom-player {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 240px;
    background: var(--player-bg);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── YouTube Viewport & High-Definition (1080p FHD) Scaler ── */
.wk-custom-player .wk-yt-viewport {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    pointer-events: none;
}

.wk-custom-player .wk-yt-scaler {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1920px;
    height: 1080px;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    pointer-events: none;
    will-change: transform;
}

.wk-custom-player .wk-yt-scaler iframe,
.wk-custom-player .wk-yt-scaler #wkYtPlayer,
.wk-custom-player .wk-yt-scaler #wkYtPlayerIframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
    display: block !important;
    pointer-events: none !important;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
}

/* Modal and Ratio Container Adaptations */
#previewPlayerContainer,
.ratio-16x9 {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
}

#previewPlayerContainer .wk-custom-player,
.ratio > .wk-custom-player {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* ── Native Controls Mode Toggle (Optional fallback to YouTube controls) ── */
.wk-custom-player.native-mode .wk-yt-scaler,
.wk-custom-player.native-mode .wk-yt-scaler iframe {
    pointer-events: auto !important;
}
.wk-custom-player.native-mode .wk-player-click-shield,
.wk-custom-player.native-mode .wk-custom-player-controls,
.wk-custom-player.native-mode .wk-custom-player-center-play {
    display: none !important;
}

/* ── HTML5 Native Video Viewport ── */
.wk-custom-player video.wk-native-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    object-fit: contain;
}

/* ── Google Drive Embed & Anti-Popout Shield ── */
.wk-custom-player .wk-drive-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

.wk-custom-player .wk-drive-wrapper iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
    background: #000;
    pointer-events: auto !important;
}

.wk-custom-player .wk-drive-shield {
    position: absolute;
    top: 0;
    right: 0;
    width: 64px;
    height: 48px;
    z-index: 20;
    background: transparent;
    cursor: default;
    pointer-events: auto;
}

/* ── Top Disguise Header Overlay (Completely Hidden for Clean View) ── */
.wk-player-top-shield {
    display: none !important;
}

/* ── Transparent Click Interceptor Shield ── */
.wk-player-click-shield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
    background: transparent;
}

/* ── Center Big Play / Pause Button ── */
.wk-custom-player-center-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--player-primary, #a435f0);
    color: #ffffff;
    border: 3px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 35px rgba(164, 53, 240, 0.65), 0 8px 25px rgba(0, 0, 0, 0.5);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 15;
    outline: none;
}

.wk-custom-player-center-play svg {
    margin-left: 4px;
    width: 32px;
    height: 32px;
    fill: #ffffff;
}

.wk-custom-player-center-play:hover {
    transform: translate(-50%, -50%) scale(1.12);
    background: var(--player-primary-hover, #b958f8);
    border-color: #ffffff;
    box-shadow: 0 0 45px rgba(164, 53, 240, 0.85), 0 10px 30px rgba(0, 0, 0, 0.6);
}

.wk-custom-player.playing .wk-custom-player-center-play {
    opacity: 0 !important;
    transform: translate(-50%, -50%) scale(0.7) !important;
    pointer-events: none !important;
    display: none !important;
}

/* ── Center Buffer / Loading Spinner ── */
.wk-player-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--player-primary, #a435f0);
    border-radius: 50%;
    animation: wkSpin 0.9s linear infinite;
    z-index: 14;
    display: none;
    pointer-events: none;
}

@keyframes wkSpin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.wk-custom-player.buffering .wk-player-spinner {
    display: block;
}

/* ── Bottom Controls Floating Gradient Bar ── */
.wk-custom-player .wk-custom-player-controls {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.75) 0%, transparent 100%);
    padding: 26px 18px 12px;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
    z-index: 20;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
}

.wk-custom-player.playing.idle .wk-custom-player-controls {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

/* ── Timeline Scrubber Bar ── */
.wk-player-timeline-wrap {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 4px;
    cursor: pointer;
    transition: height 0.18s ease;
}

.wk-player-timeline-wrap:hover {
    height: 8px;
}

.wk-player-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.42);
    border-radius: 4px;
    width: 0;
    pointer-events: none;
    transition: width 0.2s ease;
}

.wk-player-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--player-primary, #a435f0);
    border-radius: 4px;
    width: 0;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(164, 53, 240, 0.5);
}

.wk-player-scrubber-handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    transform: translate(-50%, -50%) scale(0);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.65);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.wk-player-timeline-wrap:hover .wk-player-scrubber-handle,
.wk-player-timeline-wrap.scrubbing .wk-player-scrubber-handle {
    transform: translate(-50%, -50%) scale(1);
}

/* Hover Time Tooltip */
.wk-player-time-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    pointer-events: none;
    white-space: nowrap;
    display: none;
    z-index: 30;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.wk-player-timeline-wrap:hover .wk-player-time-tooltip {
    display: block;
}

/* ── Actions Row ── */
.wk-player-actions-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
}

.wk-player-btn-group {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.wk-player-right-group {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
}

.wk-player-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    padding: 5px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease, background 0.15s ease;
    font-size: 13px;
    flex-shrink: 0;
    min-width: 32px;
    height: 32px;
    outline: none;
}

.wk-player-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.08);
}

.wk-player-btn:active {
    transform: scale(0.95);
}

.wk-player-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.wk-player-btn-fill svg {
    fill: currentColor;
    stroke: none;
}

.wk-player-time {
    font-size: 12.5px;
    color: #e2e8f0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: -0.2px;
    font-weight: 500;
    margin-left: 4px;
}

/* ── Volume Slider (Smooth Expandable on Hover) ── */
.wk-player-vol-wrap {
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.wk-player-vol-slider {
    width: 0;
    opacity: 0;
    margin-left: 0;
    height: 5px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    pointer-events: none;
    transition: width 0.24s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.24s ease, margin 0.24s ease;
}

.wk-player-vol-wrap:hover .wk-player-vol-slider,
.wk-player-vol-wrap:focus-within .wk-player-vol-slider {
    width: 60px;
    opacity: 1;
    margin-left: 6px;
    pointer-events: auto;
}

.wk-player-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.wk-player-vol-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    cursor: pointer;
}

/* ── Settings Dropdown Menu (2-Step Drilldown) ── */
.wk-settings-menu {
    position: relative;
}

.wk-settings-dropdown {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    background: rgba(24, 24, 27, 0.98);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    width: 220px;
    display: none;
    z-index: 40;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.75);
    text-align: left;
    overflow: hidden;
    padding: 6px 0;
}

.wk-settings-dropdown.show {
    display: block;
    animation: wkFadeInUp 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes wkFadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.wk-settings-panel {
    display: none;
}

.wk-settings-panel.active {
    display: block;
}

.wk-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
}

.wk-settings-row:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.wk-row-label {
    display: flex;
    align-items: center;
    gap: 9px;
}

.wk-row-label svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    color: #94a3b8;
}

.wk-row-value {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #94a3b8;
    font-size: 12px;
}

.wk-row-value svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

/* Submenu Header */
.wk-submenu-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    width: 100%;
    text-align: left;
}

.wk-submenu-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.wk-submenu-header svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
}

.wk-settings-options {
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.wk-opt-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    padding: 8px 14px;
    color: #cbd5e1;
    font-size: 12.5px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.wk-opt-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.wk-opt-btn.active {
    color: var(--player-primary, #a435f0);
    font-weight: 700;
}

.wk-opt-btn svg.wk-check-icon {
    width: 14px;
    height: 14px;
    stroke: var(--player-primary, #a435f0);
    display: none;
}

.wk-opt-btn.active svg.wk-check-icon {
    display: inline-block;
}

/* ── Up Next / Lesson Complete Overlay ── */
.wk-up-next-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.94);
    backdrop-filter: blur(8px);
    z-index: 35;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    color: #ffffff;
    animation: wkFadeIn 0.3s ease;
}

.wk-up-next-overlay.show {
    display: flex;
}

@keyframes wkFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.wk-up-next-badge {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    background: rgba(164, 53, 240, 0.25);
    color: #d8b4fe;
    border: 1px solid rgba(164, 53, 240, 0.45);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.wk-up-next-title {
    font-size: clamp(16px, 2.5vw, 22px);
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 10px;
    max-width: 550px;
    line-height: 1.35;
}

.wk-up-next-sub {
    font-size: 13.5px;
    color: #94a3b8;
    margin-bottom: 22px;
}

.wk-up-next-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.wk-btn-up-next-play {
    background: var(--player-primary, #a435f0);
    color: #ffffff;
    border: none;
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(164, 53, 240, 0.4);
}

.wk-btn-up-next-play:hover {
    background: var(--player-primary-hover, #b958f8);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(164, 53, 240, 0.55);
}

.wk-btn-up-next-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wk-btn-up-next-cancel:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ── Fullscreen Mode Cross-Browser Standard ── */
.wk-custom-player:fullscreen,
.wk-custom-player:-webkit-full-screen,
.wk-custom-player.is-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    z-index: 9999999 !important;
}

.wk-custom-player:fullscreen video,
.wk-custom-player:-webkit-full-screen video,
.wk-custom-player.is-fullscreen video {
    width: 100vw !important;
    height: 100vh !important;
    object-fit: contain !important;
}

.wk-custom-player:fullscreen .wk-yt-viewport,
.wk-custom-player:-webkit-full-screen .wk-yt-viewport,
.wk-custom-player.is-fullscreen .wk-yt-viewport {
    width: 100vw !important;
    height: 100vh !important;
}

/* ── Mobile Responsive Optimizations (< 768px) ── */
@media (max-width: 767.98px) {
    .wk-player-top-shield {
        height: 48px;
        padding: 0 12px;
    }
    
    .wk-player-top-shield .wk-top-title {
        font-size: 12.5px;
        max-width: 95%;
    }
    
    .wk-player-top-shield .wk-top-brand {
        display: none !important;
    }
    
    .wk-custom-player-center-play {
        width: 58px;
        height: 58px;
    }
    
    .wk-custom-player-center-play svg {
        width: 24px;
        height: 24px;
    }
    
    .wk-custom-player .wk-custom-player-controls {
        padding: 16px 12px 10px;
        gap: 6px;
    }
    
    .wk-player-btn {
        min-width: 28px;
        height: 28px;
        padding: 3px;
    }
    
    .wk-player-btn svg {
        width: 17px;
        height: 17px;
    }
    
    .wk-player-time {
        font-size: 11px;
    }
    
    .wk-player-vol-slider {
        display: none !important;
    }
    
    .wk-settings-dropdown {
        width: 200px;
        bottom: calc(100% + 8px);
        right: -10px;
    }
}

