/* file-view.css — styling owned by the unified file-management component
   (webui/static/js/file-list.js). Load it on any page that mounts the
   component. Design: docs/architecture/file-management-view.md.

   It carries only what the component INTRODUCES or what isn't guaranteed on
   every consuming page. The files-table / bulk-toolbar / state-badge /
   delete-confirm / trash-actions chrome still lives in admin-shell.css, and the
   entity-row / mod-group chrome in admin-files.css / admin-moderation.css; those
   are consolidated here as each call site migrates (docs plan, phase 5). The
   Trash page, for one, gains a preview Play button it never had — so .play-btn
   must live here, not only in admin-files.css. */

/* ── Per-row preview play button ── */
.play-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, background 120ms ease;
}
.play-btn:hover { color: var(--accent); background: var(--surface-hover); }
.play-btn:focus-visible { outline: 2px solid var(--accent); }

.files-table tbody tr.playing-row,
.entity-row.playing-row { background: var(--accent-glow); }
.playing-row .play-btn { color: var(--accent); }

/* Edit reads as the through-line action across every scope (incl. Trash). */
.btn-edit { border-color: var(--accent); color: var(--accent); }
.btn-edit:hover:not(:disabled) { background: var(--accent-glow); }

/* ── Scope / view switches ── */
/* Browse ⇄ List, inside the All-files scope. */
.vm-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.vm-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: 5px;
  transition: background 120ms ease, color 120ms ease;
}
.vm-btn:hover { color: var(--text); }
.vm-btn.is-active { background: var(--accent-glow); color: var(--accent); }
.vm-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Scope switch (segmented pill row): All · Review · Trash. Used by the admin
   Library page that hosts the component (wired when that page is built). */
.scope-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.scope-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  padding: var(--space-1) var(--space-4);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: background 120ms ease, color 120ms ease;
}
.scope-btn:hover { color: var(--text); }
.scope-btn.is-active { background: var(--accent-glow); color: var(--accent); }
.scope-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scope-count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
}
.scope-btn.is-active .scope-count { background: var(--accent); color: #fff; }

/* One-line description under the scope heading. */
.scope-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 var(--space-4);
  max-width: 70ch;
}

/* ── Shared modal field layout (track-edit.js access section + bulk-edit.js) ── */
/* Two controls on one row: License select + Guest control. */
.edit-form .field-split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: end;
}
/* A checkbox + label sitting on one line (overrides .edit-form label's grid). */
.edit-form .field-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}
.edit-form .field-check input { width: auto; }
.edit-form .modal-hint { color: var(--text-muted); font-size: 12px; margin-bottom: var(--space-2); }

@media (max-width: 520px) {
  .edit-form .field-split { grid-template-columns: 1fr; }
}

/* ── Grouped sort (Default ⇄ artist/album) ──
   Still one flat .files-table, sorted artist → album → track#, with separator
   rows that carry a group-select checkbox. Driven by scope.artistAlbumSort + the
   sort switch (its buttons reuse .vm-btn above). */
