/* player.css - Final Code with Menu Position Fix */

:root {
    --pc-control-color: #fff;
    --pc-control-hover: rgba(255, 255, 255, 0.18);
    --pc-highlight-color: #FFFFFF;
    --pc-background-color: transparent;
    --pc-ui-elements-color: #FFFFFF;
    --progress-offset: 38px;
    --progress-height: 8px;
    --controls-offset: 0px;
    --controls-height: 40px;
    --pc-outline: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background: #181818;
    font-family: 'Calibri', Arial, sans-serif;
}

#vjs-container {
    position: relative;
    max-width: 960px;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    border-radius: 16px;
    background: #111;
    overflow: hidden;
    box-shadow: 0 8px 32px #000c;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    transition: cursor 0.3s;
}

body:not(.is-touch) #vjs-container.controls-hidden {
    cursor: none;
}

body:not(.is-touch) #vjs-container.controls-hidden .custom-control-bar,
body:not(.is-touch) #vjs-container.controls-hidden .custom-progress-bar,
body:not(.is-touch) #vjs-container.controls-hidden #settingsMenu {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.33s;
}

.video-js {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border-radius: 16px;
    background: #111;
}

.custom-progress-bar {
    width: 100%;
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--progress-offset);
    z-index: 24;
    padding: 0 16px;
    height: var(--progress-height);
    display: flex;
    align-items: center;
    background: transparent;
    box-sizing: border-box;
    pointer-events: none;
    box-shadow: var(--pc-outline);
}

.progress-outer {
    width: 100%;
    height: 3.5px;
    background: #fff2;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: box-shadow 0.33s;
    box-shadow: 0 1px 8px #0006, var(--pc-outline);
    pointer-events: auto;
}

.progress-inner {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--pc-control-color);
    height: 100%;
    width: 0%;
    transition: width 0.33s;
    border-radius: 2px;
    box-shadow: var(--pc-outline);
}

.custom-control-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--controls-offset);
    width: 100%;
    background: transparent;
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: var(--controls-height);
    z-index: 20;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    box-sizing: border-box;
    pointer-events: none;
    gap: 0;
    box-shadow: var(--pc-outline);
}

.custom-control-bar > * { 
    pointer-events: auto; 
}

.bar-left, .bar-center, .bar-right { 
    display: flex; 
    align-items: center; 
}

.bar-left { 
    gap: 1px; 
    min-width: 0; 
    overflow: hidden; 
}

.bar-center { 
    flex: 1; 
    gap: 8px; 
    justify-content: center; 
    min-width: 0; 
}

.bar-right { 
    gap: 2px; 
}

.control-btn {
    background: none;
    border: none;
    color: var(--pc-control-color);
    font-size: 22px;
    cursor: pointer;
    border-radius: 50%;
    padding: 8px;
    transition: background 0.15s, color 0.15s, box-shadow 0.18s;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    box-shadow: var(--pc-outline);
}

.control-btn svg {
    width: 24px;
    height: 24px;
    fill: var(--pc-control-color);
    transition: fill 0.33s;
    vertical-align: middle;
}

.control-btn:hover, .control-btn.active, .control-btn:focus {
    background: var(--pc-control-hover);
    box-shadow: 0 0 18px 2px var(--pc-control-hover);
    color: var(--pc-control-color);
}

.control-btn:hover svg, .control-btn:focus svg {
    fill: var(--pc-control-color);
}

.volume-slider { 
    width: 64px; 
    height: 20px; 
    margin: 0 4px 0 0; 
    display: flex; 
    align-items: center;
    box-shadow: var(--pc-outline);
    border-radius: 2px;
}

.volume-slider input[type=range] {
    width: 100%;
    accent-color: var(--pc-control-color);
    height: 2px;
    margin: 0;
    background: transparent;
}

.time-display, .stream-title {
    color: var(--pc-control-color);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    -webkit-user-select: none;
    user-select: none;
    white-space: nowrap;
    text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.bar-left-text {
    display: flex;
    align-items: center;
    padding: 0 8px;
    box-shadow: var(--pc-outline);
    border-radius: 4px;
}

.live-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background-color: #ff4444;
    border-radius: 50%;
    margin: 0 7px 0 8px;
    vertical-align: middle;
    transition: opacity 0.3s;
    box-shadow: var(--pc-outline);
}

.live-dot.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.live-text {
    font-size: 14px;
    color: #ffffff !important;
    font-weight: 500;
    margin-right: 4px;
    transition: color 0.2s, text-shadow 0.2s;
    text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.live-text.live-button-active {
    cursor: pointer;
    color: #6cf !important;
    text-shadow: 0 0 8px rgba(102, 204, 255, 0.5);
}

.stream-title {
    color: #fff !important;
    font-size: 13px;
    font-family: 'Segoe UI', 'Roboto', 'Arial', 'Calibri', sans-serif;
    font-weight: 100;
    letter-spacing: 0.02em;
    margin-left: 4px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 320px;
    text-shadow: none;
    line-height: 1;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    top: -0px;
    opacity: 0.98;
}

#settingsMenu, #settingsMenu *,
#procast-context-menu, #procast-context-menu *,
#procast-stats-overlay, #procast-stats-overlay * {
    font-family: 'Segoe UI', 'Roboto', 'Arial', 'Calibri', sans-serif !important;
}

