/* ==========================================================================
   Remote File Manager — #modal-files
   Loaded after style.css. Built entirely from --av-* tokens (no hardcoded
   colors), so dark theme is inherited automatically via the .app[data-
   theme="dark"] wrapper inside the modal body — see #fm-app-ctx in
   index.html, same trick as #nfm-app-ctx / #nam-app-ctx.
   ========================================================================== */

/* ---- Full-screen modal shell (mirrors #modal-terminal, style.css) ---- */
#modal-files .modal-dialog {
  max-width: 95vw; width: 95vw;
  max-height: 95vh; height: 95vh;
  margin: 2.5vh auto;
}
#modal-files .modal-content { height: 100%; display: flex; flex-direction: column; }
#modal-files .modal-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  position: relative;   /* containing block for .fm-overlay */
}
#modal-files .modal-header { align-items: center; gap: 12px; }
#modal-files .modal-title { display: inline-flex; align-items: center; }

.fm-title-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: var(--av-radius-pill);
  background: var(--av-brand-primary-soft); color: var(--av-brand-primary);
  font-variant-numeric: tabular-nums;
}

.fm-tabs { display: inline-flex; gap: 6px; margin-left: auto; margin-right: 8px; }

/* ---- Two-pane grid ---- */
.fm-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  background: var(--av-surface-page);
}
.fm-pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--av-surface);
  border: 1px solid var(--av-line-100);
  border-radius: var(--av-radius-lg);
  margin: 10px;
  overflow: hidden;
}
.fm-pane.is-active { border-color: var(--av-brand-primary-mid); box-shadow: var(--av-shadow-focus); }

.fm-pane__head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: var(--av-surface-subtle);
  border-bottom: 1px solid var(--av-line-100);
  min-height: 42px;
}
.fm-pane__icon  { width: 15px; height: 15px; color: var(--av-brand-primary); flex: none; }
.fm-pane__label { font-size: 13px; font-weight: 600; color: var(--av-ink-900);
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-pane__spacer{ flex: 1; }
.fm-pane__meta  { font-size: 11px; color: var(--av-ink-500); white-space: nowrap; }

/* ---- Sticky notice (errors, agent-outdated, truncated listings) ---- */
.fm-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0; padding: 7px 12px;
  font-size: 12px; line-height: 1.4;
  border-bottom: 1px solid var(--av-line-100);
  background: rgba(255, 213, 76, 0.14); color: var(--av-ink-900);
}
.fm-notice--err { background: rgba(241, 33, 33, 0.10); }
.fm-notice__x   { margin-left: auto; cursor: pointer; color: var(--av-ink-500);
                  background: none; border: 0; line-height: 1; font-size: 15px; padding: 0 2px; }

/* ---- Breadcrumb / path bar ---- */
.fm-pathbar {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 8px 5px 12px;
  border-bottom: 1px solid var(--av-line-100);
  min-height: 34px;
}
.fm-crumbs {
  display: flex; align-items: center; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none;
  flex: 1; min-width: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
}
.fm-crumbs::-webkit-scrollbar { display: none; }
.fm-crumb {
  background: none; border: 0; padding: 2px 5px;
  border-radius: var(--av-radius-xs);
  color: var(--av-brand-primary); cursor: pointer; white-space: nowrap;
  transition: background var(--av-dur-fast) var(--av-ease-out);
}
.fm-crumb:hover { background: var(--av-brand-primary-softer); }
.fm-crumb.is-current { color: var(--av-ink-900); font-weight: 600; cursor: default; }
.fm-crumb.is-current:hover { background: none; }
.fm-crumb__sep { color: var(--av-ink-400); padding: 0 1px; user-select: none; }
.fm-path-input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---- Toolbar ---- */
.fm-toolbar {
  display: flex; align-items: center; gap: 3px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--av-line-100);
  min-height: 40px;
}
.fm-toolbar__sep    { width: 1px; height: 18px; background: var(--av-line-200); margin: 0 4px; }
.fm-toolbar__spacer { flex: 1; }
.fm-toolbar .icon-btn[disabled] { opacity: .35; pointer-events: none; }
.fm-icon-danger:hover { color: var(--av-crit-500) !important; }
.fm-filter { max-width: 160px; }

