/**
 * Estilos para modais de vídeo do menu
 */

/*
 * Camada máxima: acima do Dashlifter, admin bar, select2, etc.
 * (evite 2147483647 — alguns engines truncam; 2147483000 é seguro.)
 */
#mvm-modals-container {
    position: fixed !important;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    z-index: 2147483000;
    display: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    isolation: isolate;
    overflow: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Fechado: não participar do fluxo nem herdar altura “infinita” de layouts admin */
#mvm-modals-container:not(.has-active-modal) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Quando há modais ativos, mostrar o container */
#mvm-modals-container.has-active-modal {
    display: block;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Modal: cobre a viewport inteira por baixo do conteúdo central */
.mvm-modal {
    position: fixed !important;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    pointer-events: none;
    z-index: 2147483000;
    isolation: isolate;
}

.mvm-modal.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
}

/* Garantir que quando não está ativo, o modal não bloqueie nada */
.mvm-modal:not(.active) {
    pointer-events: none;
    display: none;
    visibility: hidden;
    opacity: 0;
}

/* Overlay */
.mvm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    cursor: pointer;
    pointer-events: auto;
    z-index: 1;
}

/* Conteúdo do modal */
.mvm-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90vh;
    max-height: 90dvh;
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    transform: scale(0.96);
    transition: transform 0.12s ease;
    z-index: 2;
    pointer-events: auto;
    overscroll-behavior: contain;
}

.mvm-modal.active .mvm-modal-content {
    transform: scale(1);
}

/* Header do modal */
.mvm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.mvm-modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

/* Botão de fechar */
.mvm-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.mvm-modal-close:hover {
    background-color: #e0e0e0;
    color: #333;
    transform: rotate(90deg);
}

.mvm-modal-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Body do modal */
.mvm-modal-body {
    padding: 30px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* Área do vídeo + overlay “Carregando…” */
.mvm-video-stage {
    position: relative;
    width: 100%;
}

.mvm-modal-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.94);
    color: #f1f5f9;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9375rem;
    line-height: 1.4;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.mvm-modal.mvm-media-ready .mvm-modal-loading {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.mvm-spinner {
    width: 42px;
    height: 42px;
    box-sizing: border-box;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: mvmSpinnerRotate 0.7s linear infinite;
}

.mvm-loading-text {
    max-width: 16em;
}

@keyframes mvmSpinnerRotate {
    to {
        transform: rotate(360deg);
    }
}

/* Wrapper do vídeo */
.mvm-video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 8px;
}

/* Proporção sugerida pelo embed Panda (padding-top do player oficial). */
.mvm-video-wrapper.mvm-panda-aspect {
    padding-bottom: 49.930651872399444%;
}

.mvm-video-wrapper iframe,
.mvm-video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.mvm-video-wrapper video {
    object-fit: contain;
}

/* Garantir que iframes sejam visíveis quando o modal está ativo */
.mvm-modal.active .mvm-video-wrapper iframe {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    height: 100% !important;
}

.mvm-video-wrapper video {
    object-fit: contain;
}

/* Prevenir scroll do body quando modal está aberto */
body.mvm-modal-open {
    overflow: hidden;
    width: 100%;
}

/* Tablets */
@media screen and (max-width: 768px) {
    .mvm-modal-content {
        max-width: min(100%, 560px);
        max-height: 92vh;
        max-height: 92dvh;
        width: calc(100% - 24px);
        margin: 0 auto;
    }

    .mvm-modal-header {
        padding: 14px 16px;
    }

    .mvm-modal-header h2 {
        font-size: clamp(1rem, 4vw, 1.25rem);
        line-height: 1.3;
    }

    .mvm-modal-body {
        padding: 16px;
    }

    .mvm-modal-close {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 28px;
    }
}

