/* Repositories tab. Uses the colour tokens from style.css. */

.repo-root { flex: 1; min-width: 0; height: 100%; overflow-y: auto; background: var(--bg1); }
.repo-wrap { width: min(980px, 100%); margin: 0 auto; padding: 24px 20px 72px; }
.repo-wrap h2 { font-size: 20px; }
.repo-note { margin: 28px 0; text-align: center; color: var(--muted); }
.repo-note .secondary-btn { margin-top: 8px; }

/* header + list navigation */
.repo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.repo-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.repo-nav a {
  padding: 8px 12px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s;
}
.repo-nav a:hover { color: var(--text); }
.repo-nav a.active { color: var(--text); border-bottom-color: var(--accent); }

.repo-bar { display: flex; gap: 8px; margin-bottom: 4px; }
.repo-search, .repo-sort {
  min-height: 36px; padding: 5px 12px; background: var(--bg0); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
}
.repo-search { flex: 1; min-width: 0; }
.repo-search:focus, .repo-sort:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 101, 242, .3); }
.repo-sort { cursor: pointer; }

/* list rows */
.repo-row { display: flex; gap: 12px; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--line); }
.repo-row-main { flex: 1; min-width: 0; }
.repo-row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.repo-link { color: #7c89ff; text-decoration: none; font-size: 16px; overflow-wrap: anywhere; }
.repo-link:hover strong { text-decoration: underline; }
.repo-owner { font-weight: 400; color: var(--muted); }
.repo-link .repo-owner { color: #7c89ff; opacity: .8; }
.repo-link strong { font-weight: 600; }
.repo-desc { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.repo-meta { margin-top: 8px; display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.repo-more { display: block; margin: 20px auto 0; }

.repo-badge {
  font-size: 12px; font-weight: 500; line-height: 18px; padding: 0 8px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
}
.repo-badge.private { color: #d29922; border-color: rgba(210, 153, 34, .5); }

/* icons */
.repo-icon {
  flex: none; width: 36px; height: 36px; border-radius: 8px; object-fit: cover;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff; user-select: none;
  border: 1px solid rgba(240, 246, 252, .1);
}
.repo-icon.lg { width: 56px; height: 56px; font-size: 24px; border-radius: 12px; }

/* star button */
.star-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 0 0 10px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; font-weight: 600;
  transition: background .15s, border-color .15s;
}
.star-btn:hover:not(:disabled) { background: #2b323b; border-color: #484f58; }
.star-btn:disabled { opacity: .6; cursor: default; }
.star-btn.on svg { color: #e3b341; }
.star-btn .star-count { padding: 0 10px; margin-left: 2px; height: 100%; display: grid; place-items: center; border-left: 1px solid var(--line); color: var(--muted); }

/* detail page */
.repo-back { display: inline-block; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-size: 13px; }
.repo-back:hover { color: var(--text); }
.repo-title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.repo-title { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; font-weight: 400; overflow-wrap: anywhere; }
.repo-title strong { font-weight: 700; }
.repo-actions { display: flex; gap: 8px; align-items: center; }
.repo-actions .secondary-btn { min-height: 30px; padding: 4px 12px; }

.repo-cols { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; margin-top: 20px; align-items: start; }
.repo-code { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.repo-code-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 12px 8px 16px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.repo-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.repo-empty p { margin: 0 0 6px; }
.repo-empty-title { color: var(--text); font-size: 16px; font-weight: 600; }
.repo-about h3 { margin: 0 0 8px; font-size: 16px; }
.repo-about p { margin: 0 0 16px; overflow-wrap: anywhere; }
.repo-about .muted { color: var(--muted); }
.repo-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.repo-facts dt { color: var(--muted); }
.repo-facts dd { margin: 0; overflow-wrap: anywhere; }

/* dialog */
#repoDialog { width: min(520px, 94vw); }
#repoDialog.scrolly { overflow-y: auto; }
#repoDialog fieldset { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
#repoDialog legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio + .radio { margin-top: 8px; }
.radio:has(input:checked) { border-color: var(--accent); background: rgba(88, 101, 242, .08); }
.radio input { margin: 4px 0 0; accent-color: var(--accent); }
.radio strong { display: block; }
.radio small { display: block; color: var(--muted); font-size: 12px; }
.icon-pick { display: flex; gap: 14px; align-items: center; }
.icon-pick .grow { flex: 1; min-width: 0; }
.icon-btns { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.icon-pick small { color: var(--muted); font-size: 12px; }
.repo-danger { border-top: 1px solid var(--line); }

/* file explorer */
.repo-code { position: relative; }
.repo-code.drop::after {
  content: "Drop to upload here"; position: absolute; inset: 0; z-index: 3; display: grid; place-items: center;
  background: rgba(13, 17, 23, .88); border: 2px dashed var(--accent); border-radius: 8px; font-weight: 600; pointer-events: none;
}
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.crumbs a { color: #7c89ff; text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }
.crumbs a.here { color: var(--text); }
.crumbs .sep { color: var(--muted); }
.add-btn { min-height: 30px; padding: 4px 12px; flex: none; }
.linkbtn { display: inline-block; text-decoration: none; color: var(--text); }

.file-list { display: block; }
.file-row {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) 72px 110px 32px; align-items: center; gap: 12px;
  min-height: 40px; padding: 4px 8px 4px 16px; border-top: 1px solid var(--line); color: var(--muted);
}
.file-row:first-child { border-top: 0; }
.file-row:hover { background: rgba(177, 186, 196, .06); }
.file-row.up { grid-template-columns: 20px minmax(0, 1fr); }
.file-name { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { color: #7c89ff; text-decoration: underline; }
.file-size, .file-when { font-size: 12px; white-space: nowrap; }
.file-size { text-align: right; }
.file-more { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.file-more:hover, .file-more:focus-visible { background: var(--bg3); color: var(--text); }

.file-menu {
  position: fixed; z-index: 60; min-width: 176px; padding: 5px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(1, 4, 9, .6);
}
.file-menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 5px; }
.file-menu button:hover, .file-menu button:focus-visible { background: var(--accent); color: #fff; outline: none; }
.file-menu button.danger { color: var(--red); }
.file-menu button.danger:hover, .file-menu button.danger:focus-visible { background: var(--red); color: #fff; }
.file-menu hr { border: 0; height: 1px; background: var(--line); margin: 5px 4px; }

.upload-tray { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg0); font-size: 13px; }
.tray-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tray-head .ghost-btn { padding: 2px 8px; }
.tray-bar { height: 4px; border-radius: 2px; background: var(--bg3); overflow: hidden; }
.tray-bar i { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.tray-errors { margin: 8px 0 0; padding-left: 18px; color: var(--red); overflow-wrap: anywhere; }

#repoDialog.wide { width: min(760px, 94vw); }
.code-area {
  width: 100%; min-height: 220px; padding: 10px 12px; resize: vertical; tab-size: 4;
  background: var(--bg0); border: 1px solid var(--line); border-radius: 6px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.code-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 101, 242, .3); }

@media (max-width: 760px) {
  .file-row { grid-template-columns: 20px minmax(0, 1fr) 64px 32px; }
  .file-when { display: none; }
  .repo-wrap { padding: 16px 12px 64px; }
  .repo-cols { grid-template-columns: minmax(0, 1fr); }
  .repo-about { order: -1; }
  .repo-row { flex-wrap: wrap; }
  .repo-row .star-btn { margin-left: 48px; }
  .repo-actions { width: 100%; }
  .repo-bar { flex-wrap: wrap; }
  .repo-sort { flex: 1; }
}
