/* Scoped report layout adjustments for the online-new Moodle 5.3 migration. */
#page-report-progress-index #completion-progress-wrapper {
    max-height: min(65vh, 40rem);
    overflow: auto;
}

#page-report-progress-index #completion-progress-wrapper:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

#page-report-progress-index #completion-progress th,
#page-report-progress-index #completion-progress td {
    height: auto;
    padding: 0.375rem 0.5rem;
}

#page-report-progress-index #completion-progress .completion-sortchoice,
#page-report-progress-index #completion-progress tbody th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 12.5rem;
    min-width: 12.5rem;
    max-width: 12.5rem;
    overflow-wrap: anywhere;
    background-color: #fff;
}

#page-report-progress-index #completion-progress .completion-sortchoice {
    z-index: 3;
    background-color: #ebf0f9;
}

#page-report-progress-index #completion-progress .completion-identifyfield,
#page-report-progress-index #completion-progress tbody td:not(.completion-progresscell) {
    width: 13.75rem;
    min-width: 13.75rem;
    max-width: 13.75rem;
    overflow-wrap: anywhere;
}

#page-report-progress-index #completion-progress .completion-header {
    width: 9.375rem;
    min-width: 9.375rem;
    max-width: 9.375rem;
}

#page-report-progress-index #completion-progress .completion-header .rotated-text-container {
    width: auto;
    max-width: 8rem;
}

#page-report-progress-index #completion-progress .completion-header .rotated-text {
    word-break: normal;
    overflow-wrap: anywhere;
}

