/* 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;
}

/* Skill MudDataGrid — fill panel; keep counts/dates on one line (never break mid-number).
   Name column may wrap; other cells stay nowrap. Soft H-scroll only if content still overflows. */
.page-grid-table.page-grid-table--datagrid {
    overflow-x: auto;
}

.page-grid-table--datagrid .mud-table-container,
.page-grid-table--datagrid .mud-data-grid {
    max-width: 100%;
}

.page-grid-table--datagrid table.mud-table-root {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.page-grid-table--datagrid .mud-table-cell {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    vertical-align: middle;
}

.page-grid-table--datagrid thead .mud-table-cell {
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: normal;
}

/* Only skill name wraps — not progress counts or dates */
.page-grid-table--datagrid .skills-grid-cell-name {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

/* Skill DataGrid ColGroup — mins sized for (99/99) and dd.MM.yy on one line */
.skills-grid-col-order {
    width: 2.5rem;
    min-width: 2.25rem;
}

.skills-grid-col-name {
    width: 100%;
    min-width: 6rem;
}

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

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

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

.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: flex-end;
}

/* ---- 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;
}

/* Card / panel mode: wrap long fields (Umiejętność, Komentarz, …).
   Desktop row mode keeps nowrap + ellipsis above. Mud cards use max-width of the
   next breakpoint (Xs→600px, Sm→960px, Md→1280px). */

/* 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) .mud-table-container {
        overflow-x: visible;
        height: auto !important;
        max-height: none;
    }

    .page-grid-table .mud-xs-table:not(.mud-data-grid) table.mud-table-root {
        table-layout: auto;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .page-grid-table .mud-xs-table:not(.mud-data-grid) tbody .mud-table-cell {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        max-width: 100%;
    }

    .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;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .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) .mud-table-container {
        overflow-x: visible;
        height: auto !important;
        max-height: none;
    }

    .page-grid-table .mud-sm-table:not(.mud-data-grid) table.mud-table-root {
        table-layout: auto;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .page-grid-table .mud-sm-table:not(.mud-data-grid) tbody .mud-table-cell {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        max-width: 100%;
    }

    .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;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .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) .mud-table-container {
        overflow-x: visible;
        height: auto !important;
        max-height: none;
    }

    .page-grid-table .mud-md-table:not(.mud-data-grid) table.mud-table-root {
        table-layout: auto;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .page-grid-table .mud-md-table:not(.mud-data-grid) tbody .mud-table-cell {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        max-width: 100%;
    }

    .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;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

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