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

/* The shell: main navigation on top, app navigation on the left, content,
   and the right-hand panel, which takes room only while it has content.
   Light and dark come from the custom properties in base.css. */

:root {
  --nx-c-gray: #6b7280;
  --nx-c-red: #dc2626;
  --nx-c-orange: #ea580c;
  --nx-c-yellow: #ca8a04;
  --nx-c-green: #16a34a;
  --nx-c-teal: #0d9488;
  --nx-c-blue: #2563eb;
  --nx-c-purple: #7c3aed;
  --nx-c-pink: #db2777;
  --nx-ok: #15803d;
}

@media (prefers-color-scheme: dark) {
  :root { --nx-ok: #4ade80; }
}

.nx-shell { display: flex; flex-direction: column; min-height: 100vh; }

.nx-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--nx-line);
  background: var(--nx-surface);
}

.nx-main, .nx-user { display: flex; align-items: center; gap: 1rem; }
.nx-brand { font-weight: 700; text-decoration: none; color: var(--nx-fg); }
.nx-top-workspace { display: flex; align-items: center; gap: 0.4rem; text-decoration: none; color: var(--nx-fg); }
.nx-user form { margin: 0; }

.nx-body { display: flex; flex: 1; min-height: 0; }

.nx-apps {
  flex: 0 0 13rem;
  padding: 0.75rem 0.5rem;
  border-right: 1px solid var(--nx-line);
  background: var(--nx-surface);
}
.nx-apps ul { list-style: none; margin: 0 0 1rem; padding: 0; }
.nx-apps a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--nx-radius);
  color: var(--nx-fg);
  text-decoration: none;
}
.nx-apps a:hover, .nx-apps a[aria-current="page"] { background: var(--nx-bg); }
.nx-apps a[aria-current="page"] { font-weight: 600; }
.nx-apps-settings { color: var(--nx-muted); font-size: 0.9rem; }

#nx-content { flex: 1; min-width: 0; padding: 1rem 1.5rem 3rem; }
#nx-content h1 { margin: 0 0 0.75rem; font-size: 1.4rem; }
#nx-content h1:not(:first-child) { margin-top: 2rem; }
#nx-content h2 { margin: 1.5rem 0 0.5rem; font-size: 1.05rem; }

#nx-panel {
  flex: 0 0 22rem;
  padding: 1rem;
  border-left: 1px solid var(--nx-line);
  background: var(--nx-surface);
  overflow-y: auto;
}
#nx-panel:empty { display: none; }
.nx-panel-head { display: flex; align-items: baseline; justify-content: space-between; }
.nx-panel-head h2 { margin: 0 0 0.5rem; font-size: 1.05rem; }

@media (max-width: 50rem) {
  .nx-body { flex-direction: column; }
  .nx-apps, #nx-panel { flex-basis: auto; border: 0; border-bottom: 1px solid var(--nx-line); }
}

/* Small parts */

.nx-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: var(--nx-radius);
  background: var(--nx-c-gray);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
}
.nx-chip[data-color="red"] { background: var(--nx-c-red); }
.nx-chip[data-color="orange"] { background: var(--nx-c-orange); }
.nx-chip[data-color="yellow"] { background: var(--nx-c-yellow); }
.nx-chip[data-color="green"] { background: var(--nx-c-green); }
.nx-chip[data-color="teal"] { background: var(--nx-c-teal); }
.nx-chip[data-color="blue"] { background: var(--nx-c-blue); }
.nx-chip[data-color="purple"] { background: var(--nx-c-purple); }
.nx-chip[data-color="pink"] { background: var(--nx-c-pink); }

.nx-card {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 14rem;
  margin: 0 0.5rem 0.5rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius);
  background: var(--nx-surface);
  color: var(--nx-fg);
  text-decoration: none;
}
.nx-card:hover { border-color: var(--nx-accent); }
.nx-card-name { font-weight: 600; }
.nx-card-note, .nx-note, .nx-empty { color: var(--nx-muted); }
.nx-card-note { margin-left: auto; font-size: 0.85rem; }
.nx-group { color: var(--nx-muted); font-weight: 400; }

.nx-list { margin: 0; padding-left: 1.2rem; }
.nx-list li { margin: 0.2rem 0; }

