/* Listarr — dark utility UI in the *arr family.
   One accent: IMDb chart yellow. Numbers are mono; status is color-coded
   everywhere (green added / blue requested / red missing). */

:root {
  --bg: #101418;
  --surface: #171d24;
  --raised: #1e2630;
  --line: #2a333f;
  --text: #e7edf3;
  --dim: #8fa0b0;
  --accent: #f5c518;
  --green: #4cd07d;
  --blue: #5aa7ff;
  --red: #ff6b5e;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

/* ── top bar ─────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  user-select: none;
}
.brand span { color: var(--accent); }

.topbar-status {
  flex: 1;
  font-size: 13px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-status .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 7px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  .topbar-status .dot { animation: none; }
}

.topbar-actions { display: flex; gap: 8px; }

/* ── buttons & inputs ────────────────────────────────────── */

.btn {
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.btn:hover { border-color: var(--dim); }
.btn:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #14181d;
  font-weight: 600;
}
.btn-accent:hover { filter: brightness(1.08); }
.btn-icon { padding: 7px 10px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-small { padding: 4px 10px; font-size: 12.5px; }

input, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  width: 100%;
}

/* ── list cards (home) ───────────────────────────────────── */

main { padding: 24px 20px 60px; max-width: 1500px; margin: 0 auto; }

.section-label {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 18px 2px 10px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.disabled { opacity: .55; }

.card-head { display: flex; justify-content: space-between; gap: 10px; }
.card-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.card h3 { font-size: 16.5px; font-weight: 600; margin-top: 2px; cursor: pointer; }
.card h3:hover { text-decoration: underline; }
.card-del {
  background: none; border: none; color: var(--dim);
  font-size: 15px; cursor: pointer; align-self: flex-start;
}
.card-del:hover { color: var(--red); }

.counts { display: flex; gap: 18px; font-family: var(--mono); }
.counts b { font-size: 19px; font-weight: 600; display: block; }
.counts span { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.c-added b { color: var(--green); }
.c-requested b { color: var(--blue); }
.c-missing b { color: var(--red); }

/* the signature: one proportional bar = the list's whole state */
.statusbar {
  display: flex;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--raised);
}
.statusbar i { display: block; }
.statusbar .added { background: var(--green); }
.statusbar .requested { background: var(--blue); }
.statusbar .missing { background: var(--red); }

.card-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}
.card-foot .spacer { flex: 1; }
.card-meta { font-size: 12px; color: var(--dim); }
.card-meta.err { color: var(--red); }

/* toggle switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.toggle input { position: absolute; opacity: 0; width: 0; }
.toggle .track {
  width: 30px; height: 17px;
  border-radius: 9px;
  background: var(--raised);
  border: 1px solid var(--line);
  position: relative;
  transition: background .15s;
  flex: none;
}
.toggle .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform .15s, background .15s;
}
.toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(13px); background: #14181d; }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── list detail ─────────────────────────────────────────── */

.detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-head h2 { font-size: 21px; }
.back {
  background: none; border: none;
  color: var(--dim); font-size: 20px; cursor: pointer; padding: 4px;
}
.back:hover { color: var(--text); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 999px;
  padding: 4px 13px;
  font-size: 12.5px;
  font-family: var(--mono);
  cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #14181d; font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.poster-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.poster-wrap { position: relative; aspect-ratio: 2/3; background: var(--raised); }
.poster-wrap img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.poster-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; text-align: center;
  color: var(--dim); font-size: 13px;
}
.rank {
  position: absolute; top: 6px; left: 6px;
  background: var(--accent); color: #14181d;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  border-radius: 4px; padding: 1px 6px;
}
.pill {
  position: absolute; bottom: 6px; left: 6px;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  border-radius: 4px; padding: 2px 7px;
  background: rgba(16,20,24,.85);
}
.pill.added { color: var(--green); }
.pill.requested { color: var(--blue); }
.pill.missing { color: var(--red); }
.pill.unknown { color: var(--dim); }

.poster-body { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.poster-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.poster-year { font-family: var(--mono); font-size: 11.5px; color: var(--dim); }
.poster-body .btn { margin-top: auto; }

.empty {
  color: var(--dim);
  text-align: center;
  padding: 70px 20px;
  font-size: 14px;
}

/* ── modals ──────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8,10,13,.7);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 460px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h2 { font-size: 17px; }
.modal label { font-size: 12.5px; color: var(--dim); display: flex; flex-direction: column; gap: 5px; }
.check-row { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-size: 14px !important; }
.check-row input { width: auto; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid label:last-child { grid-column: 1 / -1; }
.hint { font-size: 12.5px; color: var(--dim); }
.error { font-size: 13px; color: var(--red); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ── auth & multi-user ───────────────────────────────────── */

.login-backdrop {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 18vh 16px 16px;
  z-index: 100;
}
.login-box { max-width: 360px; }

.quota-badge {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  align-self: center;
}
.quota-badge.warn { color: var(--red); border-color: var(--red); }

.table-wrap { overflow-x: auto; }
.users-table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.users-table th, .users-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  white-space: nowrap;
}
.users-table th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
}
.users-table tr:last-child td { border-bottom: none; }
.users-table input { width: 84px; }
.users-table .mono { font-family: var(--mono); color: var(--dim); }

.tag-admin {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar-status { display: none; }
  main { padding: 16px 12px 50px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
