/**
 * Custom Video Player Styles
 */

.custom-player {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    overflow: visible;
    user-select: none;
    display: flex;
    flex-direction: column;
}

.custom-player.fullscreen {
    border-radius: 0;
}

/* Video Wrapper */
.player-video-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    min-height: 200px;
    flex-shrink: 0;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    overflow: hidden;
}

.player-video {
    width: 100%;
    max-height: 50vh;
    display: block;
    object-fit: contain;
    background: #000;
}

/* Overlay */
.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.player-big-play {
    width: 80px;
    height: 80px;
    background: rgba(0, 212, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.9;
}

.player-big-play:hover {
    transform: scale(1.1);
    opacity: 1;
}

.player-big-play svg {
    width: 36px;
    height: 36px;
    margin-left: 4px;
}

.player-big-play.hidden {
    display: none;
}

.player-buffer-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
}

.player-buffer-indicator.hidden {
    display: none;
}

/* Controls Container */
.player-controls {
    position: relative;
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    overflow: visible;
}

/* Progress Bar */
.player-progress-container {
    position: relative;
    padding: 8px 0;
    cursor: pointer;
    height: 24px; /* Fixed height to prevent layout shift */
    display: flex;
    align-items: center;
}

.player-progress-bar {
    position: relative;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: visible;
    transition: transform 0.1s ease;
    transform-origin: center;
}

.player-progress-container:hover .player-progress-bar {
    transform: scaleY(1.5);
}

.player-progress-buffer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.player-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    z-index: 2;
}

.player-progress-regions {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    z-index: 1;
}

.progress-region {
    position: absolute;
    top: -2px;
    height: calc(100% + 4px);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.player-progress-handle {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s, transform 0.1s;
}

.player-progress-container:hover .player-progress-handle {
    opacity: 1;
    /* Counter the parent's scaleY to keep handle circular */
    transform: translate(-50%, -50%) scaleY(0.667);
}

/* Thumbnail Preview */
.player-thumbnail-preview {
    position: absolute;
    bottom: 100%;
    margin-bottom: 12px;
    background: var(--bg-elevated);
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s, visibility 0.1s;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.player-thumbnail-preview.visible {
    opacity: 1;
    visibility: visible;
}

.thumbnail-image {
    background-size: auto;
    background-repeat: no-repeat;
    border-radius: 4px;
    /* Default size, will be overridden by JS */
    min-width: 160px;
    min-height: 90px;
}

.thumbnail-time {
    text-align: center;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-primary);
    padding: 6px 0 2px;
    font-weight: 600;
}

.player-progress-tooltip {
    position: absolute;
    bottom: 100%;
    margin-bottom: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    white-space: nowrap;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 5;
}

/* Hide time tooltip when thumbnail is visible */
.player-thumbnail-preview.visible + .player-progress-tooltip {
    opacity: 0 !important;
}

.player-progress-tooltip.visible {
    opacity: 1;
}

/* Control Buttons Row */
.player-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

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

.player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

.player-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.player-btn.active {
    color: var(--accent-primary);
}

.player-btn svg {
    width: 20px;
    height: 20px;
}

/* Time Display */
.player-time {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: monospace;
    font-size: 13px;
    color: white;
    margin: 0 8px;
}

.player-time-sep {
    color: var(--text-muted);
}

.player-frame-display {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Speed Control */
.player-speed-control {
    position: relative;
}

.player-speed-btn {
    width: auto;
    padding: 0 12px;
}

.speed-value {
    font-size: 13px;
    font-weight: 600;
}

.player-speed-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 100;
}

.player-speed-menu button {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    text-align: center;
}

.player-speed-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.player-speed-menu button.active {
    background: var(--accent-primary);
    color: black;
}

.player-speed-menu.hidden {
    display: none;
}

/* Volume Control */
.player-volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-volume-slider {
    width: 80px;
    padding: 8px 0;
    cursor: pointer;
}

.volume-track {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.volume-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: white;
    border-radius: 2px;
}

.volume-handle {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Audio Panel */
.player-audio-panel {
    position: absolute;
    bottom: 80px; /* Above controls */
    right: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 340px;
    max-width: 450px;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.player-audio-panel.hidden {
    display: none;
}

.audio-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.audio-panel-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.audio-panel-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

.audio-panel-close:hover {
    color: var(--text-primary);
}

.audio-panel-content {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.audio-track-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
}

.audio-track-row:last-child {
    margin-bottom: 0;
}

.audio-track-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audio-track-name {
    font-size: 13px;
    font-weight: 500;
}

.audio-track-lang {
    font-size: 11px;
    color: var(--text-muted);
}

.audio-track-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-track-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.audio-track-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.audio-track-btn.active {
    background: var(--accent-primary);
    color: black;
    border-color: var(--accent-primary);
}

.solo-btn.active {
    background: var(--warning);
    border-color: var(--warning);
}

.mute-btn.active {
    background: var(--error);
    border-color: var(--error);
}

.audio-track-volume {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 120px;
}

.audio-volume-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
}

.audio-volume-label {
    font-size: 11px;
    font-family: monospace;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
}

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

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

/* Fullscreen Adjustments */
.custom-player.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

.custom-player.fullscreen .player-video-wrapper {
    height: calc(100% - 100px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-player.fullscreen .player-video {
    max-height: 100%;
    width: auto;
}

.custom-player.fullscreen .player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 40px 16px 12px;
    border-top: none;
}

/* Responsive */
@media (max-width: 768px) {
    .player-time {
        display: none;
    }

    .player-frame-display {
        display: none;
    }

    .player-volume-slider {
        display: none;
    }

    .player-speed-control {
        display: none;
    }
}
