/* The Documentation folders. Colors, type and spacing come from styles.css. */
.doc-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin-bottom: var(--space-2);
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
}

.doc-crumbs[hidden],
#doc-dialog-field[hidden] {
  display: none;
}

.doc-crumbs a {
  color: var(--color-accent-text);
  text-decoration: none;
}

.doc-crumbs a:hover {
  text-decoration: underline;
}

.doc-message {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-bad-soft);
  color: var(--color-bad);
  font-size: var(--text-sm);
}

.doc-message.is-info {
  background: var(--color-sunken);
  color: var(--color-ink-muted);
}

/* Folder and file rows */
.doc-row-link {
  display: grid;
  flex: 1;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  color: var(--color-ink);
  text-decoration: none;
}

.doc-row-link:focus-visible {
  outline-offset: -2px;
}

.doc-row-chevron {
  width: 8px;
  height: 8px;
  margin-right: var(--space-1);
  border-top: 2px solid var(--color-accent);
  border-right: 2px solid var(--color-accent);
  transform: rotate(45deg);
}

.doc-row-note {
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.doc-file-icon {
  background: var(--color-bad-soft);
  color: var(--color-bad);
}

/* Dropping files */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6);
  border: 2px dashed var(--color-line-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
  text-align: center;
  transition: background-color var(--motion), border-color var(--motion);
}

.drop-zone-title {
  color: var(--color-ink);
  font-size: var(--text-md);
  font-weight: 600;
}

/* Under a list of folders, where files aren't the main thing */
.drop-zone.is-compact {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-4);
}

.drop-zone.is-compact .drop-zone-title {
  font-size: var(--text-sm);
  font-weight: 500;
}

#doc-action {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.dialog-text[hidden] {
  display: none;
}

body.is-dragging .drop-zone {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

#doc-view > * + * {
  margin-top: var(--space-4);
}

.doc-empty {
  margin: 0;
  padding: var(--space-6);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-ink-muted);
  text-align: center;
}

@media (max-width: 760px) {
  .doc-row-link {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: var(--space-1) var(--space-3);
  }

  .doc-row-link .file-icon {
    grid-row: 1 / span 2;
  }

  .doc-row-link .doc-row-note {
    grid-column: 2;
  }
}

/* Contracts: Create New, the choice of template, a contract just made */
.doc-action-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.contract-choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.contract-choice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-sunken);
  color: var(--color-ink);
  text-decoration: none;
  transition: background-color var(--motion);
}

.contract-choice:hover {
  background: var(--color-accent-soft);
}

.contract-choice-name {
  color: var(--color-accent-text);
  font-weight: 600;
}

.contract-choice-text {
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
}

.file-row.is-new {
  background: var(--color-accent-soft);
}

/* An SOP in its service folder (sop.html) */
.sop-file-icon {
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
}

/* SOP versions (sop.html): the current one is marked, the others can be
   made current with a visible button */
.sop-list-title {
  margin-top: var(--space-6);
  font-size: var(--text-lg);
}

#sop-view > .sop-list-title:first-child {
  margin-top: 0;
}

#sop-view > * + * {
  margin-top: var(--space-3);
}

#sop-view > .sop-list-title + * {
  margin-top: 0;
}

#sop-action {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sop-badge {
  flex: none;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-good-soft);
  color: var(--color-good);
  font-size: var(--text-xs);
  font-weight: 600;
}

.sop-promote {
  flex: none;
  padding: 4px var(--space-3);
  font-size: var(--text-sm);
}

.sop-folder-note {
  margin: 0;
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
}

@media (max-width: 760px) {
  .sop-row {
    flex-wrap: wrap;
    padding-bottom: var(--space-2);
  }

  .sop-row .doc-row-link {
    flex-basis: 100%;
  }

  .sop-row .sop-promote,
  .sop-row .sop-badge {
    margin-left: calc(44px + var(--space-4) + var(--space-4));
  }
}

/* A service's tools in their order: a number and a grip before each row;
   drag the grip (or Alt + arrow keys) to move a tool, the numbers follow */
.tool-order {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  align-self: stretch;
  padding: 0 0 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--color-ink-muted);
  font: inherit;
  cursor: grab;
  touch-action: none;
}

.tool-order-num {
  min-width: 18px;
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tool-order-grip {
  display: inline-flex;
  opacity: 0.45;
  transition: opacity var(--motion);
}

.tool-order-grip svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.file-row:hover .tool-order-grip,
.tool-order:focus-visible .tool-order-grip {
  opacity: 1;
}

.tool-order-list .doc-row-link {
  padding-left: var(--space-2);
}

.tool-order-list.is-sorting,
.tool-order-list.is-sorting .tool-order {
  cursor: grabbing;
  user-select: none;
}

.tool-order-list .file-row.is-dragging {
  position: relative;
  z-index: 1;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-accent), var(--shadow-raised);
}
