/**
 * Fix2QIK Secure Video Player Styles
 * 
 * Minimal, theme-agnostic styling for video player.
 * Dark theme by default, responsive design.
 * 
 * @package Fix2QIK_Secure_Video
 * @version 1.0.0
 */

/* === Base Container === */
.f2qsv-player {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    background: #000;
    color: #fff;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    border-radius: 4px;
}

/* Aspect ratio containers */
.f2qsv-player.f2qsv-aspect-16-9 {
    aspect-ratio: 16 / 9;
}

.f2qsv-player.f2qsv-aspect-4-3 {
    aspect-ratio: 4 / 3;
}

.f2qsv-player.f2qsv-aspect-1-1 {
    aspect-ratio: 1 / 1;
}

.f2qsv-player.f2qsv-aspect-21-9 {
    aspect-ratio: 21 / 9;
}

/* Container for video + UI */
.f2qsv-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* === Video Element === */
.f2qsv-video-element {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    cursor: pointer;
}

/* === iFrame (YouTube/Vimeo) === */
.f2qsv-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* === Loading State === */
.f2qsv-loader,
.f2qsv-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 14px;
    z-index: 10;
}

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

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

/* === Error State === */
.f2qsv-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 2rem;
    text-align: center;
    min-height: 200px;
    color: #ff6b6b;
    background: rgba(0, 0, 0, 0.9);
}

.f2qsv-error svg {
    opacity: 0.7;
}

/* === Player UI Controls === */
.f2qsv-ui {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 20;
}

.f2qsv-ui.f2qsv-ui-visible,
.f2qsv-container:hover .f2qsv-ui,
.f2qsv-player:focus-within .f2qsv-ui {
    opacity: 1;
}

/* === Buttons === */
.f2qsv-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease;
    flex-shrink: 0;
}

.f2qsv-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.f2qsv-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.f2qsv-btn svg {
    display: block;
}

/* === Time Display === */
.f2qsv-time {
    min-width: 90px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    flex-shrink: 0;
}

/* === Seek Bar === */
.f2qsv-seek-wrapper {
    flex: 1;
    min-width: 60px;
    display: flex;
    align-items: center;
}

.f2qsv-seek {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
}

.f2qsv-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease;
}

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

.f2qsv-seek::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* === Volume Control === */
.f2qsv-volume-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.f2qsv-volume {
    -webkit-appearance: none;
    appearance: none;
    width: 60px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
}

.f2qsv-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

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

/* Hide volume slider on narrow screens, show on hover */
@media (max-width: 500px) {
    .f2qsv-volume {
        width: 0;
        opacity: 0;
        transition: width 0.2s ease, opacity 0.2s ease;
    }
    
    .f2qsv-volume-wrapper:hover .f2qsv-volume,
    .f2qsv-volume-wrapper:focus-within .f2qsv-volume {
        width: 50px;
        opacity: 1;
    }
}

/* === Speed Control === */
.f2qsv-speed {
    padding: 4px 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
}

.f2qsv-speed:hover,
.f2qsv-speed:focus {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.7);
}

.f2qsv-speed option {
    background: #222;
    color: #fff;
}

/* === Fullscreen Styles === */
.f2qsv-container:fullscreen,
.f2qsv-container:-webkit-full-screen {
    width: 100%;
    height: 100%;
    background: #000;
}

.f2qsv-container:fullscreen .f2qsv-video-element,
.f2qsv-container:-webkit-full-screen .f2qsv-video-element {
    max-height: 100vh;
}

/* === Responsive Adjustments === */
@media (max-width: 400px) {
    .f2qsv-ui {
        gap: 6px;
        padding: 8px;
    }
    
    .f2qsv-btn {
        width: 28px;
        height: 28px;
    }
    
    .f2qsv-time {
        font-size: 11px;
        min-width: 75px;
    }
    
    .f2qsv-speed {
        font-size: 11px;
        padding: 3px 4px;
    }
}

/* Hide speed on very small screens */
@media (max-width: 320px) {
    .f2qsv-speed {
        display: none;
    }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {
    .f2qsv-spinner {
        animation: none;
    }
    
    .f2qsv-ui,
    .f2qsv-seek::-webkit-slider-thumb {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .f2qsv-btn {
        border: 1px solid #fff;
    }
    
    .f2qsv-seek,
    .f2qsv-volume {
        background: #666;
    }
}

/* === Print === */
@media print {
    .f2qsv-player {
        display: none;
    }
}

/* Download Button (v1.3.0+) */
.f2qsv-download-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s;
    width: 40px;
    height: 40px;
}

.f2qsv-download-btn:hover {
    opacity: 1;
}

.f2qsv-download-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.f2qsv-download-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Ads-Off Badge (v1.3.0+) */
.f2qsv-adsoff-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 6px 12px;
    background: rgba(40, 167, 69, 0.9);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    z-index: 30;
    pointer-events: none;
}

