/* Shared responsive grid/table wrapper for list pages (management, admin, skill DataGrids).
   Mud always adds .mud-*-table when Breakpoint is set; card layout only applies inside
   Mud's max-width media queries (Xs: 600px, Sm: 960px, Md: 1280px). Scope overrides the same way.

   IMPORTANT: MudDataGrid also renders with .mud-table + .mud-data-grid. MudTable-only chrome
   (table-layout:fixed, nowrap, ellipsis max-width:0) must use :not(.mud-data-grid) or it
   collapses skill DataGrid columns into the left half of the page. */

.page-grid-table {
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.page-grid-table .mud-table-container,
.page-grid-table .mud-data-grid {
    min-width: 0;
}

/* Wide MudDataGrid pages — fill container; horizontal scroll when below min-width.
   Do NOT use table-layout:fixed here (group colspan + ColGroup fight fixed layout). */
.page-grid-table--datagrid table.mud-table-root {
    width: 100%;
    min-width: 45rem;
}

/* Skill DataGrid ColGroup sizes (Student / Teacher / Mentor / Parent — rem/ch, not page-grid chrome) */
.skills-grid-col-order {
    width: 3rem;
    min-width: 3rem;
}

.skills-grid-col-name {
    /* Width 100% + table width 100% → this column absorbs leftover space */
    width: 100%;
    min-width: 12rem;
}

.skills-grid-col-flag {
    width: 7rem;
    min-width: 7rem;
}

.skills-grid-col-date {
    width: 9rem;
    min-width: 9rem;
}

.skills-grid-col-actions {
    width: 4.5rem;
    min-width: 4.5rem;
}

/* Progressive hide for date cols — display:none only; never d-*-table-cell on <col> */
@media (max-width: 960px) {
    col.skills-grid-col-md {
        display: none;
    }
}

.page-grid-table .mud-table-cell {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.page-grid-actions-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Desktop MudTable chrome (NOT MudDataGrid) ---- */

.page-grid-table .mud-table:not(.mud-data-grid) table.mud-table-root {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
    min-width: 100%;
}

.page-grid-table .mud-table:not(.mud-data-grid) tbody .mud-table-cell {
    white-space: nowrap;
    vertical-align: middle;
}

.page-grid-table .mud-table:not(.mud-data-grid) .page-grid-cell-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
}

.page-grid-table .mud-table:not(.mud-data-grid) .mud-table-cell.sticky-right {
    position: sticky;
    right: 0;
    background-color: var(--mud-palette-surface);
    z-index: 10;
    box-shadow: -0.125rem 0 0.25rem rgba(0, 0, 0, 0.1);
}

.page-grid-table .mud-table:not(.mud-data-grid) thead .mud-table-cell.sticky-right {
    background-color: var(--mud-palette-surface) !important;
    z-index: 11;
}

.page-grid-table .mud-table:not(.mud-data-grid) tbody .mud-table-cell.sticky-right {
    background-color: var(--mud-palette-surface) !important;
}

/* Breakpoint.Xs → cards at max-width 600px (MudTable cards only; skill DataGrids keep scroll) */
@media (max-width: 600px) {
    .page-grid-table:has(.mud-xs-table:not(.mud-data-grid)) {
        overflow-x: visible;
    }

    .page-grid-table .mud-xs-table:not(.mud-data-grid) .page-grid-cell-ellipsis {
        max-width: none;
        overflow: visible;
        white-space: normal;
        text-overflow: unset;
        text-align: end;
    }

    .page-grid-table .mud-xs-table:not(.mud-data-grid) .mud-table-cell.sticky-right {
        position: static;
        box-shadow: none;
    }
}

/* Breakpoint.Sm → cards at max-width 960px */
@media (max-width: 960px) {
    .page-grid-table:has(.mud-sm-table:not(.mud-data-grid)) {
        overflow-x: visible;
    }

    .page-grid-table .mud-sm-table:not(.mud-data-grid) .page-grid-cell-ellipsis {
        max-width: none;
        overflow: visible;
        white-space: normal;
        text-overflow: unset;
        text-align: end;
    }

    .page-grid-table .mud-sm-table:not(.mud-data-grid) .mud-table-cell.sticky-right {
        position: static;
        box-shadow: none;
    }
}

/* Breakpoint.Md → cards at max-width 1280px (legacy; prefer Xs for management lists) */
@media (max-width: 1280px) {
    .page-grid-table:has(.mud-md-table:not(.mud-data-grid)) {
        overflow-x: visible;
    }

    .page-grid-table .mud-md-table:not(.mud-data-grid) .page-grid-cell-ellipsis {
        max-width: none;
        overflow: visible;
        white-space: normal;
        text-overflow: unset;
        text-align: end;
    }

    .page-grid-table .mud-md-table:not(.mud-data-grid) .mud-table-cell.sticky-right {
        position: static;
        box-shadow: none;
    }
}