/* Keep the native grader name column and controls; bound the scrolling area. */
#page-grade-report-grader-index.path-grade-report-grader .gradeparent {
    min-height: 0;
    max-height: min(65vh, 40rem);
    overflow: auto;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent tr.heading {
    top: 0;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent tr.lastrow:not(.userrow) {
    bottom: 0;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .cell {
    height: auto;
    padding: 0.375rem 0.5rem;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .highlightable.cell:not(.collapsed) {
    width: 9.375rem;
    min-width: 9.375rem;
}

/* Allow the header's text flex item to shrink beside sorting and menu buttons. */
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .heading .highlightable [data-collapse="content"] > .flex-grow-1 {
    min-width: 0;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .heading .highlightable .gradeitemheader {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    max-width: none;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    max-height: 2.5em;
    padding: 0;
    text-indent: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    overflow: hidden;
    line-height: 1.25;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent th.header {
    width: 12.5rem;
    min-width: 12.5rem;
    max-width: 12.5rem;
    white-space: normal;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell,
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .username {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Reserve the native row menu's width so it does not wrap below the name. */
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell .username {
    display: inline-block;
    max-width: calc(100% - 3rem);
    vertical-align: middle;
    font-size: 0.8125rem;
    line-height: 1.25;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell .userinitials,
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell .userpicture {
    width: 1.625rem;
    height: 1.625rem;
    min-width: 1.625rem;
    line-height: 1.625rem;
    font-size: 0.75rem;
    vertical-align: middle;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userfield:not(.collapsed) {
    width: 13.75rem;
    min-width: 13.75rem;
    max-width: 13.75rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

@media print {
    #page-report-progress-index #completion-progress-wrapper,
    #page-grade-report-grader-index.path-grade-report-grader .gradeparent {
        max-height: none;
        overflow: visible;
    }
}

/* Working-page density. This sheet is loaded only for the selected working paths.
   The body guard is an additional boundary; fixed navbar dimensions are untouched. */
body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) #page.drawers .main-inner {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group).remui-notification #page.drawers:has(.site-announcement) .main-inner {
    margin-top: 2rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) #page-header {
    margin-bottom: 0.75rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) #page-header #page-navbar {
    margin-bottom: 0.5rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) #page-header .dashboard-bar-wrapper {
    gap: 0.5rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) #region-main {
    font-size: 0.875rem;
    line-height: 1.5;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group).main-area-bg #region-main > div[role="main"] {
    padding: 1rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .secondary-navigation {
    margin-bottom: 0.75rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .secondary-navigation:not(.edw-tabs-navigation) .moremenu .nav-link {
    height: 2.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .edw-tabs-navigation .nav-tabs {
    column-gap: 1.25rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .tertiary-navigation {
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0.5rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .tertiary-navigation > .d-flex {
    flex-wrap: wrap;
    row-gap: 0.25rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .tertiary-navigation .navitem,
body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .tertiary-navigation > .btn,
body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .tertiary-navigation > .urlselect {
    margin-bottom: 0.5rem;
}

body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) .tertiary-navigation .navitem:not(:last-child) {
    margin-right: 0.75rem;
}

/* Reduce section and activity card whitespace on course views only. */
body.path-course-view #region-main .course-content ul.topics li.section,
body.path-course-view #region-main .course-content ul.weeks li.section {
    padding: 1rem;
}

body.path-course-view #region-main .course-content ul.topics li.section:not(:last-of-type),
body.path-course-view #region-main .course-content ul.weeks li.section:not(:last-of-type) {
    margin-bottom: 1rem;
}

body.path-course-view #region-main .course-content ul.topics li.section .activity.activity-wrapper .activity-item,
body.path-course-view #region-main .course-content ul.weeks li.section .activity.activity-wrapper .activity-item {
    padding: 0.75rem 1rem;
}

/* Native group form stays visible, with room for the complete selected label. */
body.path-grade .online-grade-group-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    margin: 0 0 0.75rem;
    font-size: 0.8125rem;
}

body.path-grade .online-grade-group-selector form,
body.path-grade .online-grade-group-selector .singleselect,
body.path-grade .online-grade-group-selector form > div {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    margin: 0;
}

body.path-grade .online-grade-group-selector label {
    margin: 0;
}

body.path-grade .online-grade-group-selector select {
    box-sizing: border-box;
    height: 2rem;
    min-height: 2rem;
    min-width: 15rem;
    max-width: 100%;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.8125rem;
    line-height: 1.25;
}

/* Strong report density is restricted to these two reports. */
:is(#page-grade-report-grader-index.path-grade-report-grader, #page-report-progress-index) .tertiary-navigation .navitem > .btn,
:is(#page-grade-report-grader-index.path-grade-report-grader, #page-report-progress-index) .tertiary-navigation .navitem > .dropdown > .btn,
:is(#page-grade-report-grader-index.path-grade-report-grader, #page-report-progress-index) .tertiary-navigation .navitem > .select-menu > .btn,
:is(#page-grade-report-grader-index.path-grade-report-grader, #page-report-progress-index) .groupselector select {
    min-height: 2rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.8125rem;
    line-height: 1.5;
}

#page-report-progress-index #completion-progress tbody th,
#page-report-progress-index #completion-progress tbody td {
    height: 2.625rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.25;
    vertical-align: middle;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > .cell {
    height: 2.625rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.25;
    vertical-align: middle;
}

/* The name is complete and wraps naturally. Only its decorative image is hidden. */
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell .username .userpicture,
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell .username .userinitials {
    display: none;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > .user.cell {
    padding-inline-start: 0.5rem !important;
    white-space: nowrap;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell .username {
    max-width: calc(100% - 2.5rem);
    white-space: normal;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell > .action-menu {
    padding-inline-start: 0.25rem;
    margin-inline-end: 0;
    vertical-align: middle;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .user.cell .cellmenubtn {
    box-sizing: border-box;
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    min-height: 2rem;
    padding: 0.25rem;
    line-height: 1.25;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > .userfield > div {
    padding-top: 0;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow .gradevalue,
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow td.grade_type_value {
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow input.form-control,
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow select {
    height: 2rem;
    min-height: 2rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.8125rem;
}

@media (max-width: 767.98px) {
    body:is(.path-course, .path-grade, .path-report, .path-user, .path-group) #page.drawers .main-inner {
        margin-top: 0.75rem;
        margin-bottom: 0.75rem;
    }

    body:is(.path-course, .path-grade, .path-report, .path-user, .path-group).main-area-bg #region-main > div[role="main"] {
        padding: 0.75rem;
    }

    body.path-grade .online-grade-group-selector,
    body.path-grade .online-grade-group-selector form,
    body.path-grade .online-grade-group-selector .singleselect,
    body.path-grade .online-grade-group-selector form > div,
    body.path-grade .online-grade-group-selector select {
        width: 100%;
        min-width: 0;
    }

    body.path-grade .online-grade-group-selector select {
        height: 2.75rem;
        min-height: 2.75rem;
        font-size: 0.875rem;
    }
}

/* Remove empty status-icon reserve from data cells, preserving real grade icons. */
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > td.gradecell > [data-collapse="content"].h-100 {
    height: auto !important;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > td.gradecell .grade_icons:empty {
    display: none;
}

/* Compact the course cover and stats while retaining the native responsive layout. */
body.path-course-view #page-header.hasbackground.design-1 {
    min-height: 11rem;
    height: auto;
    padding: 1rem;
}

body.path-course-view #wdm_course-stats.edw-stats-wrapper,
body.path-course-view #wdm_course-stats .edw-stats-wrapper {
    padding: 0.75rem;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

body.path-course-view #wdm_course-stats .stats-mb-devices {
    gap: 0.5rem;
}

body.path-course-view #wdm_course-stats .stat-block .inner {
    gap: 0.75rem;
}

body.path-course-view #wdm_course-stats .stat-block .info-container .h-exbold-2 {
    font-size: 1.5rem;
    line-height: 1.2;
}

body.path-course-view #wdm_course-stats .stat-block .inner .edw-icon {
    font-size: 1.5rem;
    line-height: 1;
    width: 1.5rem;
    height: 1.5rem;
}

/* Keep grade values, their native menu and real status icons on one compact row. */
#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > td.gradecell > [data-collapse="content"].h-100 {
    flex-direction: row !important;
    align-items: center;
    gap: 0.25rem;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > td.gradecell > [data-collapse="content"].h-100 > .flex-grow-1.align-items-end {
    flex-grow: 0 !important;
}

#page-grade-report-grader-index.path-grade-report-grader .gradeparent .userrow > td.gradecell > [data-collapse="content"].h-100 .grade_icons {
    margin-top: 0;
}
