/* Custom Video Player Styles */

.custom-player-wrapper {
    width: 100%;
    margin: 2rem 0;
}

.custom-video-player {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
}

.video-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1;
}

.custom-video-player:has(.video-thumbnail[style*="display: none"]) .video-element,
.custom-video-player .video-thumbnail[style*="display: none"] ~ * .video-element {
    z-index: 1;
}

.custom-video-player .video-thumbnail {
    z-index: 2;
}

/* Thumbnail Preview */
.video-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    cursor: pointer;
    z-index: 2;
}

.video-thumbnail.hidden {
    display: none !important;
}

.custom-video-player.playing .video-element {
    z-index: 2;
}

.custom-video-player.playing .video-thumbnail {
    z-index: 1;
}

.thumbnail-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease;
}

.play-overlay:hover {
    background: rgba(0, 0, 0, 0.5);
}

.play-button-large {
    width: 80px;
    height: 80px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.play-button-large:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
}

.play-button-large svg {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    color: #000;
}

/* Video Controls */
.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 40px 20px 15px;
    transform: translateY(0);
    transition: all 0.3s ease;
    z-index: 3;
}

.video-controls.visible {
    opacity: 1;
}

.custom-video-player:not(:hover) .video-controls:not(.visible) {
    opacity: 0;
    transform: translateY(10px);
}

.controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Progress Bar */
.progress-bar-container {
    position: relative;
    margin-bottom: 15px;
}

.progress-bar {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    transition: height 0.2s ease;
}

.progress-bar:hover {
    height: 8px;
}

.progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    pointer-events: none;
}

.progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--card-primary-color, #00a1e1);
    border-radius: 3px;
    pointer-events: none;
}

.progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.progress-bar:hover .progress-handle {
    opacity: 1;
}

.time-tooltip {
    position: absolute;
    bottom: 15px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    transform: translateX(-50%);
    display: none;
}

/* Controls Row */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Control Buttons */
.video-controls button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.video-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.video-controls button svg {
    width: 20px;
    height: 20px;
}

.play-pause-btn svg {
    width: 24px;
    height: 24px;
}

/* Volume Control */
.volume-control {
    display: flex;
    align-items: center;
    position: relative;
}

.volume-control:hover .volume-slider {
    width: 80px;
    opacity: 1;
    margin-left: 10px;
}

.volume-slider {
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.volume-range {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
}

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

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

/* Time Display */
.time-display {
    color: white;
    font-size: 14px;
    font-family: monospace;
    user-select: none;
}

.time-separator {
    opacity: 0.5;
}

/* Speed Button */
.speed-btn {
    min-width: 40px;
}

.speed-text {
    font-size: 14px;
    font-weight: 600;
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* Fullscreen Styles */
.custom-video-player:fullscreen {
    border-radius: 0;
}

.custom-video-player:fullscreen .video-controls {
    padding: 60px 40px 20px;
}

.custom-video-player:fullscreen .controls-row {
    font-size: 16px;
}

.custom-video-player:fullscreen .play-button-large {
    width: 100px;
    height: 100px;
}

.custom-video-player:fullscreen .play-button-large svg {
    width: 40px;
    height: 40px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .video-controls {
        padding: 30px 15px 10px;
    }
    
    .controls-row {
        font-size: 12px;
    }
    
    .video-controls button {
        padding: 6px;
    }
    
    .video-controls button svg {
        width: 18px;
        height: 18px;
    }
    
    .play-button-large {
        width: 60px;
        height: 60px;
    }
    
    .play-button-large svg {
        width: 24px;
        height: 24px;
    }
    
    .volume-control:hover .volume-slider {
        width: 60px;
    }
    
    .pip-btn,
    .speed-btn {
        display: none;
    }
}

/* Keyboard Focus Styles */
.video-controls button:focus {
    outline: 2px solid var(--card-primary-color, #00a1e1);
    outline-offset: 2px;
}

/* Picture-in-Picture */
.custom-video-player.pip-active {
    opacity: 0.7;
}

/* Error Display */
.video-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    z-index: 5;
}

.error-content {
    text-align: center;
    padding: 2rem;
}

.error-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.error-details {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Integration with Rich Content System */
.rich-video-container .custom-video-player {
    margin: 0;
}

.rich-video-container .video-title {
    margin-bottom: 1rem;
}

.rich-video-container .video-caption {
    margin-top: 1rem;
}