/* ─────────────────────────────────────────────────────────────────────
   grid-enhance.css — V9 DBGrid behavior (companion to grid-enhance.js).
   Fixed (sticky) column header, a bounded vertical scroll box, and
   drag-to-resize column grips. Tokens only (guardrail-clean).
   dual-scroll.js still owns the horizontal twin scrollbar.
   ───────────────────────────────────────────────────────────────────── */

/* The vertical scroll viewport wrapped around a grid table. Height is set
   by grid-enhance.js (fills to the bottom of the viewport). Horizontal
   overflow stays available so wide grids scroll both ways in one box. */
.zd-grid-box {
    overflow: auto;
    border: 1px solid var(--zd-hairline-2);
    border-radius: var(--zd-radius-sm);
    background: var(--zd-panel);
}

/* Fixed header: the thead row stays pinned while the body scrolls. This is
   the "disconnected header" effect without a second table — columns stay
   aligned with the body automatically. */
table.zd-grid-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--zd-grid-head);
    /* a hairline under the pinned header so rows don't bleed through on scroll */
    box-shadow: inset 0 -1px 0 var(--zd-hairline-2);
}

/* Drag-to-resize grip on the right edge of every header cell. */
table.zd-grid-sticky thead th { position: sticky; } /* ensure positioning context */
.zd-col-grip {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 4;
    touch-action: none;
}
.zd-col-grip:hover,
.zd-col-grip.is-active {
    background: color-mix(in srgb, var(--zd-accent) 45%, transparent);
}

/* While dragging a column: lock the cursor + kill text selection app-wide. */
body.zd-col-resizing,
body.zd-col-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* A resized grid stops auto-fitting column widths so the drag sticks. */
table.zd-grid-sticky.zd-cols-fixed {
    table-layout: fixed;
}

/* Fixed-layout cells MUST clip: a column pinned narrower than its content would
   otherwise let nowrap text overflow and visually overlap the next column
   (the Company Look-Up phone/fax/rep/date collision). Ellipsis truncates
   cleanly instead; drag-resize (or the content-fit default) restores the rest. */
table.zd-grid-sticky.zd-cols-fixed th,
table.zd-grid-sticky.zd-cols-fixed td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Small "reset column widths" affordance shown when a grid has custom widths. */
.zd-grid-reset {
    appearance: none;
    border: 1px solid var(--zd-hairline-2);
    background: var(--zd-panel);
    color: var(--zd-muted);
    font: inherit;
    font-size: calc(11px / var(--geo-scale, 1));
    line-height: 1.2;
    padding: 2px 8px;
    border-radius: 999px;
    cursor: pointer;
    margin: 4px 0 0 auto;
}
.zd-grid-reset:hover {
    color: var(--zd-accent);
    border-color: var(--zd-accent-line);
}
