/*!
 * VidPly v1.0.0 - Styles
 * (c) 2025 Matthias Peltzer
 * Released under GPL-2.0-or-later License
 */

/**
 * VidPly - Modern Video Player Styles
 */

/* CSS Custom Properties (Root Variables) */
:root {
    /* Primary Brand Colors */
    --vidply-active-bg: var(--vidply-white-05);
    --vidply-bg-caption: var(--vidply-black-80);
    --vidply-bg-controls: linear-gradient(180deg, rgb(var(--vidply-black-rgb), 0) 0%, rgb(var(--vidply-black-rgb), 0.9) 100%);
    --vidply-bg-dialog: rgb(20 20 20 / 98%);
    --vidply-bg-dialog-dark: rgb(18 18 18 / 98%);

    /* Primary Color Variations */
    --vidply-bg-menu: rgb(20 20 20 / 98%);
    --vidply-bg-menu-rgb: 20, 20, 20;
    --vidply-bg-overlay: var(--vidply-black-80);
    --vidply-bg-playlist: #1a1a1a;
    --vidply-bg-playlist-header: var(--vidply-black-40);
    --vidply-bg-track-info: linear-gradient(180deg, var(--vidply-black-80) 0%, var(--vidply-black-60) 100%);
    --vidply-bg-transcript: rgb(30 30 30 / 98%);
    --vidply-black: #000;
    --vidply-black-30: rgb(var(--vidply-black-rgb), 0.3);
    --vidply-black-40: rgb(var(--vidply-black-rgb), 0.4);

    /* White Color Variations */
    --vidply-black-50: rgb(var(--vidply-black-rgb), 0.5);
    --vidply-black-60: rgb(var(--vidply-black-rgb), 0.6);
    --vidply-black-80: rgb(var(--vidply-black-rgb), 0.8);
    --vidply-black-90: rgb(var(--vidply-black-rgb), 0.9);
    --vidply-black-98: rgb(var(--vidply-black-rgb), 0.98);
    --vidply-black-rgb: 0, 0, 0;
    --vidply-border: var(--vidply-white-15);
    --vidply-border-focus: var(--vidply-primary);
    --vidply-border-hover: var(--vidply-white-30);
    --vidply-border-light: var(--vidply-white-10);
    --vidply-focus-outline: 2px solid var(--vidply-primary);
    --vidply-focus-outline-white: 2px solid var(--vidply-primary-light);
    --vidply-hover-bg: var(--vidply-white-10);
    --vidply-primary: #0a406e;
    --vidply-primary-10: rgb(var(--vidply-primary-rgb), 0.1);
    --vidply-primary-15: rgb(var(--vidply-primary-rgb), 0.15);

    /* Black Color Variations */
    --vidply-primary-20: rgb(var(--vidply-primary-rgb), 0.2);
    --vidply-primary-25: rgb(var(--vidply-primary-rgb), 0.25);
    --vidply-primary-30: rgb(var(--vidply-primary-rgb), 0.3);
    --vidply-primary-40: rgb(var(--vidply-primary-rgb), 0.4);
    --vidply-primary-50: rgb(var(--vidply-primary-rgb), 0.5);
    --vidply-primary-60: rgb(var(--vidply-primary-rgb), 0.6);
    --vidply-primary-70: rgb(var(--vidply-primary-rgb), 0.7);
    --vidply-primary-80: rgb(var(--vidply-primary-rgb), 0.8);
    --vidply-primary-dark: #083358;

    /* UI Background Colors */
    --vidply-primary-dark-rgb: 8, 51, 88;
    --vidply-primary-light: #60a5fa;
    --vidply-primary-rgb: 10, 64, 110;
    --vidply-shadow-lg: 0 12px 48px var(--vidply-black-80);
    --vidply-shadow-md: 0 4px 12px var(--vidply-black-40);
    --vidply-shadow-sm: 0 2px 4px var(--vidply-black-30);
    --vidply-text-disabled: var(--vidply-white-60);
    --vidply-text-muted: var(--vidply-white-70);
    --vidply-text-primary: var(--vidply-white);
    --vidply-text-secondary: var(--vidply-white-90);
    --vidply-text-subtle: var(--vidply-white-50);

    /* Border Colors */
    --vidply-white: #fff;
    --vidply-white-05: rgb(var(--vidply-white-rgb), 0.05);
    --vidply-white-08: rgb(var(--vidply-white-rgb), 0.08);
    --vidply-white-10: rgb(var(--vidply-white-rgb), 0.1);

    /* Shadow Colors */
    --vidply-white-15: rgb(var(--vidply-white-rgb), 0.15);
    --vidply-white-20: rgb(var(--vidply-white-rgb), 0.2);
    --vidply-white-25: rgb(var(--vidply-white-rgb), 0.25);

    /* Text Colors */
    --vidply-white-30: rgb(var(--vidply-white-rgb), 0.3);
    --vidply-white-40: rgb(var(--vidply-white-rgb), 0.4);
    --vidply-white-50: rgb(var(--vidply-white-rgb), 0.5);
    --vidply-white-60: rgb(var(--vidply-white-rgb), 0.6);
    --vidply-white-70: rgb(var(--vidply-white-rgb), 0.7);

    /* State Colors */
    --vidply-white-80: rgb(var(--vidply-white-rgb), 0.8);
    --vidply-white-90: rgb(var(--vidply-white-rgb), 0.9);
    --vidply-white-95: rgb(var(--vidply-white-rgb), 0.95);
    --vidply-white-rgb: 255, 255, 255;
}

