/* Shared spreadsheet styling for every data grid in the application.
   Moved out of the Employee view so all grids look identical and there is one place to change it. */

.zk-grid { width: 100%; }

/* Handsontable ships its cells with border-collapse:separate, which lets each cell paint its own
   line. Adjacent lines then stack (a 1px border either side of a cell edge reads as 2px), and at
   a fractional device pixel ratio they land on different pixel boundaries - which is why the first
   row looked heavier than the rest and why the lines changed as you zoomed. Collapsing makes one
   shared line per gridline, painted once, the way a spreadsheet does it. */
.zk-grid .htCore,
.zk-grid .htCore table,
.zk-grid .ht_master table,
.zk-grid .ht_clone_left table,
.zk-grid .ht_clone_top table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

.zk-grid .htCore th,
.zk-grid .htCore td {
    border: 1px solid #000 !important;
    box-sizing: border-box !important;
    background-clip: padding-box;
    vertical-align: middle;
}

.zk-grid .htCore td {
    font-size: 12px !important;
    line-height: 15px !important;
    padding: 0 3px !important;
    color: #000;
}

/* Handsontable 14 wraps cell text in a .relative div that carries its own height, so pinning the
   line-height on the cell alone leaves the row as tall as before. Both have to be pinned. */
.zk-grid .htCore td .relative {
    line-height: 15px !important;
    height: auto !important;
    min-height: 0 !important;
}

.zk-grid .htCore tr { height: 22px !important; }

.zk-grid .htCore th {
    font-size: 11px !important;
    line-height: 15px !important;
    padding: 0 3px !important;
    color: #000;
    background: #f0f0f0;
    font-weight: 600;
}

.zk-grid .htCore th .colHeader { color: #000; }

.zk-grid .htCore .ht__row_header,
.zk-grid .htCore tbody th {
    border: 1px solid #000 !important;
    background: #f0f0f0;
    color: #000;
    font-size: 11px !important;
    line-height: 15px !important;
}

/* Label for the row-number column. Handsontable emits the corner cell with a non-breaking space
   and rewrites it on every render; `rowHeaders: ['SL']` is ignored in 14.4 and writing the text
   from JavaScript was undone by the next render. CSS content is applied after the DOM is written,
   so it cannot be lost that way.

   Read from --zk-rowheader, which the script sets on the host and which therefore survives the
   corner cell being rebuilt; attr(data-zk-rowheader) is the fallback for a grid mounted without
   the script having run. */
.zk-grid .htCore thead th:first-child .cornerHeader::after {
    content: var(--zk-rowheader, attr(data-zk-rowheader));
    font-size: 11px;
    font-weight: 600;
    color: #000;
}

/* Group heading rows: merged across the grid, bold, on a tinted band. */
.zk-grid .htCore td.group-heading {
    background: #dbe5f1 !important;
    font-weight: 700;
    color: #14304f;
    border-top: 1px solid #000 !important;
}

.zk-grid .htCore td.group-heading .relative { padding-left: 4px; }

.zk-grid .ht_master .wtHolder { scrollbar-width: thin; }

/* Small screens cannot show ten columns; let the grid scroll sideways rather than crush them. */
.zk-grid .ht_master { overflow-x: auto; }

/* ---------------------------------------------------------
   Row action buttons

   These were inline styles on the generated <a>/<button>: 16x16, border-radius 50%, a flat
   fill and no hover state at all. Inline styles cannot express :hover or :focus-visible, so
   the buttons gave no feedback when pointed at and the only way to tell them apart was the
   fill colour - two saturated dots in a column, which reads as decoration rather than as
   controls.

   They are now classes, with the per-action colour handed in as --zk-act, so one rule styles
   all four (view / edit / delete / restore) and a new action needs no new CSS here.

   The shape is a rounded square, not a circle. At 20x20 a circle has to shrink its glyph to
   roughly 9px to stay optically round, and under 10px the eye and the trash can and the pencil
   stop being reliably distinguishable. A 5px radius keeps the softened corners that make a
   control look modern while giving the icon the full box to sit in.

   focus-visible carries a ring, because the inline version had no visible focus state at all
   and the buttons are reachable by keyboard.

   Every selector here is scoped under .zk-grid, and that is not tidiness. Handsontable's own
   stylesheet carries ".handsontable a { color: rgb(16,74,204) }", which is specificity 0,1,1 -
   higher than a bare ".zk-act" at 0,1,0. Unscoped, both the view and the edit icon rendered in
   Handsontable's blue, the per-action colour silently did nothing, and text-decoration:underline
   came back on top of text-decoration:none for the same reason. Scoping to ".zk-grid .zk-act"
   makes it 0,2,0 and the action colour actually applies.

   The background is written twice on purpose: a flat tint first, then the color-mix that tints
   it from --zk-act. A browser without color-mix keeps the first and still gets a correct-looking
   button rather than an invalid declaration that falls back to nothing. */
.zk-grid .zk-act {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid var(--zk-act);
    border-radius: 5px;
    background: #f2f6fc;
    background: color-mix(in srgb, var(--zk-act) 12%, #fff);
    color: var(--zk-act);
    line-height: 0;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    margin: 0 1px;
    transition: background-color .12s ease, color .12s ease, box-shadow .12s ease;
}

.zk-grid .zk-act:hover {
    background: var(--zk-act);
    color: #fff;
}

.zk-grid .zk-act:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--zk-act);
}

/* Handsontable sets a font-size on its cells that would otherwise sit oddly around the glyph.
   The svg carries its own width and height, so the font only has to stop inheriting. */
.zk-grid .zk-act svg {
    display: block;
    font-size: 0;
}

/* A cell whose value opens its record (the device name). Scoped under .zk-grid for the same
   specificity reason as .zk-act: Handsontable's ".handsontable a" rule also colours anchors.
   Underline appears on hover and keyboard focus only, so a list of names still reads as text. */
.zk-grid .zk-cell-link {
    color: #0d6efd;
    text-decoration: none;
}

.zk-grid .zk-cell-link:hover,
.zk-grid .zk-cell-link:focus-visible {
    text-decoration: underline;
}

.zk-grid .zk-cell-link:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 1px;
    border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .zk-grid .zk-act { transition: none; }
}
/* "Grouped by" control. Sits above the grid, outside it, so it is part of the card the grid
   lives in rather than part of the table surface. The select is sized to its longest option
   ("Employment type") so the control does not jump width when the choice changes. */
.zk-group-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0 6px;
}

.zk-group-bar .zk-group-label {
    font-size: 12px;
    font-weight: 600;
    color: #344054;
    margin: 0;
    white-space: nowrap;
}

.zk-group-bar .zk-group-select {
    width: auto;
    min-width: 190px;
    font-size: 12px;
    padding: 2px 24px 2px 6px;
    background-position: right 4px center;
}

/* Read-only feedback. Grey, not red or green: it reports a view state, not a pass/fail. */
.zk-group-bar .zk-group-state {
    font-size: 12px;
    color: #667085;
    white-space: nowrap;
}
