/* Video Player Styles */
.video-player {
    position: relative;
    /* width: 100%; */
    /* height: 100%; */
    /* max-height: 1080px; */
    /* max-width: 1920px; */
    background-color: var(--bg-tertiary);
    border-radius: 10px 0px 0px 10px;
    overflow: hidden;
    width: 70vw;
    aspect-ratio: 16/9;
    /* box-shadow: 0 8px 32px var(--shadow); */
}

.hls-player {
    /* width: 100%; */
    /* height: auto; */
    aspect-ratio: 16/9;
    background-color: #000;
    /* border-radius: 10px; */
    border-radius: 10px 0px 0px 10px;
    outline: none;
    /* height: 75vh; */
    /* max-height: 1080px; */
    width: 70vw;
    /* max-width: 1920px; */
}

.hls-player::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 0 0 10px 10px;
}

.hls-player::-webkit-media-controls-play-button,
.hls-player::-webkit-media-controls-pause-button {
    background-color: var(--primary-color);
    border-radius: 50%;
}

.hls-player::-webkit-media-controls-timeline {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    margin: 0 10px;
}

.hls-player::-webkit-media-controls-current-time-display,
.hls-player::-webkit-media-controls-time-remaining-display {
    color: white;
    font-family: inherit;
}

/* Custom Player Overlay */
.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* Pause Overlay */
.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    cursor: pointer;
    pointer-events: auto;
    opacity: 1;
}

.pause-overlay-visible {
    opacity: 1;
}

.pause-overlay-exiting {
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

/* Ensure pause overlay doesn't interfere when hidden */
.pause-overlay:not(:visible) {
    pointer-events: none;
}

.pause-icon {
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.8);
    opacity: 1;
    transform: scale(1);
}

.pause-icon-entering {
    opacity: 0;
    transform: scale(0.8);
}

.pause-icon-visible {
    opacity: 1;
    transform: scale(1);
}

.pause-icon.icon-transition {
    transform: scale(1.2);
    background-color: rgba(0, 0, 0, 0.9);
    border-color: var(--primary-color);
    transition: all 0.15s ease-out;
}

.pause-icon:hover {
    background-color: rgba(0, 0, 0, 0.9);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.pause-icon i {
    color: white;
    font-size: 32px;
    transition: all 0.15s ease;
}

.quality-selector {
    position: absolute;
    top: 15px;
    right: 15px;
    pointer-events: auto;
}

.quality-selector select {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

.quality-selector select:hover {
    background-color: rgba(0, 0, 0, 0.9);
    border-color: var(--primary-color);
}

.quality-selector option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Chapter Navigation */
.chapter-navigation {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    border: 1px solid var(--border-color);
}

.chapter-navigation h4 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.chapter-item:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-color);
    transform: translateX(2px);
}

.chapter-time {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 12px;
    min-width: 50px;
    font-family: 'Courier New', monospace;
}

.chapter-title {
    color: var(--text-primary);
    font-size: 14px;
    flex: 1;
}

/* Chapter Timeline (for video overlay) */
.chapter-timeline-overlay {
    position: absolute;
    bottom: 80px;
    left: 15px;
    right: 15px;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.video-player:hover .chapter-timeline-overlay {
    opacity: 1;
}

.chapter-timeline {
    position: relative;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 10px;
}

.chapter-progress {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 3px;
    transition: width 0.1s ease;
}

.chapter-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.chapter-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
}

.chapter-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-size: 12px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 4px;
}

.current-chapter {
    font-weight: 500;
}

.chapter-time {
    opacity: 0.8;
}

/* Loading States */
.player-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 18px;
    z-index: 20;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error States */
.player-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 20;
}

.player-error i {
    font-size: 48px;
    color: var(--error-color);
    margin-bottom: 15px;
    display: block;
}

.player-error h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.player-error p {
    opacity: 0.8;
    font-size: 14px;
}

