/* ============================================================
   assets/filebrowser.css — the shared file browser (filebrowser.js)
   ------------------------------------------------------------
   Namespaced .fb-* only. Controls are stock .btn-* / .mod-tb primitives from
   design-system.css and app.css — nothing here re-declares a primitive's
   geometry. Selection visuals (.pt-sel, .pt-selbox, .pt-selbar) come from
   app.css so grids, tables and both file surfaces stay identical.
   ============================================================ */

.fb { display: flex; flex-direction: column; min-height: 0; }
.fb-fail, .fb-loading { padding: 40px 0; text-align: center; color: var(--ink-faint); font-size: 13px; }
.fb-loading i { animation: spin 1s linear infinite; }

/* ── Address bar (where am I?) ───────────────────────────── */
.fb-crumbs { margin: 0 0 12px; }
.fb-path {
  display: flex; align-items: center; gap: 1px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin;
  background: var(--bg2); border: 1px solid var(--bd); border-radius: 9px;
  padding: 5px 10px; min-height: var(--ctl-h);
}
.fb-path-ico { color: var(--accent); font-size: 17px; flex: 0 0 auto; margin-right: 7px; }
.fb-crumb {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  background: none; border: none; cursor: pointer;
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap;
}
.fb-crumb:hover { background: var(--white); color: var(--accent); }
/* The folder you are actually standing in — reads as a place, not a link. */
.fb-crumb-cur { color: var(--ink); font-weight: 750; cursor: default; }
.fb-crumb-cur:hover { background: none; color: var(--ink); }
.fb-crumb-sep { color: var(--ink-faint); font-size: 14px; flex: 0 0 auto; }
.fb-path-depth {
  flex: 0 0 auto; margin-left: auto; padding-left: 12px;
  font-size: 11px; font-weight: 650; color: var(--ink-faint); white-space: nowrap;
}
@media (max-width: 600px) { .fb-path-depth { display: none; } }

/* ── Layout: main + optional details pane ────────────────── */
.fb-cols { display: flex; gap: 14px; align-items: flex-start; min-height: 0; }
.fb-main { flex: 1; min-width: 0; outline: none; }
.fb-main.fb-dropzone { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 10px; }
.fb-details {
  flex: 0 0 244px; width: 244px; align-self: stretch;
  border: 1px solid var(--bd); border-radius: 10px; background: var(--bg2);
  padding: 14px; position: sticky; top: 10px;
}
@media (max-width: 820px) { .fb-details { display: none; } }

.fb-det-thumb { width: 100%; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; background: var(--white); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.fb-det-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fb-det-ico i { font-size: 46px; color: var(--ink-faint); }
.fb-det-hd { font-size: 13px; font-weight: 700; color: var(--ink); word-break: break-word; margin-bottom: 10px; }
.fb-det-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--bd); font-size: 12px; }
.fb-det-row span { color: var(--ink-soft); }
.fb-det-row b { color: var(--ink); font-weight: 650; text-align: right; word-break: break-word; }
.fb-det-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.fb-det-empty { text-align: center; color: var(--ink-faint); padding: 18px 4px; }
.fb-det-empty i { font-size: 26px; }
.fb-det-empty p { font-size: 12px; margin: 8px 0 0; }
.fb-det-hint { color: var(--ink-faint); }

/* ── Toolbar bits ────────────────────────────────────────── */
/* The project dropdown (files.js toolbarExtra). Height from --ctl-h-sm so it
   lines up with the icon buttons beside it. The Sort dropdown that used to
   share this class is gone — sorting is on the column headings now. */
.fb-sel {
  height: var(--ctl-h-sm); max-width: 170px;
  padding: 0 8px; border: 1px solid var(--bd); border-radius: 7px;
  background: var(--white); color: var(--ink); font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.fb-sel:hover { border-color: var(--accent); }
/* ★ Geometry comes from the .btn-icon primitive in the markup — this only sets
   colour and state, per the design-system rule. It previously declared
   width/height itself using `--ctl-sm`, A TOKEN THAT DOES NOT EXIST (the real
   one is --ctl-h-sm). An undefined custom property makes the declaration
   invalid at computed-value time, so both fell back to `auto` and every view /
   sort / back / up button shrank to the bare glyph. */
.fb-tgl { border: 1px solid var(--bd); border-radius: 7px; background: var(--white); color: var(--ink-soft); }
.fb-tgl:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--white); }
.fb-tgl.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.fb-tgl:disabled { opacity: .4; cursor: default; }

