/* Trove's own pages under /.trove/ (admin-page.js). Colours, fonts and base styles come from
   tokens.css (DESIGN.md), linked first. */

/* The page's own column, inside the frame (frame.css) */
.admin .main {
  max-width: 60rem;
  line-height: 1.5;
}

/* The page's header: its title in the serif, then a line saying what it's for */
.admin .main > h1:first-child {
  margin: 0 0 var(--space-2);
  font-size: var(--text-2xl);
}

.admin .lead {
  margin: 0 0 var(--space-5);
  max-width: 40rem;
  color: var(--neutral);
}

/* For someone not yet in (login, an invite, a share's password): one centred column */
.admin.alone .main {
  max-width: 32rem;
  margin: var(--space-7) auto 0;
}

.admin table {
  border-collapse: collapse;
  width: 100%;
}

.admin th,
.admin td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow-wrap: break-word;
}

.admin th {
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--neutral);
  background: var(--secondary);
}

.admin input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-code);
}

/* A name that has to be typed: it can't be corrected */
.admin input[type="text"]:placeholder-shown {
  border-color: var(--warning);
  outline: 1px solid var(--warning);
}

.admin .refused td {
  color: var(--danger);
}

.admin .actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.admin form.fields {
  display: grid;
  gap: var(--space-3);
  /* No wider than the column, whatever a long folder name in a select asks for */
  grid-template-columns: minmax(0, 1fr);
  max-width: 32rem;
}

.admin form.fields label {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

/* Shown or Hidden, side by side (the Account page's display choices) */
.admin form.fields fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.admin form.fields fieldset label,
.admin form.fields label.check {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
}

.admin legend small {
  color: var(--neutral);
}

/* display: grid above would otherwise win over hidden */
.admin form.fields [hidden] {
  display: none;
}

/* Files or a folder chosen on the upload page (upload.js) */
.admin #sending progress {
  width: 100%;
}

/* Each file and how it's going: a copy of trove.css's */
.upload-files {
  margin: var(--space-2) 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

/* Rows of one height, whatever the stage: name, size and stage on a line, with an uploading
   file's bar along its foot */
.upload-files li {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 4.5rem 6.5rem;
  gap: 0 var(--space-2);
  align-items: center;
  height: 1.75rem;
  border-bottom: 1px solid var(--border);
}

/* A big upload's list: as tall as the most rows it had a moment ago (--rows, at most 8; renderFiles),
   scrolling past that */
.upload-files.many {
  height: calc(var(--rows, 8) * 1.75rem);
  overflow-y: auto;
}

.upload-files .file,
.upload-files .stage {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-files .size,
.upload-files .stage {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.upload-files .size,
.upload-rest {
  color: var(--neutral);
}

.upload-rest {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.upload-files progress {
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  width: 100%;
  height: 3px;
}

.upload-files .done .stage {
  color: var(--success);
}

.upload-files .failed .stage {
  color: var(--danger);
}

/* A file skipped as already in the chest (ticket 51): its name, where the chest has it, and a
   button to send it anyway, in the row's one height */
.upload-files li.skipped {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto;
}

.upload-files .skipped .stage {
  color: var(--neutral);
  text-align: left;
}

.upload-files .anyway {
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
}

.upload-skipped {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
}

/* How an upload is going (summary in uploader.js): each number that changes in a box wide enough
   for its longest, right-aligned in even-width digits, so the text around it never moves. The
   speed and time left keep their room before there's a speed; groups wrap whole. */
.upload-stats {
  font-variant-numeric: tabular-nums;
}

.upload-stats > span {
  white-space: nowrap;
}

.upload-stats > span + span::before {
  content: " · ";
}

.upload-stats > span:has(> :empty)::before {
  visibility: hidden;
}

.upload-stats :is(.bytes, .count, .speed, .time-left) {
  display: inline-block;
  text-align: right;
}

.upload-stats .bytes {
  min-width: 7ch;
}

.upload-stats .speed {
  min-width: 9ch;
}

.upload-stats .time-left {
  min-width: 21ch;
  text-align: left;
}

/* Files renamed as they were added without confirming (renderAdded, telos/keeping ticket 47) */
.renamed {
  margin: var(--space-2) 0;
  font-size: var(--text-sm);
}

.renamed ul {
  max-height: calc(8 * 1.5rem);
  margin: var(--space-1) 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.renamed li {
  overflow: hidden;
  line-height: 1.5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.renamed .from {
  color: var(--neutral);
}

/* A link to copy and send (a share's, an invite's) */
.admin .link {
  font-family: var(--font-code);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.admin p.link {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.admin form.inline {
  display: inline;
}

.admin h1 {
  margin: var(--space-6) 0 var(--space-4);
}

.admin h2 {
  margin: var(--space-6) 0 var(--space-3);
}

/* A question over the page (manage-routes.js): open without script, so no ::backdrop; the
   shadow dims the page behind it instead */
.admin dialog.ask {
  position: fixed;
  inset: 0;
  margin: auto;
  max-width: min(32rem, calc(100vw - 2rem));
  height: fit-content;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--field);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.45);
  z-index: 1;
}

.admin dialog.ask h2 {
  margin-top: 0;
}

.admin textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-reading);
  line-height: 1.5;
}

.admin .row-actions {
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
}

/* Row actions: small buttons, never broken across lines */
.admin td button,
.admin td .row-actions a {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.admin select {
  max-width: 100%;
}

.admin form.fields select {
  width: 100%;
  min-width: 0;
}

@media (max-width: 800px) {
  .admin.alone .main {
    margin-top: var(--space-5);
  }

  /* Tables scroll sideways rather than squeeze */
  .admin .main {
    overflow-x: auto;
  }
}

/* The upload page's drop zone (upload.js): with script, a dashed box to drop files on, its file
   inputs hidden behind labels that look like buttons; without, the browser's own inputs */
.admin .drop-zone {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  border: 2px dashed var(--field);
  border-radius: var(--radius-md);
  text-align: center;
}

.admin .drop-zone.over {
  border-color: var(--primary);
  background: var(--secondary);
}

.admin .drop-zone .drop-hint {
  flex-basis: 100%;
  margin: 0;
  color: var(--neutral);
}

.admin .drop-zone.scripted .choose {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  box-sizing: border-box;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--field);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.admin .drop-zone.scripted .choose:hover {
  background: var(--secondary);
}

.admin .drop-zone.scripted .choose:first-of-type {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.admin .drop-zone.scripted .choose[hidden] {
  display: none;
}

/* The input stays focusable: its label shows the focus ring */
.admin .drop-zone.scripted input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.admin .drop-zone.scripted .choose:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* The Duplicates page (duplicate-routes.js, telos/keeping ticket 50): a group per section, each
   copy with a small square thumbnail */
.duplicates {
  margin-bottom: var(--space-5);
}

.duplicates h2 small {
  color: var(--neutral);
  font-weight: normal;
}

.duplicates td.thumb {
  width: 48px;
}

.duplicates td.thumb img {
  display: block;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
