/**
 * Video Thumbnail Widget Styles
 */

.vtw-video-container {
    position: fixed;
    bottom: var(--vtw-bottom-offset, 20px);
    width: var(--vtw-small-width, 200px);
    height: var(--vtw-small-height, 150px);
    z-index: 2147483647;
    border-radius: var(--vtw-border-radius, 8px);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: #000;
}

/* Position variants */
.vtw-video-container.vtw-position-left {
    left: var(--vtw-side-offset, 20px);
}

.vtw-video-container.vtw-position-right {
    right: var(--vtw-side-offset, 20px);
}

/* Expanded state */
.vtw-video-container.vtw-expanded {
    width: var(--vtw-large-width, 400px);
    height: var(--vtw-large-height, 300px);
    cursor: default;
}

/* Video element */
.vtw-video-container .vtw-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}

/* Hide all native video controls */
.vtw-video-container .vtw-video {
    outline: none;
}

.vtw-video-container .vtw-video::-webkit-media-controls-panel,
.vtw-video-container .vtw-video::-webkit-media-controls-play-button,
.vtw-video-container .vtw-video::-webkit-media-controls-start-playback-button,
.vtw-video-container .vtw-video::-webkit-media-controls {
    display: none !important;
    -webkit-appearance: none;
}

.vtw-video-container .vtw-video::-moz-media-controls {
    display: none !important;
}

.vtw-video-container .vtw-video::--ms-media-controls {
    display: none !important;
}

/* Close button */
.vtw-close-btn, .vtw-close-btn:focus {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0;
}

.vtw-close-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.vtw-close-btn span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    line-height: 1;
}

/* Custom Video Controls */
.vtw-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 20px 16px 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 5;
}

.vtw-video-container.vtw-expanded:hover .vtw-controls,
.vtw-video-container.vtw-expanded .vtw-controls:focus-within {
    opacity: 1;
    visibility: visible;
}

.vtw-video-container:not(.vtw-expanded) .vtw-controls {
    display: none;
}

/* Top Row - Play button, progress bar, and time */
.vtw-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Bottom Row - Speed controls and volume */
.vtw-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Play/Pause Button */
.vtw-play-btn {
    background: transparent !important;
    border: none !important;
    padding: 8px !important;
    color: #ffffff !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 40px !important;
    height: 40px !important;
    font-size: 0 !important;
    box-shadow: none !important;
    outline: none !important;
}

.vtw-play-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    transform: scale(1.05) !important;
}

.vtw-play-btn:focus {
    background: rgba(255, 255, 255, 0.2) !important;
    outline: 2px solid #ffffff !important;
    outline-offset: 2px !important;
}

.vtw-play-btn:active {
    transform: scale(0.95) !important;
    background: rgba(255, 255, 255, 0.3) !important;
}

.vtw-play-btn svg {
    width: 20px !important;
    height: 20px !important;
    fill: currentColor !important;
    pointer-events: none !important;
}

/* Progress Container */
.vtw-progress-container {
    flex: 1;
    cursor: pointer;
    padding: 8px 0;
    margin: 0 16px;
}

.vtw-progress-track {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.vtw-progress-bar {
    height: 100%;
    background: #ffffff;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s ease;
}

.vtw-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

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

.vtw-progress-container:hover .vtw-progress-track {
    height: 6px;
}

/* Time Display */
.vtw-time-display {
    color: #ffffff !important;
    font-size: 13px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    min-width: 80px !important;
}

.vtw-time-separator {
    opacity: 0.7;
}

/* Volume Container */
.vtw-volume-container {
    position: relative;
    display: flex;
    align-items: center;
}

.vtw-volume-btn {
    background: transparent !important;
    border: none !important;
    padding: 8px !important;
    color: #ffffff !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 40px !important;
    height: 40px !important;
    font-size: 0 !important;
    box-shadow: none !important;
    outline: none !important;
}

.vtw-volume-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    transform: scale(1.05) !important;
}