/* Reset and Base Styles */
.vidply-player {
    background: var(--vidply-black);
    box-sizing: border-box;
    color: var(--vidply-text-primary);
    contain: layout style;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    max-width: 100%;
    overflow: visible;
    position: relative;
    text-size-adjust: 100%;
    width: 100%;
}

/* Player Focus Outline */
.vidply-player:focus {
    outline: 3px solid var(--vidply-primary-light);
    outline-offset: 4px;
}

.vidply-player:focus:not(:focus-visible) {
    outline: none;
}

.vidply-player:focus-visible {
    outline: 3px solid var(--vidply-primary-light);
    outline-offset: 4px;
}

/* Mobile: Ensure player contains all elements properly */
@media (width <= 640px) {
    .vidply-player {
        isolation: isolate; /* Create stacking context */
        overflow: visible; /* Allow menus to overflow but within bounds */
    }
}

.vidply-player *,
.vidply-player *::before,
.vidply-player *::after {
    box-sizing: inherit;
}

/* Responsive container */

.vidply-player.vidply-audio {
    aspect-ratio: auto;
    background: linear-gradient(135deg, var(--vidply-primary-20) 0%, rgb(var(--vidply-primary-dark-rgb), 0.2) 100%);
    height: auto;
}

.vidply-player.vidply-audio .vidply-menu {
    max-height: 150px;
}

