/* TerraStack.Blazor.UI
   ---------------------------------------------------------------------------
   Link from the host app:
     <link href="_content/TerraStack.Blazor.UI/TerraStack.Blazor.UI.css" rel="stylesheet" />

   Optional. Every component keeps a working inline fallback, so an app that has
   not linked this file still renders correctly - it just loses the row tinting
   on the frozen column described below.
   --------------------------------------------------------------------------- */

/* ── TableListComponent: frozen first column ────────────────────────────────
   A sticky cell is painted after its siblings, so it needs an opaque background
   of its own or the columns scrolling underneath show straight through it. A
   flat palette colour is not enough: the row it sits in is striped, hovered and
   selected with *translucent* overlays, and a cell painted a fixed colour stays
   stubbornly untinted while the rest of the row changes.

   So the cell paints two layers - an opaque base plus the row's current overlay
   as a gradient - and the row publishes its overlay through --ts-row-tint. The
   selectors below mirror MudBlazor's own striped/hover rules so the tint lands
   on exactly the rows MudBlazor tints. A host that restyles those states can
   set --ts-row-tint in its own rule to keep the frozen column in step. */

.ts-sticky-table td.ts-sticky-col {
    /* !important beats the inline fallback style on the element itself. */
    background-color: var(--mud-palette-surface) !important;
    background-image: linear-gradient(var(--ts-row-tint, transparent),
                                      var(--ts-row-tint, transparent)) !important;
}

.ts-sticky-table.mud-table-striped .mud-table-container .mud-table-root .mud-table-body .mud-table-row:nth-of-type(odd) {
    --ts-row-tint: var(--mud-palette-table-striped);
}

@media (hover: hover) and (pointer: fine) {
    .ts-sticky-table.mud-table-hover .mud-table-container .mud-table-root .mud-table-body .mud-table-row:hover {
        --ts-row-tint: var(--mud-palette-table-hover);
    }
}

/* ── Table lists: numeric columns ───────────────────────────────────────────
   Money, percentage and number columns carry ts-num on both the heading and the
   cells. Right-aligned, fixed-width figures line up by place value so amounts can
   be compared down the column. The inline text-align on the element is the
   fallback; tabular figures need this file. */

.ts-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* The sort label is a flex row; push it to the right edge with the text. */
th.ts-num .mud-table-sort-label {
    justify-content: flex-end;
}

/* ── Table lists: card mode ─────────────────────────────────────────────────
   Below the Sm breakpoint MudTable turns each row into a stacked label/value card.
   The edit pencil would then sit alone on a blank first line; the whole card already
   opens the record on tap, so drop it there. Lists that can't be viewed keep it
   (the class is only set when CanView is true). Matches MudBlazor's 960px query. */

@media (max-width: 960px) {
    .mud-sm-table .mud-table-cell.ts-row-edit {
        display: none;
    }
}
