/**
 * 🦊 Light Fox Custom HLS Player
 * Кастомный плеер в оранжевом стиле
 */

/* ========== КОНТЕЙНЕР ПЛЕЕРА ========== */
.lf-player-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    /* Блокировка зума на мобильных */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Блокировка зума для всего оверлея */
.lf-player-overlay {
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.lf-player-container video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #000;
    /* Блокировка зума на видео элементе */
    touch-action: none;
    -webkit-touch-callout: none;
    pointer-events: none; /* События идут через overlay */
}

/* ========== ОВЕРЛЕЙ ДЛЯ КЛИКОВ ========== */
.lf-player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0; /* Покрываем всё видео */
    z-index: 5;
    display: flex;
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

/* Зоны тапа влево/вправо */
.lf-seek-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lf-seek-zone.left {
    justify-content: flex-start;
    padding-left: 10%;
}

.lf-seek-zone.right {
    justify-content: flex-end;
    padding-right: 10%;
}

/* Центральная зона (play/pause) */
.lf-play-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ========== ИНДИКАТОР ПЕРЕМОТКИ ========== */
.lf-seek-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.lf-seek-indicator.left {
    left: 15%;
}

.lf-seek-indicator.right {
    right: 15%;
}

.lf-seek-indicator.show {
    animation: lfSeekFade 0.8s ease;
}

@keyframes lfSeekFade {
    0% { opacity: 0; transform: translateY(-50%) scale(0.8); }
    20% { opacity: 1; transform: translateY(-50%) scale(1); }
    80% { opacity: 1; transform: translateY(-50%) scale(1); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.9); }
}

.lf-seek-indicator svg {
    width: 28px;
    height: 28px;
    fill: #ff8a50;
}

/* ========== ЦЕНТРАЛЬНАЯ КНОПКА PLAY ========== */
.lf-center-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 138, 80, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 15;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 3px 20px rgba(255, 138, 80, 0.4);
    pointer-events: auto; /* Кнопка кликабельна */
}

.lf-center-play svg {
    width: 20px;
    height: 20px;
    fill: white;
    margin-left: 2px; /* Компенсация для иконки play */
}

.lf-center-play:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 25px rgba(255, 138, 80, 0.6);
}

/* Показываем центральную кнопку когда видео на паузе или при hover (десктоп) */
.lf-player-container.paused .lf-center-play,
.lf-player-container.controls-visible .lf-center-play {
    opacity: 1;
}

.lf-player-container.paused .lf-center-play {
    opacity: 1 !important;
}

/* На десктопе (мышь) - hover показывает */
@media (hover: hover) and (pointer: fine) {
    .lf-player-container:hover .lf-center-play {
        opacity: 1;
    }
}

/* ========== ПАНЕЛЬ КОНТРОЛОВ ========== */
.lf-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 30px 16px 12px;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: auto; /* Контролы кликабельны */
    touch-action: manipulation;
}

/* Контролы видны при паузе или по тапу/наведению */
.lf-player-container.paused .lf-controls,
.lf-player-container.controls-visible .lf-controls {
    opacity: 1;
}

/* На десктопе (мышь) - hover показывает */
@media (hover: hover) and (pointer: fine) {
    .lf-player-container:hover .lf-controls {
        opacity: 1;
    }
}

/* ========== ПРОГРЕСС-БАР ========== */
.lf-progress-container {
    width: 100%;
    height: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 8px;
}

.lf-progress-bar {
    position: relative;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: visible;
}

.lf-progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    pointer-events: none;
}

.lf-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #ff8a50, #ff6b35);
    border-radius: 3px;
    pointer-events: none;
}

.lf-progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #ff8a50;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.lf-progress-container:hover .lf-progress-handle,
.lf-progress-container.dragging .lf-progress-handle {
    opacity: 1;
}

.lf-progress-container:hover .lf-progress-bar {
    height: 7px;
}

/* Превью времени при наведении */
.lf-progress-tooltip {
    position: absolute;
    bottom: 25px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.lf-progress-container:hover .lf-progress-tooltip {
    opacity: 1;
}

/* ========== НИЖНЯЯ ПАНЕЛЬ КНОПОК ========== */
.lf-controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: visible;
}

.lf-control-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

/* Время может сжиматься если нужно */
.lf-time {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}

.lf-control-btn:hover {
    background: rgba(255, 138, 80, 0.3);
}

.lf-control-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Кнопка play/pause в панели */
.lf-play-btn {
    width: auto;
    height: auto;
}

/* ========== ВРЕМЯ ========== */
.lf-time {
    color: white;
    font-size: 14px;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    white-space: nowrap;
}