/* ====== СТИЛИ МЕНЮ НАСТРОЕК ====== */
#settingsMenu {
    position: fixed;
    width: 148px;
    background: rgba(80, 80, 80, 0.33);
    border-radius: 16px;
    box-shadow: 0 4px 24px #000c;
    border: 1px solid #262a38;
    font-size: 13px; color: #fff;
    z-index: 3000; display: none;
    flex-direction: column; padding: 3px 0;
    max-height: 68vh; overflow-y: auto;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity 0.14s, transform 0.13s;
    opacity: 0; pointer-events: none;
}

#settingsMenu.open {
    display: flex; opacity: 1; pointer-events: auto;
    transform: translateY(0);
}

.settings-menu-list {
    display: flex; flex-direction: column; width: 100%;
}

.settings-menu-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px 10px 10px;
    font-size: 13px; font-weight: 400; cursor: pointer;
    border: none; background: none; color: #fff;
    transition: background .11s, color .11s; border-radius: 8px; gap: 5px;
}

.settings-menu-item:active, .settings-menu-item:hover {
    background: var(--pc-control-hover); color: #fff;
}

.settings-menu-arrow {
    margin-left: auto; font-size: 14px; opacity: 0.57;
}

.settings-menu-back {
    font-size: 13px; font-weight: 400;
    padding: 10px 0 10px 8px; cursor: pointer;
    background: none; color: #fff; border: none; outline: none;
    display: flex; align-items: center; border-radius: 8px;
}

.settings-menu-back:hover {
    background: rgba(103,188,245,0.08);
}

.settings-menu-check {
    margin-right: 7px; color: #6af5da; font-size: 13px;
    width: 13px; text-align: right; font-family: Arial, sans-serif;
}

#settingsMenu::-webkit-scrollbar { 
    width: 6px; 
    background: #2d2e34; 
}

#settingsMenu::-webkit-scrollbar-thumb { 
    background: #222225; 
    border-radius: 8px; 
}

/* ====== СТИЛИ ДЛЯ КОНТЕКСТНОГО МЕНЮ ====== */
#procast-context-menu {
    display: none;
    position: absolute; /* <-- This was changed from fixed to absolute */
    z-index: 3000;
    width: 250px;
    background: rgba(80, 80, 80, 0.33);
    border-radius: 16px;
    box-shadow: 0 4px 24px #000c;
    border: 1px solid #262a38;
    padding: 5px;
    -webkit-user-select: none;
    user-select: none;
    /* Properties for perfect centering */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#procast-context-menu .pcm-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    border: none;
    background: none;
    color: #fff;
    transition: background .11s;
    border-radius: 8px;
}

#procast-context-menu .pcm-item:hover {
    background: var(--pc-control-hover);
}

#procast-context-menu .pcm-item svg {
    width: 20px;
    height: 20px;
    fill: #fff;
    opacity: 0.9;
    flex-shrink: 0;
}

/* ====== СТИЛИ ДЛЯ МЕНЮ СТАТИСТИКИ ====== */
#procast-stats-overlay {
    display: none;
    position: absolute;
    z-index: 3000;
    line-height: 1.4;
    font-size: 13px;
    color: #e7faff;
    background: rgba(80, 80, 80, 0.33);
    border-radius: 16px;
    box-shadow: 0 4px 24px #000c;
    border: 1px solid #262a38;
    padding: 12px 18px;
}

#procast-stats-overlay .stat-close {
    position: absolute;
    top: 8px;
    right: 12px;
    cursor: pointer;
    color: #fff;
    font-size: 18px;
    opacity: 0.6;
    transition: opacity .12s, color .12s;
    -webkit-user-select: none;
    user-select: none;
}

#procast-stats-overlay .stat-close:hover {
    opacity: 1;
    color: #ff5656;
}

#yt-stats-content {
    -webkit-user-select: text;
    user-select: text;
}

#yt-stats-content .stat-label {
    color: #A2B9E1;
    font-weight: 500 !important;
}

#yt-stats-content .stat-latency {
    color: #56ff86;
}

#yt-stats-content .stat-error {
    color: #ff5656;
}

/* ====== СТИЛИ ДЛЯ ГРАФИКОВ В СТАТИСТИКЕ ====== */
#stats-graphs {
    margin-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

.graph-container {
    margin-bottom: 12px;
}