/* ---- File list ---- */
.fm-list {
  flex: 1; min-height: 0;
  overflow: auto; overscroll-behavior: contain;
  outline: none;
}
.fm-list.is-dropzone { box-shadow: inset 0 0 0 2px var(--av-brand-primary); }
.fm-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fm-tbl thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 10px; font-weight: 600;
  color: var(--av-ink-500); letter-spacing: .06em; text-transform: uppercase;
  padding: 7px 10px; border-bottom: 1px solid var(--av-line-100);
  background: var(--av-surface-subtle); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.fm-tbl tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--av-line-100);
  color: var(--av-ink-900); white-space: nowrap;
}
.fm-row { cursor: default; transition: background var(--av-dur-fast) var(--av-ease-out); }
.fm-row:hover               { background: var(--av-brand-primary-softest); }
.fm-row.is-selected         { background: var(--av-brand-primary-soft); }
.fm-row.is-cursor td:first-child { box-shadow: inset 2px 0 0 var(--av-brand-primary); }
.fm-row.is-locked           { opacity: .5; }
.fm-row.is-dragging         { opacity: .4; }

.fm-th-check, .fm-td-check { width: 30px; padding-right: 0 !important; }
.fm-th-size,  .fm-td-size  { width: 84px;  text-align: right; }
.fm-th-mtime, .fm-td-mtime { width: 132px; }
.fm-th-mode,  .fm-td-mode  { width: 86px; }

.fm-name { display: flex; align-items: center; gap: 7px; min-width: 0; }
.fm-name > span { overflow: hidden; text-overflow: ellipsis; }
.fm-name__icon { width: 15px; height: 15px; flex: none; }
.fm-name__icon--dir  { color: var(--av-brand-primary); }
.fm-name__icon--file { color: var(--av-ink-500); }
.fm-name__icon--link { color: var(--av-info-500); }
.fm-name__target { color: var(--av-ink-500); font-size: 11px; }

@media (max-width: 700px) {
  .fm-th-mode, .fm-td-mode, .fm-th-mtime, .fm-td-mtime { display: none; }
}

/* ---- Pane footer + flash ---- */
.fm-pane__foot {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; min-height: 28px;
  font-size: 11px;
  border-top: 1px solid var(--av-line-100);
  background: var(--av-surface-subtle);
}
.fm-flash { opacity: 0; transition: opacity var(--av-dur-base) var(--av-ease-out); font-weight: 500; }
.fm-flash.is-on { opacity: 1; }
.fm-flash--ok   { color: var(--av-ok-500); }
.fm-flash--warn { color: var(--av-warn-500); }
.fm-flash--err  { color: var(--av-crit-500); }

/* ---- Mid transfer column ---- */
.fm-mid {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.fm-mid__btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--av-radius-sm);
  border: 1px solid var(--av-line-200); background: var(--av-surface);
  color: var(--av-ink-700); cursor: pointer;
  transition: all var(--av-dur-fast) var(--av-ease-out);
}
.fm-mid__btn:hover { background: var(--av-brand-primary-softer); color: var(--av-brand-primary); border-color: var(--av-brand-primary-mid); }
.fm-mid__btn svg { width: 16px; height: 16px; }

