/**
 * School of Technical Analysis (STA Nepal) - Course Video Player
 * Modular Stylesheet (Plyr Theme, Mini Player, PiP, Overlays, Anti-Recording)
 */

:root {
    --plyr-color-main: #f59e0b;
    --plyr-video-control-color: #ffffff;
    --plyr-video-control-color-hover: #f59e0b;
    --plyr-range-fill-background: #f59e0b;
    --plyr-range-thumb-background: #f59e0b;
    --plyr-range-thumb-shadow: 0 1px 1px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(245, 158, 11, 0.5);
    --plyr-audio-range-thumb-active-shadow-width: 4px;
}

/* ── Plyr Volume Slider Controls ── */
.plyr__volume {
    min-width: 70px;
    max-width: 110px;
}
@media (max-width: 480px) {
    .plyr__volume { min-width: 50px; }
}

/* ── Volume Keyboard Shortcut Toast ── */
#sta-vol-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(9, 13, 22, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f59e0b;
    padding: 9px 22px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 700;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(245, 158, 11, 0.35);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

/* ── In-Page Floating Mini Player / PiP Card ── */
#sta-pip-fallback {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 350px !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 999998 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    background: #090d16 !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(245, 158, 11, 0.4) !important;
    flex-direction: column !important;
    display: none;
    animation: staPipPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes staPipPop {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.sta-pip-header {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(234, 88, 12, 0.3)) !important;
    padding: 8px 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    cursor: grab !important;
    user-select: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}
.sta-pip-header:active { cursor: grabbing !important; }

.sta-pip-label-tag {
    color: #f59e0b !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
}

.sta-pip-tool-btn, .sta-pip-close {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    border-radius: 6px !important;
    width: 24px !important;
    height: 24px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
}
.sta-pip-tool-btn:hover {
    background: rgba(245, 158, 11, 0.25) !important;
    color: #f59e0b !important;
    border-color: rgba(245, 158, 11, 0.5) !important;
}
.sta-pip-close:hover {
    background: rgba(239, 68, 68, 0.35) !important;
    color: #fff !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
}

.sta-pip-slot {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    background: #000 !important;
    position: relative !important;
    overflow: hidden !important;
}
.sta-pip-slot .custom-system-video,
.sta-pip-slot .plyr,
.sta-pip-slot video {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
}

.sta-pip-footer {
    background: rgba(0, 0, 0, 0.9) !important;
    padding: 5px 12px !important;
    color: rgba(255, 255, 255, 0.45) !important;
    font-size: 10px !important;
    font-weight: 500 !important;
    text-align: center !important;
    cursor: grab !important;
    user-select: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
}
.sta-pip-footer:active { cursor: grabbing !important; }

/* ── Main Course Player Wrapper ── */
.course-video-area {
    background: #020617 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5) !important;
    padding: 0 !important;
}

.course-video-wrap {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    position: relative !important;
    overflow: hidden !important;
    background: #000000 !important;
    border-radius: 15px !important;
}

.course-video-wrap .plyr,
.course-video-wrap .plyr--video,
.course-video-wrap .plyr__video-wrapper {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 16 / 9 !important;
    background: #000000 !important;
}

.course-video-wrap iframe,
.course-video-wrap video {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 16 / 9 !important;
    object-fit: contain !important;
    background: #000000 !important;
}

.plyr__poster {
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
}

/* ── Centered Stable Overlaid Play Button ── */
.plyr__control--overlaid {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 76px !important;
    height: 76px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%) !important;
    box-shadow: 0 10px 30px rgba(234, 88, 12, 0.5) !important;
    border: none !important;
    animation: none !important;
    transition: box-shadow 0.25s ease, opacity 0.25s ease !important;
    cursor: pointer !important;
    z-index: 2 !important;
}

.plyr__control--overlaid:hover,
.plyr__control--overlaid:focus,
.plyr__control--overlaid:active {
    transform: translate(-50%, -50%) !important;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    box-shadow: 0 14px 38px rgba(234, 88, 12, 0.75) !important;
}

.plyr__control--overlaid svg {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    width: 28px !important;
    height: 28px !important;
    display: block !important;
    margin: 0 !important;
    fill: #ffffff !important;
    color: #ffffff !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25)) !important;
}

.plyr__control--overlaid svg.icon--not-pressed,
.plyr__control--overlaid svg:not(.icon--pressed) {
    left: 2.5px !important;
}

.plyr__control--overlaid svg.icon--pressed {
    left: 0 !important;
}

