/* Screen styles: program list, program form and program page (S-03..S-15). imported by assets/app.js. */

/* Lists without bullets inside table cells and cards (organisms of a program). */
.sv-plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sv-space-1);
}

.sv-table__title {
  font-weight: var(--sv-weight-semibold);
  margin-right: var(--sv-space-2);
}

.sv-table__actions {
  text-align: right;
  white-space: nowrap;
}

/* Review chips of the program list (F-017). */
.sv-review-chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sv-space-1);
  color: var(--sv-review-fg);
}

/* "+n" authority codes of a program row. */
.sv-more > summary {
  cursor: pointer;
  color: var(--sv-color-link);
  font-size: var(--sv-text-sm);
}

/* Library card of the program list (F-019). */
.sv-library {
  list-style: none;
  margin: 0 0 var(--sv-space-3);
  padding: 0;
  display: grid;
  gap: var(--sv-space-3);
}

.sv-library__item a {
  display: inline-flex;
  align-items: center;
  gap: var(--sv-space-1);
  font-weight: var(--sv-weight-medium);
}

.sv-library__description {
  margin: var(--sv-space-1) 0 0;
  color: var(--sv-color-text-muted);
  font-size: var(--sv-text-sm);
}

/* Program form: authority grid. */
.sv-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--sv-space-1) var(--sv-space-4);
}

.sv-hint--warning {
  color: var(--sv-warning-fg);
}

.sv-form-actions__end {
  margin-left: auto;
}

.sv-program-form .sv-card + .sv-card,
.sv-program-form .sv-alert + .sv-card {
  margin-top: var(--sv-space-4);
}

/* Program form (S-04): the organism list, its tools and the "Add organisms" dialog. */
.sv-organism-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sv-space-2) var(--sv-space-4);
  margin-bottom: var(--sv-space-3);
}

.sv-organism-tools .sv-field--choice {
  margin: 0;
}

.sv-organism-tools__count {
  margin: 0 0 0 auto;
  font-size: var(--sv-text-sm);
}

.sv-organism-list {
  list-style: none;
  margin: var(--sv-space-2) 0 0;
  padding: 0;
  border: 1px solid var(--sv-color-border);
  border-radius: var(--sv-radius-md);
}

.sv-organism-list:empty {
  display: none;
}

.sv-organism-list__item {
  display: grid;
  grid-template-columns: auto auto 2rem minmax(0, 1fr) minmax(10rem, 14rem) auto auto;
  grid-template-areas: "select handle number organism matrix co actions";
  align-items: center;
  gap: var(--sv-space-2) var(--sv-space-3);
  padding: var(--sv-space-2) var(--sv-space-3);
  background: var(--sv-color-surface);
}

.sv-organism-list__item + .sv-organism-list__item {
  border-top: 1px solid var(--sv-color-border);
}

.sv-organism-list__item:first-child { border-radius: var(--sv-radius-md) var(--sv-radius-md) 0 0; }
.sv-organism-list__item:last-child { border-radius: 0 0 var(--sv-radius-md) var(--sv-radius-md); }
.sv-organism-list__item:only-child { border-radius: var(--sv-radius-md); }

.sv-organism-list__item.is-invalid {
  background: var(--sv-error-bg);
}

.sv-organism-list__item.is-dragging {
  opacity: 0.5;
}

.sv-organism-list__select { grid-area: select; display: flex; }
.sv-organism-list__handle {
  grid-area: handle;
  display: flex;
  color: var(--sv-color-text-muted);
  cursor: grab;
  touch-action: none;
}

