/* Goodgallery admin panel (/_admin/). Same dark palette as the gallery.
   One container level: the card. Lists inside it are separated by hairlines,
   not boxed again. Buttons come in three weights: primary (one per screen at
   most), default (bordered), and quiet (text only) for maintenance and
   per-row actions. Red is kept for things that cannot be undone. */

:root {
  --bg: #0a0a0a;
  --surface: #121212;
  --surface-raised: #1c1c1c;
  --fg: #e2e2e2;
  --muted: #8d8d8d;
  --border: #262626;
  --line: #1e1e1e;
  --control-border: #333333;
  --accent: #ffffff;
  --ok: #8fd18f;
  --busy: #e6c463;
  --danger: #ff8080;
  --danger-border: #7a3434;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Components below set display; the hidden attribute must still win. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }

h1 { font-size: 26px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; margin: 0; overflow-wrap: anywhere; }

/* Section labels: small, quiet, out of the way of the content. */
h2 {
  display: inline;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.count { font-weight: 400; letter-spacing: 0; text-transform: none; margin-left: 4px; }

main { max-width: 860px; margin: 0 auto; padding: 6px 20px 72px; }

:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.35); outline-offset: 2px; }

/* ---------- header: brand, build queue, links ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 10px 20px;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand-group { display: flex; align-items: baseline; gap: 8px; }
.brand { font-size: 15px; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-sub { color: var(--muted); font-size: 14px; }
.brand-version { color: var(--muted); font-size: 12px; }

.queue { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; flex: 1 1 auto; }
.queue-status { margin: 0 8px 0 0; font-size: 13px; color: var(--muted); }
.queue-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: 1px;
}
.queue-status.idle::before { background: var(--ok); }
.queue-status.busy::before { background: var(--busy); }
.queue-status.busy { color: var(--fg); }

.topbar-links { margin-left: auto; display: flex; gap: 16px; font-size: 13px; }
.topbar-links a { color: var(--muted); }
.topbar-links a:hover { color: var(--fg); }

/* ---------- notice: a toast that does not push the page around ---------- */

.notice {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(640px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--control-border);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  background: #202020;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  overflow-wrap: anywhere;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.notice.is-error { border-left-color: var(--danger); color: var(--danger); }
.notice-close { flex: none; font-size: 16px; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { display: block; }

details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
details[open] > summary::before { transform: rotate(45deg); }
details[open] > summary { margin-bottom: 10px; }

/* A troubleshooting step is kept out of the routine actions: collapsed, explained, red. */
.troubleshooting { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.troubleshooting > summary { font-size: 13px; color: var(--muted); }
.troubleshooting > summary:hover { color: var(--fg); }
.troubleshooting p { color: var(--muted); font-size: 13px; margin: 0 0 12px; max-width: 64ch; }
.troubleshooting #rescanTreeBlock { margin-bottom: 20px; }
/* The recursive rebuild sits one more disclosure down, and is red before it is opened. */
.nuclear { margin-top: 20px; }
.nuclear > summary { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; color: var(--danger); }
.nuclear p { margin-top: 12px; }

#signIn { max-width: 440px; margin: 12vh auto 0; }
#signIn h1 { font-size: 22px; margin-bottom: 6px; }
#signIn p { color: var(--muted); margin: 0 0 14px; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 2px; overflow-wrap: anywhere; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--fg); }
.breadcrumb .separator { margin: 0 6px; }

.facts { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.badge {
  display: inline-block;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--fg);
}
.status-built { color: var(--ok); }
.status-busy { color: var(--busy); }
.status-none { color: var(--muted); }
.status-error { color: var(--danger); }

.warning {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--busy);
  border-radius: 0 6px 6px 0;
  background: rgba(230, 196, 99, 0.06);
  font-size: 13px;
}

.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.command {
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 12px 0;
  user-select: all;
}

/* ---------- controls ---------- */

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.push-right { margin-left: auto; }

button, .button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  background: var(--surface-raised);
  border: 1px solid var(--control-border);
  border-radius: 6px;
  padding: 0 12px;
  height: 32px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { border-color: #555; background: #232323; color: var(--accent); text-decoration: none; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--fg); color: #000; border-color: var(--fg); }
button.primary:hover:not(:disabled) { background: #fff; border-color: #fff; }
button.quiet { background: transparent; border-color: transparent; color: var(--muted); font-weight: 400; }
button.quiet:hover:not(:disabled) { background: var(--surface-raised); border-color: transparent; color: var(--fg); }
button.danger { color: var(--danger); border-color: var(--danger-border); }
button.danger:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); background: rgba(255, 128, 128, 0.08); }
button.quiet.danger { color: var(--muted); border-color: transparent; }
button.quiet.danger:hover:not(:disabled) { color: var(--danger); border-color: transparent; background: rgba(255, 128, 128, 0.08); }
button.small { height: 28px; padding: 0 10px; font-size: 12px; }

input[type=text], input[type=search] {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--control-border);
  border-radius: 6px;
  padding: 0 10px;
  height: 32px;
  min-width: 0;
}
input[type=text]:focus, input[type=search]:focus { outline: none; border-color: #666; }
input[type=search] { width: 100%; margin-bottom: 6px; }
input[type=checkbox] { width: 14px; height: 14px; margin: 0; accent-color: var(--fg); }

.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1 1 180px; }

/* ---------- row lists (subfolders, images, trash, uploads, sessions) ---------- */

.rows { list-style: none; margin: 0; padding: 0; }
.rows:empty { display: none; }
.rows.scroll { max-height: 420px; overflow-y: auto; }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 7px 8px;
  border-top: 1px solid var(--line);
  border-radius: 6px;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-raised); }
.row.empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.row.empty:hover { background: none; }
.row-name {
  flex: 1 1 200px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.row-buttons { display: flex; gap: 4px; }

.subfolder-row .row-name { font-weight: 500; }
.subfolder-row.is-hidden .row-name { color: var(--muted); font-style: italic; }
.hidden-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }

.upload-row progress { flex: 1 1 100%; height: 3px; accent-color: var(--ok); margin: 0 0 2px; }
.upload-row.done progress { display: none; }
.upload-row.failed .row-meta { color: var(--danger); }
.upload-row.retrying .row-meta { color: var(--busy); }
.uploads { margin-top: 10px; max-height: 260px; overflow-y: auto; }

.drop-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  padding: 14px;
  border: 1px dashed #3a3a3a;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}
body.is-dragging .drop-zone { border-color: var(--fg); color: var(--fg); background: var(--surface-raised); }

/* ---------- dialog ---------- */

dialog {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  padding: 20px;
  width: min(560px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { display: block; margin-bottom: 8px; }
dialog p { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
dialog input { flex: 1 1 200px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }

/* ---------- phone ---------- */

@media (max-width: 600px) {
  .topbar { position: static; padding: 10px 14px; gap: 8px 16px; }
  .queue { order: 3; flex-basis: 100%; }
  .queue-status { flex-basis: 100%; }
  main { padding: 4px 12px 56px; }
  .card { padding: 14px; }
  .notice { bottom: 12px; }
  .push-right { margin-left: 0; }
  .subfolder-row .row-name, .trash-row .row-name, .session-row .row-name { flex-basis: 100%; }
  .subfolder-row .row-meta { flex: 1; }
}