/* Celular: tela cheia segura (notch) + vídeo proporcional */
@media screen and (max-width: 640px) {
    .mvm-modal {
        align-items: stretch;
        justify-content: stretch;
        padding: max(8px, env(safe-area-inset-top))
            max(8px, env(safe-area-inset-right))
            max(8px, env(safe-area-inset-bottom))
            max(8px, env(safe-area-inset-left));
        box-sizing: border-box;
    }

    .mvm-modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 12px;
        height: 100%;
        min-height: 0;
        max-height: 100vh;
        max-height: 100dvh;
        transform: none;
    }

    .mvm-modal.active .mvm-modal-content {
        transform: none;
    }

    .mvm-modal-header {
        flex-shrink: 0;
        padding: max(10px, env(safe-area-inset-top)) 12px 10px 16px;
        gap: 8px;
    }

    .mvm-modal-header h2 {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
        font-size: 1rem;
        line-height: 1.25;
        text-align: left;
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .mvm-modal-close {
        flex-shrink: 0;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .mvm-modal-body {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .mvm-video-wrapper {
        flex: 0 1 auto;
        width: 100%;
        max-width: 100%;
        border-radius: 8px;
    }

    @supports (aspect-ratio: 16 / 9) {
        .mvm-video-wrapper {
            aspect-ratio: 16 / 9;
            height: auto;
            padding-bottom: 0;
            max-height: min(52vh, 52dvh);
        }
    }
}

@media screen and (max-width: 640px) {
    @supports not (aspect-ratio: 16 / 9) {
        .mvm-video-wrapper {
            max-height: min(52vh, 52dvh);
        }
    }
}

@media screen and (max-width: 380px) {
    .mvm-modal {
        padding-left: max(4px, env(safe-area-inset-left));
        padding-right: max(4px, env(safe-area-inset-right));
    }

    .mvm-modal-content {
        border-radius: 8px;
    }

    .mvm-modal-header h2 {
        font-size: 0.9375rem;
    }
}

/* Animação de entrada */
@keyframes mvmModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mvm-modal.active .mvm-modal-content {
    animation: mvmModalFadeIn 0.12s ease forwards;
}

@media screen and (max-width: 640px) {
    .mvm-modal.active .mvm-modal-content {
        animation: none;
    }
}

/* Botão de vídeo ao lado dos itens do menu */
.mvm-video-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 0;
    margin-left: 8px;
    background: rgba(0, 115, 170, 0.1);
    border: 1px solid rgba(0, 115, 170, 0.3);
    border-radius: 50%;
    color: #0073aa;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
    flex-shrink: 0;
    opacity: 0.7;
    position: relative;
    z-index: 10;
    pointer-events: auto;
    text-decoration: none;
    float: none;
    clear: none;
}

.mvm-video-button:hover {
    background: #0073aa;
    color: #ffffff;
    border-color: #0073aa;
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

.mvm-video-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    opacity: 1;
}

.mvm-video-button svg {
    width: 12px;
    height: 12px;
    display: block;
}

/* Ajustar layout dos itens do menu para incluir o botão - apenas quando necessário */
.mvm-menu-item-wrapper {
    position: relative;
}

/* Garantir que links do menu funcionem normalmente */
.mvm-menu-item-wrapper > a,
li.menu-item > a,
li.menu-item-has-children > a,
nav a,
.sidebar a,
.menu a {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 1;
}

/* Link compartilha linha com o botão: nunca width:100% aqui (recorta o play no Dashlifter) */
.mvm-menu-item-wrapper > a {
    display: flex;
    align-items: center;
    justify-content: flex-start !important;
    text-align: left !important;
    gap: 10px !important;
    flex: 1 1 0%;
    min-width: 0;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Dashlifter: reforço para evitar centralização causada por regras globais/legadas */
.dashlifter-menu-content li.dashlifter-item.mvm-menu-item-wrapper > a,
.dashlifter-menu-content li.dashlifter-item#dashlifter-menu-expiration-reports > a {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    gap: 10px !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

.dashlifter-menu-content li.dashlifter-item.mvm-menu-item-wrapper > a .mvm-link-label,
.dashlifter-menu-content li.dashlifter-item#dashlifter-menu-expiration-reports > a .mvm-link-label {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: left !important;
    line-height: 1.2 !important;
}

.dashlifter-menu-content li.dashlifter-item.mvm-menu-item-wrapper > a > i.icon,
.dashlifter-menu-content li.dashlifter-item#dashlifter-menu-expiration-reports > a > i.icon {
    margin-right: 0 !important;
    flex: 0 0 auto !important;
}

