/*
 * CPA UI v6 — Compact Flat + Telemetry Deck
 * Layer over v5. Scope: one-notch-smaller type, flatter topbar, narrower
 * content column, redesigned dashboard (pixel-HUD telemetry deck), a
 * decluttered channel-status page with category tabs (cpa-ui-v6.js), and
 * tool-tabbed integration snippets. Remove the `ui-v6` body class to revert.
 *
 * Design language: existing pixel-arcade palette, committed to a blue→mint
 * duotone with ink outlines; numbers always monospace; HUD corner brackets
 * as the signature detail.
 */

:root {
  --v6-blue: #2f6f92;
  --v6-blue-hi: #4fa7de;
  --v6-mint: #2ab992;
  --v6-mint-hi: #7ecfba;
  --v6-ink: #17243a;
  --v6-muted: #637792;
  --v6-line: rgba(38, 67, 101, .18);
  --v6-mono: "SFMono-Regular", "Cascadia Mono", "IBM Plex Mono", "Courier New", monospace;
}

/* ---- global compaction ----
   Density comes from tightened paddings/gaps, NOT from zoom: a body-level
   zoom breaks Chromium's repaint of animated background-clip:text (the VIP
   flowing-name effect), so it must stay off. */
body.ui-v6 .newapi-card-title {
  font-size: 13px;
}

/* ---- flatter topbar ---- */
body.ui-v6 .topbar {
  padding: 4px 8px;
  gap: 6px;
}

body.ui-v6 .title-copy {
  padding: 4px 12px;
  gap: 3px;
  border-width: 1px;
  border-radius: 12px;
}

body.ui-v6 .title-copy h1 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

body.ui-v6 .topbar .metric {
  padding: 4px 10px;
  border-radius: 10px;
}

/* content area fills the available width (density comes from zoom + tight gaps) */
body.ui-v6 .console-content {
  width: 100%;
}

/* ============================================================
   DASHBOARD — telemetry deck
   ============================================================ */

body.ui-v6 .dashboard-grid {
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(272px, .38fr);
}

/* staggered pixel-step entrance; disabled for reduced motion */
@media (prefers-reduced-motion: no-preference) {
  body.ui-v6 .dashboard-page.active .dashboard-overview,
  body.ui-v6 .dashboard-page.active .dashboard-leaderboard {
    animation: v6-rise .34s steps(4, end) both;
  }

  body.ui-v6 .dashboard-page.active .dashboard-leaderboard {
    animation-delay: .08s;
  }

  body.ui-v6 .dashboard-page.active .dashboard-usage-metrics .newapi-metric {
    animation: v6-rise .3s steps(3, end) both;
  }

  body.ui-v6 .dashboard-page.active .dashboard-usage-metrics .newapi-metric:nth-child(2) { animation-delay: .05s; }
  body.ui-v6 .dashboard-page.active .dashboard-usage-metrics .newapi-metric:nth-child(3) { animation-delay: .1s; }
  body.ui-v6 .dashboard-page.active .dashboard-usage-metrics .newapi-metric:nth-child(4) { animation-delay: .15s; }
}

@keyframes v6-rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.ui-v6 .dashboard-overview .newapi-card-head {
  padding: 8px 12px;
  border-bottom: 1px dashed var(--v6-line);
}

body.ui-v6 .dashboard-overview .newapi-card-body {
  gap: 8px;
  overflow-y: auto;
}

/* usage metric tiles: flat, ink outline, alternating accent spine */
body.ui-v6 .dashboard-usage-metrics {
  gap: 6px;
}

body.ui-v6 .dashboard-usage-metrics .newapi-metric {
  position: relative;
  padding: 7px 9px 7px 12px;
  border: 1px solid var(--v6-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
}

body.ui-v6 .dashboard-usage-metrics .newapi-metric::before {
  content: "";
  position: absolute;
  inset: 4px auto 4px 4px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--v6-blue-hi), var(--v6-blue));
}

body.ui-v6 .dashboard-usage-metrics .newapi-metric:nth-child(even)::before {
  background: linear-gradient(180deg, var(--v6-mint-hi), var(--v6-mint));
}

body.ui-v6 .dashboard-usage-metrics .newapi-metric span {
  font-size: 9px;
  letter-spacing: .09em;
}

body.ui-v6 .dashboard-usage-metrics .newapi-metric strong {
  margin-top: 3px;
  font-size: clamp(13px, 1.3vw, 17px);
  font-family: var(--v6-mono);
  font-variant-numeric: tabular-nums;
}

body.ui-v6 .dashboard-usage-metrics .newapi-metric em {
  margin-top: 3px;
}

/* hourly chart: HUD panel with corner brackets + duotone top rail */
body.ui-v6 .dashboard-hourly-card {
  position: relative;
  padding: 8px;
  border: 1px solid var(--v6-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
}

body.ui-v6 .dashboard-hourly-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, var(--v6-blue-hi), var(--v6-mint));
}

