/* ==========================================================================
   1. CONTAINER DO PLAYER FIXO E PARÂMETROS DE FLUXO MESTRE
   ========================================================================== */
.player-fixed-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #1e293b !important; 
    border-top: 1px solid #334155 !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4) !important;
    z-index: 9999;
    padding: 1rem 2rem;
    animation: playerSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: visible !important; /* CRÍTICO: Permite que menus e previews flutuem para fora */
    box-sizing: border-box;
}

@keyframes playerSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.player-wrapper, .player-controls {
    width: 100%;
    display: flex;
    overflow: visible !important;
    box-sizing: border-box;
}

.player-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    align-items: center;
    gap: 1.5rem;
}

.player-controls {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    min-width: 0; 
    overflow: visible !important;
}

/* ==========================================================================
   2. VIEWPORT VISUAL DA MINIATURA PADRÃO DO RODAPÉ
   ========================================================================== */
.player-video-viewport {
    position: relative;
    width: 160px;
    aspect-ratio: 16 / 9;
    background-color: #000000;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid #334155;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.player-video-viewport video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ==========================================================================
   3. CONTROLES DE REPRODUÇÃO - ARQUITETURA FLUIDA UNIVERSAL ADAPTATIVA
   ========================================================================== */
.controls-row {
    display: flex !important;
    flex-direction: row !important; /* Mantém sempre o alinhamento em linha horizontal */
    flex-wrap: wrap !important;     /* Permite adaptação e quebra interna se o visor for micro */
    justify-content: space-between; /* Distribui os blocos nas extremidades em telas grandes */
    align-items: center;
    width: 100% !important;
    gap: 1rem;
    overflow: visible !important;
    box-sizing: border-box;
}

/* Blocos internos adaptativos com proteção de encolhimento */
.controls-left, 
.controls-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap !important;
    gap: 0.5rem 0.75rem !important;
    min-width: 0;
    overflow: visible !important;
}

.controls-right {
    justify-content: flex-end;
}

.player-btn {
    background: transparent;
    border: none;
    color: #f8fafc !important; 
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    flex-shrink: 0 !important; /* Impede o navegador de esmagar o tamanho dos ícones */
    transition: background-color 0.15s ease, color 0.15s ease;
}

.player-btn:hover,
#custom-player-container #btn-player-stop:hover,
#custom-player-container #btn-player-rewind:hover,
#custom-player-container #btn-player-forward:hover,
#custom-player-container #btn-player-snapshot:hover {
    color: #06b6d4 !important;
    background-color: rgba(6, 182, 212, 0.1) !important;
}

.player-btn.active-control {
    color: #06b6d4 !important;
    background-color: rgba(6, 182, 212, 0.15) !important;
}

.player-btn.close-btn:hover {
    color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.1) !important;
}

.time-display-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: #f8fafc !important;
    white-space: nowrap;
    flex-shrink: 0 !important; /* Garante que o cronômetro nunca seja esmagado */
}

.custom-progress-bar-container {
    position: relative;
    width: 100%;
    height: 6px;
    background-color: #334155;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 0.85rem;
    overflow: visible !important;
}

.progress-bar-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    width: 0%;
    transition: width 0.15s linear;
}

.progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #06b6d4;
    border-radius: 4px;
    width: 0%;
}

.progress-bar-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    pointer-events: none;
}

.volume-control-wrapper {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0 !important;
}

.volume-slider-bar {
    width: 70px;
    height: 4px;
    cursor: pointer;
    accent-color: #06b6d4;
    flex-shrink: 0 !important;
}

/* ==========================================================================
   4. MENU FLUTUANTE CUSTOMIZADO DE VELOCIDADES
   ========================================================================== */
.player-speed-menu-wrapper {
    position: relative;
    display: inline-block;
    overflow: visible !important;
    flex-shrink: 0 !important;
}