/* ── Icons + List views ──────────────────────────────────── */
.fb-grid { display: grid; gap: 10px; }
.fb-view-icons .fb-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
/* List view renders a table, not cards — the compact card list that used to
   live here was the redundant third view and went with it. */

/* ★ -webkit-touch-callout is load-bearing on iPad, not cosmetic. The touch
   drag shim (assets/touch-dnd.js) starts a drag on a brief press-hold — which
   is exactly when iOS raises its own selection/callout bubble on an element
   that hasn't opted out. The callout steals the gesture and the drag never
   begins. Every surface that drags successfully on iPad sets this (vmb.css:10,
   leadership.css:109, operations.css:208); this one did not, which is why
   dragging worked with a mouse and not with a finger. */
.fb-item, .fb-row, .fb-rail-btn, .fb-crumb {
  -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; user-select: none;
}
.fb-item { position: relative; border: 1px solid transparent; border-radius: 9px; cursor: pointer; }
.fb-item[draggable="true"], .fb-row[draggable="true"] { cursor: grab; }
.fb-item[draggable="true"]:active, .fb-row[draggable="true"]:active { cursor: grabbing; }
/* An <img> inside a draggable card has its own iOS press-hold behaviour. */
.fb-ico img { -webkit-touch-callout: none; pointer-events: none; }
.fb-item:hover { background: var(--bg2); }
.fb-item.pt-sel { background: var(--accent-bg); border-color: var(--accent); }
.fb-item.fb-cursor { outline: 1px dashed var(--accent); outline-offset: 1px; }
.fb-item.fb-dragging { opacity: .45; }
.fb-item.fb-drop-hi { background: var(--accent-bg); border-color: var(--accent); border-style: dashed; }

