/* =========================================================
   local_telacheia
   - Botão de tela cheia para vídeos, slides e PDFs
   - Ajustes de eficiência e responsividade para mobile
   ========================================================= */

/* ---------- Wrapper de mídia ---------- */
.local-telacheia-wrap {
    position: relative;
    display: block;
    margin: 0 0 1rem 0;
    background: transparent;
}

/* Mantém proporção 16:9 quando o elemento não tem altura definida */
.local-telacheia-wrap > video,
.local-telacheia-wrap > iframe,
.local-telacheia-wrap > object,
.local-telacheia-wrap > embed {
    display: block;
    width: 100%;
    max-width: 100%;
}

/* ---------- Botão ---------- */
.local-telacheia-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    opacity: 0.85;
    transition: opacity 0.15s ease;
    padding: 6px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.local-telacheia-btn:hover,
.local-telacheia-btn:focus {
    opacity: 1;
}

.local-telacheia-btn .fa {
    margin-right: 4px;
}

/* ---------- Pseudo-fullscreen (fallback quando a Fullscreen API falha) ---------- */
.local-telacheia-pseudo {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    background: #000 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.local-telacheia-pseudo > video,
.local-telacheia-pseudo > iframe,
.local-telacheia-pseudo > object,
.local-telacheia-pseudo > embed {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}

/* ---------- Fullscreen nativo: garante que o conteúdo ocupe a tela ---------- */
.local-telacheia-wrap:fullscreen,
.local-telacheia-wrap:-webkit-full-screen,
.local-telacheia-wrap:-moz-full-screen,
.local-telacheia-wrap:-ms-fullscreen {
    background: #000;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.local-telacheia-wrap:fullscreen > video,
.local-telacheia-wrap:fullscreen > iframe,
.local-telacheia-wrap:fullscreen > object,
.local-telacheia-wrap:fullscreen > embed {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* =========================================================
   Otimizações mobile
   ========================================================= */

@media (max-width: 768px) {

    /* Botão maior e mais alcançável no toque */
    .local-telacheia-btn {
        padding: 10px 14px;
        font-size: 14px;
        opacity: 0.95;
    }

    /* Esconde o texto do botão em telas muito pequenas, mantém só o ícone */
    .local-telacheia-btn-label {
        display: none;
    }
    .local-telacheia-btn .fa {
        margin-right: 0;
        font-size: 16px;
    }

    /* Vídeos e iframes ocupam a largura total e mantêm proporção 16:9 */
    .local-telacheia-wrap > video,
    .local-telacheia-wrap > iframe {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9;
    }

    /* Conteúdo do curso mais compacto */
    #page-content,
    .course-content,
    .course-content ul.topics li.section,
    .course-content ul.weeks li.section {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Atividades com áreas de toque maiores (acessibilidade) */
    .activity-instance a,
    .section .activity .activityname a,
    .section .activity .activity-item a {
        padding: 10px 0;
        display: inline-block;
        min-height: 44px; /* recomendação WCAG/Apple */
        line-height: 1.4;
    }

    /* Reduz padding excessivo do tema padrão */
    .pagelayout-incourse #page-content,
    .pagelayout-course #page-content {
        padding-top: 0.5rem;
    }

    /* Tabelas responsivas: scroll horizontal quando estourar */
    .generaltable {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Forms ocupam largura total */
    .mform .fitem .felement,
    .mform .fitem .form-control,
    .mform input[type="text"],
    .mform input[type="email"],
    .mform input[type="number"],
    .mform select,
    .mform textarea {
        max-width: 100%;
        width: 100%;
        font-size: 16px; /* evita zoom automático do iOS */
    }

    /* Menu lateral mais leve quando aberto */
    #nav-drawer, .drawer {
        width: 85vw;
        max-width: 320px;
    }
}

/* Imagens nunca estouram o container (vale também para desktop) */
.course-content img,
.no-overflow img,
#page-content img {
    max-width: 100%;
    height: auto;
}

/* PDFs embutidos ocupam altura razoável no mobile */
@media (max-width: 768px) {
    .resourceobject,
    object[type="application/pdf"],
    embed[type="application/pdf"] {
        min-height: 60vh;
        width: 100% !important;
    }
}

/* =========================================================
   Esconder branding/propaganda do Moodle no rodapé
   ========================================================= */

/* Links que apontam para domínios do Moodle (docs, services, app store) */
#page-footer a[href*="moodle.org"],
#page-footer a[href*="moodle.com"],
#page-footer a[href*="moodle.net"],
#page-footer a[href*="getmoodleapp"],
.page-footer-popover a[href*="moodle.org"],
.page-footer-popover a[href*="moodle.com"],
.page-footer-popover a[href*="moodle.net"],
.page-footer-popover a[href*="getmoodleapp"] {
    display: none !important;
}

/* Último bloco do rodapé: "Fornecido por Moodle" + "Versão X.Y (Build: ...)"
   No HTML, esse bloco é o único .footer-section.p-3 SEM .border-bottom. */
#page-footer .footer-section.p-3:not(.border-bottom) {
    display: none !important;
}

/* "Documentação para esta página" (link Moodle docs) e "Baixar o aplicativo móvel" */
#page-footer .helplink,
#page-footer .homelink,
#page-footer .moodledocs,
.footer-support-link a[href*="moodle.org"],
.footer-support-link a[href*="moodle.com"],
.footer-support-link a[href*="getmoodleapp"] {
    display: none !important;
}

/* Containers vazios após esconder os filhos: somem também */
#page-footer .footer-support-link:empty,
#page-footer .footer-section:empty {
    display: none !important;
}

/* Banner "Thank you for choosing Moodle / Contribute today" da página
   de Notificações do admin — afeta só admins, mas tira propaganda do site */
.admin-overview-moodlenet,
.admin-page-footer .moodlenet,
img[alt*="Moodle Partner"],
a[href*="moodle.com/partner"] {
    display: none !important;
}