.files-bar-controls { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.sort-switch {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}

.files-table tr.grp td { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.files-table tbody tr.grp:hover { background: transparent; }   /* separators aren't data rows */

/* Artist = a calm tinted band with a brighter top line + a bit more air above. */
.files-table tr.grp-artist td {
  background: var(--surface);
  border-top: 1px solid var(--text-muted);
  padding-top: var(--space-3); padding-bottom: var(--space-2);
}
.files-table tbody tr.grp-artist:first-child td { border-top: none; }
.grp-artist .grp-label { font-weight: 600; color: var(--text); letter-spacing: .02em; }

/* Album = a thin faint line, indented under the artist. */
.files-table tr.grp-album td { border-top: 1px solid var(--border); }
.grp-album .grp-label { padding-left: 22px; }

/* Disc = a quiet sub-label, indented further under the album, no divider line. */
.grp-disc .grp-label {
  padding-left: 38px;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.grp-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
/* Inner flex row lives inside the <td> so the cell keeps its table-cell layout
   (and spans the full colspan width); flexing the <td> itself collapsed it. */
.grp-label-row { display: flex; align-items: center; }
.grp-label .grp-meta { opacity: .7; margin-left: var(--space-2); }
.grp-label.is-fallback { font-style: italic; }
.grp-check { cursor: pointer; accent-color: var(--accent); }

/* The cover affordance ("Add cover" / "Edit cover") sits unobtrusively at the
   right edge of the separator, pushed there by margin-left:auto in the flex row. */
.grp-cover-btn { margin-left: auto; font-weight: 400; }

/* Track rows under a group: aligned track number + indented title. */
.files-table tbody.is-grouped .cell-title-td { padding-left: 22px; }
.tracknum {
  display: inline-block; width: 2ch; margin-right: var(--space-2);
  text-align: right; color: var(--text-muted);
  font-size: 13px; font-variant-numeric: tabular-nums;
}

/* ── Needs-metadata flag ──
   A file with neither an artist nor an album-artist tag gets a calm amber tint
   + left accent (not an error) so moderators / admins / uploaders can see which
   rows want metadata first. Applies in every scope and both sort modes. */
.files-table tbody tr.fl-needs-meta td { background: rgba(217, 161, 65, 0.09); }
.files-table tbody tr.fl-needs-meta td:first-child { box-shadow: inset 3px 0 0 #d9a141; }
.files-table tbody tr.fl-needs-meta:hover td { background: rgba(217, 161, 65, 0.16); }

/* ════════════════════════════════════════════════════════════════════════════
   Component table chrome. Mirrors admin-shell.css / admin-moderation.css so the
   component renders correctly on pages that DON'T load the admin sheets (the
   shell upload page, for "My uploads"). On admin pages both load; file-view.css
   is loaded last with identical values, so nothing changes visually. The
   duplicates are removed from the admin sheets in the plan's cleanup phase
   (docs/architecture/file-management-view.md), once every consumer loads this file.
   ════════════════════════════════════════════════════════════════════════════ */

/* Danger tokens + destructive buttons + the small size (admin-shell.css). */
:root {
  --danger:        var(--error);
  --danger-bg:     rgba(224, 92, 92, 0.10);
  --danger-border: rgba(224, 92, 92, 0.35);
  --danger-solid:  #c0392b;
}
.btn-destructive-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-destructive-outline:hover:not(:disabled) { background: var(--danger-bg); }
.btn-destructive-solid {
  background: var(--danger-solid);
  border-color: var(--danger-solid);
  color: #fff;
  font-weight: 600;
}
.btn-destructive-solid:hover:not(:disabled) { filter: brightness(1.1); }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: 13px; }

/* Scope heading (compact, like the admin Files/Trash headings). */
.section-title--files {
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 16px;
  color: var(--text);
}

/* Heading + search row. */
.files-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.files-search input[type="search"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: var(--space-2) var(--space-3);
  min-width: 220px;
}
.files-search input[type="search"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The table. */
.files-table-wrap {
  max-height: 64vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.files-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.files-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.files-table .col-size,
.files-table .col-actions { text-align: right; }
.files-table tbody tr { transition: background 120ms ease; }
.files-table tbody tr:hover { background: var(--surface-hover); }
.files-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.files-table tbody tr:last-child td { border-bottom: none; }

.cell-title { font-weight: 500; }
.cell-title.is-fallback { font-weight: 400; font-style: italic; color: var(--text-muted); }
.cell-hash {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  margin-top: 2px;
}
.cell-muted { color: var(--text-muted); }
.cell-size {
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: var(--space-2); }

.files-table .col-check,
.files-table .cell-check { width: 1%; text-align: center; padding-right: 0; }
.cell-check input,
.col-check input { cursor: pointer; }

/* Bulk-action toolbar. */
.bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.bulk-selcount { color: var(--text-muted); font-size: 13px; }
.bulk-spacer { flex: 1; }

/* Inline two-step confirm + the row action wrapper. */
.delete-confirm {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: flex-end;
}
.delete-confirm-label { font-size: 13px; color: var(--text); }
.trash-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

/* The moderator's return note, shown under a row title (admin-moderation.css). */
.mod-note {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  white-space: normal;
}

/* Review-state badge (admin-shell.css). */
.state-badge {
  display: inline-block;
  padding: 1px var(--space-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.state-badge.is-submitted { color: var(--accent); border-color: var(--accent); }
.state-badge.is-returned  { color: var(--error);  border-color: var(--error); }

/* Table-level states. */
.table-state-row {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-6) var(--space-4);
}
.table-state-row td { text-align: center; color: var(--text-muted); padding: var(--space-6) var(--space-4); }
.empty-state { color: var(--text-muted); text-align: center; padding: var(--space-6) var(--space-4); }
.empty-state .drop-icon { font-size: 40px; }
.empty-state p { margin-top: var(--space-2); font-size: 14px; }

/* Responsive: collapse the table to cards below 640px. */
@media (max-width: 640px) {
  .files-table-wrap { border: none; max-height: none; overflow: visible; }
  .files-table thead { display: none; }
  .files-table,
  .files-table tbody,
  .files-table tr,
  .files-table td { display: block; width: 100%; }

  .files-table tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    padding: var(--space-2);
  }
  .files-table tbody td {
    border-bottom: none;
    padding: var(--space-1) var(--space-2);
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    text-align: left;
  }
  .files-table tbody td::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .files-table td.cell-title-td::before { align-self: flex-start; }
  .cell-size { text-align: right; }
  .cell-actions { display: block; }
  .cell-actions .btn,
  .cell-actions .delete-confirm { width: 100%; }
  .cell-actions .btn + .btn { margin-left: 0; margin-top: var(--space-2); }
  .cell-actions .delete-confirm { justify-content: stretch; flex-wrap: wrap; }
  .cell-actions .delete-confirm .btn { flex: 1; }
}