.sv-organism-list__number {
  grid-area: number;
  color: var(--sv-color-text-muted);
  font-size: var(--sv-text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.sv-organism-list__organism { grid-area: organism; min-width: 0; }
.sv-organism-list__organism > .sv-field__hint { margin: var(--sv-space-1) 0 0; }

.sv-organism-list__name {
  display: block;
  font-weight: var(--sv-weight-semibold);
  overflow-wrap: anywhere;
}

.sv-organism-list__meta {
  color: var(--sv-color-text-muted);
  font-size: var(--sv-text-sm);
}

.sv-organism-list__matrix { grid-area: matrix; }
.sv-organism-list__matrix .sv-select { width: 100%; }

.sv-organism-list__co {
  grid-area: co;
  display: flex;
  align-items: center;
  gap: var(--sv-space-2);
  margin: 0;
  white-space: nowrap;
}

.sv-organism-list__label {
  font-size: var(--sv-text-sm);
}

/* The matrix label is for screen readers on wide screens (the rows share one layout). */
.sv-organism-list__matrix > .sv-organism-list__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sv-organism-list__actions {
  grid-area: actions;
  display: flex;
  gap: var(--sv-space-1);
}

.sv-organism-list__empty {
  margin: var(--sv-space-2) 0 0;
}

/* Touch screens: no drag handle (native drag and drop needs a mouse); the arrow buttons reorder. */
@media (hover: none) {
  .sv-organism-list__handle { display: none; }
}

/* Phones and narrow screens: the organism on top, the settings below it. */
@media (max-width: 59.99em) {
  .sv-organism-list__item {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "select number organism handle"
      ". . matrix matrix"
      ". . co actions";
  }

  .sv-organism-list__number { text-align: left; }

  .sv-organism-list__matrix > .sv-organism-list__label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    display: block;
    margin-bottom: var(--sv-space-1);
  }
}

.sv-organism-picker__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sv-space-2);
}

.sv-organism-picker__tools > p {
  margin: 0;
  font-size: var(--sv-text-sm);
}

.sv-organism-picker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--sv-color-border);
  border-radius: var(--sv-radius-md);
}

.sv-organism-picker__list:empty {
  display: none;
}

.sv-organism-picker__option {
  display: flex;
  align-items: flex-start;
  gap: var(--sv-space-3);
  padding: var(--sv-space-2) var(--sv-space-3);
}

.sv-organism-picker__option + .sv-organism-picker__option {
  border-top: 1px solid var(--sv-color-border);
}

.sv-organism-picker__option > input {
  flex: none;
  margin-top: 0.15rem;
}

.sv-organism-picker__option > label {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--sv-space-2);
  min-width: 0;
  cursor: pointer;
}

.sv-organism-picker__option .sv-organism-list__name {
  display: inline;
  font-weight: var(--sv-weight-medium);
}

.sv-organism-picker__option:has(input:checked) {
  background: var(--sv-color-primary-subtle);
}

/* Copy to year: the step-1 form in one row on wide screens. */
.sv-form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sv-space-4);
}

.sv-form-inline .sv-form-actions {
  margin: 0;
}

/* Program page: organism help text (D-12). */
.sv-help > summary {
  cursor: pointer;
  color: var(--sv-color-link);
  font-size: var(--sv-text-sm);
}

.sv-help > p {
  margin: var(--sv-space-1) 0 0;
  color: var(--sv-color-text-muted);
}

/* Bulk results above the page content. */
.sv-bulk-result {
  margin-bottom: var(--sv-space-4);
}

.sv-bulk-result__list {
  margin: 0 0 var(--sv-space-3);
  padding-left: var(--sv-space-5);
}

/* Program page (S-07): target progress, site list, row inspections. */
.sv-progress-line {
  display: grid;
  gap: var(--sv-space-3);
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.sv-site-list__summary {
  margin: 0 0 var(--sv-space-2);
  color: var(--sv-color-text-muted);
  font-size: var(--sv-text-sm);
}

.sv-site-inspections li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sv-space-1);
}

.sv-site-inspections__organism {
  font-size: var(--sv-text-sm);
}

.sv-mono {
  font-family: var(--sv-font-mono, ui-monospace, monospace);
  font-size: var(--sv-text-sm);
}

/* A POST action inside a dropdown menu ("Apply program to open sites"). */
.sv-dropdown__form {
  margin: 0;
}

.sv-dropdown__form .sv-dropdown__item {
  width: 100%;
  justify-content: flex-start;
  border-radius: 0;
}

/* Site forms (S-08..S-15). */
.sv-site-form,
.sv-site-delete {
  display: grid;
  gap: var(--sv-space-3);
}

.sv-grid-2 {
  display: grid;
  gap: var(--sv-space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
}
