/* ============================================================
   FA Admin - app layer
   Loaded AFTER ds/tokens.css and ds/components.css.

   Generic chrome (buttons, cards, tables, badges, forms, shell) now comes
   from the design system. Only app-specific surfaces live here: the
   sign-in shell, the brand dot, the scope picker, and the API playground.
   ============================================================ */

/* Legacy aliases: the playground layer below was authored against these.
   They now resolve to design-system tokens, so it re-themes with the DS
   and follows dark mode for free. */
:root {
  --fa-forest: hsl(var(--primary));
  --fa-salmon: hsl(var(--brand-salmon));
  --fa-cream: hsl(var(--background));
  --fa-ink: hsl(var(--foreground));
  --fa-line: hsl(var(--border));
}

html, body { margin: 0; padding: 0; min-height: 100vh; }

/* ---------------------------------------------------------------- brand */

.fa-brand-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: var(--radius-full);
  background: hsl(var(--brand-salmon));
  flex-shrink: 0;
}

.fa-pre {
  background: hsl(158 15% 11%);
  color: #E5E5DC;
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 0;
}
.fa-pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }

/* ---------------------------------------------------------------- sign-in */

.fa-auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: hsl(var(--background));
}
.fa-auth-card {
  width: 100%;
  max-width: 24rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
}
.fa-auth-card .fa-page-title { font-size: 1.375rem; }

/* ---------------------------------------------------------------- scope picker */

.fa-scopes {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem 1.25rem;
  margin: 0;
  background: hsl(var(--primary) / 0.03);
}
.fa-scopes legend { padding: 0 0.5rem; font-size: 0.8125rem; font-weight: 600; }
.fa-scope-group { margin-bottom: 1rem; }
.fa-scope-group:last-child { margin-bottom: 0; }
.fa-scope-group h4 {
  margin: 0.5rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: hsl(var(--muted-foreground));
}
.fa-scope-item {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.625rem;
  align-items: start;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.fa-scope-item:hover { background: hsl(var(--primary) / 0.06); }
.fa-scope-item input[type="checkbox"] { margin-top: 0.125rem; accent-color: hsl(var(--primary)); }
.fa-scope-text { display: flex; flex-direction: column; gap: 0.125rem; font-size: 0.8125rem; }
.fa-scope-text .fa-code { font-size: 0.6875rem; align-self: flex-start; }
.fa-scope-text strong { font-weight: 600; }
/* Deep terracotta rather than brand salmon: this is 11px text on white, and
   salmon at full strength only reaches ~2.5:1. */
.fa-scope-cost { font-size: 0.6875rem; color: hsl(12 52% 40%); font-weight: 500; }

.fa-scope-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  margin: 0.0625rem 0.125rem 0.0625rem 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
}

/* ---------------------------------------------------------------- key/value list */

/* Used by the MCP status card. Two-column definition list. */
.kvs { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.5rem; margin: 0; font-size: 0.875rem; }
.kvs dt { color: hsl(var(--muted-foreground)); font-weight: 500; }
.kvs dd { margin: 0; }

/* Error-tinted card - the wrapper-unreachable state on the MCP page. */
.fa-card.highlight { border-color: hsl(var(--destructive) / 0.4); background: hsl(var(--destructive-tint)); }

/* ---------------------------------------------------------------- Playground */

.playground { display: flex; flex-direction: column; gap: 16px; }

/* These cards were authored against the old generic .card, which carried its
   own padding. The design system puts padding on .fa-card-content instead, and
   the playground panels do not use that wrapper, so restore it here. */
.pg-setup, .pg-request, .pg-response, .pg-history-card, .pg-livetail-card { padding: 1.25rem; }

/* Setup */
.pg-setup-grid { display: grid; grid-template-columns: 2fr 2fr 1.4fr; gap: 16px; align-items: end; }
.pg-setup-grid label { display: block; font-size: 13px; color: var(--fa-forest); }
.pg-setup-grid label input { display: block; width: 100%; margin-top: 4px; padding: 8px 12px; border: 1px solid var(--fa-line); border-radius: var(--radius-md); font: inherit; background: hsl(var(--card)); color: inherit; box-sizing: border-box; }
.pg-setup-actions { display: flex; gap: 12px; align-items: center; }
.pg-setup-hint { margin-top: 12px; }
.pg-status { font-size: 13px; padding: 4px 10px; border-radius: var(--radius-full); background: hsl(var(--muted)); color: var(--fa-forest); }
.pg-status-ok { background: hsl(var(--success-tint)); color: hsl(var(--success)); }
.pg-status-warn { background: hsl(var(--warning-tint)); color: hsl(var(--warning)); }
.pg-status-err { background: hsl(var(--destructive-tint)); color: hsl(var(--destructive)); }
.pg-status-neutral { background: hsl(var(--muted)); color: var(--fa-forest); }

