/* MudBlazor sets min-width:fit-content on .mud-chart and on .mud-chart-legend,
   so a chart with a side legend refuses to shrink and overflows narrow
   containers. .chart-fit lets the plot area absorb the shrinking while the
   legend keeps its natural width. */
.chart-fit.mud-chart {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* The SVG is the flex item that gives up space. */
.chart-fit.mud-chart > svg {
    flex: 1 1 0;
    min-width: 0;
}

/* The legend keeps its content width, but never more than half the card. */
.chart-fit.mud-chart > .mud-chart-legend {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 50%;
}

/* Long labels wrap instead of pushing the legend wider. */
.chart-fit.mud-chart > .mud-chart-legend .mud-chart-legend-item {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Data grids that should never wrap cell text. table-layout:fixed is required
   for text-overflow to take effect in table cells; without it the browser
   widens the column to fit the content instead of clipping it. */
.grid-truncate .mud-table-root {
    table-layout: fixed;
    width: 100%;
}

.grid-truncate .mud-table-root td,
.grid-truncate .mud-table-root th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-align-right{
    text-align:right;
}

/* Timecard page */
.timecard-user-card {
    width: 18rem;
    max-width: 100%;
}

.timecard-mobile-total {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
}

@media (max-width: 960px) {
    .timecard-filters > *,
    .timecard-filters .timecard-user-card,
    .timecard-summaries > * {
        width: 100%;
    }

    /* Each entry becomes a card */
    .timecard-entries.mud-sm-table {
        background: transparent;
        box-shadow: none;
    }

    .timecard-entries.mud-sm-table .mud-table-body {
        border-top: none;
    }

    .timecard-entries.mud-sm-table .mud-table-body .mud-table-row {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 0.75rem;
        border-radius: var(--mud-default-borderradius);
        background-color: var(--mud-palette-surface);
        box-shadow: var(--mud-elevation-2);
        overflow: hidden;
    }

    .timecard-entries.mud-sm-table .mud-table-body .mud-table-row.timecard-row-editing {
        outline: 2px solid var(--mud-palette-primary);
    }

    .timecard-entries.mud-sm-table .mud-table-cell {
        width: 100%;
        font-size: 0.875rem;
    }

    .timecard-entries.mud-sm-table .mud-table-row .mud-table-cell:last-child {
        border-bottom: none;
    }

    /* Header line: date on the left, action buttons on the right */
    .timecard-entries.mud-sm-table .timecard-cell-date {
        order: -2;
        flex: 1 1 auto;
        width: auto;
        font-weight: 600;
        font-size: 1rem;
        background-color: var(--mud-palette-background-gray);
    }

    .timecard-entries.mud-sm-table .timecard-cell-actions {
        order: -1;
        flex: 0 0 auto;
        width: auto;
        justify-content: flex-end;
        background-color: var(--mud-palette-background-gray);
    }

    .timecard-entries.mud-sm-table .timecard-cell-date::before,
    .timecard-entries.mud-sm-table .timecard-cell-actions::before {
        display: none;
    }

    /* In/Out side by side, flags three across */
    .timecard-entries.mud-sm-table .timecard-cell-time {
        flex: 1 1 50%;
        width: 50%;
    }

    .timecard-entries.mud-sm-table .timecard-cell-flag {
        flex: 1 1 33%;
        width: 33%;
        flex-direction: column;
        align-items: flex-start;
    }

    .timecard-entries.mud-sm-table .timecard-cell-hours {
        font-weight: 600;
    }

    .timecard-entries.mud-sm-table .timecard-cell-notes {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Editing: label above a full-width input */
    .timecard-entries.mud-sm-table .timecard-row-editing .mud-table-cell:not(.timecard-cell-date):not(.timecard-cell-actions):not(.timecard-cell-flag):not(.timecard-cell-hours):not(.timecard-cell-submit) {
        flex-direction: column;
        align-items: stretch;
    }

    .timecard-entries.mud-sm-table .timecard-row-editing .mud-table-cell > .mud-input-control,
    .timecard-entries.mud-sm-table .timecard-row-editing .mud-table-cell > .mud-picker,
    .timecard-entries.mud-sm-table .timecard-row-editing .mud-table-cell > .mud-select {
        width: 100%;
    }

    .timecard-entries.mud-sm-table .timecard-row-editing .mud-icon-button {
        padding: 8px;
    }
}
