/* ===== Player Overlay ===== */
.player-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.player-overlay.active {
    opacity: 1;
    visibility: visible;
}

.player-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ===== Player Header ===== */
.player-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    z-index: 10;
}

.player-close-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    transition: var(--transition-fast);
}

.player-close-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
}

.player-close-btn svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.player-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Video Wrapper ===== */
.video-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    object-fit: contain;
    background: #000;
}

/* ===== Player Loading ===== */
.player-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.player-loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Player Controls ===== */
.player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
}

.server-list {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
}

.server-list::-webkit-scrollbar {
    display: none;
}

.server-btn {
    flex-shrink: 0;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: #fff;
    transition: var(--transition-fast);
}

.server-btn:active {
    transform: scale(0.95);
}

.server-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.player-actions {
    display: flex;
    justify-content: center;
    gap: 32px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #fff;
    opacity: 0.8;
    transition: var(--transition-fast);
}

.action-btn:active {
    opacity: 1;
    transform: scale(0.95);
}

.action-btn svg {
    width: 24px;
    height: 24px;
}

.action-btn span {
    font-size: 11px;
}

/* ===== Fullscreen Styles ===== */
.player-overlay:-webkit-full-screen {
    width: 100%;
    height: 100%;
}

.player-overlay:-moz-full-screen {
    width: 100%;
    height: 100%;
}

.player-overlay:-ms-fullscreen {
    width: 100%;
    height: 100%;
}

.player-overlay:fullscreen {
    width: 100%;
    height: 100%;
}

/* ===== Theater Mode ===== */
.player-overlay.theater-mode .player-header,
.player-overlay.theater-mode .player-controls {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.player-overlay.theater-mode:hover .player-header,
.player-overlay.theater-mode:hover .player-controls,
.player-overlay.theater-mode .player-header:focus-within,
.player-overlay.theater-mode .player-controls:focus-within {
    opacity: 1;
}

/* ===== Lights Off Mode ===== */
.lights-off {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 299;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lights-off.active {
    opacity: 1;
    visibility: visible;
}

/* ===== Error State ===== */
.player-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    padding: 20px;
}

.player-error svg {
    width: 60px;
    height: 60px;
    color: var(--accent);
    margin-bottom: 16px;
}

.player-error h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.player-error p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.retry-btn {
    padding: 12px 32px;
    font-size: 14px;
    font-weight: 600;
    background: var(--accent);
    color: #000;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.retry-btn:active {
    transform: scale(0.95);
}

/* ===== Iframe Player ===== */
.iframe-player {
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
}

/* ===== Landscape Orientation ===== */
@media (orientation: landscape) {
    .player-header {
        padding: 12px 24px;
    }

    .player-controls {
        padding: 16px 24px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .player-actions {
        gap: 48px;
    }
}

/* ===== Touch Feedback ===== */
.player-overlay .touch-feedback {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0);
    animation: touchPulse 0.4s ease-out forwards;
    pointer-events: none;
}

@keyframes touchPulse {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* ===== Seek Indicator ===== */
.seek-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.seek-indicator.left {
    left: 20%;
}

.seek-indicator.right {
    right: 20%;
}

.seek-indicator.visible {
    opacity: 1;
}

.seek-indicator svg {
    width: 40px;
    height: 40px;
}

.seek-indicator span {
    font-size: 14px;
    font-weight: 600;
}