/* ---- Transfer queue strip ---- */
.fm-queue {
  border-top: 1px solid var(--av-line-100);
  background: var(--av-surface);
  flex: none;
}
.fm-queue__bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 6px 12px; min-height: 36px;
}
.fm-queue__toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--av-ink-900);
  padding: 2px 4px;
}
.fm-queue__chev { width: 13px; height: 13px; transition: transform var(--av-dur-fast) var(--av-ease-out); }
.fm-queue[data-collapsed="1"] .fm-queue__chev { transform: rotate(180deg); }
.fm-queue__toggle .count {
  font-size: 10px; font-weight: 700; color: var(--av-ink-500);
  background: var(--av-line-100); padding: 1px 6px; border-radius: var(--av-radius-pill);
}
.fm-progress { flex: 1; min-width: 80px; height: 4px; border-radius: 2px; background: var(--av-line-100); overflow: hidden; }
.fm-progress__fill { height: 100%; width: 0%; background: var(--av-brand-primary); transition: width 120ms linear; }
.fm-queue__pct { flex: none; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
/* Bytes / files / speed / ETA. Its own row so it survives the collapsed
   state — knowing how long is left is exactly what you want without having
   to expand the strip. */
.fm-queue__stats {
  padding: 0 12px 6px; font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.fm-queue__stats:empty { display: none; }
.fm-queue__list {
  list-style: none; margin: 0; padding: 0 12px 8px;
  max-height: 220px; overflow-y: auto;
}
/* Collapsing hides the per-item rows only; the bar and the summary line stay. */
.fm-queue[data-collapsed="1"] .fm-queue__list { display: none; }

.fm-qitem {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 6px 4px; border-bottom: 1px solid var(--av-line-100);
  font-size: 12px;
}
.fm-qitem:last-child { border-bottom: 0; }
.fm-qitem__dir  { flex: none; color: var(--av-ink-500); width: 16px; text-align: center; }
.fm-qitem__name { flex: none; width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--av-ink-900); }
.fm-qitem__bar  { flex: 1; height: 4px; border-radius: 2px; background: var(--av-line-100); overflow: hidden; }
.fm-qitem__fill { height: 100%; width: 0%; background: var(--av-brand-primary); transition: width 120ms linear; }
.fm-qitem.is-error .fm-qitem__fill { background: var(--av-crit-500); }
.fm-qitem.is-done  .fm-qitem__fill { background: var(--av-ok-500); width: 100% !important; }
.fm-qitem__pct   { flex: none; width: 40px; text-align: right; color: var(--av-ink-500); font-variant-numeric: tabular-nums; }
.fm-qitem__err   { flex: none; color: var(--av-crit-500); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-qitem__action { flex: none; background: none; border: 0; cursor: pointer; color: var(--av-ink-500); padding: 2px 4px; }
.fm-qitem__action:hover { color: var(--av-brand-primary); }

.fm-qitem__sub {
  flex-basis: 100%; padding-left: 24px;
  color: var(--av-ink-500); font-size: 0.85em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fm-qitem__details-toggle {
  flex-basis: 100%; text-align: left; padding-left: 24px;
  background: none; border: 0; cursor: pointer;
  color: var(--av-brand-primary); font-size: 0.85em;
}
.fm-qitem__details {
  flex-basis: 100%; margin: 2px 0 0; padding-left: 40px;
  max-height: 120px; overflow-y: auto;
  color: var(--av-ink-500); font-size: 0.85em;
}
.fm-qitem__fill.is-indeterminate {
  width: 30% !important;
  animation: fm-qitem-indeterminate 1.2s ease-in-out infinite;
}
@keyframes fm-qitem-indeterminate {
  0%   { margin-left: -30%; }
  100% { margin-left: 100%; }
}

/* ---- Inline overlay (confirm / prompt / overwrite) ---- */
.fm-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35);
}
.fm-overlay__card {
  width: min(420px, 90%);
  background: var(--av-surface);
  border-radius: var(--av-radius-lg);
  box-shadow: var(--av-shadow-elevated);
  padding: 18px 20px;
}
.fm-overlay__title { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--av-ink-900); }
.fm-overlay__body  { font-size: 13px; color: var(--av-ink-700); line-height: 1.45; max-height: 240px; overflow-y: auto; }
.fm-overlay__body ul { margin: 6px 0 0; padding-left: 18px; }
.fm-overlay__inputlabel { display: block; font-size: 12px; font-weight: 500; color: var(--av-ink-900); margin-top: 10px; margin-bottom: 4px; }
.fm-overlay__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---- Empty / loading state reuses .empty from aviro-app.css ---- */

/* ---- Narrow widths: stack panes, show tab switcher ---- */
@media (max-width: 991px) {
  .fm-body { grid-template-columns: 1fr; }
  .fm-mid {
    flex-direction: row; justify-content: center;
    grid-row: 2;
  }
  #fm-body[data-visible="remote"] #fm-pane-local,
  #fm-body[data-visible="local"]  #fm-pane-remote { display: none; }
}
@media (min-width: 992px) {
  .fm-tabs { display: none; }
}
