/*
 * Shared dashboard styles. Loaded by every page under /admin/<page>/index.html.
 * Verbatim copy of the inline styles in /index.html (the legacy monolithic SPA)
 * — keeping them in lockstep until that file is retired in step 6 of the
 * per-page migration in next-steps.md. Once /index.html is removed, this file
 * becomes the sole source of truth.
 *
 * Cache-Control for this file is set in Program.cs to public, max-age=300,
 * must-revalidate so it's reused across page navigations but still updates
 * within ~5 minutes of a deploy.
 */

:root {
  --bg: #0d1117; --panel: #161b22; --border: #30363d;
  --fg: #e6edf3; --muted: #8b949e; --accent: #58a6ff;
  --good: #3fb950; --warn: #d29922; --bad: #f85149;
  --sidebar-w: 220px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--fg);
       display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Embedded mode: page is rendered inside an <iframe> on /admin/catalogue-health/.
   Suppress the sidebar/banners/topbar (already shown by the parent) and collapse
   the grid so the iframe shows ONLY the page content. Activated by chrome.js
   when ?embed=1 is set or window.top !== window.self. */
body[data-embedded="1"] { display: block; min-height: auto; }
body[data-embedded="1"] aside,
body[data-embedded="1"] #chrome-sidebar,
body[data-embedded="1"] #chrome-banners,
body[data-embedded="1"] .topbar,
body[data-embedded="1"] .menu-toggle { display: none !important; }
body[data-embedded="1"] main { padding: 12px 16px; }
/* sidebar */
aside { background: var(--panel); border-right: 1px solid var(--border);
        display: flex; flex-direction: column; gap: 4px; padding: 14px 0; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 16px 16px;
         border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), #8957e5);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-family: ui-monospace, monospace; font-size: 16px;
  box-shadow: 0 2px 8px rgba(88,166,255,0.3);
}
.brand .name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.brand .name .sub { color: var(--muted); font-size: 11px; font-weight: 400; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 16px;
        color: var(--muted); text-decoration: none; font-size: 13px;
        border-left: 2px solid transparent; cursor: pointer; }
nav a:hover { color: var(--fg); background: rgba(255,255,255,0.03); }
nav a.active { color: var(--fg); background: rgba(88,166,255,0.08);
               border-left-color: var(--accent); }
nav a .icon { width: 16px; text-align: center; opacity: 0.8; }
nav .spacer { flex: 1; }
nav .who { padding: 12px 16px; border-top: 1px solid var(--border);
           color: var(--muted); font-size: 12px; }
nav .who b { color: var(--fg); }
nav .who .role { background: rgba(88,166,255,0.15); color: var(--accent);
                  border: 1px solid rgba(88,166,255,0.3); padding: 1px 7px;
                  border-radius: 999px; font-size: 11px; margin-left: 4px; }

