/**
 * Site footer bar (theme_custom).
 * Colours come from --custom-footer-* (inline on the element + runtime_colors.css.php).
 * Horizontal alignment follows the same column as #page.drawers .main-inner / #page-content.
 */

.theme-custom-has-footer {
    --tc-footer-inset-x: 1rem;
    --tc-footer-content-max: 100%;
    --tc-footer-content-pad-x: calc(0.5rem + 15px);
}

@media (min-width: 768px) {
    .theme-custom-has-footer {
        --tc-footer-inset-x: 3rem;
    }

    body.limitedwidth.theme-custom-has-footer,
    body.pagelayout-standard.theme-custom-has-footer {
        --tc-footer-content-max: 830px;
    }

    body.pagelayout-course.theme-custom-has-footer,
    body.pagelayout-incourse.theme-custom-has-footer,
    body.pagelayout-report.theme-custom-has-footer,
    body.theme-custom-course-page.theme-custom-has-footer,
    body.theme-custom-course-form.theme-custom-has-footer,
    body.theme-custom-dashboard.theme-custom-has-footer,
    body.theme-custom-mycourses.theme-custom-has-footer,
    body.theme-custom-course-index.theme-custom-has-footer,
    body.theme-custom-user-profile.theme-custom-has-footer,
    body.theme-custom-user-edit-profile.theme-custom-has-footer,
    body.theme-custom-user-preferences.theme-custom-has-footer,
    body.theme-custom-user-pref-form.theme-custom-has-footer,
    body.theme-custom-user-grades.theme-custom-has-footer,
    body.theme-custom-user-calendar.theme-custom-has-footer,
    body.theme-custom-user-files.theme-custom-has-footer {
        --tc-footer-inset-x: 0;
        --tc-footer-content-max: min(1720px, 98vw);
        --tc-footer-content-pad-x: clamp(1rem, 4vw, 3rem);
    }

    body.theme-custom-admin-shell.theme-custom-has-footer,
    body.theme-custom-admin-hub.theme-custom-has-footer {
        --tc-footer-content-max: 100%;
    }
}

.theme-custom-has-footer #page-wrapper.theme-custom-page-wrapper,
.theme-custom-has-footer #page-wrapper.theme-custom-login-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.theme-custom-has-footer #page-wrapper.theme-custom-page-wrapper > #page,
.theme-custom-has-footer #page-wrapper.theme-custom-login-wrapper > #page {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.theme-custom-has-footer #page.drawers {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.theme-custom-has-footer #page.drawers .main-inner {
    flex: 1 0 auto;
    margin-bottom: 0;
}

/* Dashboard / My courses: custom catalogue fills the page — do not stretch the white card. */
body.theme-custom-dashboard.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-mycourses.theme-custom-has-footer #page.drawers .main-inner {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    height: auto !important;
    padding-bottom: 0.75rem !important;
}

body.theme-custom-dashboard.theme-custom-has-footer #page.drawers #page-footer.footer-popover,
body.theme-custom-mycourses.theme-custom-has-footer #page.drawers #page-footer.footer-popover {
    flex: 0 0 auto !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: visible !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
    border-radius: 0 !important;
}

body.theme-custom-dashboard.theme-custom-has-footer #page.drawers #page-footer .footer-content-popover,
body.theme-custom-mycourses.theme-custom-has-footer #page.drawers #page-footer .footer-content-popover,
body.theme-custom-dashboard.theme-custom-has-footer #page.drawers #page-footer .footer-content-debugging,
body.theme-custom-mycourses.theme-custom-has-footer #page.drawers #page-footer .footer-content-debugging {
    display: none !important;
}

/* Boost #page-footer sits inside #page.drawers; keep float buttons, hide the bar. */
.theme-custom-has-footer #page.drawers #page-footer.footer-popover {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
}

body.pagelayout-course.theme-custom-has-footer #page.drawers .main-inner,
body.pagelayout-incourse.theme-custom-has-footer #page.drawers .main-inner,
body.pagelayout-report.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-course-page.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-course-form.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-dashboard.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-mycourses.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-course-index.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-user-profile.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-user-edit-profile.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-user-preferences.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-user-pref-form.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-user-grades.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-user-calendar.theme-custom-has-footer #page.drawers .main-inner,
body.theme-custom-user-files.theme-custom-has-footer #page.drawers .main-inner {
    margin-bottom: 0;
}

html.theme-custom-a11y-dark-mode body.theme-custom-has-footer #page.drawers #page-footer.footer-popover {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Fixed Save/Cancel bar — keep custom footer content above the action bar when scrolled to the end. */
body.theme-custom-mform-sticky-actions.theme-custom-has-footer .custom-site-footer {
    margin-bottom: 4.25rem;
}

.custom-site-footer {
    flex-shrink: 0;
    width: 100%;
    margin-top: 0;
    padding: 0.875rem var(--tc-footer-inset-x);
    background-color: var(--custom-footer-bg, #3f444e) !important;
    color: var(--custom-footer-color, #f8fafc) !important;
    font-size: 0.875rem;
    line-height: 1.5;
    border-top: 1px solid color-mix(in srgb, var(--custom-footer-color, #f8fafc) 12%, transparent);
    box-sizing: border-box;
}

.custom-site-footer__inner,
.custom-site-footer__inner p,
.custom-site-footer__inner span,
.custom-site-footer__inner div {
    color: inherit;
}

.custom-site-footer a {
    color: var(--custom-footer-color, #f8fafc) !important;
    text-decoration: underline;
}

.custom-site-footer a:hover,
.custom-site-footer a:focus {
    opacity: 0.85;
}

.custom-site-footer__inner {
    width: 100%;
    max-width: var(--tc-footer-content-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--tc-footer-content-pad-x);
    padding-right: var(--tc-footer-content-pad-x);
    box-sizing: border-box;
    text-align: center;
}

.custom-site-footer__inner > :last-child {
    margin-bottom: 0;
}

.custom-site-footer__inner p {
    margin-bottom: 0.35rem;
}

.custom-site-footer__inner a {
    color: var(--custom-footer-color, #f8fafc) !important;
}

html.theme-custom-a11y-dark-mode .custom-site-footer {
    background-color: var(--custom-footer-bg, #3f444e) !important;
    color: var(--custom-footer-color, #f8fafc) !important;
}

html.theme-custom-a11y-dark-mode .custom-site-footer a {
    color: var(--custom-footer-color, #f8fafc) !important;
}