.nx-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--nx-line);
}
.nx-row-name { font-weight: 600; }
.nx-row code { color: var(--nx-muted); }
.nx-inline { display: flex; gap: 0.4rem; margin: 0 0 0 auto; }
.nx-inline.nx-inline-next { margin-left: 0; }
.nx-row[data-archived] .nx-row-name { color: var(--nx-muted); }

/* Forms */

.nx-form {
  max-width: 28rem;
  margin: 1.5rem 0 0;
  padding: 1rem;
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius);
  background: var(--nx-surface);
}
#nx-panel .nx-form { margin-top: 0.75rem; padding: 0; border: 0; }
.nx-form h2 { margin: 0 0 0.5rem !important; }

.nx-field { display: block; margin-top: 0.6rem; }
.nx-field-label { display: block; color: var(--nx-muted); font-size: 0.9rem; }
.nx-field input, .nx-field select, .nx-inline input {
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius);
  background: var(--nx-bg);
  color: var(--nx-fg);
  font: inherit;
}
.nx-inline input { width: 16rem; margin: 0; }
.nx-field input[aria-invalid="true"], .nx-field select[aria-invalid="true"] { border-color: var(--nx-danger); }
.nx-field-error { display: block; margin-top: 0.2rem; color: var(--nx-danger); font-size: 0.9rem; }
.nx-check { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.75rem; }