/* main */
main { padding: 16px 24px; }
.topbar { display: flex; justify-content: space-between; align-items: center;
          margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.topbar .meta { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }

.page { display: none; }
.page.active { display: block; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
         padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; text-transform: uppercase;
            letter-spacing: 0.05em; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.now { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: start; }
.now .art { width: 96px; height: 96px; border-radius: 6px; background: var(--bg);
            border: 1px solid var(--border); object-fit: cover; }
.now .info { display: flex; flex-direction: column; gap: 6px; }
.now .title { font-size: 22px; font-weight: 600; }
.now .artist { font-size: 16px; color: var(--muted); }
.now .album { font-size: 13px; color: var(--muted); }
.now .none { color: var(--muted); font-style: italic; grid-column: 1 / -1; }

.links a, .editbtn, .iconbtn { display: inline-block; padding: 2px 8px; border-radius: 4px;
           font-size: 11px; text-decoration: none; margin-right: 4px;
           border: 1px solid var(--border); color: var(--accent);
           background: rgba(88,166,255,0.08); cursor: pointer; }
.links a:hover, .editbtn:hover, .iconbtn:hover { background: rgba(88,166,255,0.18); }
.iconbtn.danger { color: var(--bad); border-color: rgba(248,81,73,0.4);
                  background: rgba(248,81,73,0.08); }
.iconbtn.danger:hover { background: rgba(248,81,73,0.18); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
         font-family: ui-monospace, monospace; background: rgba(88, 166, 255, 0.15);
         color: var(--accent); border: 1px solid rgba(88, 166, 255, 0.3); }
.badge.active { background: rgba(63, 185, 80, 0.18); color: var(--good);
                border-color: rgba(63, 185, 80, 0.45); }
.badge.inactive { background: rgba(139, 148, 158, 0.15); color: var(--muted);
                  border-color: var(--border); }

.meter { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden;
         border: 1px solid var(--border); margin-top: 8px; }
.meter > div { height: 100%; background: linear-gradient(90deg, var(--good), var(--accent));
               transition: width 0.3s ease; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border);
         vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase;
     letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
td.mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
td .thumb { width: 36px; height: 36px; border-radius: 4px; object-fit: cover;
            border: 1px solid var(--border); background: var(--bg); display: block; }
td .thumb.ph { display: inline-block; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
        padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: 11px; text-transform: uppercase;
                letter-spacing: 0.05em; margin-bottom: 6px; }
.stat .value { font-size: 22px; font-weight: 600; color: var(--fg);
                font-family: ui-monospace, monospace; }
.stat .sub { color: var(--muted); font-size: 11px; margin-top: 4px; }
/* metrics charts */
.charts { display: grid; grid-template-columns: 1fr; gap: 16px; }
.chart-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.chart-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.chart-host { width: 100%; height: 180px; position: relative; }
.chart-host svg { width: 100%; height: 100%; display: block; }
.chart-host .axis { stroke: var(--border); stroke-width: 1; }
.chart-host .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.6; }
.chart-host .bar { fill: var(--accent); }
.chart-host .bar.zero { fill: var(--border); }
.chart-host .lbl { fill: var(--muted); font-size: 10px; font-family: ui-monospace, monospace; }
.chart-host .vlbl { fill: var(--fg); font-size: 11px; font-family: ui-monospace, monospace; }
/* RAG-coloured stat values */
.stat .value.rag-good  { color: var(--good); }
.stat .value.rag-warn  { color: var(--warn); }
.stat .value.rag-bad   { color: var(--bad); }
/* Trend arrows next to a stat value (matched internally / externally). */
.trend-arrow      { font-size: 0.65em; vertical-align: 0.15em; margin-left: 6px; }
.trend-arrow.trend-up      { color: var(--good); }
.trend-arrow.trend-down    { color: var(--bad); }
.trend-arrow.trend-neutral { color: var(--muted); }
/* System alert banner shown above the page content when /api/alerts/active
   returns one or more rows. Designed to be impossible to ignore; uses --bad
   for system-wide failures and --warn for per-stream conditions. */
.alert-banner {
  margin: 8px 16px 0; padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--bad);
  background: rgba(248, 81, 73, 0.10);
  color: var(--fg); font-size: 0.92rem; line-height: 1.4;
}
.alert-banner.warn {
  border-color: var(--warn);
  background: rgba(210, 153, 34, 0.10);
}
.alert-banner .alert-title {
  font-weight: 600; color: var(--bad); margin-right: 6px;
}
.alert-banner.warn .alert-title { color: var(--warn); }
.alert-banner ul { margin: 4px 0 0 0; padding-left: 18px; }
.alert-banner li { margin-top: 2px; position: relative; padding-right: 20px; }
/* Per-row dismiss button on each alert. Subtle — visible on hover, big-enough
   hit area on touch. POSTs to /api/alerts/dismiss; if the underlying condition
   is still real the alert simply re-fires on the evaluator's next pass. */
.alert-banner .dismiss-btn {
  position: absolute; top: 0; right: 0;
  background: transparent; color: inherit; border: 0; cursor: pointer;
  font-size: 1.05em; line-height: 1; padding: 2px 6px; opacity: 0.55;
}
.alert-banner .dismiss-btn:hover { opacity: 1; }

/* Warm-up banner: shown above page content while the in-memory fingerprint
   index is rehydrating. Recognition rates will be artificially low until
   this completes; banner auto-hides once /api/warmup reports completed. */
.warmup-banner {
  margin: 8px 16px 0; padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(56, 139, 253, 0.10);
  color: var(--fg); font-size: 0.92rem; line-height: 1.4;
}
.warmup-banner .warmup-title { font-weight: 600; color: var(--accent); margin-right: 6px; }
.warmup-banner progress { width: 220px; height: 8px; vertical-align: middle; margin-left: 8px; }

