/* VideoPDF — the video-transcription space inside the contents modal, and
   the Settings → VideoPDF section. Tokens only (test_theme_preference.py
   refuses raw colour literals outside the palette blocks), so both themes
   come out of the same rules. */

/* The button beside the Libros/Muestras/Informes toggle. Same pill family as
   the segments, but a standalone control: it is not a fourth segment. */
.contents-modal-header .contents-videopdf-button {
  padding: 5px 16px !important;
  min-height: 0 !important;
  height: auto !important;
  font-size: 0.85em;
  border-radius: 999px;
  flex: 0 0 auto;
}
.contents-modal-header .contents-videopdf-button.is-active {
  background: var(--marron) !important;
  color: var(--on-accent) !important;
  border-color: var(--marron) !important;
}

/* The panel owns the modal's remaining height and scrolls internally. */
.videopdf-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 4px;
}

.videopdf-banner {
  border-left: 3px solid var(--marron);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: var(--text-sm);
}
.videopdf-banner.is-error {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.videopdf-error-raw {
  color: var(--muted);
  font-size: var(--text-xs);
  margin-top: 4px;
}

/* YouTube URL | Video file — two options above the form, same pill family as
   the VideoPDF button itself. */
.videopdf-source-switch {
  display: inline-flex;
  gap: 4px;
  align-self: flex-start;
}
.videopdf-source-switch button {
  border-radius: 999px;
  padding: 4px 14px;
  font-size: var(--text-sm);
}
.videopdf-source-switch button.is-active {
  background: var(--marron);
  color: var(--on-accent);
  border-color: var(--marron);
}
.videopdf-source-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.videopdf-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: var(--space-2);
  align-items: end;
}
.videopdf-form .field { min-width: 0; }
.videopdf-form .field input, .videopdf-form .field select { width: 100%; }

/* File picker: the native input is visually hidden (still focusable, still
   inside the label) and drawn as a chip + the chosen name, in the same box as
   the URL input it replaces. */
.videopdf-form .field .videopdf-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.videopdf-file {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.videopdf-file-button {
  flex: 0 0 auto;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--marron);
  color: var(--on-accent);
  font-size: var(--text-sm);
  font-weight: 600;
}
.videopdf-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: var(--text-sm);
}
.videopdf-file.has-file .videopdf-file-name { color: var(--ink); }
.videopdf-file:has(.videopdf-file-input:focus-visible) {
  outline: 2px solid var(--marron);
  outline-offset: 2px;
}

/* Pick from WebDAV: the file list and its Refresh button share the first
   field's box, like the file chip and the URL input it replaces. */
/* Liveness: a dot that pulses once per NEW worker heartbeat (the view is
   rebuilt each poll; the pulse class is added only when the beat changed),
   and turns amber/red when the beats stop. Colour carries the state, the
   sentence beside it says it in words. */
.videopdf-live {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--muted);
}
.videopdf-live-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.videopdf-live.is-alive .videopdf-live-dot { background: var(--ok); }
.videopdf-live.is-late .videopdf-live-dot { background: var(--warn); }
.videopdf-live.is-stalled .videopdf-live-dot { background: var(--danger); }
.videopdf-live.is-stalled { color: var(--danger); }
.videopdf-live-dot.is-beat { animation: videopdf-beat 900ms ease-out 1; }
@keyframes videopdf-beat {
  0% { box-shadow: 0 0 0 0 var(--ok); transform: scale(1.35); }
  100% { box-shadow: 0 0 0 9px transparent; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .videopdf-live-dot.is-beat { animation: none; }
}
.videopdf-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: var(--text-sm);
}
.videopdf-steps-now { color: var(--ink); font-weight: 600; }
.videopdf-steps-next { color: var(--muted); }

.videopdf-archive-summary { cursor: default; min-height: 34px; padding-left: 10px; }
.videopdf-archive-status:empty { display: none; }

/* The WebDAV file browser: toolbar, then a scrolling table whose header
   stays put. Fixed height so a folder of hundreds of videos scrolls inside
   the panel instead of pushing the job list off screen. */
.videopdf-archive {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
}
.videopdf-archive-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.videopdf-archive-toolbar input[type="search"] { flex: 1 1 auto; min-width: 0; }
.videopdf-archive-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.videopdf-archive-scroll {
  max-height: 280px;
  overflow: auto;
  border-top: 1px solid var(--line);
}
.videopdf-archive-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.videopdf-archive-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 0;
  text-align: left;
}
.videopdf-archive-sort {
  width: 100%;
  text-align: inherit;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--ink) !important;
  padding: 6px 8px !important;
  min-height: 0 !important;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
