/*!
 * SPDX-FileCopyrightText: 2025 The LivePlayer Project Authors
 * SPDX-License-Identifier: MPL-2.0
 */

/* liveplayer.css (v1.0.0) */

/* Component root container, size defined by user in HTML */
.live-player-component {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Player main container, inherits size from parent */
.player-container {
    flex-grow: 1;
    position: relative;
    background-color: #000;
    font-size: 16px; /* Base font size, controls will scale relatively */
    color: #fff;
    overflow: hidden; /* Hide child elements that overflow, such as menus */
    display: flex; /* Use Flexbox to center the video */
    justify-content: center;
    align-items: center;
}
.player-container.no-cursor { cursor: none; }

/* Video element styles to achieve letterbox effect */
.video-element {
    width: 100%;
    height: 100%;
    /* `object-fit: contain` ensures video maintains aspect ratio with black bars for excess space */
    object-fit: contain;
    display: block;
}

/* Overlay common styles */
.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 20;
    transition: opacity 0.3s;
}

.loading-overlay {
    color: #fff;
    font-size: 3em;
}

/* "Fancy" loading animation */
.loading-equalizer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px; /* Total height of the animation */
}

.loading-equalizer div {
    width: 6px;
    height: 100%;
    margin: 0 3px;
    background-color: #ffffff; /* Bar color */
    animation: stretch 1.2s infinite ease-in-out;
}

/* Set different animation delays for each bar */
.loading-equalizer div:nth-child(2) {
    animation-delay: -1.1s;
}

.loading-equalizer div:nth-child(3) {
    animation-delay: -1.0s;
}

.loading-equalizer div:nth-child(4) {
    animation-delay: -0.9s;
}

.loading-equalizer div:nth-child(5) {
    animation-delay: -0.8s;
}

@keyframes stretch {
    0%, 40%, 100% {
        transform: scaleY(0.4);
    }
    20% {
        transform: scaleY(1.0);
    }
}

/* Offline status display */
.player-offline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent black background */
    color: #ffffff;
    display: none; /* default hidden */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    text-align: center;
    z-index: 5; /* Ensure it stays above video but below controls (if needed) */
}

.offline-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.offline-content .fa-video-slash {
    font-size: 48px; /* One big icon */
    margin-bottom: 16px;
    opacity: 0.8;
}

.offline-content span {
    font-size: 16px;
    max-width: 80%;
}

.player-error-overlay {
    color: #ffc107;
    font-size: 1.1em;
    padding: 20px;
}

/* Controller container */
.controls-container {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    padding: 10px 15px;
    display: flex; align-items: center; gap: 1em;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 30;
}
.player-container:hover .controls-container,
.player-container.paused .controls-container,
.controls-container.visible {
    opacity: 1; visibility: visible;
}

.controls-left, .controls-right { display: flex; align-items: center; gap: 1.25em; }
.controls-right { margin-left: auto; }

/* Controller button */
.control-button {
    background: none; border: none; color: #fff;
    font-size: 1.1em; cursor: pointer; padding: 0;
    transition: color 0.2s, transform 0.2s;
}
.control-button:hover { color: #3498db; transform: scale(1.1); }

/* Play/Pause icon states */
.play-pause-btn .fa-pause { display: none; }
.player-container.paused .play-pause-btn .fa-play { display: block; }
.player-container.paused .play-pause-btn .fa-pause { display: none; }

/* Fullscreen icon states */
.fullscreen-btn .fa-compress { display: none; }
.player-container.fullscreen .fullscreen-btn .fa-expand { display: none; }
.player-container.fullscreen .fullscreen-btn .fa-compress { display: block; }

/* Volume container */
.volume-container { display: flex; align-items: center; gap: 0.75em; }
.volume-slider {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 80px;
    height: 5px;
    --track-color: rgba(255, 255, 255, 0.5); /* Store default track color in CSS variable for easy overriding */
    background: var(--track-color);
    border-radius: 2.5px;
    outline: none;
    transition: background-color 0.3s;
    vertical-align: middle;
}

/* Mute icon initial state */
.mute-btn .fa-volume-up { display: none; }

/* Non-intrusive mute indicator */
.unmute-notice {
    color: #ffc107; font-size: 0.8em;
    cursor: pointer; background-color: rgba(0,0,0,0.5);
    padding: 4px 8px; border-radius: 4px;
    display: none; align-items: center; gap: 5px;
}
.unmute-notice.visible { display: flex; }

/* Line switching menu */
.line-switch-container { position: relative; }
.line-switch-menu {
    position: absolute; bottom: 100%; right: 0;
    background-color: rgba(30, 30, 30, 0.9);
    list-style: none; padding: 5px 0; margin: 0 0 10px 0;
    border-radius: 4px; box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    z-index: 11;
}
.line-switch-menu.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.line-switch-menu li { padding: 8px 20px; cursor: pointer; white-space: nowrap; }
.line-switch-menu li:hover { background-color: #3498db; }
.line-switch-menu li.active { font-weight: bold; color: #3498db; }

/* Log area */
.log-output {
    margin-top: 15px;
    width: 100%;
    height: 150px;
    background-color: #242526; border: 1px solid #3a3b3c;
    border-radius: 4px; color: #b0b3b8;
    font-family: 'Courier New', Courier, monospace; font-size: 0.8em;
    padding: 10px; overflow-y: scroll;
    white-space: pre-wrap; resize: vertical;
    flex-shrink: 0; /* Prevent it from being compressed when space is insufficient */
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 0.75em;
    transition: filter 0.2s; /* Add smooth transition for color changes */
}

/* When volume container has `.muted` class, make all child elements gray */
.volume-container.muted .volume-slider {
    background: #555; /* Change track color to gray */
}

.volume-container.muted .volume-slider::-webkit-slider-thumb {
    background: #999; /* Change slider color to gray as well */
}
.volume-container.muted .volume-slider::-moz-range-thumb {
    background: #999;
}


.volume-slider {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 80px;
    height: 5px;
    --track-color: rgba(255, 255, 255, 0.5); /* Store default track color in CSS variable for easy overriding */
    background: var(--track-color);
    border-radius: 2.5px;
    outline: none;
    transition: background-color 0.3s;
    vertical-align: middle;
}