.player-btn.speed-display-btn {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.4rem 0.65rem;
    border: 1px solid #475569;
    border-radius: 0.5rem;
    background-color: #334155;
    min-width: 58px;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

.player-btn.speed-display-btn:hover {
    border-color: #06b6d4;
}

.player-speed-dropdown-list {
    position: absolute;
    bottom: calc(100% + 12px); 
    right: 0;
    background-color: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #475569;
    border-radius: 0.5rem;
    min-width: 90px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    padding: 0.35rem 0;
    display: none; 
    flex-direction: column;
    z-index: 2147483647 !important;
}

.player-speed-menu-wrapper.menu-open .player-speed-dropdown-list {
    display: flex;
    animation: speedMenuFadeIn 0.15s cubic-bezier(0, 0, 0.2, 1);
}

@keyframes speedMenuFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.speed-menu-item {
    font-size: 0.8rem;
    font-weight: 600;
    color: #cbd5e1;
    padding: 0.45rem 1rem;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.speed-menu-item:hover {
    background-color: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.speed-menu-item.active-speed {
    color: #06b6d4;
    font-weight: 700;
    background-color: rgba(6, 182, 212, 0.08);
}

.speed-menu-item.active-speed::after {
    content: "✓";
    font-size: 0.75rem;
    margin-left: 6px;
}

/* ==========================================================================
   5. PREVIEW DE CENA E TOOLTIP DE VOLUME FLUTUANTE (MÓDULO GEOMÉTRICO)
   ========================================================================== */
.custom-progress-bar-container .timeline-preview-box {
    position: absolute;
    bottom: calc(100% + 14px); 
    left: var(--preview-x, 0px);
    transform: translateX(-50%);
    background-color: #0f172a;
    border: 2px solid #06b6d4; 
    border-radius: 0.5rem;
    padding: 4px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.7);
    display: none; 
    pointer-events: none;
    z-index: 2147483647 !important; 
}

#timeline-preview-canvas {
    display: block;
    border-radius: 0.35rem;
    background-color: #000000;
}

#timeline-preview-time {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #06b6d4;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.slider-tooltip-container.dynamic-volume-tooltip {
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible !important;
}

.slider-tooltip-container.dynamic-volume-tooltip::after {
    content: attr(data-player-tooltip-content);
    position: absolute;
    bottom: calc(100% + 14px); 
    left: var(--tooltip-x, 50%);
    transform: translateX(-50%) translateY(4px);
    background-color: #0f172a;
    color: #f8fafc;
    padding: 0.3rem 0.55rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: opacity 0.1s ease-out, transform 0.1s ease-out;
    z-index: 2147483647 !important;
}

.slider-tooltip-container.dynamic-volume-tooltip[data-player-tooltip-content]::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   6. BOTÃO DE RECUPERAÇÃO FLUTUANTE BILÍNGUE
   ========================================================================== */
.player-recovery-floating-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: #06b6d4;
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 25px rgba(6, 182, 212, 0.4);
    z-index: 9998;
    animation: recoveryBounceIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.player-recovery-floating-btn:hover {
    background-color: #0891b2;
    transform: scale(1.05);
}

@keyframes recoveryBounceIn {
    from { transform: scale(0.3) translateY(40px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ==========================================================================
   7. BLINDAGEM DE TELA CHEIA DO CONTÊINER INTEIRO (CROSS-DEVICE MANAGER)
   ========================================================================== */
#custom-player-container:fullscreen,
#custom-player-container:-webkit-full-screen,
#custom-player-container:-moz-full-screen,
#custom-player-container:-ms-fullscreen,
#custom-player-container.ios-virtual-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    background-color: #000000 !important;
    padding: 1.5rem !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    z-index: 2147483647 !important; 
}

#custom-player-container::backdrop {
    background-color: #000000 !important;
}

#custom-player-container:fullscreen .player-wrapper,
#custom-player-container:-webkit-full-screen .player-wrapper,
#custom-player-container.ios-virtual-fullscreen .player-wrapper {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    gap: 1rem !important;
    justify-content: space-between !important;
    overflow: visible !important;
}

#custom-player-container:fullscreen .player-video-viewport,
#custom-player-container:-webkit-full-screen .player-video-viewport,
#custom-player-container.ios-virtual-fullscreen .player-video-viewport {
    width: 100% !important;
    height: 100% !important;
    flex: 1 !important;
    max-height: calc(100vh - 140px) !important; 
    background-color: #000000 !important;
    border: none !important;
    border-radius: 0.5rem !important;
    box-shadow: none !important;
}