/* ── Plyr Control Buttons & Bar ── */
.plyr__controls {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 14px 16px 12px !important;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(9, 13, 22, 0.95) 100%) !important;
    z-index: 10 !important;
}

.plyr--video .plyr__control {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.plyr--video .plyr__control:hover,
.plyr--video .plyr__control.plyr__tab-focus {
    background: rgba(245, 158, 11, 0.85) !important;
    color: #0f172a !important;
    border-color: #f59e0b !important;
    transform: translateY(-1px) scale(1.05) !important;
}

.plyr--video .plyr__control[data-plyr="play"] {
    background: #f59e0b !important;
    color: #0f172a !important;
    border-color: #f59e0b !important;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4) !important;
}

.plyr--video .plyr__control[data-plyr="play"]:hover {
    background: #fbbf24 !important;
    color: #000000 !important;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.6) !important;
}

.plyr--video .plyr__control[aria-expanded="true"] {
    background: #f59e0b !important;
    color: #0f172a !important;
    border-color: #f59e0b !important;
}

/* Ensure buttons are never hidden by vendor CSS */
.plyr--video .plyr__control[data-plyr="fullscreen"],
.plyr--video .plyr__control[data-plyr="pip"],
.plyr--video .plyr__menu {
    display: inline-flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.plyr--video .plyr__control svg {
    display: block !important;
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
    pointer-events: none !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4)) !important;
}

.plyr--video .plyr__control[data-plyr="play"] svg {
    fill: #0f172a !important;
    filter: none !important;
}

/* Explicit Flexbox Ordering across the bar */
.plyr__controls > .plyr__control[data-plyr="play"] { order: 1 !important; margin: 0 4px 0 0 !important; }
.plyr__controls > .plyr__control[data-plyr="rewind"] { order: 2 !important; margin: 0 2px !important; }
.plyr__controls > .plyr__control[data-plyr="fast-forward"] { order: 3 !important; margin: 0 6px 0 2px !important; }
.plyr__controls > .plyr__progress { order: 4 !important; flex: 1 1 auto !important; min-width: 120px !important; margin: 0 10px !important; }
.plyr__controls > .plyr__time--current { order: 5 !important; font-size: 13px !important; font-weight: 600 !important; color: #fff !important; margin: 0 2px !important; }
.plyr__controls > .plyr__time--duration { order: 6 !important; font-size: 13px !important; font-weight: 600 !important; color: rgba(255, 255, 255, 0.7) !important; margin: 0 8px 0 0 !important; }
.plyr__controls > .plyr__volume { order: 7 !important; display: flex !important; align-items: center !important; gap: 4px !important; margin: 0 8px !important; min-width: 90px !important; }
.plyr__controls > .plyr__menu { order: 8 !important; margin: 0 2px !important; }
.plyr__controls > .plyr__control[data-plyr="pip"] { order: 9 !important; margin: 0 2px !important; }
.plyr__controls > .plyr__control[data-plyr="fullscreen"] { order: 10 !important; margin: 0 0 0 2px !important; }

/* Active Mini Player action bar button */
.sta-action-btn.sta-pip-btn--active,
#sta-pip-btn.sta-pip-btn--active {
    background: #f59e0b !important;
    color: #0f172a !important;
    border-color: #f59e0b !important;
}
.sta-action-btn.sta-pip-btn--active svg,
#sta-pip-btn.sta-pip-btn--active svg {
    stroke: #0f172a !important;
}

.plyr--full-ui input[type="range"] {
    color: #f59e0b !important;
}

/* ── Next Video Circular Progress Overlay ── */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    visibility: hidden;
}

.circular-progress-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.outer-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 7;
    fill: none;
}

.circular-progress {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    stroke-dasharray: 440;
    stroke-dashoffset: 440;
    stroke: #f59e0b;
    stroke-width: 7;
    fill: none;
    transition: stroke-dashoffset 5s linear;
}

.progress-ring {
    transform: rotate(-90deg);
}

.cancel-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: pointer;
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
    font-size: 16px;
    height: 32px;
    width: 32px;
    line-height: 32px;
    border-radius: 50%;
    text-align: center;
    transition: background 0.2s ease;
}
.cancel-icon:hover {
    background: #ef4444;
}

.overlay-text {
    position: absolute;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    top: 72%;
    transform: translateY(-50%);
}

/* ── Security Blackout Pulse Animation ── */
@keyframes staPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.8; }
}