/* Fullscreen Styles */
.video-player:-webkit-full-screen {
    border-radius: 0;
}

.video-player:-moz-full-screen {
    border-radius: 0;
}

.video-player:fullscreen {
    border-radius: 0;
}

.video-player:-webkit-full-screen .hls-player {
    border-radius: 0;
    width: 100vw !important;
    height: 100vh !important;
    object-fit: contain;
}

.video-player:-moz-full-screen .hls-player {
    border-radius: 0;
    width: 100vw !important;
    height: 100vh !important;
    object-fit: contain;
}

.video-player:fullscreen .hls-player {
    border-radius: 0;
    width: 100vw !important;
    height: 100vh !important;
    object-fit: contain;
}

/* Player Container */
.player-container {
    position: relative;
    width: 100%;
    background-color: #000;
    border-radius: 10px;
    overflow: hidden;
}

/* Custom Controls */
.custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 20px 15px 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Changed to none to allow clicks through */
    z-index: 10;
}

/* Enable pointer events only for interactive elements */
.custom-controls .progress-bar,
.custom-controls .controls-row,
.custom-controls button,
.custom-controls select,
.custom-controls input {
    pointer-events: auto;
}

/* Ensure video area above controls is clickable */
.video-player {
    cursor: pointer;
}

.hls-player {
    cursor: pointer;
}

.player-container:hover .custom-controls {
    opacity: 1;
}

.video-player:hover .custom-controls {
    opacity: 1;
}

.progress-container {
    margin-bottom: 15px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.progress-filled {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 3px;
    transition: width 0.1s ease;
}

.progress-handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    background-color: var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progress-bar:hover .progress-handle {
    opacity: 1;
}

/* Progress Bar Chapter Markers */
.progress-chapter-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.progress-chapter-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.2s ease;
    z-index: 3;
}

.progress-chapter-marker:hover {
    background-color: var(--primary-color);
    height: 12px;
    top: -3px;
    width: 3px;
    transform: translateX(-0.5px);
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.play-pause-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.play-pause-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.time-display {
    color: white;
    font-size: 14px;
    font-weight: 500;
    min-width: 100px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.volume-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.volume-slider {
    width: 80px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background-color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background-color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.fullscreen-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    margin-left: auto;
}

.fullscreen-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Quality Control */
.quality-control {
    position: relative;
    display: inline-block;
}

.quality-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.quality-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Time preview tooltip */
.time-preview {
    position: fixed;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: Arial, sans-serif;
    z-index: 1000;
    pointer-events: none;
    display: none;
    white-space: nowrap;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    margin-bottom: 10px;
}

.progress-filled {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 3px;
    transition: width 0.1s ease;
    position: relative;
}

.progress-thumb {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-color: var(--primary-color);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progress-bar:hover .progress-thumb {
    opacity: 1;
}

/* Responsive Player */
@media (max-width: 768px) {
    .quality-selector {
        top: 10px;
        right: 10px;
    }
    
    .quality-selector select {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .chapter-navigation {
        bottom: 70px;
        left: 10px;
        right: 10px;
    }
    
    .custom-controls {
        padding: 15px 10px 10px;
    }
    
    .controls-row {
        gap: 10px;
    }
    
    .volume-control {
        display: none;
    }
    
    .time-display {
        font-size: 12px;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .quality-selector select {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .chapter-info {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .play-pause-btn {
        font-size: 18px;
    }
    
    .fullscreen-btn {
        font-size: 14px;
    }
}

/* Mobile Fullscreen Fixes */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .video-player:fullscreen,
    .video-player:-webkit-full-screen,
    .video-player:-moz-full-screen {
        width: 100vw !important;
        height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 9999 !important;
    }
    
    .video-player:fullscreen .hls-player,
    .video-player:-webkit-full-screen .hls-player,
    .video-player:-moz-full-screen .hls-player {
        width: 100vw !important;
        height: 100vh !important;
        object-fit: contain !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
    }
}