/* rq.Grid — styling for the grid that replaces the Kendo Grid.
 *
 * Built on the rq-* tokens so it themes with everything else, and kept
 * deliberately plain: most grids in this app render a row template that
 * brings its own markup, so this styles the frame (scroll area, pager,
 * empty and error states) and stays out of the rows' way.
 */

.rq-grid {
    display: flex;
    flex-direction: column;
    min-height: 0;               /* so it can shrink inside a flex parent */
    position: relative;
}

/* The scroll container. The Kendo grid wrote a fixed pixel height here and
   relied on overflow to scroll the rest; this simply fills the space it is
   given and scrolls, which is why nothing needs to measure anything. */
.rq-grid-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.rq-grid-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.rq-grid-table > tbody > tr { border-bottom: 1px solid var(--rq-border); }
.rq-grid-table > tbody > tr:last-child { border-bottom: 0; }
.rq-grid-table > tbody > tr > td {
    padding: 10px 12px;
    vertical-align: middle;
    color: var(--rq-text);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.rq-grid-table > tbody > tr:hover { background: var(--rq-accent-soft); }
.rq-grid-table > tbody > tr.is-selected { background: var(--rq-accent-soft); }

.rq-grid-empty > td,
.rq-grid-error > td {
    padding: 24px 12px;
    text-align: center;
    color: var(--rq-sub);
    font-size: 13px;
}
.rq-grid-error > td { color: var(--rq-danger-text); }

/* Loading: a quiet overlay rather than a spinner that shifts the layout.
   The grid keeps its current rows visible and dims them, so a refresh does
   not blank the list someone is reading. */
.rq-grid-loading .rq-grid-content {
    opacity: 0.55;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

/* ---------------------------------------------------------------- pager */

.rq-grid-pager {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-top: 1px solid var(--rq-border);
}

.rq-grid-page {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--rq-border);
    border-radius: 6px;
    background: var(--rq-surface);
    color: var(--rq-text);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.rq-grid-page:hover:not(:disabled) {
    background: var(--rq-accent-soft);
    border-color: var(--rq-accent);
}

.rq-grid-page.is-current {
    background: var(--rq-accent);
    border-color: var(--rq-accent);
    color: var(--rq-on-accent);
    font-weight: 600;
}

.rq-grid-page:disabled { opacity: 0.45; cursor: default; }

.rq-grid-page:focus-visible {
    outline: 2px solid var(--rq-focus-ring);
    outline-offset: 2px;
}

.rq-grid-gap { padding: 0 2px; color: var(--rq-faint); }

/* --------------------------------------------------------------- header */

.rq-grid-table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 9px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--rq-sub);
    background: var(--rq-surface-sunken);
    border-bottom: 1px solid var(--rq-border);
    white-space: nowrap;
    user-select: none;
}

.rq-grid-table > thead > tr > th.is-sortable { cursor: pointer; }
.rq-grid-table > thead > tr > th.is-sortable:hover { color: var(--rq-text); }
.rq-grid-table > thead > tr > th:focus-visible {
    outline: 2px solid var(--rq-focus-ring);
    outline-offset: -2px;
}

/* Sort indicator: a faint chevron that only commits to a direction once
   the column is sorted, so a sortable header reads as sortable without
   every column shouting it. */
.rq-grid-sort {
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    margin-left: 6px;
    opacity: 0.35;
    vertical-align: middle;
    border: solid currentColor;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg) translateY(-2px);
}
th.is-sorted-asc  .rq-grid-sort { opacity: 1; transform: rotate(-135deg) translateY(-2px); }
th.is-sorted-desc .rq-grid-sort { opacity: 1; }

/* ------------------------------------------------------ command column */

.rq-grid-cmd { white-space: nowrap; text-align: right; }
.rq-grid-cmd .rq-btn + .rq-btn { margin-left: 4px; }

/* --------------------------------------------------- popup editor modal
   One modal for every grid on the page (rq.gridEdit.js creates it once).
   Plain fixed-position markup rather than Bootstrap's modal so it has no
   JS dependency and cannot be affected by another modal's state. */

/* z-index above Kendo's Window (it stacks at ~10000 and climbs), because
   the two grids that use this editor both live INSIDE a Kendo Window for
   now. At Bootstrap's 1060 the editor opened perfectly and was invisible —
   every assertion passed while a person would have seen nothing. */
.rq-modal { position: fixed; inset: 0; z-index: 10100; display: flex; align-items: center; justify-content: center; }
.rq-modal[hidden] { display: none; }
.rq-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.rq-modal-dialog {
    position: relative;
    width: min(700px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    background: var(--rq-surface-raised);
    color: var(--rq-text);
    border: 1px solid var(--rq-border);
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.rq-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--rq-border);
}
.rq-modal-title { margin: 0; font-size: 15px; font-weight: 600; }
.rq-modal-close {
    border: 0; background: none; color: var(--rq-sub);
    font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.rq-modal-close:hover { color: var(--rq-text); }
.rq-modal-body { padding: 16px 18px; overflow-y: auto; }
.rq-modal-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--rq-border);
}
body.rq-modal-open { overflow: hidden; }

/* Pushed to the end so the page buttons stay left-aligned and the count
   does not jump around as the number of pages changes. */
.rq-grid-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--rq-sub);
}