/* Com modal aberto, o painel fica por baixo — não elevar z-index do menu (impedia ver o vídeo). */

/* Garantir que o botão não interfira com o link */
.mvm-menu-item-wrapper > a + .mvm-video-button {
    margin-left: 8px;
    flex-shrink: 0;
    display: inline-flex;
    vertical-align: middle;
}

/* Para menus que usam flexbox */
.mvm-menu-item-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Responsividade do botão */
@media (max-width: 768px) {
    .mvm-video-button {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }
    
    .mvm-video-button svg {
        width: 14px;
        height: 14px;
    }
}

/*
 * Dashlifter: <a> com width:100% empurrava o botão (depois do </a>) para fora da linha.
 * Flex na <li>: ordem natural do DOM = [ícone + texto] … [play] (botão após o texto).
 */
.dashlifter-menu-content li.dashlifter-item:has(> .mvm-video-button),
.dashlifter-menu-content li.dashlifter-item.mvm-menu-item-wrapper:has(> .mvm-video-button) {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: visible;
}

.dashlifter-menu-content li.dashlifter-item:has(> .mvm-video-button) > a,
.dashlifter-menu-content li.dashlifter-item.mvm-menu-item-wrapper:has(> .mvm-video-button) > a {
    flex: 1 1 0%;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100%;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    text-align: left !important;
    align-items: center !important;
    box-sizing: border-box;
}

.dashlifter-menu-content li.dashlifter-item:has(> .mvm-video-button) > a .dashlifter-nav-label,
.dashlifter-menu-content li.dashlifter-item.mvm-menu-item-wrapper:has(> .mvm-video-button) > a .dashlifter-nav-label {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left !important;
}

.dashlifter-menu-content li.dashlifter-item:has(> .mvm-video-button) > .mvm-video-button,
.dashlifter-menu-content li.dashlifter-item.mvm-menu-item-wrapper:has(> .mvm-video-button) > .mvm-video-button {
    flex-shrink: 0;
    margin-left: 0 !important;
    margin-right: 4px !important;
}

/* Submenu deslizante */
.dashlifter-menu-content .dashlifter-submenu li.dashlifter-item:has(> .mvm-video-button) {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: visible;
}

.dashlifter-menu-content .dashlifter-submenu li.dashlifter-item:has(> .mvm-video-button) > a {
    flex: 1 1 0%;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100%;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    text-align: left !important;
    align-items: center !important;
}

.dashlifter-menu-content .dashlifter-submenu li.dashlifter-item:has(> .mvm-video-button) > a .dashlifter-nav-label {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left !important;
}

.dashlifter-menu-content .dashlifter-submenu li.dashlifter-item:has(> .mvm-video-button) > .mvm-video-button {
    flex-shrink: 0;
    margin-left: 0 !important;
    margin-right: 4px !important;
}

/* Menu lateral antigo (layout.php / dashboard-nav) */
#dashlifter-navigation .dashlifter-dashboard-menu > li:has(> .mvm-video-button),
#dashlifter-navigation li.submenu-item:has(> .mvm-video-button) {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

#dashlifter-navigation .dashlifter-dashboard-menu > li:has(> .mvm-video-button) > a,
#dashlifter-navigation li.submenu-item:has(> .mvm-video-button) > a.submenu-link,
#dashlifter-navigation li.submenu-item:has(> .mvm-video-button) > a {
    flex: 1 1 0%;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100%;
}

#dashlifter-navigation .dashlifter-dashboard-menu > li:has(> .mvm-video-button) > .mvm-video-button,
#dashlifter-navigation li.submenu-item:has(> .mvm-video-button) > .mvm-video-button {
    flex-shrink: 0;
    margin-left: 0 !important;
    margin-right: 4px !important;
}

