/* Files tab: folder sidebar, toolbar and the Data/Assets/References tables. */

/* Folders and the list they filter are one instrument, so they share a box and
   a hairline — the resources tab's arrangement. */
.workspace {
  min-height: max(520px, calc(100dvh - 238px));
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(162px, 14%) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-raised);
  box-shadow: 0 9px 28px rgba(34, 31, 25, .045);
}
.workspace-main { min-width: 0; max-width: 100%; container-type: inline-size; padding: 18px; overflow-x: clip; }
/* The drop target is the whole tab; the ring is drawn inside so it can never
   widen the page. */
.workspace.is-dragover { position: relative; }
.workspace.is-dragover::after {
  content: "Drop files or folders to upload";
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 2px dashed var(--blue);
  border-radius: 3px;
  background: color-mix(in srgb, var(--blue-soft) 55%, transparent);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  pointer-events: none;
  text-transform: uppercase;
}

.folder-sidebar {
  -webkit-user-select: none;
  user-select: none;
  min-width: 0;
  padding: 12px 9px;
  border-right: 1px solid var(--line);
  background: rgba(23, 23, 19, .018);
}
/* Reached from the picker on a phone, where the sidebar is off screen. */
.folder-picker { display: none; }

/* Head: what the panel is, then what you can do to it. A new folder lands
   inside whichever row is selected, so the note says which that is before
   the button is pressed. */
/* Depth comes from the nesting, kept tight so a nested name still has room:
   a 14px disclosure column and a short guide inset per level. */