/* Video/Audio Element */
.vidply-player video,
.vidply-player audio {
    display: block;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

/* Mobile: Video element order and sizing */
@media (width <= 640px) {
    .vidply-player video,
    .vidply-player audio {
        flex: 0 0 auto; /* Don't grow or shrink */
        height: auto;
        order: 1; /* Before controls */
    }
}

/* Hide native browser captions - we'll display our own */
.vidply-player video::cue {
    display: none;
}

.vidply-player video::-webkit-media-text-track-container {
    display: none !important;
}

.vidply-player video::-webkit-media-text-track-display {
    display: none !important;
}

/* Video wrapper for proper clipping */
.vidply-video-wrapper {
    background: linear-gradient(135deg, var(--vidply-black) 0%, #2a2a2a 100%);
    height: 100%;
    order: 1; /* First in flex order */
    overflow: hidden;
    position: relative;
    width: 100%;
    z-index: 1; /* Base video layer */
}

/* Mobile: Simplify video wrapper */
@media (width <= 640px) {
    .vidply-video-wrapper {
        display: block;
        height: auto;
        overflow: visible;
    }
}

/* For audio players, allow menus to overflow */
.vidply-player.vidply-audio .vidply-video-wrapper {
    overflow: visible;
}

/* Hide fullscreen button in audio players */
.vidply-player.vidply-audio .vidply-fullscreen {
    display: none;
}

/* Centered Play Button Overlay */
.vidply-play-overlay {
    cursor: pointer;
    filter: drop-shadow(0 8px 32px rgb(0 0 0 / 30%));
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.vidply-play-overlay:hover {
    filter: drop-shadow(0 12px 48px rgb(0 0 0 / 40%));
    transform: translate(-50%, -50%) scale(1.1);
}

.vidply-play-overlay:hover .vidply-play-overlay-bg {
    fill: rgb(255 255 255 / 100%);
}

.vidply-play-overlay:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Hide play overlay in audio players */
.vidply-player.vidply-audio .vidply-play-overlay {
    display: none;
}

/* Controls Container */
.vidply-controls {
    background: linear-gradient(to top, var(--vidply-black-90) 0%, var(--vidply-black-50) 100%);
    bottom: 0;
    left: 0;
    opacity: 0;
    overflow: visible;
    padding: 20px 16px 16px;
    pointer-events: none;
    position: absolute;
    right: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.vidply-controls.vidply-controls-visible,
.vidply-player:hover .vidply-controls,
.vidply-player.vidply-paused .vidply-controls {
    opacity: 1;
    pointer-events: auto;
}

/* For audio players, always show controls */
.vidply-audio .vidply-controls {
    background: var(--vidply-black-50);
    opacity: 1;
    pointer-events: auto;
    position: relative;
}

/* Mobile: Controls underneath video */
@media (width <= 640px) {
    .vidply-controls {
        background: var(--vidply-black-90);
        border-top: 1px solid var(--vidply-border-light);
        bottom: auto;
        left: 0;
        opacity: 1;
        order: 2; /* After video-wrapper (1) */
        padding: 12px;
        pointer-events: auto;
        position: relative;
        right: 0;
        width: 100%;
        z-index: 10;
    }

    /* Allow menus to position within controls */
    .vidply-controls-buttons,
    .vidply-controls-left,
    .vidply-controls-right {
        position: relative;
    }
}

/* Progress Bar */
.vidply-progress-container {
    background: var(--vidply-white-20);
    border-radius: 3px;
    cursor: pointer;
    height: 5px;
    margin-bottom: 12px;
    position: relative;
    transition: height 0.2s ease;
    width: 100%;
}

.vidply-progress-container:hover,
.vidply-progress-container:focus {
    height: 8px;
}

.vidply-progress-container:focus {
    outline: var(--vidply-focus-outline-white);
    outline-offset: 2px;
}

.vidply-progress-buffered {
    background: var(--vidply-white-40);
    border-radius: 3px;
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    transition: width 0.2s ease;
    width: 0;
}

.vidply-progress-played {
    background: var(--vidply-primary-light);
    border-radius: 3px;
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    transition: width 0.1s linear;
    width: 0;
}

.vidply-progress-handle {
    background: var(--vidply-white);
    border-radius: 50%;
    box-shadow: var(--vidply-shadow-sm);
    height: 12px;
    opacity: 0;
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity 0.2s ease;
    width: 12px;
}

.vidply-progress-container:hover .vidply-progress-handle,
.vidply-progress-container:focus .vidply-progress-handle {
    opacity: 1;
}

.vidply-progress-tooltip {
    background: var(--vidply-black-90);
    border-radius: 4px;
    bottom: 12px;
    color: var(--vidply-white);
    display: none;
    font-size: 12px;
    padding: 4px 8px;
    pointer-events: none;
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Button Container */
.vidply-controls-buttons {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.vidply-controls-left,
.vidply-controls-right {
    align-items: center;
    display: flex;
    gap: 8px;
    overflow: visible;
    position: relative;
}


/* Buttons */
.vidply-button {
    align-items: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--vidply-white);
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    min-height: 32px;
    min-width: 32px;
    padding: 6px;
    position: relative;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.vidply-button:hover {
    background: var(--vidply-hover-bg);
}

.vidply-button:active {
    transform: scale(0.95);
}

.vidply-button:focus {
    outline: var(--vidply-focus-outline-white);
    outline-offset: 2px;
}

.vidply-button:focus:not(:focus-visible) {
    outline: none;
}

.vidply-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Icons */
.vidply-icon {
    display: inline-block;
    fill: currentcolor;
    height: 26px;
    width: 26px;
}

.vidply-icon svg {
    display: block;
    height: 100%;
    width: 100%;
}

/* Volume Control */
.vidply-volume-slider {
    background: var(--vidply-white-20);
    border-radius: 3px;
    cursor: pointer;
    height: 100px;
    margin: 0 auto;
    position: relative;
    width: 6px;
}

.vidply-volume-slider:focus {
    outline: var(--vidply-focus-outline-white);
    outline-offset: 2px;
}

.vidply-volume-track {
    height: 100%;
    position: relative;
    width: 100%;
}

.vidply-volume-fill {
    background: var(--vidply-primary-light);
    border-radius: 2px;
    bottom: 0;
    height: 80%;
    left: 0;
    position: absolute;
    transition: height 0.1s ease;
    width: 100%;
}

.vidply-volume-handle {
    background: var(--vidply-white);
    border-radius: 50%;
    box-shadow: var(--vidply-shadow-sm);
    height: 10px;
    left: 50%;
    position: absolute;
    top: -4px;
    transform: translateX(-50%);
    width: 10px;
}

/* Time Display */
.vidply-time {
    align-items: center;
    color: #fff;
    display: flex;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    gap: 4px;
    padding: 0 4px;
    user-select: none;
}

/* Speed Button */
.vidply-speed {
    gap: 4px;
}

.vidply-speed-text {
    font-size: 12px;
    min-width: 28px;
    text-align: center;
}

/* Menu Backdrop (for mobile) */
.vidply-menu-backdrop {
    animation: fadeIn 0.2s ease;
    background: rgb(0 0 0 / 50%);
    bottom: 0;
    display: none;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 19;
}

.vidply-menu-backdrop.visible {
    display: block;
}

/* Mobile: Don't use backdrop, menus position above buttons */
@media (width <= 640px) {
    .vidply-menu-backdrop {
        display: none !important;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Menus */
.vidply-menu {
    backdrop-filter: blur(10px);
    background: var(--vidply-bg-menu);
    border: 1px solid var(--vidply-border);
    border-radius: 8px;
    bottom: calc(100% + 8px);
    box-shadow: var(--vidply-shadow-lg), 0 0 0 1px var(--vidply-white-10);
    max-height: 250px;
    min-width: 200px;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    padding: 8px 0;
    position: absolute;
    right: 50%;
    touch-action: pan-y;

    /* iOS momentum scrolling */
    transform: translateX(50%);

    /* Ensure menus appear above all player content including overlays */
    z-index: 20;
}

/* Menu positioned below button */
.vidply-menu.vidply-menu-below::after {
    border-bottom: 6px solid var(--vidply-bg-menu);
    border-top: none;
    bottom: auto;
    top: -6px;
}

/* Arrow pointing to button */
.vidply-menu::after {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--vidply-bg-menu);
    bottom: -6px;
    content: '';
    height: 0;
    position: absolute;
    right: 50%;
    transform: translateX(50%);
    width: 0;
}

/* Volume menu popup */
.vidply-volume-menu {
    min-width: 50px;
    overflow-y: hidden;
    padding: 16px 12px;
    width: 50px;
}

/* For audio players, show menus below buttons */
.vidply-player.vidply-audio .vidply-menu {
    bottom: auto;
    top: calc(100% + 8px);
}

.vidply-player.vidply-audio .vidply-menu::after {
    border-bottom: 6px solid var(--vidply-bg-menu);
    border-top: none;
    bottom: auto;
    top: -6px;
}

.vidply-menu-item {
    align-items: center;
    background: transparent;
    border: none;
    color: var(--vidply-white);
    cursor: pointer;
    display: flex;
    font-size: 14px;
    font-weight: 400;
    justify-content: space-between;
    padding: 12px 16px;
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    width: 100%;
}

.vidply-menu-item:hover {
    background: var(--vidply-primary-20);
    color: var(--vidply-white);
}

.vidply-menu-item:focus {
    background: var(--vidply-primary-25);
    color: var(--vidply-white);
    outline: none;
}

.vidply-menu-item:active {
    background: var(--vidply-primary-30);
}

.vidply-captions-menu .vidply-menu-item:hover,
.vidply-captions-menu .vidply-menu-item:focus,
.vidply-speed-menu .vidply-menu-item:hover,
.vidply-speed-menu .vidply-menu-item:focus {
    text-decoration: underline;
}

.vidply-menu-item:hover .vidply-chapter-title,
.vidply-menu-item:focus .vidply-chapter-title {
    text-decoration: underline;
}

.vidply-menu-item-active {
    background: var(--vidply-primary-15);
    color: var(--vidply-primary-light);
}

.vidply-menu-item-active .vidply-icon {
    color: var(--vidply-primary-light);
    height: 20px;
    width: 20px;
}

.vidply-menu-item-with-value {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
}

.vidply-menu-item-label {
    align-items: center;
    display: flex;
    flex: 1;
    gap: 10px;
}

.vidply-menu-item-label .vidply-icon {
    height: 24px;
    opacity: 0.9;
    width: 24px;
}

.vidply-menu-item-value {
    background: var(--vidply-white-10);
    border-radius: 4px;
    color: var(--vidply-text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 2px 8px;
    white-space: nowrap;
}

/* Chapter menu specific */
.vidply-chapter-time {
    color: var(--vidply-text-muted);
    display: inline-block;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 500;
    margin-right: 12px;
    min-width: 60px;
}

.vidply-chapter-title {
    color: var(--vidply-white-95);
    flex: 1;
}

/* Caption style menu */
.vidply-caption-style-menu.vidply-settings-menu {
    background: var(--vidply-bg-menu);
    padding: 16px;
}

.vidply-style-group {
    margin-bottom: 16px;
}

.vidply-style-group:last-child {
    margin-bottom: 0;
}

.vidply-style-group label {
    font-weight: 500;
    letter-spacing: 0.01em;
}

.vidply-style-select,
.vidply-style-group input[type="color"],
.vidply-style-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
}

.vidply-style-select {
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.vidply-style-select:hover {
    background: var(--vidply-white-15);
    border-color: var(--vidply-border-hover);
}

.vidply-style-select:focus {
    background: var(--vidply-white-15);
    border-color: var(--vidply-border-focus);
}

.vidply-style-group input[type="color"] {
    outline: none;
    transition: border-color 0.2s ease;
}

.vidply-style-group input[type="color"]:hover {
    border-color: var(--vidply-border-hover);
}

.vidply-style-group input[type="color"]:focus {
    border-color: var(--vidply-border-focus);
}

.vidply-style-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: var(--vidply-primary);
    border: 2px solid var(--vidply-white);
    border-radius: 50%;
    box-shadow: var(--vidply-shadow-sm);
    cursor: pointer;
    height: 16px;
    transition: transform 0.15s ease, background 0.15s ease;
    width: 16px;
}

.vidply-style-group input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--vidply-primary-80);
    transform: scale(1.15);
}

.vidply-style-group input[type="range"]::-moz-range-thumb {
    background: var(--vidply-primary);
    border: 2px solid var(--vidply-white);
    border-radius: 50%;
    box-shadow: var(--vidply-shadow-sm);
    cursor: pointer;
    height: 16px;
    transition: transform 0.15s ease, background 0.15s ease;
    width: 16px;
}

.vidply-style-group input[type="range"]::-moz-range-thumb:hover {
    background: var(--vidply-primary-80);
    transform: scale(1.15);
}

.vidply-style-group input[type="range"]::-webkit-slider-runnable-track {
    background: var(--vidply-white-20);
    border-radius: 3px;
    height: 6px;
    width: 100%;
}

.vidply-style-group input[type="range"]::-moz-range-track {
    background: var(--vidply-white-20);
    border-radius: 3px;
    height: 6px;
    width: 100%;
}

/* Captions */
.vidply-captions {
    background: var(--vidply-bg-caption);
    border-radius: 4px;
    bottom: 16px;
    color: var(--vidply-white);
    display: none;
    font-family: sans-serif;
    font-size: 100%;
    left: 50%;
    line-height: 1.4;
    max-width: 90%;
    padding: 8px 16px;
    pointer-events: none;
    position: absolute;
    text-align: center;
    transform: translateX(-50%);
    transition: bottom 0.3s ease;
    z-index: 4;
}

.vidply-audio .vidply-captions {
    bottom: auto;
    top: -42px;
}

.vidply-captions:empty {
    display: none;
}

/* Desktop only: Move captions up when controls are visible */
@media (width >= 641px) {
    .vidply-controls-visible .vidply-captions {
        bottom: 96px;
    }
}

/* Mobile: Always at 121px */
@media (width <= 640px) {
    .vidply-captions {
        bottom: 122px;
    }
}

/* Settings Dialog */
.vidply-settings-overlay {
    align-items: center;
    animation: vidply-fade-in 0.2s ease;
    backdrop-filter: blur(8px);
    background: var(--vidply-bg-overlay);
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 20;
}

@keyframes vidply-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.vidply-settings-dialog {
    animation: vidply-slide-up 0.3s ease;
    background: var(--vidply-bg-dialog);
    border: 1px solid var(--vidply-border);
    border-radius: 12px;
    box-shadow: var(--vidply-shadow-lg);
    max-height: 80%;
    max-width: 500px;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    padding: 24px;

    /* iOS momentum scrolling */
    touch-action: pan-y;
    width: 90%;
}

@keyframes vidply-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.vidply-settings-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.vidply-settings-header h2 {
    color: var(--vidply-white);
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.vidply-settings-close {
    min-height: auto;
    min-width: auto;
    padding: 4px;
}

.vidply-settings-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.vidply-settings-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vidply-settings-section h3 {
    color: var(--vidply-white);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.vidply-settings-section label {
    color: var(--vidply-white-90);
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.vidply-settings-select,
.vidply-settings-color,
.vidply-settings-range {
    background: var(--vidply-white-10);
    border: 1px solid var(--vidply-white-20);
    border-radius: 6px;
    color: var(--vidply-white);
    font-size: 14px;
    padding: 8px 12px;
    transition: border-color 0.2s ease, background 0.2s ease;
    width: 100%;
}

/* Fix select option colors - black text on white background */
.vidply-settings-select option {
    background: #fff;
    color: #000;
}

.vidply-settings-select:hover,
.vidply-settings-color:hover,
.vidply-settings-range:hover {
    background: var(--vidply-white-15);
    border-color: var(--vidply-border-hover);
}

.vidply-settings-select:focus,
.vidply-settings-color:focus,
.vidply-settings-range:focus {
    background: var(--vidply-white-15);
    border-color: var(--vidply-border-focus);
    box-shadow: 0 0 0 3px var(--vidply-primary-20);
    outline: none;
}

.vidply-settings-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vidply-settings-value {
    color: var(--vidply-text-muted);
    display: inline-block;
    font-size: 13px;
    min-width: 40px;
    text-align: right;
}

.vidply-settings-footer {
    border-top: 1px solid var(--vidply-white-10);
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
}

.vidply-settings-footer .vidply-button {
    background: var(--vidply-white-10);
    border-radius: 6px;
    min-width: auto;
    padding: 10px 20px;
}

.vidply-settings-footer .vidply-button:hover {
    background: var(--vidply-white-20);
}

/* Fullscreen Styles */
.vidply-player.vidply-fullscreen,
.vidply-player:fullscreen {
    height: 100vh;
    max-width: none;
    width: 100vw;
}

/* Transcript in Fullscreen */
.vidply-player.vidply-fullscreen .vidply-transcript-window,
.vidply-player:fullscreen .vidply-transcript-window {
    bottom: 80px !important;
    height: auto !important;
    left: auto !important;
    max-height: calc(100vh - 180px) !important;
    max-width: 400px;
    position: fixed !important;
    right: 20px !important;
    top: auto !important;
    width: 400px;
}

/* Loading State */
.vidply-loading {
    display: none;
    height: 50px;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
}

.vidply-player.vidply-buffering .vidply-loading {
    display: block;
}

.vidply-loading::after {
    animation: vidply-spin 0.8s linear infinite;
    border: 4px solid var(--vidply-white-20);
    border-radius: 50%;
    border-top-color: var(--vidply-white);
    content: '';
    display: block;
    height: 100%;
    width: 100%;
}

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

/* Screen Reader Only */
.vidply-sr-only {
    height: 1px;
    left: -10000px;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .vidply-controls {
        background: var(--vidply-black);
    }

    .vidply-button:focus {
        outline: 3px solid;
    }

    .vidply-progress-played {
        background: currentcolor;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .vidply-player *,
    .vidply-player *::before,
    .vidply-player *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode (default) - additional contrast */
@media (prefers-color-scheme: dark) {
    .vidply-settings-dialog {
        background: var(--vidply-bg-dialog-dark);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .vidply-button {
        min-height: 48px;
        min-width: 48px;
    }

    .vidply-progress-container {
        height: 10px;
    }

    .vidply-menu-item {
        font-size: 16px;
        padding: 16px 20px;
    }
}

/* Responsive Breakpoints */
@media (width <= 640px) {
    .vidply-controls {
        padding: 16px 12px 12px;
    }

    .vidply-time {
        font-size: 11px;
    }

    .vidply-speed-text {
        display: none;
    }

    .vidply-settings-dialog {
        animation: slideUpFromBottom 0.3s ease;
        border-radius: 16px 16px 0 0;
        bottom: 0;
        margin: 0;
        max-height: 90vh;
        max-width: 100%;
        padding: 20px;
        position: fixed;
        top: auto;
        width: 100%;
    }

    .vidply-settings-overlay {
        align-items: flex-end;
    }

    /* Bottom sheet style for menus - positioned within controls */
    .vidply-menu {
        border-radius: 8px;
        bottom: calc(100% + 4px);
        left: 50%;
        max-height: 250px;
        min-width: 200px;
        position: absolute;
        right: auto;
        top: auto;
        transform: translateX(-50%);
        width: auto;
        z-index: 15;
    }

    .vidply-menu::after {
        border-bottom: 6px solid var(--vidply-bg-menu);
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-top: none;
        bottom: -6px;
        content: '';
        height: 0;
        left: 50%;
        position: absolute;
        transform: translateX(-50%);
        width: 0;
    }

    /* Remove the drag handle on mobile menus */
    .vidply-menu::before {
        display: none;
    }

    /* Caption style menu - narrower on mobile */
    .vidply-caption-style-menu.vidply-settings-menu {
        left: 50%;
        max-width: calc(100vw - 40px);
        min-width: 280px;
        padding: 16px;
        transform: translateX(-50%);
        width: auto;
    }

    .vidply-style-group {
        margin-bottom: 20px;
    }

    .vidply-style-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .vidply-style-select,
    .vidply-style-group input[type="color"] {
        font-size: 16px;
        padding: 12px;
    }

    /* Stack controls vertically on mobile */
    .vidply-controls-buttons {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .vidply-controls-left,
    .vidply-controls-right {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    /* Smaller buttons and icons */
    .vidply-button {
        min-height: 36px;
        min-width: 36px;
        padding: 5px;
    }

    .vidply-icon {
        height: 22px;
        width: 22px;
    }

    /* Reduce gaps */
    .vidply-controls-left,
    .vidply-controls-right {
        gap: 4px;
    }
}

@keyframes slideUpFromBottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Landscape mobile optimization */
@media (width <= 896px) and (orientation: landscape) {
    .vidply-menu {
        max-height: 50vh;
    }

    .vidply-transcript-window {
        max-height: 70vh;
    }

    .vidply-settings-dialog {
        max-height: 80vh;
    }
}

/* Extra small screens */
@media (width <= 480px) {
    .vidply-speed-text {
        display: none;
    }

    .vidply-button {
        min-height: 32px;
        min-width: 32px;
        padding: 4px;
    }

    .vidply-icon {
        height: 20px;
        width: 20px;
    }
}

/* Focus Visible Polyfill */
.vidply-player :focus:not(:focus-visible) {
    outline: none;
}

.vidply-player :focus-visible {
    outline: var(--vidply-focus-outline-white);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .vidply-controls {
        display: none;
    }
}

/* ============================================================================
   Playlist Styles
   ============================================================================ */

/* Track Info Display (below video, above playlist) */
.vidply-track-info {
    background: var(--vidply-bg-track-info);
    border-bottom: 1px solid var(--vidply-border-light);
    order: 2; /* After video-wrapper */
    padding: 16px 20px;
}

.vidply-track-number {
    color: var(--vidply-text-muted);
    font-size: 12px;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.vidply-track-title {
    color: var(--vidply-white);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.vidply-track-artist {
    color: var(--vidply-white-80);
    font-size: 14px;
}

/* Playlist Panel */
.vidply-playlist-panel {
    background: var(--vidply-bg-playlist);
    border-top: 1px solid var(--vidply-border-light);
    max-height: 400px;
    order: 3; /* After track info */
    -webkit-overflow-scrolling: touch;

    /* iOS momentum scrolling */
    overflow-y: auto;
    touch-action: pan-y;
}

.vidply-playlist-header {
    background: var(--vidply-bg-playlist-header);
    border-bottom: 1px solid var(--vidply-border-light);
    color: var(--vidply-white-90);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 2;
}

.vidply-playlist-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

/* Playlist Items */
.vidply-playlist-item {
    align-items: center;
    background: transparent;
    border-left: 3px solid transparent;
    cursor: pointer;
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    position: relative;
    transition: all 0.2s ease;
}

.vidply-playlist-item:hover {
    background: var(--vidply-active-bg);
    border-left-color: var(--vidply-primary-50);
}

.vidply-playlist-item:focus {
    background: var(--vidply-white-08);
    border-left-color: var(--vidply-primary);
    outline: 2px solid var(--vidply-primary-light);
    outline-offset: -2px;
    z-index: 1;
}

.vidply-playlist-item:focus:not(:focus-visible) {
    outline: none;
}

.vidply-playlist-item:focus-visible {
    background: var(--vidply-white-08);
    border-left-color: var(--vidply-primary);
    outline: 2px solid var(--vidply-primary-light);
    outline-offset: -2px;
    z-index: 1;
}

.vidply-playlist-item-active {
    background: var(--vidply-primary-15);
    border-left-color: var(--vidply-primary);
}

.vidply-playlist-item-active:hover {
    background: var(--vidply-primary-20);
}

.vidply-playlist-item-active:focus,
.vidply-playlist-item-active:focus-visible {
    background: var(--vidply-primary-20);
    outline: 2px solid var(--vidply-primary-light);
    outline-offset: -2px;
}

/* Playlist Thumbnail */
.vidply-playlist-thumbnail {
    align-items: center;
    background-color: var(--vidply-white-10);
    background-position: center;
    background-size: cover;
    border-radius: 4px;
    display: flex;
    flex-shrink: 0;
    height: 45px;
    justify-content: center;
    overflow: hidden;
    width: 80px;
}

.vidply-playlist-thumbnail-icon {
    color: var(--vidply-text-subtle);
    height: 32px;
    transition: all 0.2s ease;
    width: 32px;
}

.vidply-playlist-item:hover .vidply-playlist-thumbnail-icon {
    color: var(--vidply-text-muted);
    transform: scale(1.1);
}

.vidply-playlist-item-active .vidply-playlist-thumbnail-icon {
    color: var(--vidply-primary-light);
}

/* Playlist Item Info */
.vidply-playlist-item-info {
    flex: 1;
    min-width: 0;
}

.vidply-playlist-item-title {
    color: var(--vidply-white);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vidply-playlist-item-active .vidply-playlist-item-title {
    color: var(--vidply-primary-light);
}

.vidply-playlist-item-artist {
    color: var(--vidply-text-disabled);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Playlist Item Icon */
.vidply-playlist-item-icon {
    flex-shrink: 0;
    height: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
    width: 20px;
}

.vidply-playlist-item:hover .vidply-playlist-item-icon,
.vidply-playlist-item-active .vidply-playlist-item-icon {
    opacity: 0.7;
}

.vidply-playlist-item-active .vidply-playlist-item-icon {
    color: var(--vidply-primary-light);
    opacity: 1;
}

/* Playlist Scrollbar */
.vidply-playlist-panel::-webkit-scrollbar {
    width: 8px;
}

.vidply-playlist-panel::-webkit-scrollbar-track {
    background: var(--vidply-black-30);
}

.vidply-playlist-panel::-webkit-scrollbar-thumb {
    background: var(--vidply-white-20);
    border-radius: 4px;
}

.vidply-playlist-panel::-webkit-scrollbar-thumb:hover {
    background: var(--vidply-border-hover);
}

/* Audio Player with Playlist */
.vidply-player.vidply-audio.vidply-has-playlist {
    min-height: 200px;
}

.vidply-player.vidply-audio.vidply-has-playlist audio {
    display: none;
}

.vidply-player.vidply-audio.vidply-has-playlist .vidply-video-wrapper {
    flex: 1;
}

.vidply-player.vidply-audio.vidply-has-playlist .vidply-controls {
    margin-top: auto;
}

/* Transcript Window */
.vidply-transcript-window {
    backdrop-filter: blur(10px);
    background: var(--vidply-bg-transcript);
    border: 1px solid var(--vidply-border);
    border-radius: 8px;
    box-shadow: 0 10px 40px var(--vidply-black-60);
    display: none;
    flex-direction: column;
    max-width: 400px;
    order: 4; /* After video-wrapper (1), track-info (2), and playlist-panel (3) */
    position: absolute;
    top: 0;
    width: 400px;
    z-index: 5;
}

/* Minimum height for audio player transcript */
.vidply-player.vidply-audio .vidply-transcript-window {
    min-height: 200px;
}

.vidply-transcript-header {
    align-items: center;
    background: var(--vidply-active-bg);
    border-bottom: 1px solid var(--vidply-border-light);
    border-radius: 8px 8px 0 0;
    cursor: move;
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    user-select: none;
}

.vidply-transcript-header h3 {
    color: var(--vidply-white);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.vidply-transcript-close {
    align-items: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--vidply-text-muted);
    cursor: pointer;
    display: flex;
    height: 28px;
    justify-content: center;
    padding: 4px;
    transition: all 0.2s ease;
    width: 28px;
}

.vidply-transcript-close:hover {
    background: var(--vidply-white-10);
    color: var(--vidply-white);
}

.vidply-transcript-close .vidply-icon {
    height: 18px;
    width: 18px;
}

.vidply-transcript-content {
    flex: 1;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;

    /* iOS momentum scrolling */
    padding: 12px 0;
    touch-action: pan-y;
}

.vidply-transcript-entry {
    border-left: 3px solid transparent;
    cursor: pointer;
    padding: 12px 20px;
    transition: background 0.2s ease;
}

.vidply-transcript-entry:hover,
.vidply-transcript-entry:focus {
    background: var(--vidply-active-bg);
}

.vidply-transcript-entry-active {
    background: var(--vidply-primary-15);
    border-left-color: var(--vidply-primary-light);
}

.vidply-transcript-time {
    color: var(--vidply-primary-light);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    margin-right: 8px;
}

.vidply-transcript-text {
    color: var(--vidply-white-90);
    font-size: 14px;
    line-height: 1.6;
}

.vidply-transcript-entry-active .vidply-transcript-text {
    color: var(--vidply-white);
    text-decoration: underline;
}

.vidply-transcript-entry:hover .vidply-transcript-text,
.vidply-transcript-entry:focus .vidply-transcript-text {
    text-decoration: underline;
}

/* Transcript Scrollbar */
.vidply-transcript-content::-webkit-scrollbar {
    width: 8px;
}

.vidply-transcript-content::-webkit-scrollbar-track {
    background: var(--vidply-black-30);
}

.vidply-transcript-content::-webkit-scrollbar-thumb {
    background: var(--vidply-white-20);
    border-radius: 4px;
}

.vidply-transcript-content::-webkit-scrollbar-thumb:hover {
    background: var(--vidply-border-hover);
}

/* Sign Language Video */
.vidply-sign-language-video {
    background: var(--vidply-black);
    border: 2px solid var(--vidply-white-30);
    border-radius: 4px;
    box-shadow: 0 4px 12px var(--vidply-black-60);
    height: auto !important;
    max-width: 400px;
    min-width: 150px;
    position: absolute;
    transition: opacity 0.3s ease;
    width: 35% !important;
    z-index: 3;
}

.vidply-fullscreen .vidply-sign-language-video {
    max-width: 600px;
}

/* Sign Language Video Positions */
.vidply-sign-position-bottom-right {
    bottom: 16px; /* Above controls */
    right: 16px;
}

.vidply-controls-visible + .vidply-sign-position-bottom-right,
.vidply-controls-visible + .vidply-captions + .vidply-sign-position-bottom-right {
    bottom: 95px; /* Above controls */
}

.vidply-sign-position-bottom-left {
    bottom: 16px; /* Above controls */
    left: 16px;
}

.vidply-controls-visible + .vidply-sign-position-bottom-left,
.vidply-controls-visible + .vidply-captions + .vidply-sign-position-bottom-left {
    bottom: 95px; /* Above controls */
}

.vidply-sign-position-top-right {
    right: 16px;
    top: 16px;
}

.vidply-sign-position-top-left {
    left: 16px;
    top: 16px;
}

/* Responsive Sign Language Video */
@media (width <= 640px) {
    .vidply-sign-language-video {
        min-width: 120px;
        width: 35%;
    }
    
    .vidply-sign-position-bottom-right,
    .vidply-sign-position-bottom-left {
        bottom: 126px !important; /* Adjust for smaller controls */
    }
}

/* Responsive Adjustments */
@media (width <= 640px) {
    .vidply-playlist-thumbnail {
        height: 34px;
        width: 60px;
    }

    .vidply-playlist-item {
        gap: 10px;
        padding: 10px 12px;
    }

    .vidply-track-info {
        padding: 12px 16px;
    }

    .vidply-track-title {
        font-size: 16px;
    }

    /* Mobile transcript underneath video and controls */
    .vidply-transcript-window {
        border: none;
        border-radius: 0;
        border-top: 1px solid var(--vidply-border-light);
        box-shadow: none;
        order: 3; /* After controls (which are order: 2) */
        position: relative;
        width: 100%;
        z-index: 5;
    }

    .vidply-transcript-header {
        border-radius: 0;
        padding: 12px 16px;
    }

    .vidply-transcript-content {
        max-height: 400px;
    }

    /* Don't show dragging cursor on mobile */
    .vidply-transcript-header {
        cursor: default !important;
    }
}