/* Stats strip */
.pg-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.pg-stat { background: hsl(var(--card)); border: 1px solid var(--fa-line); border-radius: var(--radius-lg); padding: 14px 16px; text-align: center; }
.pg-stat-value { font-size: 24px; font-weight: 600; color: var(--fa-forest); line-height: 1.1; transition: color 0.3s; }
.pg-stat-value.pg-status-ok { color: hsl(var(--success)); background: none; }
.pg-stat-value.pg-status-warn { color: hsl(var(--warning)); background: none; }
.pg-stat-value.pg-status-err { color: hsl(var(--destructive)); background: none; }
.pg-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); color: hsl(var(--muted-foreground)); margin-top: 4px; }

/* Tabs - visual style comes from the design system (.fa-tabs / .fa-tab and
   .fa-tabs-underline / .fa-tab-underline); only playground layout lives here. */
.pg-tabs-card { padding: 0; }
.pg-tabs { margin: 16px 20px 0; }
.pg-tab-content { padding: 20px; }
.pg-tab-content h3 { margin: 0 0 4px; color: var(--fa-forest); font-size: 16px; }
.pg-tab-content > p { margin: 0 0 16px; }
.pg-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.pg-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--fa-forest); flex: 0 1 auto; min-width: 140px; }
.pg-form input, .pg-form select, .pg-form textarea { padding: 8px 12px; border: 1px solid var(--fa-line); border-radius: var(--radius-md); font: inherit; background: hsl(var(--card)); color: inherit; min-width: 140px; }
.pg-form textarea { font-family: var(--font-mono); font-size: 12px; min-width: 320px; }

.pg-subtabs { margin: -4px 0 16px; }

.pg-chips { margin-top: 14px; padding: 10px 12px; background: hsl(var(--sage) / 0.18); border-radius: var(--radius-md); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pg-chip { font: inherit; font-size: 12px; font-family: var(--font-mono); padding: 4px 10px; background: hsl(var(--card)); border: 1px solid var(--fa-line); border-radius: var(--radius-full); cursor: pointer; color: var(--fa-forest); }
.pg-chip:hover { background: var(--fa-forest); color: hsl(var(--primary-foreground)); border-color: var(--fa-forest); }

/* Request / response panels */
.pg-io { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pg-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pg-panel-head h3 { margin: 0; font-size: 14px; color: var(--fa-forest); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); }
.pg-meta { display: flex; gap: 6px; }
.pg-meta-pill { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 11px; background: hsl(var(--primary) / 0.10); color: var(--fa-forest); }
.pg-meta-pill.ok { background: hsl(var(--success-tint)); color: hsl(var(--success)); }
.pg-meta-pill.err { background: hsl(var(--destructive-tint)); color: hsl(var(--destructive)); }

.pg-code { background: hsl(158 15% 11%); color: #E5E5DC; padding: 16px; border-radius: var(--radius-md); overflow: auto; max-height: 460px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; margin: 0; white-space: pre; word-break: normal; }
.pg-code .pg-key { color: #A8BCA1; }
.pg-code .pg-str { color: #E5C8A8; }
.pg-code .pg-num { color: #C2A68D; }
.pg-code .pg-bool { color: #E5826D; font-weight: 500; }
.pg-code .pg-null { color: #8A8F8C; font-style: italic; }

/* History */
.pg-history-card { padding-bottom: 4px; }
.pg-history { font-size: 13px; }
.pg-history th { font-size: 11px; }
.pg-history .pg-path { max-width: 380px; }
.pg-history .pg-empty td { padding: 24px; text-align: center; }
.pg-history .pg-row-err code { color: hsl(var(--destructive)); }

/* Live tail */
.pg-livetail-card { padding-bottom: 4px; }
.pg-livetail { font-size: 12px; }
.pg-livetail th { font-size: 11px; }
.pg-livetail tr.pg-fresh { animation: pg-flash 1.6s ease-out; }
.pg-livetail .small { font-size: 11px; }
@keyframes pg-flash {
  0% { background: hsl(var(--brand-salmon) / 0.25); }
  100% { background: transparent; }
}

.pg-livedot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fa-salmon); margin-left: 6px; vertical-align: middle; animation: pg-pulse 2s ease-in-out infinite; }
@keyframes pg-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Responsive: collapse two-col layout on narrow screens */
@media (max-width: 1100px) {
  .pg-io { grid-template-columns: 1fr; }
  .pg-stats { grid-template-columns: repeat(2, 1fr); }
  .pg-setup-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .fa-content { padding: 1.5rem 1.25rem; }
}
