/* =============================================================================
   CODEVIEW component — default theme
   ============================================================================= */

/* Own hard max-width + centering, independent of .content-wrap — matches
   ffs-download's/ffs-doxygen's precedent (screen_width:"full" tenants zero
   out .content-wrap's max-width). Wider than ffs-download's 960px: a file
   tree + code pane wants more room. */
.page-codeview {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  box-sizing: border-box;
}

.cv-empty,
.cv-notfound,
.cv-indexing,
.cv-search-indexing {
  display: block;
  padding: 24px 0;
  color: #777;
  font-style: italic;
}

/* ── breadcrumbs ── */
.cv-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px;
  margin: 4px 0 18px;
  font-size: 0.95em;
}

.cv-crumb {
  color: #1b52a8;
  text-decoration: none;
}
.cv-crumb:hover { text-decoration: underline; }

.cv-crumb-current {
  color: #444;
  font-weight: 600;
}

.cv-crumb-sep {
  color: #aaa;
  padding: 0 2px;
}

/* ── git metadata panel ── */
.cv-git {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  align-items: baseline;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: #f7f7f7;
  border-radius: 6px;
  font-size: 0.9em;
}

.cv-git-row {
  display: flex;
  gap: 6px;
}

.cv-git-label {
  color: #888;
}

.cv-git-value {
  color: #333;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cv-git-message {
  flex-basis: 100%;
  color: #555;
  font-style: italic;
}

/* ── search box ── */
.cv-search {
  margin-bottom: 16px;
}

.cv-search-input {
  width: 100%;
  max-width: 420px;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-sizing: border-box;
  font-size: 0.95em;
}

.cv-search-results {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cv-search-hit {
  color: #1b52a8;
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.cv-search-hit:hover { text-decoration: underline; }

/* ── repo-list landing view ──
   minmax(260px, 320px) (not 1fr) so a handful of cards on a wide screen
   keep a sane width instead of stretching edge to edge — the grid packs
   from the start instead of spreading remaining columns out. */
.cv-repo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 320px));
  justify-content: start;
  gap: 16px;
}

.cv-repo-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 96px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-left: 3px solid #888;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cv-repo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.09);
}

.cv-repo-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.cv-repo-icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.cv-repo-titlebox {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.cv-repo-name {
  display: block;
  font-weight: 600;
  color: #1b52a8;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cv-repo-name:hover { text-decoration: underline; }

.cv-repo-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 1px 7px;
  color: #666;
  background: #f1f1f1;
  border-radius: 999px;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.cv-repo-desc {
  display: block;
  color: #555;
  font-size: 0.88em;
  line-height: 1.35;
}

.cv-repo-meta {
  display: block;
  margin-top: auto;
  padding-top: 4px;
  color: #888;
  font-size: 0.85em;
}

/* ── directory tree ── */
.cv-tree {
  display: flex;
  flex-direction: column;
  border: 1px solid #eee;
  border-radius: 6px;
  overflow: hidden;
}

.cv-tree-row {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.cv-tree-row:last-child { border-bottom: none; }
.cv-tree-row:hover { background: #f7f7f7; }

.cv-tree-link {
  color: #222;
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.cv-tree-dir .cv-tree-link { font-weight: 600; }
.cv-tree-link:hover { text-decoration: underline; }

/* ── file view ── */
.cv-file-note {
  display: block;
  margin-bottom: 10px;
  color: #a35c00;
}

.cv-btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  background: #1b52a8;
  color: #fff;
  text-decoration: none;
  font-size: 0.9em;
}
.cv-btn:hover { opacity: 0.9; }

.cv-file-body {
  display: block;
}
.cv-file-body pre.cv-file {
  margin: 0;
  border-radius: 8px;
  overflow-x: auto;
}
.cv-file-body pre.cv-file code {
  font-size: 0.88em;
  line-height: 1.5;
}

/* ── "tree" view mode: persistent sidebar + content pane ── */
.cv-layout {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.cv-sidebar {
  flex: 0 0 260px;
  max-width: 260px;
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cv-sidebar-backlink {
  display: block;
  color: #1b52a8;
  text-decoration: none;
  font-size: 0.85em;
  margin-bottom: 4px;
}
.cv-sidebar-backlink:hover { text-decoration: underline; }

.cv-sidebar-scroll {
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 6px 0;
}

.cv-sbnode {
  padding: 3px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-sbnode-link {
  color: #333;
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}
.cv-sbnode--dir .cv-sbnode-link { font-weight: 600; color: #222; }
.cv-sbnode-link:hover { text-decoration: underline; }

.cv-sbnode--active {
  background: #eaf1fb;
  border-radius: 4px;
}
.cv-sbnode--active .cv-sbnode-link { color: #1b52a8; font-weight: 600; }

.cv-content {
  flex: 1 1 auto;
  min-width: 0;
}

.cv-readme {
  display: block;
  line-height: 1.6;
}

/* "tree" mode directory landing with no matching landing_files entry —
   centered both ways, never the plain listing (see buildDirContent()). */
.cv-empty-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: #999;
  font-style: italic;
  text-align: center;
}

/* Narrow viewports: stack sidebar above content instead of side-by-side. */
@media (max-width: 720px) {
  .cv-layout { flex-direction: column; }
  .cv-sidebar { position: static; max-width: none; width: 100%; }
  .cv-sidebar-scroll { max-height: 40vh; }
}

/* ── breadcrumb-row trailing controls (theme toggle + render-preview
   toggle) — one shared flush-right wrapper (.cv-breadcrumbs is already
   display:flex; margin-left:auto on THIS wrapper, not on the individual
   controls, so either one can be absent without the other losing its
   flush-right position — same "flush right in a flex row" idiom used
   elsewhere for a group-heading chevron). ── */
.cv-breadcrumb-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cv-render-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 0.85em;
  cursor: pointer;
}
.cv-render-toggle:hover { background: #f2f2f2; }
.cv-render-toggle-icon { width: 16px; height: 16px; }

.cv-render-preview {
  display: block;
  line-height: 1.6;
}

.cv-render-failed {
  color: #a33;
  font-style: italic;
}

/* ── dark/light highlight-theme toggle — sun shown while the dark theme
   is active (click for light), moon shown once light is active (click
   for dark); see CodeviewPage::buildThemeToggle() for the JS. ── */
.cv-theme-toggle {
  display: inline-flex;
  align-items: center;
  color: #666;
  cursor: pointer;
  padding: 2px;
}
.cv-theme-toggle:hover { color: #333; }
.cv-theme-toggle .cv-theme-icon-moon { display: none; }
.cv-theme-toggle[data-theme="light"] .cv-theme-icon-sun  { display: none; }
.cv-theme-toggle[data-theme="light"] .cv-theme-icon-moon { display: inline; }

/* ── built-in hex-view fallback ── */
.cv-hex {
  display: block;
  overflow-x: auto;
  font-size: 0.82em;
  line-height: 1.5;
  white-space: pre;
}

/* ── image file view: Preview / Hex / Info toggles (reuses
   .cv-render-toggle/.cv-render-toggle-icon for the buttons themselves —
   same look as the generic render-preview toggle, no accent-color
   dependency so one block covers all 3 themes). ── */
.cv-image-preview {
  max-width: 100%;
  height: auto;
  display: block;
}

.cv-image-info {
  border-collapse: collapse;
  font-size: 0.88em;
}
.cv-image-info caption {
  text-align: left;
  font-weight: 600;
  padding: 4px 8px;
  color: #666;
}
.cv-image-info td {
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
}
.cv-image-info td:first-child {
  color: #666;
  white-space: nowrap;
}