body.ui-v6 .dashboard-hourly-card::after {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  border-radius: 8px;
  background:
    linear-gradient(var(--v6-ink), var(--v6-ink)) top left / 10px 2px,
    linear-gradient(var(--v6-ink), var(--v6-ink)) top left / 2px 10px,
    linear-gradient(var(--v6-ink), var(--v6-ink)) bottom right / 10px 2px,
    linear-gradient(var(--v6-ink), var(--v6-ink)) bottom right / 2px 10px;
  background-repeat: no-repeat;
  opacity: .28;
}

body.ui-v6 .dashboard-hourly-title {
  font-size: 10px;
  letter-spacing: .14em;
}

body.ui-v6 .dashboard-hourly-total {
  font-family: var(--v6-mono);
  font-variant-numeric: tabular-nums;
  border-color: var(--v6-line);
}

body.ui-v6 .hourly-chart {
  height: 100%;
  min-height: 220px;
  border: 1px dashed rgba(38, 67, 101, .14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(243, 250, 255, .8));
}

body.ui-v6 .hourly-chart.is-empty {
  height: 100%;
  min-height: 220px;
}

body.ui-v6 .hourly-svg {
  height: 100%;
  min-height: 200px;
}

/* state metrics strip removed per operator request — the freed space goes to the chart */
body.ui-v6 .dashboard-state-metrics {
  display: none !important;
}

/* card body rows after removal: metrics / chart (flexible) / actions */
body.ui-v6 .dashboard-overview .newapi-card-body {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

body.ui-v6 .dashboard-overview .newapi-actions.compact {
  justify-content: flex-end;
}

/* leaderboard column: tighter */
body.ui-v6 .dashboard-leaderboard .panel-head {
  padding: 8px 12px;
}

body.ui-v6 .dashboard-leaderboard .podium {
  gap: 6px;
}

/* generic metric fallback (non-dashboard pages) */
body.ui-v6 .newapi-metric {
  padding: 7px 9px;
  border-radius: 10px;
}

body.ui-v6 .newapi-metric strong {
  margin-top: 4px;
  font-size: 14px;
}

/* ============================================================
   CHANNEL STATUS — declutter + category tabs
   ============================================================ */

body.ui-v6 .channel-status-summary {
  display: none !important;
}

/* summary row is gone, so re-map shell rows: toolbar + grid */
body.ui-v6 .channel-status-shell {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

/* make room for the category tabs injected as the first toolbar item */
body.ui-v6 .channel-status-toolbar {
  grid-template-columns: auto minmax(150px, 1fr) minmax(120px, .4fr) auto;
  gap: 6px;
}

body.ui-v6 .channel-cat-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

body.ui-v6 .channel-cat-tab {
  padding: 4px 12px;
  border: 1px solid var(--v6-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: #2c4a6e;
  font-size: 11px;
  font-weight: 900;
  font-family: inherit;
  letter-spacing: .04em;
  cursor: pointer;
}

body.ui-v6 .channel-cat-tab:hover {
  border-color: rgba(47, 111, 146, .55);
}

body.ui-v6 .channel-cat-tab.active {
  border-color: var(--v6-blue);
  background: var(--v6-blue);
  color: #fff;
}

body.ui-v6 .channel-card {
  padding: 10px;
  gap: 8px;
  border-radius: 10px;
}

/* long provider pools (e.g. grok-4.5) must not stretch the card:
   clamp detail lines to one line, full text stays in the title attribute */
body.ui-v6 .channel-provider-line,
body.ui-v6 .channel-card-foot {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.ui-v6 .channel-status-grid {
  gap: 8px;
}

/* category filter applied by cpa-ui-v6.js */
body.ui-v6 .channel-card.v6-cat-hidden {
  display: none !important;
}

body.ui-v6 .v6-cat-empty {
  padding: 18px;
  color: var(--v6-muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

/* ============================================================
   INSTANCES — tool-tabbed integration snippets
   ============================================================ */

body.ui-v6 .instance-tool-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--v6-line);
}

body.ui-v6 .instance-tool-tab {
  padding: 5px 12px;
  border: 1px solid var(--v6-line);
  border-radius: 8px 8px 0 0;
  border-bottom: 0;
  background: rgba(248, 251, 255, .75);
  color: #2c4a6e;
  font-size: 11px;
  font-weight: 900;
  font-family: inherit;
  letter-spacing: .03em;
  cursor: pointer;
}

body.ui-v6 .instance-tool-tab:hover {
  background: rgba(255, 255, 255, .95);
}

body.ui-v6 .instance-tool-tab.active {
  border-color: var(--v6-blue);
  background: var(--v6-blue);
  color: #fff;
}

body.ui-v6 .instance-tool-pane {
  display: grid;
  gap: 6px;
}

/* keep the hidden attribute effective (display:grid above would defeat it) */
body.ui-v6 .instance-tool-pane[hidden] {
  display: none !important;
}

body.ui-v6 .instance-tool-note {
  color: var(--v6-muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1.5;
}

body.ui-v6 .instance-tool-pane .newapi-snippet {
  font-family: var(--v6-mono);
  font-size: 11px;
  line-height: 1.55;
}