/* ========== ГРОМКОСТЬ ========== */
.lf-volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lf-volume-slider {
    width: 0;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #ff8a50 0%, rgba(255, 255, 255, 0.3) 0%);
    border-radius: 2px;
    cursor: pointer;
    opacity: 0;
    transition: width 0.2s, opacity 0.2s;
}

.lf-volume-container:hover .lf-volume-slider {
    width: 80px;
    opacity: 1;
}

.lf-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.lf-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ========== SPACER ========== */
.lf-spacer {
    flex: 1;
}

/* ========== СКОРОСТЬ ВОСПРОИЗВЕДЕНИЯ (ГОРИЗОНТАЛЬНОЕ МЕНЮ) ========== */
.lf-speed-container {
    position: relative;
}

.lf-speed-btn {
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    min-width: 50px;
}

.lf-speed-menu {
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%) translateY(10px);
    margin-bottom: 6px;
    background: rgba(0, 0, 0, 0.95);
    border-radius: 6px;
    padding: 4px 6px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 100;
    /* Горизонтальное расположение */
    display: flex;
    flex-direction: row;
    gap: 3px;
    white-space: nowrap;
}

.lf-speed-container:hover .lf-speed-menu,
.lf-speed-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(50%) translateY(0);
}

.lf-speed-option {
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 5px;
    color: white;
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 34px;
}

.lf-speed-option:hover {
    background: rgba(255, 138, 80, 0.4);
}

.lf-speed-option.active {
    background: #ff8a50;
    color: white;
    font-weight: 600;
}

/* ========== PICTURE-IN-PICTURE ========== */
.lf-pip-btn {
    display: none;
}

/* Показываем PiP только если браузер поддерживает */
.lf-player-container.pip-supported .lf-pip-btn {
    display: flex;
}

/* ========== CHROMECAST ========== */
.lf-cast-btn {
    display: flex;
    position: relative;
}

.lf-cast-btn svg {
    width: 22px;
    height: 22px;
    transition: all 0.3s ease;
}

/* Подключено к Chromecast */
.lf-cast-btn.connected {
    color: #ff8a50;
}

.lf-cast-btn.connected svg {
    fill: #ff8a50;
    filter: drop-shadow(0 0 4px rgba(255, 138, 80, 0.5));
}

/* Анимация при подключении */
.lf-cast-btn.connected::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: castPulse 2s ease-in-out infinite;
}

@keyframes castPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

/* Overlay при трансляции на TV */
.cast-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
}

.cast-overlay-content {
    text-align: center;
    color: #fff;
}

.cast-overlay-content svg {
    color: #ff8a50;
    margin-bottom: 12px;
}

.cast-overlay-content p {
    font-size: 18px;
    margin: 0 0 16px;
    color: #ccc;
}

.cast-overlay-stop {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.cast-overlay-stop:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ========== FULLSCREEN ========== */
.lf-fullscreen-btn svg.exit {
    display: none;
}

.lf-player-container.fullscreen .lf-fullscreen-btn svg.enter {
    display: none;
}

.lf-player-container.fullscreen .lf-fullscreen-btn svg.exit {
    display: block;
}

/* Fullscreen стили */
.lf-player-container:fullscreen,
.lf-player-container:-webkit-full-screen {
    max-width: none;
    border-radius: 0;
}

/* ========== ЗАГРУЗКА ========== */
.lf-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.lf-player-container.loading .lf-loader {
    opacity: 1;
}

.lf-loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 138, 80, 0.3);
    border-top-color: #ff8a50;
    border-radius: 50%;
    animation: lfSpin 0.8s linear infinite;
}

@keyframes lfSpin {
    to { transform: rotate(360deg); }
}

/* ========== ОШИБКА ========== */
.lf-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 30;
    display: none;
}

.lf-player-container.error .lf-error {
    display: block;
}

.lf-error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.lf-error-message {
    font-size: 16px;
    margin-bottom: 8px;
}