.upload { display: flex; flex-direction: column; gap: 8px; }
.upload input:not([type=radio]):not([type=checkbox]),
.form-row input, .form-row select, .search-bar input, .search-bar select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font: inherit;
}
.upload input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.upload button, .form-row button, .search-bar button, .pager button {
  background: var(--accent); color: var(--bg); border: 0; border-radius: 6px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.upload button:disabled, .form-row button:disabled, .pager button:disabled
  { opacity: 0.5; cursor: not-allowed; }
.pager button.ghost { background: transparent; color: var(--fg);
                      border: 1px solid var(--border); font-weight: 500; }

.status { font-size: 12px; color: var(--muted); min-height: 1.5em; }
.status.ok { color: var(--good); }
.status.err { color: var(--bad); }

.form-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.form-row.col4 { grid-template-columns: 1fr 2fr 1fr auto; }

.stream-list { list-style: none; padding: 0; margin: 0 0 12px;
                display: flex; flex-direction: column; gap: 8px; }
.stream-list li { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
                  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
.stream-list .name { font-weight: 600; }
.stream-list .url { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px;
                     word-break: break-all; }
.stream-list .owner { color: var(--muted); font-size: 11px; }

/* search */
.search-bar { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 12px; }

/* pagination */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end;
         margin-top: 10px; color: var(--muted); font-size: 12px; }

/* dialogs */
dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--border);
         border-radius: 10px; padding: 0; min-width: 380px; max-width: 580px;
         max-height: calc(100vh - 32px); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog .head { padding: 14px 20px; border-bottom: 1px solid var(--border);
                display: flex; justify-content: space-between; align-items: center;
                flex: 0 0 auto; }
dialog .head h3 { margin: 0; font-size: 14px; }
dialog .body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px;
                flex: 1 1 auto; overflow-y: auto; min-height: 0; }
dialog .body label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
/* metadata-edit dialog provider-lookup cards */
#metadata-lookup-results { display: block; }
.lookup-card {
  display: grid !important;
  grid-template-columns: 20px 40px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  margin: 0 0 6px 0;
  cursor: pointer;
  color: var(--fg);
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.lookup-card input[type=radio] { margin: 4px 0 0 0; }
.lookup-card-body { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.lookup-card-prov { display: inline-block; background: #1f3a5f; color: #cfe1ff;
                    padding: 1px 6px; border-radius: 3px; font-size: 10px;
                    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.lookup-card-title { font-size: 13px; color: var(--fg); margin-bottom: 2px; }
.lookup-card-album { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.lookup-card-tail { font-size: 11px; color: #999; }
.lookup-card-tail a, .lookup-card-tail button { font-size: 11px; }
dialog .body input { width: 100%; background: var(--bg); color: var(--fg);
                     border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; }
dialog .foot { padding: 12px 20px; border-top: 1px solid var(--border);
                display: flex; justify-content: flex-end; gap: 8px;
                flex: 0 0 auto; }
dialog .foot button { background: var(--accent); color: var(--bg); border: 0; border-radius: 6px;
                      padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
dialog .foot button.ghost { background: transparent; color: var(--muted);
                             border: 1px solid var(--border); }
.attrs { display: flex; flex-direction: column; gap: 6px; }
.attrs .row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
.attrs button { padding: 6px 10px; font-size: 11px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* mobile menu trigger */
.menu-toggle {
  display: none; background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 18px; cursor: pointer;
}

/* tablet — collapse 2-col grids */
@media (max-width: 900px) {
  main { padding: 12px 14px; }
  .topbar h1 { font-size: 18px; }
  .now { grid-template-columns: 80px 1fr; }
  .now .art { width: 80px; height: 80px; }
  .now .title { font-size: 18px; }
  .form-row, .form-row.col4, .search-bar {
    grid-template-columns: 1fr; }
  .stream-list li { grid-template-columns: 1fr; }
  /* horizontally scroll wide tables instead of overflowing the viewport */
  .panel table { display: block; overflow-x: auto; white-space: nowrap; }
  .panel table thead, .panel table tbody, .panel table tr { display: table; width: 100%; table-layout: fixed; }
}

/* phone — off-canvas sidebar */
@media (max-width: 720px) {
  body { grid-template-columns: 1fr; }
  aside {
    position: fixed; top: 0; left: 0; height: 100vh; width: 80%; max-width: 280px;
    transform: translateX(-100%); transition: transform 0.2s ease;
    z-index: 50; box-shadow: 4px 0 16px rgba(0,0,0,0.4);
  }
  body.menu-open aside { transform: translateX(0); }
  body.menu-open::after {
    content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40;
  }
  .menu-toggle { display: inline-flex; align-items: center; }
  main { padding: 10px 12px; }
  .topbar { gap: 8px; margin-bottom: 12px; }
  .panel { padding: 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  dialog { min-width: 0; width: calc(100vw - 24px); margin: 12px auto; }
}
