/* <Datagrid /> — default styling, lm-datagrid-* convention */
.lm-datagrid {
    font: 13.5px/1.4 system-ui, sans-serif;
    color: var(--lm-font-color, #18181b);
    border: 1px solid var(--lm-border-color, #e4e4e7);
    border-radius: 10px;
    background: var(--lm-background-color, #fff);
    outline: none;
    overflow: hidden;
}

.lm-datagrid:focus-visible {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.lm-datagrid-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--lm-border-color, #e4e4e7);
}

.lm-datagrid-search {
    flex: 0 0 240px;
    padding: 6px 10px;
    border: 1px solid var(--lm-border-color, #e4e4e7);
    border-radius: var(--lm-radius, 6px);
    font: inherit;
}

.lm-datagrid-count {
    color: var(--lm-font-grayout, #71717a);
    font-size: 12px;
}

.lm-datagrid-header,
.lm-datagrid-row {
    display: grid;
    align-items: center;
}

.lm-datagrid-header {
    border-bottom: 1px solid var(--lm-border-color, #e4e4e7);
    background: var(--lm-background-color-header, #fafafa);
    user-select: none;
}

.lm-datagrid-th {
    position: relative; /* anchors the resize handle */
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 9px 12px;
    font-weight: 600;
    font-size: 12.5px;
    color: var(--lm-font-color, #3f3f46);
    white-space: nowrap;
    overflow: hidden;
}

/* Column resize: a 6px hit zone on the th right edge */
.lm-datagrid-resize {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
}

.lm-datagrid-resize:hover {
    background: rgba(37, 99, 235, 0.35);
}

/* While a resize drag is in flight: the cursor stays col-resize and
   text selection is suspended everywhere in the grid */
.lm-datagrid-resizing,
.lm-datagrid-resizing * {
    cursor: col-resize !important;
    user-select: none;
}

.lm-datagrid-th[data-sortable='true'] {
    cursor: pointer;
}

.lm-datagrid-th[data-sortable='true']:hover {
    color: var(--lm-font-color, #18181b);
}

/* Sort indicator: a CSS-drawn chevron (the old ▲/▼ text glyphs rendered
   tiny and at the mercy of the platform font). It rotates between asc and
   desc, and sortable-but-unsorted headers hint a faint one on hover. */
.lm-datagrid-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 14px;
    height: 14px;
    color: inherit; /* same color as the header text */
}

.lm-datagrid-arrow::before {
    content: '';
    width: 5px;
    height: 5px;
    border-right: 1.6px solid currentColor;
    border-bottom: 1.6px solid currentColor;
    opacity: 0;
    transform: translateY(-1px) rotate(45deg); /* chevron pointing down */
    transition:
        transform var(--lm-duration, 0.15s) var(--lm-ease, ease),
        opacity var(--lm-duration, 0.15s) var(--lm-ease, ease);
}

.lm-datagrid-arrow[data-dir]::before {
    opacity: 1;
}

.lm-datagrid-arrow[data-dir='asc']::before {
    transform: translateY(1px) rotate(-135deg); /* pointing up */
}

/* hover a sortable, unsorted column: faint hint that it sorts */
.lm-datagrid-th[data-sortable='true']:hover .lm-datagrid-arrow:not([data-dir])::before {
    opacity: 0.45;
}

.lm-datagrid-th[data-align='right'] {
    justify-content: flex-end;
}

.lm-datagrid-th[data-align='center'] {
    justify-content: center;
}

.lm-datagrid-body {
    position: relative;
    overscroll-behavior: contain;
}

.lm-datagrid-canvas {
    position: relative;
}

.lm-datagrid-window {
    will-change: transform;
}

.lm-datagrid-row {
    border-bottom: 1px solid var(--lm-background-color-highlight, #f4f4f5);
    box-sizing: border-box;
}

/* zebra: every second window row (view-index parity, so the stripes
   survive virtual scrolling). Hover and selection rules below win. */
.lm-datagrid-zebra {
    background: var(--lm-background-color-highlight, #f4f4f5);
}

.lm-datagrid-row:hover {
    background: var(--lm-background-color-header, #fafafa);
}

.lm-datagrid-selected,
.lm-datagrid-selected:hover {
    background: var(--lm-background-color-highlight, #eff6ff);
}

.lm-datagrid-cell {
    padding: 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height: 100%;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.lm-datagrid-cell[data-align='right'] {
    justify-content: flex-end;
    font-variant-numeric: tabular-nums;
}

.lm-datagrid-cell[data-align='center'] {
    justify-content: center;
}

.lm-datagrid-active {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.55);
    border-radius: var(--lm-radius, 6px);
}

/* While editing, the editor's ring is the only ring */
.lm-datagrid-active:has(.lm-datagrid-editor) {
    box-shadow: none;
}

/* In-place editing: the cell itself becomes the editor — same
   geometry, same typography, just a focus ring and a caret */
.lm-datagrid-editor {
    flex: 1;
    min-width: 0;
    outline: none;
    box-shadow: inset 0 0 0 2px var(--lm-main-color, #2563eb);
    border-radius: var(--lm-radius, 6px);
    padding: 3px 5px;
    margin: -3px -5px;
    white-space: pre;
    overflow: hidden;
    cursor: text;
}

.lm-datagrid-cell[data-align='right'] .lm-datagrid-editor {
    text-align: right;
}

.lm-datagrid-empty {
    padding: 28px;
    text-align: center;
    color: var(--lm-font-grayout, #a1a1aa);
}

/* Three zones: info | CENTERED pager | (balance) — the pager sits on
   the true middle of the row, vertically and horizontally */
.lm-datagrid-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    border-top: 1px solid var(--lm-border-color, #e4e4e7);
    background: var(--lm-background-color-header, #fafafa);
    font-size: 12.5px;
    color: var(--lm-font-grayout, #52525b);
}

.lm-datagrid-footer::after {
    content: '';
}

.lm-datagrid-pageinfo {
    font-variant-numeric: tabular-nums;
}

.lm-datagrid-pages {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
}

.lm-datagrid-pages button {
    min-width: 28px;
    height: 28px;
    margin: 0; /* host pages often style bare <button> with margins */
    padding: 0 6px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--lm-radius, 6px);
    font: inherit;
    color: var(--lm-font-color, #3f3f46);
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.lm-datagrid-pages button:hover:not(:disabled):not([data-current]) {
    background: var(--lm-border-color, #e4e4e7);
}

.lm-datagrid-pages button[data-current] {
    background: var(--lm-main-color, #2563eb);
    border-color: var(--lm-main-color, #2563eb);
    color: #fff;
    font-weight: 600;
}

.lm-datagrid-pages button:disabled {
    opacity: 0.35;
    cursor: default;
}

.lm-datagrid-gap {
    color: var(--lm-font-grayout, #a1a1aa);
    padding: 0 2px;
    user-select: none;
}