.lf-error-hint {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

.lf-error-retry {
    background: #ff8a50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.lf-error-retry:hover {
    background: #ff6b35;
    transform: scale(1.05);
}

/* ========== МОБИЛЬНЫЕ СТИЛИ ========== */
@media (max-width: 768px) {
    .lf-player-container {
        border-radius: 0;
    }

    .lf-center-play {
        width: 44px;
        height: 44px;
    }

    .lf-center-play svg {
        width: 18px;
        height: 18px;
    }

    /* Контролы ниже на мобилках */
    .lf-controls {
        padding: 6px 8px 4px;
    }

    .lf-progress-container {
        margin-bottom: 4px;
    }

    .lf-controls-row {
        gap: 4px;
    }

    .lf-control-btn {
        padding: 6px;
        flex-shrink: 0;
    }

    .lf-control-btn svg {
        width: 22px;
        height: 22px;
    }

    /* На мобильных громкость - просто кнопка mute */
    .lf-volume-slider {
        display: none !important;
    }

    .lf-time {
        font-size: 11px;
    }

    .lf-speed-btn {
        font-size: 11px;
        padding: 5px 6px;
        min-width: 36px;
    }

    /* Меню скорости на мобилках - горизонтальное с большими touch targets */
    .lf-speed-menu {
        padding: 8px 6px;
        gap: 6px;
    }

    .lf-speed-option {
        padding: 10px 8px;
        font-size: 12px;
        min-width: 36px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Всегда показываем контролы на мобильных немного дольше */
    .lf-player-container.controls-visible .lf-controls {
        opacity: 1;
    }

    .lf-seek-indicator {
        padding: 12px 18px;
        font-size: 16px;
    }

    .lf-seek-indicator svg {
        width: 24px;
        height: 24px;
    }
}

/* ========== МАЛЕНЬКИЕ ЭКРАНЫ (iPhone SE, iPhone mini и т.д.) ========== */
@media (max-width: 480px) {
    .lf-controls {
        padding: 5px 6px 3px;
    }

    .lf-progress-container {
        margin-bottom: 3px;
        height: 18px;
    }

    .lf-controls-row {
        gap: 3px;
    }

    .lf-control-btn {
        padding: 7px;
    }

    .lf-control-btn svg {
        width: 22px;
        height: 22px;
    }


    .lf-time {
        font-size: 11px;
    }

    .lf-speed-btn {
        font-size: 11px;
        padding: 5px 7px;
        min-width: 36px;
    }

    /* PiP кнопка остаётся на маленьких экранах */

    /* Cast кнопка */
    .lf-cast-btn svg {
        width: 20px;
        height: 20px;
    }

    .lf-center-play {
        width: 42px;
        height: 42px;
    }

    .lf-center-play svg {
        width: 17px;
        height: 17px;
    }

    .lf-seek-indicator {
        padding: 10px 14px;
        font-size: 14px;
        gap: 8px;
    }

    .lf-seek-indicator svg {
        width: 20px;
        height: 20px;
    }

    .lf-seek-indicator.left {
        left: 8%;
    }

    .lf-seek-indicator.right {
        right: 8%;
    }

    /* Меню скорости компактнее */
    .lf-speed-menu {
        padding: 5px;
        gap: 3px;
    }

    .lf-speed-option {
        padding: 8px 7px;
        font-size: 11px;
        min-width: 34px;
        min-height: 36px;
    }
}

/* ========== ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (iPhone SE 1st gen, 320px и меньше) ========== */
@media (max-width: 360px) {
    .lf-controls {
        padding: 4px 5px 2px;
    }

    .lf-controls-row {
        gap: 2px;
    }

    .lf-control-btn {
        padding: 5px;
    }

    .lf-control-btn svg {
        width: 19px;
        height: 19px;
    }


    .lf-time {
        font-size: 10px;
    }

    /* Скрываем громкость на совсем маленьких */
    .lf-volume-container {
        display: none;
    }

    .lf-speed-btn {
        font-size: 10px;
        padding: 4px 5px;
        min-width: 28px;
    }

    .lf-cast-btn svg {
        width: 19px;
        height: 19px;
    }
}

/* ========== СКРЫТИЕ КУРСОРА И КОНТРОЛОВ ПРИ НЕАКТИВНОСТИ ========== */
.lf-player-container.hide-cursor {
    cursor: none;
}

.lf-player-container.hide-cursor .lf-controls {
    opacity: 0 !important;
    pointer-events: none;
}

.lf-player-container.hide-cursor .lf-center-play {
    opacity: 0 !important;
}

/* ========== ДВОЙНОЙ ТАП АНИМАЦИЯ ========== */
.lf-double-tap-ripple {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255, 138, 80, 0.4);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 8;
    animation: lfRipple 0.5s ease-out;
}

@keyframes lfRipple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* ========== ЗАЩИТА ОТ СКРИНШОТОВ ========== */
.lf-protection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    /* БЕЗ transition для мгновенной реакции! */
    pointer-events: none;
}

.lf-protection-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Мгновенное скрытие видео при активной защите */
.lf-player-container .lf-video.protected {
    opacity: 0 !important;
    visibility: hidden !important;
}

.lf-protection-content {
    text-align: center;
    color: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

.lf-protection-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: lfProtectionPulse 2s ease-in-out infinite;
}

.lf-protection-text {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.lf-protection-subtext {
    font-size: 14px;
    opacity: 0.7;
}

@keyframes lfProtectionPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}