.graph-title {
    color: #A2B9E1;
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 6px;
    text-align: center;
}

#network-graph, #speed-graph {
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(20, 20, 20, 0.8);
    display: block;
    margin: 0 auto;
    height: 80px; /* Явно задаем компактную высоту */
}

#procast-stats-overlay {
    width: auto;
    min-width: 360px;
    max-width: 400px;
}

/* ====== СТИЛИ ДЛЯ AMBIENT MODE ====== */
#vjs-container.ambient-mode {
    position: relative;
    overflow: visible;
}

.ambient-glow {
    position: absolute;
    top: -80px;
    left: -80px;
    right: -80px;
    bottom: -80px;
    z-index: -2;
    opacity: 0.6;
    filter: blur(80px);
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(100, 150, 255, 0.4) 0%, transparent 70%);
    transition: all 1s ease-out;
}

.ambient-bg {
    position: absolute;
    top: -40px;
    left: -40px;
    right: -40px;
    bottom: -40px;
    z-index: -1;
    opacity: 0.3;
    filter: blur(40px);
    border-radius: 20px;
    pointer-events: none;
    background: linear-gradient(45deg, rgba(100, 150, 255, 0.1), rgba(100, 150, 255, 0.2), rgba(100, 150, 255, 0.1));
    transition: all 1s ease-out;
}

body.player-theater #vjs-container.ambient-mode .ambient-glow {
    top: -100px;
    left: -100px;
    right: -100px;
    bottom: -100px;
    filter: blur(100px);
}

body.player-theater #vjs-container.ambient-mode .ambient-bg {
    top: -60px;
    left: -60px;
    right: -60px;
    bottom: -60px;
    filter: blur(60px);
}

/* ====== СТИЛИ ДЛЯ МОДАЛЬНОГО ОКНА SPEEDTEST ====== */
#speedtest-modal-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10001;
    background: transparent; 
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none; 
}

#speedtest-modal {
    /* --- ИЗМЕНЕНИЕ ЗДЕСЬ: Задаем точные размеры, как у iframe --- */
    width: 750px; 
    height: 420px;
    max-width: 96vw;
    max-height: 90vh;
    /* --- Убираем все, что делает контейнер видимым --- */
    background: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    /* --- Позиционирование для дочерних элементов --- */
    position: relative;
    pointer-events: auto;
}

#speedtest-modal-close {
    position: absolute; 
    /* --- Позиция кнопки относительно контейнера --- */
    top: 16px; 
    right: 4px;
    color: #fff;
    font-size: 29px;
    font-family: sans-serif;
    opacity: .5;
    cursor: pointer;
    z-index: 10; /* Ставим выше iframe */
    transition: opacity 0.18s, color 0.14s;
    background: none; 
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#speedtest-modal-close:hover {
    opacity: 1; 
    color: #ff4949;
}

#speedtest-iframe {
    /* --- Iframe теперь занимает 100% невидимого родителя --- */
    width: 100%; 
    height: 100%;
    border: none; 
    background: transparent;
}

/* ====== ПРОЧИЕ И АДАПТИВНЫЕ СТИЛИ ====== */
@media (max-width: 700px) {
    #vjs-container { border-radius: 0; }
    .volume-slider, [data-control="timeSlash"], #durationDisplay, .stream-title { display: none; }
    #speedtest-modal { width: 100vw; height: 430px; min-width: 0; border-radius: 0; }
    #speedtest-iframe { min-height: 490px; }
}

body.player-theater #vjs-container { 
    width: 90vw !important; 
    max-width: 100vw !important; 
    border-radius: 0; 
    box-shadow: none; 
    transition: all 0.26s cubic-bezier(.2,1.6,.42,1.01); 
}

body.player-theater { 
    background: #181818 !important; 
}

@media (max-aspect-ratio: 1/1) {
    .bar-left, .bar-right { gap: 0; }
    .control-btn { width: 36px; height: 36px; padding: 6px; }
    .custom-control-bar { height: 36px; }
}

@keyframes live-pulse { 
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7); } 
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(255, 68, 68, 0); } 
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); } 
}

.live-dot.live-dot-pulsing { 
    animation: live-pulse 2s infinite; 
}

#pipBtn { 
    transform: translateY(1px); 
}

#vjs-container.is-fullscreen { 
    border-radius: 0; 
}

#vjs-container.is-fullscreen .custom-control-bar,
#vjs-container.is-fullscreen .custom-progress-bar,
#vjs-container.is-fullscreen #settingsMenu,
#vjs-container.is-fullscreen #procast-context-menu,
#vjs-container.is-fullscreen #procast-stats-overlay,
#vjs-container.is-fullscreen #speedtest-modal-bg {
    z-index: 2147483647;
}

/* Player video styles */
.player-video {
    width: 100%;
    height: 100%;
}

/* Hidden class */
.hidden {
    display: none !important;
}