#custom-player-container:fullscreen video,
#custom-player-container:-webkit-full-screen video,
#custom-player-container.ios-virtual-fullscreen video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important; 
}

#custom-player-container:fullscreen .player-controls,
#custom-player-container:-webkit-full-screen .player-controls,
#custom-player-container.ios-virtual-fullscreen .player-controls {
    width: 100% !important;
    background-color: #1e293b !important; 
    padding: 1.25rem 1.5rem !important;
    border-radius: 0.75rem !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    z-index: 2147483647 !important; 
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.6) !important;
}

#custom-player-container:fullscreen .player-btn,
#custom-player-container:-webkit-full-screen .player-btn,
#custom-player-container.ios-virtual-fullscreen .player-btn { 
    color: #ffffff !important; 
}

#custom-player-container:fullscreen .time-display-container,
#custom-player-container:-webkit-full-screen .time-display-container,
#custom-player-container.ios-virtual-fullscreen .time-display-container { 
    color: #e2e8f0 !important; 
}

#custom-player-container:fullscreen .player-speed-dropdown-list,
#custom-player-container:-webkit-full-screen .player-speed-dropdown-list,
#custom-player-container.ios-virtual-fullscreen .player-speed-dropdown-list {
    z-index: 2147483647 !important;
    background-color: #0f172a !important;
}

/* ==========================================================================
   8. COMPATIBILIDADE ERGONÔMICA RESPONSIVA (MOBILE SAFE COM AUTO-CENTRALIZAÇÃO)
   ========================================================================== */
@media (max-width: 768px) {
    body {
        padding-bottom: 240px !important; /* Resguarda a base para o rodapé se expandir verticalmente */
    }

    .player-fixed-bottom {
        padding: 0.75rem 1rem !important;
    }

    /* O wrapper mestre passa a ser coluna para centralizar a miniatura acima dos botões */
    .player-wrapper {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .player-video-viewport {
        width: 140px !important;
        aspect-ratio: 16 / 9 !important;
    }

    /* Calibração responsiva mestre para o controls-row no mobile */
    .controls-row {
        justify-content: center !important; /* Centraliza as linhas de botões em telas pequenas */
        gap: 0.75rem !important;
    }

    /* Centraliza os botões internos de forma harmônica em aparelhos touch */
    .controls-left, 
    .controls-right {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Oculta o slider analógico de volume no mobile para poupar espaço (o clique de mudo continua ativo) */
    .volume-slider-bar {
        display: none !important;
    }

    /* Desativa tooltips gráficos de mouse por ausência de ponteiro físico no celular */
    .custom-progress-bar-container .timeline-preview-box,
    .slider-tooltip-container.dynamic-volume-tooltip::after {
        display: none !important;
        opacity: 0 !important;
    }

    /* Garante que a lista suspensa de velocidades abra centralizada horizontalmente no celular */
    .player-speed-dropdown-list {
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}





/* FULLSCREEN TOTAL DO CONTAINER */
#custom-player-container.fullscreen-mode-active {
    width: 100vw !important; height: 100vh !important; max-width: 100vw !important; max-height: 100vh !important;
    position: fixed !important; top: 0 !important; left: 0 !important; background-color: #000000 !important;
    padding: 1.5rem !important; display: flex !important; flex-direction: column !important; justify-content: space-between !important; z-index: 999999 !important;
}
#custom-player-container.fullscreen-mode-active .player-wrapper { flex-direction: column !important; width: 100% !important; height: 100% !important; max-width: 100% !important; justify-content: space-between !important; }
#custom-player-container.fullscreen-mode-active .player-video-viewport { width: 100% !important; height: 100% !important; flex: 1 !important; max-height: calc(100vh - 120px) !important; }
#custom-player-container.fullscreen-mode-active video { width: 100% !important; height: 100% !important; object-fit: contain !important; }
#custom-player-container.fullscreen-mode-active .player-controls { width: 100% !important; background: #333 !important; padding: 1rem 1.5rem !important; border-radius: 0.75rem !important; }


