/* SPDX-License-Identifier: MIT OR Apache-2.0 */

/* The table view: a grid with fixed column widths in its own scroller. */

:root { --nx-sel: #dbeafe; }
@media (prefers-color-scheme: dark) { :root { --nx-sel: #1e3a5f; } }

.nx-view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-bottom: 0.5rem; }
.nx-view-head h1 { margin: 0 !important; }

.nx-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin: 0; }
.nx-filter select, .nx-filter input, .nx-filter button, .nx-add-record {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius);
  background: var(--nx-bg);
  color: var(--nx-fg);
  font: inherit;
}
.nx-filter button, .nx-add-record { cursor: pointer; }
.nx-add-record { border-color: var(--nx-accent); background: var(--nx-accent); color: #fff; }

#nx-grid-msg { min-height: 1.2rem; margin: 0 0 0.25rem; }

.nx-scroller { position: relative; overflow: auto; max-height: calc(100vh - 12rem); border: 1px solid var(--nx-line); }

#nx-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; outline: none; }
#nx-grid th, #nx-grid td {
  box-sizing: border-box;
  width: 12rem;
  height: 1.9rem;
  padding: 0 0.4rem;
  border-right: 1px solid var(--nx-line);
  border-bottom: 1px solid var(--nx-line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  scroll-margin: 2.2rem 0 0.3rem;
}
#nx-grid th { position: sticky; top: 0; z-index: 2; background: var(--nx-surface); text-align: left; }
#nx-grid th a.nx-sort { color: inherit; text-decoration: none; }
#nx-grid th a.nx-column-menu { float: right; color: var(--nx-muted); text-decoration: none; }
#nx-grid .nx-row-tools, #nx-grid .nx-new-column { width: 2rem; padding: 0; text-align: center; }
#nx-grid .nx-new-column a { display: block; text-decoration: none; }
#nx-grid [data-kind="number"] { text-align: right; font-variant-numeric: tabular-nums; }
#nx-grid td[data-kind="number"] { width: 8rem; }
#nx-grid th[data-kind="number"] { width: 8rem; }
#nx-grid [data-kind="bool"] { width: 5rem; text-align: center; }
#nx-grid [data-kind="date"], #nx-grid [data-kind="time"] { width: 8rem; }

/* Cells are marked as a range, not as text: a drag over them marks cells. */
#nx-grid tbody td { background: var(--nx-bg); user-select: none; }
#nx-grid tbody td.nx-sel { background: var(--nx-sel); }
#nx-grid td.nx-act { box-shadow: inset 0 0 0 2px var(--nx-accent); }
#nx-grid td[data-ro] { color: var(--nx-muted); }
#nx-grid td.nx-pending { color: var(--nx-muted); font-style: italic; }
#nx-grid td.nx-cell-error, #nx-grid td.nx-cell-conflict { box-shadow: inset 0 0 0 2px var(--nx-danger); }
#nx-grid tr.nx-more td { width: auto; text-align: center; color: var(--nx-muted); }

.nx-row-delete { border: 0; background: none; color: var(--nx-muted); font: inherit; cursor: pointer; }
.nx-row-delete:hover { color: var(--nx-danger); }

/* The editor lies over its cell; it is not a child of it, so a row that is
   replaced while it is open does not close it (ADR 4 §3). */
.nx-grid-editor { position: absolute; z-index: 3; }
.nx-grid-editor input, .nx-grid-editor select, .nx-grid-editor textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 1.9rem;
  padding: 0 0.3rem;
  border: 2px solid var(--nx-accent);
  background: var(--nx-bg);
  color: var(--nx-fg);
  font: inherit;
}
.nx-grid-editor textarea { min-width: 20rem; padding: 0.2rem 0.3rem; }

/* "No records." is for an empty grid only; rows added later hide it. */
.nx-scroller:has(#nx-grid tbody tr) > .nx-empty { display: none; }
.nx-scroller > .nx-empty { margin: 0.5rem; }

#nx-grid .nx-row-tools { width: 4.2rem; min-width: 4.2rem; white-space: nowrap; }
.nx-row-open { color: var(--nx-muted); text-decoration: none; }
.nx-row-open:hover { color: var(--nx-accent); }
a.nx-add-record { text-decoration: none; }

/* Saved views, groups, footer */

.nx-views { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--nx-line); }
.nx-views a { padding: 0.25rem 0; color: var(--nx-muted); text-decoration: none; }
.nx-views a[aria-current="page"] { color: var(--nx-fg); border-bottom: 2px solid var(--nx-accent); }
.nx-view-settings { margin-left: auto; }
#nx-grid tr.nx-group td { background: var(--nx-bg-soft, transparent); font-weight: 600; }
#nx-grid tr.nx-group a { color: var(--nx-fg); text-decoration: none; }
.nx-group-field, .nx-group-count, .nx-group-total, .nx-footer-label { color: var(--nx-muted); font-weight: 400; }
.nx-group-total { margin-left: 0.75rem; }
#nx-grid tfoot td { border-top: 2px solid var(--nx-line); font-weight: 600; background: var(--nx-bg); }