/* Navigation buttons (v1.5.0+) */
.f2qsv-btn-prev,
.f2qsv-btn-next {
    opacity: 0.5;
    cursor: not-allowed;
}

.f2qsv-btn-prev:not(:disabled),
.f2qsv-btn-next:not(:disabled) {
    opacity: 1;
    cursor: pointer;
}

.f2qsv-btn-prev:not(:disabled):hover,
.f2qsv-btn-next:not(:disabled):hover {
    background: rgba(255,255,255,0.25);
}

/* Playlist indicator (v1.5.0+) */
.f2qsv-playlist-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 12px;
    border-radius: 4px;
    z-index: 30;
    pointer-events: none;
}

/* Hide navigation on very small screens */
@media (max-width: 360px) {
    .f2qsv-btn-prev,
    .f2qsv-btn-next {
        display: none;
    }
}

/* ====================
   Quality Control (v1.6.0+)
   ==================== */

/* Quality button */
.f2qsv-btn-quality {
    position: relative;
}

/* Quality menu dropdown */
.f2qsv-quality-menu {
    position: absolute;
    bottom: 45px;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    border-radius: 6px;
    padding: 8px 0;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* Quality menu option */
.f2qsv-quality-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    color: #fff;
    border: none;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.f2qsv-quality-option.active {
    background: rgba(33, 150, 243, 0.3);
    color: #2196f3;
    font-weight: 600;
}

.f2qsv-quality-option.active::after {
    content: ' ✓';
    float: right;
}

/* Quality switching loader */
.f2qsv-quality-switching {
    background: rgba(0, 0, 0, 0.85);
}

.f2qsv-quality-switching span {
    color: #2196f3;
    font-weight: 600;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .f2qsv-quality-menu {
        bottom: 40px;
        min-width: 140px;
    }
    
    .f2qsv-quality-option {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ====================
   Download Progress (v1.6.1)
   Mobile network fix with progress indicator
   ==================== */

.f2qsv-loading-text {
    color: #fff;
    font-size: 14px;
    margin-bottom: 4px;
}

.f2qsv-loading-progress {
    width: 80%;
    max-width: 280px;
    text-align: center;
}

.f2qsv-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.f2qsv-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2196f3, #21cbf3);
    border-radius: 3px;
    width: 0%;
    transition: width 0.2s ease;
}

.f2qsv-progress-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* Animate the progress bar shimmer */
@keyframes f2qsv-progress-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

.f2qsv-progress-fill {
    background-size: 200px 100%;
    animation: f2qsv-progress-shimmer 1.5s ease-in-out infinite;
}

/* Mobile-specific styles */
@media (max-width: 480px) {
    .f2qsv-loading-progress {
        width: 90%;
    }
    
    .f2qsv-loading-text {
        font-size: 13px;
    }
}

/* ====================
   v1.9.0 - Lazy-load placeholder
   ==================== */

/* Wrapper class added in lazy mode (single-video player) */
.f2qsv-wrapper.f2qsv-lazy,
.f2qsv-pl-video-area.f2qsv-lazy {
    position: relative;
}

/* The placeholder div replaces the <video> element until the user clicks */
.f2qsv-lazy-placeholder {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    outline: none;
}

.f2qsv-lazy-placeholder:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* The big centered play button - SVG circle with triangle */
.f2qsv-lazy-play-btn {
    pointer-events: none; /* clicks are handled by the placeholder itself */
    transition: transform 0.15s ease;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.f2qsv-lazy-placeholder:hover .f2qsv-lazy-play-btn {
    transform: scale(1.08);
}

/* Fallback when no poster is set: subtle gradient instead of pure black */
.f2qsv-lazy-placeholder:not([style*="background-image"]) {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}

/* ====================
   v1.9.0 - Playlist track list (Audiplay-style)
   ==================== */

.f2qsv-pl-tracklist {
    margin-top: 0;
    background: #1f2937;
    color: #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    overflow: hidden;
}

/* Header bar - clickable to collapse */
.f2qsv-pl-tracklist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #111827;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid #374151;
    outline: none;
}

.f2qsv-pl-tracklist-header:hover {
    background: #1f2937;
}

.f2qsv-pl-tracklist-header:focus-visible {
    outline: 2px solid #f59e0b;
    outline-offset: -2px;
}

.f2qsv-pl-tracklist-title {
    font-weight: 600;
    color: #f3f4f6;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Header label collapse arrow is now Unicode in the title text (▼/▲), so the
   chevron SVG element and its rotation rule from v1.9.0/v1.9.2 are gone. */

.f2qsv-pl-tracklist-collapsed .f2qsv-pl-tracklist-body {
    display: none;
}

/* Body - scrollable list of rows */
.f2qsv-pl-tracklist-body {
    max-height: 320px;
    overflow-y: auto;
    background: #1f2937;
}

/* Individual track row */
.f2qsv-pl-track {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(75, 85, 99, 0.4);
    cursor: pointer;
    transition: background-color 0.12s ease;
    outline: none;
}

.f2qsv-pl-track:last-child {
    border-bottom: none;
}

.f2qsv-pl-track:hover:not(.f2qsv-pl-track-locked):not(.f2qsv-pl-track-current) {
    background: #374151;
}

.f2qsv-pl-track:focus-visible {
    outline: 2px solid #f59e0b;
    outline-offset: -2px;
}

/* Number badge */
.f2qsv-pl-track-num {
    flex: 0 0 28px;
    text-align: center;
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    margin-right: 10px;
}

/* Label */
.f2qsv-pl-track-label {
    flex: 1;
    color: #e5e7eb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Current playing item - orange accent */
.f2qsv-pl-track-current {
    background: rgba(245, 158, 11, 0.08);
    cursor: default;
}

.f2qsv-pl-track-current .f2qsv-pl-track-num,
.f2qsv-pl-track-current .f2qsv-pl-track-label {
    color: #f59e0b;
    font-weight: 600;
}

/* Past items - dimmer but clickable */
.f2qsv-pl-track-past .f2qsv-pl-track-num {
    color: #6b7280;
}

/* Locked items - greyed out, not clickable */
.f2qsv-pl-track-locked {
    cursor: not-allowed;
    opacity: 0.45;
}

.f2qsv-pl-track-locked:hover {
    background: transparent;
}

/* Scrollbar styling for body */
.f2qsv-pl-tracklist-body::-webkit-scrollbar {
    width: 8px;
}

.f2qsv-pl-tracklist-body::-webkit-scrollbar-track {
    background: #111827;
}

.f2qsv-pl-tracklist-body::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 4px;
}

.f2qsv-pl-tracklist-body::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* On narrow screens, slightly smaller padding */
@media (max-width: 480px) {
    .f2qsv-pl-tracklist-header,
    .f2qsv-pl-track {
        padding: 9px 12px;
    }
    
    .f2qsv-pl-tracklist-body {
        max-height: 240px;
    }
}

/* ====================
   v1.9.3 - Playlist container layout fix
   ====================

   Bug: in v1.9.0 the track list became a sibling of the video area inside the
   playlist's outer container. But that container inherits .f2qsv-player rules:
       aspect-ratio: 16/9 (or whichever variant) -> locks the container height
       overflow: hidden                          -> clips anything below
   So the track list rendered but was clipped off-screen, height-locked.

   Fix: for the playlist case only, drop aspect-ratio from the outer container
   (let it size to its content) and drop overflow:hidden (let the track list
   show below). Move aspect-ratio onto the inner .f2qsv-pl-video-area which
   wraps the <video>, so the video itself still has its locked 16:9 / 4:3 / etc.
   box. Single-video player rules are untouched.

   Specificity: .f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-* is (0,3,0)
   which beats the original (0,2,0) .f2qsv-player.f2qsv-aspect-* rules
   regardless of source order, so no !important needed.
*/

.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-16-9,
.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-4-3,
.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-1-1,
.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-21-9 {
    aspect-ratio: auto;
}

.f2qsv-player.f2qsv-playlist-player {
    overflow: visible;
    background: transparent;
}

/* Video area wraps the <video> and inherits the aspect ratio that used to
   sit on the outer container. Also keeps the rounded top corners + clip so
   the video edges meet the rounded card cleanly. */
.f2qsv-player.f2qsv-playlist-player .f2qsv-pl-video-area {
    position: relative;
    background: #000;
    overflow: hidden;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-16-9 .f2qsv-pl-video-area {
    aspect-ratio: 16 / 9;
}
.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-4-3 .f2qsv-pl-video-area {
    aspect-ratio: 4 / 3;
}
.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-1-1 .f2qsv-pl-video-area {
    aspect-ratio: 1 / 1;
}
.f2qsv-player.f2qsv-playlist-player.f2qsv-aspect-21-9 .f2qsv-pl-video-area {
    aspect-ratio: 21 / 9;
}

/* Track list sits flush against video area; remove top radius so the seam is
   clean (it already has its own bottom radius from v1.9.0). */
.f2qsv-player.f2qsv-playlist-player .f2qsv-pl-tracklist {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