.vtw-volume-btn:focus {
    background: rgba(255, 255, 255, 0.2) !important;
    outline: 2px solid #ffffff !important;
    outline-offset: 2px !important;
}

.vtw-volume-btn:active {
    transform: scale(0.95) !important;
    background: rgba(255, 255, 255, 0.3) !important;
}

.vtw-volume-btn svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
    pointer-events: none !important;
}

/* Volume Slider */
.vtw-volume-slider {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 16px 8px;
    border-radius: 8px;
    margin-bottom: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.vtw-volume-container:hover .vtw-volume-slider,
.vtw-volume-slider:focus-within {
    opacity: 1;
    visibility: visible;
}

.vtw-volume-track {
    position: relative;
    width: 4px;
    height: 80px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
}

.vtw-volume-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 2px;
    height: 100%;
    transition: height 0.1s ease;
}

.vtw-volume-handle {
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    transform: translateX(-50%);
    cursor: pointer;
}

/* Speed Controls */
.vtw-speed-controls {
    display: flex !important;
    gap: 8px !important;
}

.vtw-speed-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    padding: 6px 12px !important;
    border-radius: 16px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-width: 40px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    outline: none !important;
}

.vtw-speed-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    transform: translateY(-1px) !important;
}

.vtw-speed-btn:focus {
    background: rgba(255, 255, 255, 0.2) !important;
    outline: 2px solid #ffffff !important;
    outline-offset: 2px !important;
}

.vtw-speed-btn:active {
    transform: translateY(0) scale(0.95) !important;
    background: rgba(255, 255, 255, 0.3) !important;
}

.vtw-speed-btn.vtw-active {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: #ffffff !important;
}

.vtw-speed-btn.vtw-active:hover {
    background: rgba(255, 255, 255, 0.9) !important;
    transform: translateY(-1px) !important;
}

.vtw-speed-btn.vtw-active:active {
    transform: translateY(0) scale(0.95) !important;
    background: rgba(255, 255, 255, 0.8) !important;
}

/* Delayed start state - initially hidden */
.vtw-video-container.vtw-delayed-start {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
}

/* Show delayed start video when ready */
.vtw-video-container.vtw-delayed-start.vtw-show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Hidden state - highest priority */
.vtw-video-container.vtw-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(100%) !important;
}

/* Loading state */
.vtw-video-container.vtw-loading {
    background: #000;
}

.vtw-video-container.vtw-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: vtw-spin 1s linear infinite;
}

@keyframes vtw-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .vtw-video-container {
        width: var(--vtw-small-width, 200px);
        height: var(--vtw-small-height, 150px);
        bottom: var(--vtw-bottom-offset, 20px);
    }
    
    .vtw-video-container.vtw-position-left {
        left: var(--vtw-side-offset, 20px);
    }
    
    .vtw-video-container.vtw-position-right {
        right: var(--vtw-side-offset, 20px);
    }
    
    .vtw-video-container.vtw-expanded {
        width: 100vw !important;
        height: 100vh !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 0 !important;
    }
    
    .vtw-close-btn {
        width: 25px;
        height: 25px;
        font-size: 15px;
        top: 5px;
        right: 5px;
    }
}

@media (max-width: 480px) {
    .vtw-video-container {
        width: var(--vtw-small-width, 200px);
        height: var(--vtw-small-height, 150px);
    }
    
    .vtw-video-container.vtw-expanded {
        width: 100vw !important;
        height: 100vh !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 0 !important;
    }
}

/* Accessibility improvements */
.vtw-video-container:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.vtw-close-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Prevent video from interfering with page scroll */
.vtw-video-container .vtw-video {
    touch-action: none;
}

/* Smooth transitions for better UX */
.vtw-video-container * {
    transition: opacity 0.3s ease;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .vtw-close-btn {
        background: #000;
        border: 1px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .vtw-video-container,
    .vtw-video-container *,
    .vtw-close-btn {
        transition: none !important;
        animation: none !important;
    }
}
