/* NodeBook — cards, badges and chips, avatars, list rows. */

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.card-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 24px;
}

/* tool-kaarttitel: 14/20 bold */
.card-head h3 {
  font-size: var(--text-lg);
  line-height: 20px;
}

.card-head .spacer {
  flex: 1;
}

.card-note {
  font-size: var(--text-sm);
  color: var(--text-2);
  margin-top: calc(-1 * var(--space-2));
}

.card--danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.kv dt {
  color: var(--text-3);
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------- badges / chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}

.badge .icon svg {
  width: 13px;
  height: 13px;
}

/* Node types: the hue is data, so it tints the badge and colours its symbol; the name is in the text colour. */
.badge--type {
  background: color-mix(in srgb, var(--type-color) 16%, transparent);
  color: var(--text);
}

.badge--type .icon {
  color: var(--type-color);
}

.badge--owned {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--info {
  background: var(--info-soft);
  color: var(--info);
}

.badge--dirty {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

[data-type="1"] {
  --type-color: var(--t-companion);
}

[data-type="2"] {
  --type-color: var(--t-repeater);
}

[data-type="3"] {
  --type-color: var(--t-room);
}

[data-type="4"] {
  --type-color: var(--t-sensor);
}

.chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* tool-chip: 12/16 semibold, a pill. Pressed: pale gold with a gold rim, in bold (never colour alone). */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--accent);
  font-weight: 700;
}

@media (hover: hover) {
  button.chip:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
}

.chip .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--type-color, var(--text-3));
}

.chip .count {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- avatar ---------- */

.avatar {
  --size: 40px;
  width: var(--size);
  height: var(--size);
  border-radius: var(--radius-md);
  flex: none;
  display: grid;
  place-items: center;
  font-size: calc(var(--size) * 0.5);
  line-height: 1;
  background: color-mix(in srgb, var(--type-color, var(--text-3)) 15%, var(--surface-2));
  color: var(--type-color, var(--text-2));
  border: 1px solid color-mix(in srgb, var(--type-color, var(--text-3)) 30%, transparent);
  position: relative;
}

.avatar--lg {
  --size: 56px;
}

.avatar--sm {
  --size: 32px;
  border-radius: var(--radius-sm);
}

.avatar .key-mark {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  border: 2px solid var(--bg-elev);
}

.avatar .key-mark svg {
  width: 10px;
  height: 10px;
}

/* ---------- list rows ---------- */

.list-tools {
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.list-tools-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  min-height: 30px;
}

.list-tools-row select {
  width: auto;
  min-height: 32px;
  font-size: var(--text-sm);
  padding-top: 4px;
  padding-bottom: 4px;
}

.list-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.rows {
  list-style: none;
  margin: 0;
  padding: var(--space-2);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
  min-height: 56px;
  position: relative;
}

@media (hover: hover) {
  .row:hover {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
  }
}

/* The row open on the right: the pale gold of the active item, its name in bold, a gold stripe. */
.row[aria-current="true"] {
  background: var(--accent-soft);
}

.row[aria-current="true"] .row-title {
  font-weight: 700;
}

.row[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.row-title .name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-end {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-3);
  flex: none;
}

.row-check {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  color: var(--accent-ink);
}

.row.is-selected {
  background: var(--accent-soft);
}

.row.is-selected .row-check {
  background: var(--accent);
  border-color: var(--accent);
}

.bulkbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--text-sm);
}

.bulkbar strong {
  margin-right: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.search-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.search-row .search {
  flex: 1;
  min-width: 0;
}

.search-row .btn {
  min-height: 38px;
}

.chip--static {
  cursor: default;
  height: 26px;
  font-size: var(--text-xs);
  background: var(--surface-2);
}

.action-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

.action-tile {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  text-align: left;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.action-tile:disabled {
  background: var(--surface-2);
  color: var(--text-2);
  cursor: not-allowed;
}

@media (hover: hover) {
  .action-tile:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
  }

  .action-tile--danger:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: var(--danger);
  }
}

.action-tile-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
  flex: none;
}

.action-tile-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-tile-text span {
  font-size: var(--text-sm);
  color: var(--text-2);
}

.action-tile--danger .action-tile-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.rule-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 128px;
  gap: var(--space-3);
  align-items: center;
  min-height: 40px;
  cursor: pointer;
}

.rule-row input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

.narrow-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.narrow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.rule-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.rule-row--multi {
  grid-template-columns: minmax(0, 1fr) auto 128px;
  cursor: default;
}

.rule-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.rule-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
  flex: none;
}

.rule-not {
  min-height: 34px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.narrow-preview {
  font-weight: 600;
}

@media (max-width: 560px) {
  .rule-row--multi {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .rule-row--multi .rule-value {
    grid-column: 1 / -1;
    padding-left: 30px;
  }
}

.rule-value {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.rule-value input,
.rule-value select {
  min-height: 34px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.rule-value .unit {
  color: var(--text-3);
  font-size: var(--text-sm);
}

.pair-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.pair-input select {
  width: auto;
}

.group-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.group-label .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--type-color);
}

.empty-list {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--text-3);
  font-size: var(--text-sm);
}

.status-icon {
  display: inline-flex;
}

.status-icon--warn {
  color: var(--warn);
}

.status-icon--error {
  color: var(--danger);
}

.status-icon--dirty {
  color: var(--accent-strong);
}

/* The Fleet page's Deleted records card (views/deleted.js). */
.deleted-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.deleted-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border);
}

.deleted-row:first-child {
  border-top: 0;
}

.deleted-what {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  overflow-wrap: anywhere;
}

.server-version-by {
  color: var(--text-2);
}