.fb-view-icons .fb-item { padding: 12px 8px 10px; text-align: center; }
.fb-view-icons .fb-ico { height: 62px; display: flex; align-items: center; justify-content: center; margin-bottom: 7px; }
.fb-view-icons .fb-ico i { font-size: 40px; color: var(--ink-faint); }
.fb-view-icons .fb-folder .fb-ico i { color: var(--accent); }
.fb-view-icons .fb-ico img { max-width: 100%; max-height: 62px; border-radius: 5px; object-fit: cover; }
.fb-view-icons .fb-nm { font-size: 12px; color: var(--ink); word-break: break-word; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.fb-view-icons .fb-sub { font-size: 10.5px; color: var(--ink-faint); margin-top: 3px; }


/* ── Details (table) view ────────────────────────────────── */
.fb-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fb-table th {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--bd);
  color: var(--ink-faint); font-weight: 700; font-size: 10px;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.fb-th { cursor: pointer; user-select: none; }
.fb-th:hover { color: var(--ink); }
.fb-th.sorted { color: var(--accent); }
.fb-table td { padding: 6px 10px; border-bottom: 1px solid var(--bd); color: var(--ink); vertical-align: middle; }
.fb-row { cursor: pointer; }
.fb-row:hover td { background: var(--bg2); }
.fb-row.pt-sel td { background: var(--accent-bg); }
.fb-row.fb-cursor td { box-shadow: inset 0 -1px 0 var(--accent); }
.fb-row.fb-dragging { opacity: .45; }
.fb-row.fb-drop-hi td { background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.fb-td-sel { width: 32px; }
.fb-td-ic  { width: 28px; }
.fb-td-ic i { font-size: 17px; color: var(--ink-faint); }
.fb-folder .fb-td-ic i { color: var(--accent); }
.fb-td-nm { font-weight: 600; word-break: break-word; }
.fb-td-sz, .fb-td-dt { white-space: nowrap; color: var(--ink-soft); }

.fb-rowbox {
  /* 20px was under-sized even for a mouse; the touch block below adds reach. */
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: var(--white); border: 1.5px solid var(--bd);
  color: transparent; cursor: pointer; opacity: .35; transition: opacity .12s, background .12s;
}
.fb-rowbox i { font-size: 14px; }
.fb-row:hover .fb-rowbox { opacity: 1; }
.fb-rowbox.on { opacity: 1; background: var(--accent); border-color: var(--accent); color: #fff; }
.pt-selmode .fb-rowbox { opacity: 1; }
@media (hover: none) { .fb-rowbox { opacity: 1; } }

/* ── Inline rename ───────────────────────────────────────── */
.fb-rename {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--white); border: 1px solid var(--accent); border-radius: 5px;
  padding: 2px 5px;
}
.fb-view-icons .fb-rename { text-align: center; }

/* ── Context menu ────────────────────────────────────────── */
.fb-ctx {
  position: fixed; z-index: 9000; min-width: 186px;
  background: var(--white); border: 1px solid var(--bd); border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .17); padding: 5px;
}
.fb-ctx-i {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--ink); font-size: 12.5px; padding: 7px 9px; border-radius: 6px;
}
.fb-ctx-i:hover { background: var(--accent-bg); }
.fb-ctx-i i { color: var(--ink-soft); font-size: 15px; }
.fb-ctx-i.danger { color: #DC2626; }
.fb-ctx-i.danger i { color: #DC2626; }
.fb-ctx-i.danger:hover { background: #FEE2E2; }
.fb-ctx-sep { height: 1px; background: var(--bd); margin: 4px 2px; }

/* ── Empty state ─────────────────────────────────────────── */
.fb-empty { text-align: center; padding: 46px 16px; color: var(--ink-faint); }
.fb-empty i { font-size: 38px; }
.fb-empty h3 { font-size: 15px; color: var(--ink); margin: 10px 0 4px; }
.fb-empty p { font-size: 12.5px; margin: 0; }

/* ── Navigation rail (the tree pane) ─────────────────────── */
.fb-rail {
  flex: 0 0 208px; width: 208px; align-self: stretch;
  border-right: 1px solid var(--bd); padding-right: 10px;
}
@media (max-width: 720px) { .fb-rail { display: none; } }
.fb-rail-row { display: flex; align-items: center; gap: 4px; border-radius: 7px; }
.fb-rail-row:hover { background: var(--bg2); }
.fb-rail-row.on { background: var(--accent-bg); }
.fb-rail-row.on .fb-rail-btn { color: var(--accent); font-weight: 700; }
.fb-rail-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px;
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--ink-soft); font-size: 12px; padding: 6px 6px; border-radius: 7px;
}
.fb-rail-btn i { color: var(--accent); flex: 0 0 auto; font-size: 15px; }
.fb-rail-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-rail-n { font-size: 10.5px; color: var(--ink-faint); padding-right: 6px; flex: 0 0 auto; }
.fb-rail-row.fb-drop-hi { background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent); }

/* ── Pagination footer ───────────────────────────────────── */
.fb-more { display: flex; justify-content: center; padding: 16px 0 4px; }
.fb-count { font-size: 11.5px; color: var(--ink-faint); }

/* ── Touch sizing ────────────────────────────────────────────
   The browser's own controls (not design-system primitives) reach a real
   target the same way: grow the hit region, leave the visual box alone. */
@media (hover: none) and (pointer: coarse) {
  .fb-rowbox { position: relative; }
  .fb-rowbox::after,
  .fb-crumb::after,
  .fb-rail-btn::after,
  .files-fx-ren::after, .files-fx-del::after, .files-fvis::after {
    content: ''; position: absolute; inset: -10px;
  }
  .fb-crumb, .fb-rail-btn, .files-fx-ren, .files-fx-del, .files-fvis { position: relative; }
  /* Row height in Details view — a 6px cell is a hard thing to hit precisely. */
  .fb-table td { padding-top: 10px; padding-bottom: 10px; }
  .fb-ctx-i { padding: 11px 12px; font-size: 13.5px; }
}

/* A sort key that isn't the active one — listed so you can pick it, but not
   competing with the one that's actually in force. */
.fb-ctx-i.muted i { color: var(--ink-faint); opacity: .5; }
.fb-ctx-i.muted { color: var(--ink-soft); }