.folder-tree { display: grid; gap: 1px; }
/* Everything/Unfiled are not part of the hierarchy, so they sit apart from it. */
.tree-root-line + .tree-line:not(.tree-root-line),
.tree-root-line + .tree-branch { margin-top: 11px; }
.tree-branch { min-width: 0; }
.tree-line { min-width: 0; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; }
.tree-children { display: grid; gap: 1px; margin-left: 6px; padding-left: 7px; border-left: 1px solid var(--line); }
.tree-branch.is-collapsed > .tree-children { display: none; }
.tree-toggle { width: 14px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.tree-toggle span { font-size: 14px; line-height: 1; transition: transform .12s ease-out; }
.tree-toggle[aria-expanded="true"] span { transform: rotate(90deg); }
.tree-toggle:hover { color: var(--ink); }
.tree-spacer { width: 14px; }
.tree-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 6px 5px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-size: var(--text-control);
  transition: color .12s, background .12s;
}
.tree-row:hover { background: rgba(23, 23, 19, .045); color: var(--ink); }
.tree-row.is-active { background: var(--blue-soft); color: var(--ink); }
.tree-row.is-folder-drop { background: var(--blue-soft); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.tree-row > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row small { color: var(--muted); font-size: var(--text-meta); font-variant-numeric: tabular-nums; }
.tree-icon { display: grid; place-items: center; }
.tree-icon svg { width: 15px; height: 15px; }
.tree-row.is-root .tree-icon { opacity: .5; }

/* Always there, so nothing depends on what happens to be selected. */
.tree-actions { display: flex; align-items: center; }
.tree-action { width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 2px; background: transparent; color: #b6b0a5; cursor: pointer; transition: color .12s, background .12s; }
.tree-action svg { width: 13px; height: 13px; }
.tree-action:hover { background: rgba(23, 23, 19, .07); color: var(--blue); }
.tree-action.is-danger:hover { color: var(--red); }

.tree-form { display: grid; grid-template-columns: 16px minmax(0, 1fr); align-items: center; gap: 6px; padding: 5px 5px 5px 20px; }
.tree-form input { min-width: 0; padding: 3px 5px; border: 1px solid var(--blue); border-radius: 2px; outline: 0; background: var(--paper-raised); color: var(--ink); font-size: var(--text-control); }
.tree-children .tree-form { padding-left: 5px; }

.folder-new { width: 100%; margin-top: 10px; padding: 7px 0; border: 1px dashed var(--line); border-radius: 2px; background: transparent; color: var(--muted); cursor: pointer; font-size: var(--text-control); }
.folder-new:hover { border-color: var(--blue); border-style: solid; color: var(--blue); }

.sidebar-empty { margin: 12px 4px 0; color: var(--muted); font-size: var(--text-control); }

.dl-toolbar { max-width: 100%; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.dl-search { position: relative; display: flex; align-items: center; }
.dl-search input { width: 260px; max-width: 100%; min-height: 30px; padding: 0 26px 0 10px; border: 1px solid var(--line); border-radius: 2px; background: var(--paper-raised); color: inherit; font-size: var(--text-control); }
.dl-search.is-active input { border-color: var(--blue); }
.dl-search button { position: absolute; right: 4px; width: 20px; height: 20px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.dl-toolbar-actions { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.dl-btn { min-height: 30px; max-width: 150px; padding: 1px 10px 0; border: 1px solid var(--line); border-radius: 2px; background: transparent; color: var(--muted); cursor: pointer; font-size: var(--text-control); }
.dl-btn:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.dl-btn:disabled { opacity: .4; cursor: not-allowed; }
.dl-btn.is-danger:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.dl-count { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

/* Keyboard-navigable list: arrows move the cursor row, shift extends.
   Text is unselectable so shift-click extends the selection instead of
   dragging a text range across rows. */
.list-scroll { max-width: 100%; overflow-x: auto; outline: 0; -webkit-user-select: none; user-select: none; }
/* Drawn inside: an outset ring pushed the pane into horizontal overflow. */
.list-scroll:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

.list-table { width: 100%; border-collapse: collapse; }
/* Widths come from the colgroup; modal tables keep automatic layout. */
.list-scroll .list-table { table-layout: fixed; }
.list-table col.col-select { width: 28px; }
/* One 24px button each: details, download, share, delete. A column too narrow
   for them all does not wrap — the cell clips and paints an ellipsis. */
.list-table col.col-actions { width: 110px; }
.list-table tbody tr { cursor: default; }
/* The cursor ring is drawn with insets: under border-collapse the row's top
   border loses to the previous row's bottom border, so only part of it shows. */
.list-table tr.is-cursor td { box-shadow: inset 0 1px 0 var(--blue), inset 0 -1px 0 var(--blue); }
.list-table tr.is-cursor td:first-child { box-shadow: inset 0 1px 0 var(--blue), inset 0 -1px 0 var(--blue), inset 2px 0 0 var(--blue); }
.list-table tr.is-cursor td:last-child { box-shadow: inset 0 1px 0 var(--blue), inset 0 -1px 0 var(--blue), inset -2px 0 0 var(--blue); }
.list-table th { padding: 0 12px 0 0; border-bottom: 1px solid var(--line); text-align: left; }
.list-table th button { display: inline-flex; align-items: center; gap: 5px; width: 100%; padding: 0 0 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.list-table th button:hover { color: var(--ink); }
.list-table th.is-sorted button { color: var(--blue); }
.sort-mark { font-size: 7px; }
.list-table td { padding: 9px 10px 9px 0; overflow: hidden; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.list-table tbody tr:last-child td { border-bottom: 0; }
/* Hover stays off selected rows so it never competes with the selection tint. */
.list-table tbody tr:not(.is-selected):hover { background: var(--paper-raised); }
.list-table tr.is-selected { background: var(--blue-soft); }
.list-table a { color: var(--blue); }
.list-table .col-select { padding-right: 0; }
.list-table .col-actions { padding-right: 0; overflow: visible; text-align: right; text-overflow: clip; white-space: nowrap; }
.list-table td { min-width: 0; }
.cell-name { max-width: 100%; overflow: hidden; color: var(--ink); text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }

.row-select { width: 100%; padding: 3px 4px; border: 1px solid transparent; border-radius: 2px; background: transparent; color: var(--muted); font-size: 12px; }
.row-select:hover, .row-select:focus { border-color: var(--line); background: var(--paper-raised); color: var(--ink); }
.row-select:disabled { opacity: .5; }
.row-action { flex: 0 0 auto; width: 24px; height: 24px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 2px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; vertical-align: middle; }
.row-action:hover { background: rgba(23, 23, 19, .07); color: var(--ink); }
.row-action.is-danger:hover { color: var(--red); }
.row-action svg { width: 14px; height: 14px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.status-dot { width: 7px; height: 7px; display: inline-block; margin-right: 8px; border-radius: 50%; background: #9ca3af; vertical-align: middle; }
.status-done { background: var(--green); }
.status-error { background: var(--red); }
.status-parsing, .status-pending { background: #d97706; }

.type-pill { padding: 3px 8px 2px; border-radius: 999px; background: color-mix(in srgb, var(--pill) 16%, var(--paper)); color: var(--pill); font-size: 9px; font-weight: 700; letter-spacing: .1em; }

.load-more { display: block; width: 100%; margin-top: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 2px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.load-more:hover { border-color: var(--ink); color: var(--ink); }

@media (max-width: 700px) {
  /* The tree costs a fifth of the width and there are no crumbs to navigate
     with, so it moves into a sheet behind a picker that names the folder the
     list is showing. */
  .workspace { min-height: 0; grid-template-columns: minmax(0, 1fr); }
  .workspace-main { min-height: 420px; padding: 13px; }
  .folder-sidebar { display: none; }
  /* Creating a folder redraws the panel, which throws away the sheet the
     button was pressed in, so the field never gets focus. Folder creation is
     a desktop action. */
  .folder-new { display: none; }

  .folder-picker {
    min-height: var(--tap);
    display: flex;
    align-items: baseline;
    gap: 9px;
    padding: 11px 13px 8px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(23, 23, 19, .018);
    color: var(--ink);
    cursor: pointer;
    text-align: left;
  }
  .folder-picker span { color: var(--muted); font-size: var(--text-meta); font-weight: 700; letter-spacing: var(--tracking-label); text-transform: uppercase; }
  .folder-picker strong { min-width: 0; overflow: hidden; font-size: var(--text-control); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
  .folder-picker::after { content: "⌄"; margin-left: auto; color: var(--muted); }
  /* The list carries the name and nothing else: the tick column, the type and
     the row actions all belong to a file's own sheet, which a tap opens. */
  .list-table .col-select,
  .list-table .col-actions,
  .list-table .col-type { display: none; }
  /* One size through the row, matching the folder tree beside it. */
  .list-table td { padding-block: 11px; font-size: var(--text-control); }

  /* Only the search survives the toolbar; the rest act on a selection that
     cannot be made without the tick column. */
  .dl-toolbar { margin-bottom: 12px; padding-bottom: 12px; }
  .dl-toolbar-actions { display: none; }
  .dl-search { flex: 1 1 100%; }
  .dl-search input { width: 100%; }

  .tree-row { padding-block: 9px; }
  .tree-toggle { height: var(--tap-dense); }
  .tree-action { width: var(--tap-dense); height: var(--tap-dense); }
}

.folder-dialog-body { position: relative; display: grid; gap: 14px; padding: 26px 18px 30px; }
.folder-dialog-close { position: absolute; top: 12px; right: 12px; }
.folder-dialog .folder-sidebar { display: block; padding: 0; border-right: 0; background: transparent; }

@container (max-width: 1200px) {
  .list-scroll .col-sample,
  .list-scroll .col-instrument,
  .list-scroll .col-size,
  .list-scroll .col-timestamp,
  .list-scroll .col-uploaded,
  .list-scroll .col-group,
  .list-scroll .col-updated,
  .list-scroll .col-authors,
  .list-scroll .col-year,
  .list-scroll .col-journal,
  .list-scroll .col-doi,
  .list-scroll .col-added {
    display: none;
  }

  .list-scroll col.col-type { width: 84px !important; }
  /* Details goes first when the room runs out; the other three stay. */
  .list-scroll col.col-actions { width: 80px; }
  .list-scroll .col-actions .row-action[data-details] { display: none; }
}

/* Bundles sit in the same list as files, tagged by member count. */
.member-count { margin-left: 8px; padding: 2px 7px 1px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 9px; white-space: nowrap; }