.videopdf-archive-table th.videopdf-archive-col-bytes,
.videopdf-archive-table th.videopdf-archive-col-modified { text-align: right; }
.videopdf-archive-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.videopdf-archive-name {
  max-width: 0;          /* with width:100% on the column: ellipsis, never a wider table */
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.videopdf-archive-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.videopdf-archive-last {
  white-space: nowrap;
  color: var(--muted);
  font-size: var(--text-xs);
}
.videopdf-archive-table tbody tr[tabindex] { cursor: pointer; }
.videopdf-archive-table tbody tr[tabindex]:hover { background: var(--surface-soft); }
.videopdf-archive-table tbody tr:focus-visible { outline: 2px solid var(--marron); outline-offset: -2px; }
.videopdf-archive-table tbody tr.is-chosen {
  background: var(--surface-strong);
  box-shadow: inset 3px 0 0 var(--marron);
  font-weight: 600;
}
.videopdf-archive-table tbody tr.is-disabled td { color: var(--muted); }
.videopdf-archive-table tbody tr.is-disabled .videopdf-archive-name { text-decoration: line-through; }
.videopdf-archive-empty td { color: var(--muted); text-align: center; padding: 14px 8px; }

/* One piece of work at a time: what is running, next to the disabled
   Estimate button, and pinned at the top of the list. */
.videopdf-busy {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: 6px 10px;
  border-left: 3px solid var(--marron);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: var(--text-sm);
}
.videopdf-busy[hidden] { display: none; }
.videopdf-active-row { border-color: var(--marron); }

.videopdf-jobs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.videopdf-job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: var(--space-2);
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.videopdf-job-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.videopdf-job-url {
  color: var(--muted);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.videopdf-pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: var(--surface-soft);
  white-space: nowrap;
}
.videopdf-pill-ok, .videopdf-pill-done, .videopdf-pill-committed, .videopdf-pill-purged {
  color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft);
}
.videopdf-pill-warn, .videopdf-pill-awaiting_go, .videopdf-pill-processing, .videopdf-pill-rendering,
.videopdf-pill-preprocessing, .videopdf-pill-ready, .videopdf-pill-delivering, .videopdf-pill-queued,
.videopdf-pill-downloading, .videopdf-pill-running, .videopdf-pill-receiving, .videopdf-pill-uploaded,
.videopdf-pill-transferring, .videopdf-pill-created {
  color: var(--warn-strong); border-color: var(--warn); background: var(--surface-strong);
}
.videopdf-pill-fail, .videopdf-pill-failed, .videopdf-pill-cancelled {
  color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft);
}

.videopdf-stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.videopdf-stage-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.videopdf-stage-head h3 {
  margin: 0;
  font-size: var(--text-base);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.videopdf-estimate {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.videopdf-estimate th, .videopdf-estimate td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.videopdf-estimate th:first-child, .videopdf-estimate td:first-child { text-align: left; }
.videopdf-estimate thead th {
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.videopdf-estimate tbody tr { cursor: pointer; }
.videopdf-estimate tbody tr.is-chosen { background: var(--surface-strong); font-weight: 600; }

.videopdf-warnings { display: flex; flex-direction: column; gap: 4px; }

.videopdf-cover {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-2);
}

.videopdf-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.videopdf-actions .videopdf-ack {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--muted);
}
.videopdf-actions .videopdf-ack input[type="checkbox"] {
  appearance: auto;
  width: 14px !important;
  height: 14px !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

.videopdf-progress { display: flex; flex-direction: column; gap: 6px; }
.videopdf-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.videopdf-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.4s ease;
}
.videopdf-log {
  max-height: 160px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-xs);
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  white-space: pre-wrap;
}

.videopdf-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-3);
  min-height: 0;
}
.videopdf-viewer {
  width: 100%;
  height: min(60dvh, 720px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.videopdf-side { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.videopdf-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
  font-size: var(--text-sm);
}
.videopdf-card dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; }
.videopdf-card dt { color: var(--muted); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.08em; }
.videopdf-card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.videopdf-card .field { margin-top: 6px; }
.videopdf-downloads { display: flex; flex-wrap: wrap; gap: 6px; }
.videopdf-downloads a { font-size: var(--text-sm); }
/* The proper-name check's quiet line under the result: one summary, a list on demand. Text only. */
.videopdf-names { font-size: var(--text-sm); color: var(--muted); }
.videopdf-names summary { cursor: pointer; }
.videopdf-names ul { margin: 4px 0 0; padding-left: 18px; }
.videopdf-names li { overflow-wrap: anywhere; }
.videopdf-names .videopdf-names-evidence { display: block; font-size: var(--text-2xs); }

@media (max-width: 900px) {
  .videopdf-result { grid-template-columns: 1fr; }
  .videopdf-form { grid-template-columns: 1fr 1fr; }
}

/* Settings → VideoPDF */
.video2pdf-routes { display: flex; flex-direction: column; gap: 4px; }
.video2pdf-route, .video2pdf-route-head {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
}
.video2pdf-route-head span {
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.video2pdf-route > span { font-size: var(--text-sm); }
.video2pdf-route input { width: 100%; min-width: 0; }
.video2pdf-mode-field { display: inline-flex; gap: 6px; align-items: center; }
/* Settings → VideoPDF · storage: one row per leftover category. */
.video2pdf-storage { display: flex; flex-direction: column; gap: 2px; }
.video2pdf-storage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5em 6em auto;
  gap: var(--space-2);
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.video2pdf-storage-label { font-size: var(--text-sm); }
.video2pdf-storage-count, .video2pdf-storage-size {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--muted);
}
.video2pdf-storage-status { grid-column: 1 / -1; margin: 0; }
.video2pdf-storage-status:empty { display: none; }
@media (max-width: 600px) {
  .video2pdf-storage-row { grid-template-columns: minmax(0, 1fr) auto; }
  .video2pdf-storage-count, .video2pdf-storage-size { text-align: left; }
}
.video2pdf-test-result { overflow-x: auto; }
.video2pdf-names-results { margin: 4px 0 0; padding-left: 18px; font-size: var(--text-sm); }
.video2pdf-names-results li { overflow-wrap: anywhere; }
.video2pdf-names-results .video2pdf-names-url { display: block; color: var(--muted); font-size: var(--text-2xs); }
.video2pdf-selftest {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.video2pdf-selftest th, .video2pdf-selftest td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.video2pdf-selftest th {
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
#video2pdf-advanced-json { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-xs); }