/* The upload control of a file field: the file it holds, the chooser, "remove". */
.nx-file-control { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.nx-file-control > .nx-field-label { flex-basis: 100%; }
.nx-file-control[aria-busy="true"] { opacity: 0.6; }
.nx-file-shown:empty, .nx-file-message:empty { display: none; }
.nx-thumb { display: inline-block; max-width: 2.5rem; max-height: 2.5rem; margin-right: 0.4rem; vertical-align: middle; }
.nx-panel .nx-thumb, .nx-record .nx-thumb { max-width: 10rem; max-height: 10rem; }

.nx-file-item { display: inline-flex; align-items: center; gap: 0.25rem; margin-right: 0.5rem; }

/* A form in its saved layout: sections are grids of one to four columns. */
.nx-form-section { display: grid; gap: 0.75rem 1rem; grid-template-columns: 1fr; border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.nx-form-section > legend { font-weight: 600; padding: 0; margin-bottom: 0.5rem; }
@media (min-width: 48rem) {
  .nx-form-section[data-columns="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nx-form-section[data-columns="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nx-form-section[data-columns="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nx-form-section [data-span="2"] { grid-column: span 2; }
  .nx-form-section [data-span="3"] { grid-column: span 3; }
  .nx-form-section [data-span="4"] { grid-column: span 4; }
}
.nx-form-heading { margin: 0.5rem 0 0; font-size: 1rem; }
.nx-form-separator { width: 100%; border: 0; border-top: 1px solid currentColor; opacity: 0.2; }
.nx-form-tab { margin-bottom: 0.5rem; }
.nx-form-tab > summary { cursor: pointer; font-weight: 600; padding: 0.4rem 0; }

/* The editor of a form's layout (table/forms.rs): wider than a form, its
   rows on one line, the buttons that move things small and side by side. */
#nx-form-layout { max-width: 52rem; }
#nx-form-layout fieldset { min-width: 0; margin: 0.75rem 0 0; padding: 0.75rem; border: 1px solid var(--nx-line); border-radius: var(--nx-radius); }
#nx-form-layout .nx-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.35rem 0; }
#nx-form-layout .nx-row .nx-row-name { flex: 0 0 10rem; }
#nx-form-layout .nx-row input[type="text"] { flex: 1 1 10rem; min-width: 0; padding: 0.3rem 0.5rem; border: 1px solid var(--nx-line); border-radius: var(--nx-radius); background: var(--nx-bg); color: var(--nx-fg); font: inherit; }
#nx-form-layout .nx-row select { padding: 0.3rem; border: 1px solid var(--nx-line); border-radius: var(--nx-radius); background: var(--nx-bg); color: var(--nx-fg); font: inherit; }
#nx-form-layout .nx-row .nx-check { margin: 0; white-space: nowrap; }
#nx-form-layout .nx-form-moves { display: inline-flex; gap: 0.2rem; margin-left: auto; white-space: nowrap; }
#nx-form-layout .nx-form-moves button { margin: 0; padding: 0.15rem 0.5rem; background: transparent; color: var(--nx-fg); border: 1px solid var(--nx-line); }
#nx-form-layout .nx-row > button { margin: 0; }

/* The board of a view (kanban): columns side by side, cards in them. */
#nx-board { display: flex; gap: .75rem; align-items: flex-start; padding: .25rem 0 1rem; }
.nx-lane { flex: 0 0 17rem; background: var(--nx-bg-soft, #f3f4f6); border: 1px solid var(--nx-line); border-radius: 6px; padding: .5rem; }
.nx-lane-head { display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: baseline; margin-bottom: .5rem; }
.nx-lane-head h2 { font-size: 1rem; margin: 0; flex: 1 1 auto; }
.nx-lane-count, .nx-lane-sum { font-size: .85rem; color: var(--nx-c-gray); }
.nx-lane-cards { display: flex; flex-direction: column; gap: .4rem; min-height: 2.5rem; }
.nx-kcard { background: var(--nx-bg, #fff); border: 1px solid var(--nx-line); border-radius: 4px; padding: .4rem .5rem; }
#nx-board[data-movable] .nx-kcard { cursor: grab; }
.nx-kcard-title { font-weight: 600; display: block; }
.nx-kcard-line { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; }
.nx-kcard-label { color: var(--nx-c-gray); }
.nx-kcard-ghost { opacity: .4; }
.nx-lane-more { margin: .5rem 0 0; }

/* A view as a calendar (plan 3.3). An entry is a bar in the colour of its option. */
.nx-cal-nav { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; margin: .25rem 0 .5rem; }
.nx-cal-nav h2 { font-size: 1.1rem; margin: 0 .75rem; }
.nx-cal-nav a[aria-current] { font-weight: 600; text-decoration: none; }
.nx-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(7rem, 1fr)); border-top: 1px solid var(--nx-line); border-left: 1px solid var(--nx-line); }
.nx-cal-weekday { font-size: .85rem; color: var(--nx-c-gray); padding: .2rem .4rem; border-right: 1px solid var(--nx-line); border-bottom: 1px solid var(--nx-line); }
.nx-cal-day { min-height: 6.5rem; padding: .2rem; border-right: 1px solid var(--nx-line); border-bottom: 1px solid var(--nx-line); display: flex; flex-direction: column; }
.nx-cal-grid[data-span="week"] .nx-cal-day { min-height: 20rem; }
.nx-cal-day[data-outside] { background: var(--nx-bg-soft, #f3f4f6); }
.nx-cal-day[data-outside] .nx-cal-date { color: var(--nx-c-gray); }
.nx-cal-day[data-today] .nx-cal-date { font-weight: 700; color: var(--nx-c-blue); }
.nx-cal-head { display: flex; justify-content: space-between; font-size: .85rem; }
.nx-cal-add { visibility: hidden; text-decoration: none; padding: 0 .3rem; }
.nx-cal-day:hover .nx-cal-add, .nx-cal-add:focus { visibility: visible; }
.nx-cal-entries { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 1.5rem; }
.nx-centry { display: block; font-size: .85rem; padding: 1px 4px; border-radius: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: var(--nx-bg-soft, #e5e7eb); color: inherit; text-decoration: none; border-left: 3px solid var(--nx-c-gray); }
.nx-centry[data-movable] { cursor: grab; }
.nx-centry-time { color: var(--nx-c-gray); }
.nx-centry[data-color="red"] { border-left-color: var(--nx-c-red); }
.nx-centry[data-color="orange"] { border-left-color: var(--nx-c-orange); }
.nx-centry[data-color="yellow"] { border-left-color: var(--nx-c-yellow); }
.nx-centry[data-color="green"] { border-left-color: var(--nx-c-green); }
.nx-centry[data-color="teal"] { border-left-color: var(--nx-c-teal); }
.nx-centry[data-color="blue"] { border-left-color: var(--nx-c-blue); }
.nx-centry[data-color="purple"] { border-left-color: var(--nx-c-purple); }
.nx-centry[data-color="pink"] { border-left-color: var(--nx-c-pink); }
.nx-cal-more { margin: 0 0 .5rem; }

/* Rich text (plan 3.4): the editor in the record form and the text shown to a reader. */
.nx-rich { border: 1px solid var(--nx-line); border-radius: 4px; }
.nx-rich-tools { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-bottom: 1px solid var(--nx-line); background: var(--nx-bg-soft, #f3f4f6); }
.nx-rich-tools button { min-width: 2rem; padding: 1px 6px; }
.nx-rich-url { flex: 1 1 10rem; min-width: 8rem; }
.nx-rich-area { min-height: 8rem; padding: .4rem .6rem; overflow-y: auto; max-height: 30rem; }
.nx-rich-area:focus { outline: 2px solid var(--nx-c-blue); outline-offset: -2px; }
.nx-rich-area > :first-child, .nx-rich-view > :first-child { margin-top: 0; }
.nx-rich-view { max-height: 30rem; overflow-y: auto; }

/* Location (plan 3.5): address, coordinates and, with a tile source, a map. */
fieldset.nx-location { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.nx-location > legend { padding: 0; }
.nx-location label { display: flex; flex-direction: column; gap: 2px; }
.nx-location label > span { font-size: .85rem; color: var(--nx-c-gray); }
.nx-location-point { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.nx-map { height: 16rem; margin-top: .4rem; border: 1px solid var(--nx-line); border-radius: 4px; cursor: crosshair; }

/* Print layouts (plan 3.7): the designer beside its preview, documents of a record. */
.nx-print-designer { display: grid; grid-template-columns: minmax(26rem, 1fr) minmax(20rem, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 70rem) { .nx-print-designer { grid-template-columns: 1fr; } }
.nx-print-preview { width: 100%; height: calc(100vh - 8rem); min-height: 30rem; position: sticky; top: 1rem; border: 1px solid var(--nx-line); background: #fff; }
.nx-print-columns { display: flex; flex-wrap: wrap; gap: .5rem; }
.nx-print-column { flex: 1 1 12rem; min-width: 0; padding-left: .5rem; border-left: 2px solid var(--nx-line); }
.nx-print-block textarea { width: 100%; box-sizing: border-box; }
.nx-prints h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.nx-prints ul { margin: 0; padding-left: 1.25rem; }
.nx-print-all { display: inline-block; }
.nx-print-all form { margin: .25rem 0; }