.nx-form button, .nx-inline button {
  margin-top: 0.9rem;
  padding: 0.4rem 0.9rem;
  border: 0;
  border-radius: var(--nx-radius);
  background: var(--nx-accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.nx-inline button { margin-top: 0; }
button.nx-danger { background: var(--nx-danger); }
button.nx-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--nx-accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.nx-message-ok { color: var(--nx-ok); }
.nx-message-warning { border-left: 4px solid var(--nx-danger, #b3261e); padding: 0.4rem 0.7rem; margin: 0.6rem 0; }

#nx-messages {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: 24rem;
}
#nx-messages > * {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--nx-danger);
  border-radius: var(--nx-radius);
  background: var(--nx-bg);
}

/* Structure: tags on rows, the statements of a change */

.nx-tag {
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--nx-line);
  border-radius: 999px;
  color: var(--nx-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.nx-row[data-trashed] .nx-row-name { color: var(--nx-muted); text-decoration: line-through; }
.nx-row[data-state="failed"] .nx-tag { border-color: var(--nx-danger); color: var(--nx-danger); }
.nx-row code { overflow-wrap: anywhere; }

.nx-statements { margin: 0.5rem 0; padding-left: 1.2rem; }
.nx-statements li { margin: 0.3rem 0; overflow-wrap: anywhere; }
.nx-statements li[data-class="destructive"] code { color: var(--nx-danger); }

/* The record form in the panel */

.nx-field textarea {
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius);
  background: var(--nx-bg);
  color: var(--nx-fg);
  font: inherit;
}
.nx-field textarea[aria-invalid="true"] { border-color: var(--nx-danger); }
.nx-field-value { display: block; min-height: 1.4rem; white-space: pre-wrap; }
div.nx-form { border: 0; padding: 0; }

/* Tabs of a record in the panel, and its history */

.nx-tabs { display: flex; gap: 1rem; margin: 0.25rem 0 0.75rem; border-bottom: 1px solid var(--nx-line); }
.nx-tabs a { padding: 0.25rem 0; color: var(--nx-muted); text-decoration: none; }
.nx-tabs a[aria-current="page"] { border-bottom: 2px solid var(--nx-accent); color: var(--nx-fg); }

.nx-history { margin: 0; padding: 0; list-style: none; }
.nx-history li { padding: 0.5rem 0; border-bottom: 1px solid var(--nx-line); }
.nx-history-head { margin: 0 0 0.25rem; color: var(--nx-muted); font-size: 0.9rem; }
.nx-history dl { margin: 0; }
.nx-history dt { margin-top: 0.3rem; color: var(--nx-muted); font-size: 0.85rem; }
.nx-history dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.nx-history-old { text-decoration: line-through; color: var(--nx-muted); }
.nx-history .nx-inline { margin: 0.2rem 0 0; }

.nx-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0.5rem 0 1rem; }
.nx-facts dt { color: var(--nx-muted); }
.nx-facts dd { margin: 0; overflow-wrap: anywhere; }

/* Options of choice fields */

.nx-option {
  display: inline-block;
  padding: 0 0.45rem;
  border-radius: 0.75rem;
  background: var(--nx-c-gray);
  color: #fff;
  font-size: 0.9em;
  line-height: 1.5;
  white-space: nowrap;
}
.nx-option[data-color="red"] { background: var(--nx-c-red); }
.nx-option[data-color="orange"] { background: var(--nx-c-orange); }
.nx-option[data-color="yellow"] { background: var(--nx-c-yellow); }
.nx-option[data-color="green"] { background: var(--nx-c-green); }
.nx-option[data-color="teal"] { background: var(--nx-c-teal); }
.nx-option[data-color="blue"] { background: var(--nx-c-blue); }
.nx-option[data-color="purple"] { background: var(--nx-c-purple); }
.nx-option[data-color="pink"] { background: var(--nx-c-pink); }
.nx-option[data-archived] { opacity: 0.6; text-decoration: line-through; }
/* The sign between two options: in the text of the cell, not on the screen. */
.nx-sep { display: inline-block; width: 0.25rem; overflow: hidden; color: transparent; white-space: pre; vertical-align: bottom; }

.nx-checks { margin: 0.75rem 0 0; padding: 0; border: 0; }
.nx-checks .nx-check { margin-top: 0.25rem; }
.nx-options { margin: 0.75rem 0 0; padding: 0.5rem; border: 1px solid var(--nx-line); border-radius: var(--nx-radius); }
.nx-options legend { color: var(--nx-muted); font-size: 0.9rem; }
.nx-options table { width: 100%; border-collapse: collapse; }
.nx-options th { text-align: left; color: var(--nx-muted); font-size: 0.8rem; font-weight: 400; }
.nx-options td { padding: 0.15rem 0.25rem 0.15rem 0; }
.nx-options input[type="text"], .nx-options select { width: 100%; min-width: 5rem; }
.nx-options .nx-option-pos { width: 3.5rem; }

/* Links between records */

.nx-link-picker { display: flex; align-items: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.nx-link-picker .nx-field { flex: 1 1 12rem; }
.nx-link-search { flex: 0 1 9rem; margin-bottom: 0; }
.nx-linked ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.nx-linked-grid { border-collapse: collapse; margin: 0.2rem 0; font-size: 0.9em; }
.nx-linked-grid th, .nx-linked-grid td { border: 1px solid var(--nx-line, #d0d4da); padding: 0.15rem 0.45rem; text-align: left; }
.nx-linked-grid th { font-weight: 600; }
.nx-add-linked { display: inline-block; margin-top: 0.2rem; }
.nx-link-setup { margin: 0.75rem 0 0; padding: 0.5rem; border: 1px solid var(--nx-line); border-radius: var(--nx-radius); }
.nx-link-setup legend { color: var(--nx-muted); font-size: 0.9rem; }

/* View settings and the filter builder */

.nx-view-part, .nx-cond-group { margin: 0.75rem 0 0; padding: 0.5rem; border: 1px solid var(--nx-line); border-radius: var(--nx-radius); }
.nx-view-part legend, .nx-cond-group legend { color: var(--nx-muted); font-size: 0.9rem; }
.nx-view-part table { border-collapse: collapse; }
.nx-view-part td, .nx-view-part th { padding: 0.1rem 0.5rem 0.1rem 0; text-align: left; font-weight: 400; font-size: 0.9rem; }
.nx-view-part .nx-check { margin-top: 0; }
.nx-view-key { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }
.nx-cond { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }
.nx-cond input[type="text"] { flex: 1 1 6rem; min-width: 4rem; }
.nx-cond-add { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.nx-cond-remove { padding: 0 0.4rem; }

/* Search boxes look like the other inputs. */
input[type="search"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius);
  background: var(--nx-bg);
  color: var(--nx-fg);
  font: inherit;
}

/* A short explanation at the top of a builder page; open until closed. */
.nx-help { margin: 0 0 1rem; padding: .5rem .75rem; border: 1px solid var(--nx-line, #ccc); border-radius: 4px; max-width: 60rem; }
.nx-help summary { cursor: pointer; font-weight: 600; }
.nx-help ul { margin: .5rem 0 0; padding-left: 1.25rem; }
