/* The upload area: a drop area around the file field and, with the script (browser/upload-area.js), a list of the
   files sent, each with its state. Shared tokens and layout words only, on the root of the area, and logical
   properties only, so that a right-to-left page needs no other sheet (packages/components/src/styles.ts). */
.upload-area {
  display: flex;
  flex-direction: column;
  gap: var(--nw-space-12);
}

/* The pieces: the picker for a toolbar, the zone around the content of the app, and the list of the page. */
.upload-area.upload-button {
  display: inline-flex;
}

.upload-area.upload-menu {
  display: inline-flex;
}

.upload-area.upload-drop {
  display: block;
}

/* The zone, or the row of it that takes the drop of its own, while files are over it. */
.upload-area.upload-drop[data-over],
.upload-area.upload-drop [data-over] {
  background: var(--nw-color-action-tint);
}

.upload-area form {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: var(--nw-space-8);
}

/* The choice of a type for the documents, when the form offers types, and the kind and the comment of a new version:
   each label above its control. */
.upload-area .type,
.upload-area .kind,
.upload-area .comment {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: var(--nw-space-4);
}

/* The comment of a new version, which only the script sends: out of sight until it is there. */
.upload-area .comment[hidden] {
  display: none;
}

.upload-area .drop {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: var(--nw-space-8);
  padding: var(--nw-space-16);
  border: var(--nw-border-width-1) solid var(--nw-color-border);
  border-radius: var(--nw-radius-m);
  background: var(--nw-color-surface-sunken);
}

.upload-area .drop[data-over] {
  border-color: var(--nw-color-action);
  background: var(--nw-color-action-tint);
}

.upload-area .drop p {
  margin: 0;
}

.upload-area .hint {
  color: var(--nw-color-text-muted);
}

.upload-area .files {
  display: flex;
  flex-direction: column;
  gap: var(--nw-space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

.upload-area .files:empty {
  display: none;
}

.upload-area .files li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--nw-space-8);
  padding: var(--nw-space-8);
  border: var(--nw-border-width-1) solid var(--nw-color-border-subtle);
  border-radius: var(--nw-radius-m);
  background: var(--nw-color-surface);
}

.upload-area .name {
  overflow-wrap: anywhere;
  font-weight: var(--nw-font-weight-medium);
}

.upload-area .state {
  color: var(--nw-color-text-muted);
}

.upload-area li.added .state {
  color: var(--nw-color-status-ok-ink);
}

.upload-area li.refused .state {
  color: var(--nw-color-status-danger-ink);
}

.upload-area li.unconfirmed .state {
  color: var(--nw-color-status-attention-ink);
}

/* A file waiting, sent or added shows its bar and its percent (that of a file added is full); one not added, none. */
.upload-area li.refused progress,
.upload-area li.refused .percent,
.upload-area li.unconfirmed progress,
.upload-area li.unconfirmed .percent,
.upload-area li.cancelled progress,
.upload-area li.cancelled .percent,
.upload-area li:not(.waiting) .cancel {
  display: none;
}

/* The panel of the files (progress): a popover of the browser, which sits in the top layer fixed to the window, its
   place taken from the end of the window by the auto margins, so that it is never wider than the window leaves it, at
   any width, and what opens after it (a dialog, a menu) is above it. A browser without popovers shows it where it is. */
.upload-area.upload-progress {
  margin-block: auto var(--nw-space-16);
  margin-inline: auto var(--nw-space-16);
  padding: var(--nw-space-12);
  color: var(--nw-color-text);
  background: var(--nw-color-surface-raised);
  border: var(--nw-border-width-1) solid var(--nw-color-border-strong);
  border-radius: var(--nw-radius-m);
  box-shadow: var(--nw-shadow-overlay);
}

.upload-area.upload-progress[hidden] {
  display: none;
}

.upload-area.upload-progress > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--nw-space-8);
}

.upload-area.upload-progress .count {
  margin-block: 0;
  margin-inline: 0 auto;
  font-weight: var(--nw-font-weight-semibold);
  color: var(--nw-color-text-strong);
}

.upload-area.upload-progress > header button {
  min-block-size: var(--nw-size-control-compact);
  padding-inline: var(--nw-space-12);
  font: inherit;
  color: var(--nw-color-accent-text);
  background: var(--nw-color-surface);
  border: var(--nw-border-width-1) solid var(--nw-color-border-strong);
  border-radius: var(--nw-radius-m);
  cursor: pointer;
}

/* A long list scrolls in the panel: the panel is never taller than the window leaves it, whatever the number of files. */
.upload-area.upload-progress .files {
  max-block-size: var(--nw-size-rail-width);
  overflow-y: auto;
}

.upload-area.upload-progress[data-folded] .files {
  display: none;
}

/* A name too long for the panel is cut at its end; the whole of it is the title of the line. */
.upload-area.upload-progress .name {
  display: block;
  max-inline-size: var(--nw-size-rail-width);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A form that asks before it sends (the form of a new version, made for one target): the place to drop or choose a
   file, the width of the form; the file chosen, its size and the way to choose another on one line; the buttons of the
   form on one line. */
.upload-area[data-upload-review] .drop {
  align-self: stretch;
  border-color: var(--nw-color-border-strong);
}

.upload-area .chosen {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--nw-space-4) var(--nw-space-8);
  align-self: stretch;
  margin: 0;
  padding: var(--nw-space-8) var(--nw-space-12);
  border-radius: var(--nw-radius-m);
  background: var(--nw-color-surface-sunken);
}

.upload-area .chosen .size {
  color: var(--nw-color-text-muted);
}

.upload-area .chosen [data-upload-pick] {
  margin-inline: auto 0;
}

.upload-area .kind {
  margin: 0;
  padding: 0;
  border: 0;
}

.upload-area .kind label {
  display: flex;
  align-items: center;
  gap: var(--nw-space-8);
}

.upload-area .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--nw-space-12);
  margin: 0;
}

/* What the script hides of a form, whatever display its part has above: the steps of a form that asks before it sends. */
.upload-area [hidden] {
  display: none;
}
