/* =============================================================================
   admin.css — minimal scaffolding around the Vela Design System.

   The DS supplies every visual primitive via `<vi-*>` components and
   token-driven CSS custom properties (see
   https://ds.cdn.velaintelligence.com/ai/component-catalog.yaml and
   https://ds.cdn.velaintelligence.com/ai/tokens.yaml). This file only
   contains app-specific scaffolding the DS doesn't (and shouldn't) own:

     · Sharper-corner override on the DS radius ref tokens
     · App-shell layering (canvas vs aside vs sidebar surfaces)
     · The Deal Intelligence brand lockup glyphs
     · A code-block style (DS doesn't ship one)
     · The settings-row layout used by the appearance switcher

   Everything else — layout primitives, tables, lists, timeline, modals,
   forms, empty states, badges — comes from the DS. If you're tempted to
   add a new rule here, check the DS catalog first.
   ========================================================================== */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  /* Disable rubber-band / pull-to-refresh — the admin shell is an app
     surface, not a document. Without this, dragging at the top of the page
     on macOS/touch devices bounces the whole viewport. */
  overscroll-behavior: none;
  font-family: var(--vi-ref-font-sans, system-ui, sans-serif);
  background: var(--vi-sem-surface-canvas, #fff);
  color: var(--vi-sem-text-default, #111);
}

/* <vi-page> defaults to no intrinsic height. Force a viewport-filling shell
   and widen both rails. The aside width isn't exposed as a DS token, so we
   target ::part(aside) directly (the catalog lists `aside` as an exposed
   part on vi-page). */
vi-page#shell {
  display: block;
  min-height: 100vh;
  --vi-page-navigation-width: 220px;
}
vi-page#shell::part(aside) { width: 220px; }

/* ── app-shell surface layering ──────────────────────────────────────────── */

/* Canvas + sidebar + aside all use DS semantic surface tokens, so they flip
   with the theme switcher automatically. Sidebar and aside elevate above
   the canvas content area (DS Explorer pattern). */
.app-canvas  { background: var(--vi-sem-surface-canvas);  color: var(--vi-sem-text-default); }
.app-sidebar { background: var(--vi-sem-surface-default); color: var(--vi-sem-text-default);
               border-right: 1px solid var(--vi-sem-border-default); }
/* Aside: in vi-page's grid the `aside` slot lives in the LEFT column,
   stacked BELOW the navigation (see `packages/components/src/vi-page.ts`
   — "Left column (nav + aside, flush)"). So our user chip sits at the
   bottom of the sidebar, not on a right rail.
   - Border-right matches .app-sidebar so the column-divider line is
     continuous from top to bottom — without it, the divider breaks
     where the chip begins. */
.app-aside {
  padding: 16px 8px;
  border-right: 1px solid var(--vi-sem-border-default);
  background: var(--vi-sem-surface-default);
  height: 100%;
  box-sizing: border-box;
}

/* Two-line content inside the chip's default slot. Block children so they
   stack inside the row's .content span (which has white-space:nowrap, but
   that only stops text wrap — block stacking still works). */
.user-chip__stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  line-height: 1.2;
}
.user-chip__name {
  display: block;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--vi-sem-text-default);
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip__email {
  display: block;
  font-size: 0.74rem;
  color: var(--vi-sem-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidenav-wrap { padding: 16px 8px; }

#content {
  padding: 24px 32px;
  max-width: 1280px;
  /* Pages render their lists into here; min-width:0 lets flex/grid children
   * (including <vi-data-grid>) actually constrain to the available width
   * instead of expanding to their content's natural width. */
  min-width: 0;
}

/* ── data-grid sizing ───────────────────────────────────────────────────── */

/* <vi-data-grid> is a block-level host that the DS doesn't width-constrain
 * by itself: its own shadow `:host { display: block }` lets the host take
 * the natural width of its inner table, and its `.table-wrap` (exposed as
 * ::part(base)) has `overflow: auto` with no width so it grows to fit the
 * table instead of constraining it. Pin both layers explicitly + force
 * box-sizing + content min-width so the host stays inside #content's
 * available width and any actually-too-wide row scrolls horizontally
 * inside the table wrap (rather than the page itself). */
vi-data-grid {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
vi-data-grid::part(base) {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Primary identifier cell rendered as a clickable affordance — the
 * canonical "open this row" pattern in admin tables now that the
 * wrapper no longer auto-injects an Open column. Used as a slotted
 * <a> on orgs (href-based) or <button> on requests (handler-based). */
.data-grid__name-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--vi-sem-text-accent, currentColor);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.data-grid__name-link:hover { text-decoration: underline; }
/* The slot wrapping `#content` is the actual flex item; it needs an
 * explicit min-width:0 already, but force max-width:100% too so a wide
 * table inside cannot push #content itself beyond its track. */
#content { width: 100%; box-sizing: border-box; }

/* ── topbar (a <vi-flank>) ───────────────────────────────────────────────── */

/* <vi-flank> handles the start/end layout internally but ships with zero
   padding (verified in `packages/components/src/vi-flank.ts` — no padding
   props or tokens). We own the host's left/right padding here. Matching
   the consumer web app's `--space-6` (2rem = 32px) so the brand lockup
   sits at the same x-position across both surfaces. */
.topbar {
  display: block;
  box-sizing: border-box;
  height: 60px;
  line-height: 60px;
  padding: 0 2rem;
  border-bottom: 1px solid var(--vi-sem-border-default, #e5e5e5);
}

/* Anchor the global toast stack to the top-right of the viewport — a few
   pixels off the top and right edges, ignoring the topbar geometry. The
   DS exposes `--vi-cmp-toast-stack-inset` for per-app override. */
vi-toast-stack#vi-global-toast-stack {
  --vi-cmp-toast-stack-inset: 0.5rem 0.5rem 1rem 1rem;
}

/* Modal description paragraph — sits between the (sub)heading and the
   first form field. Inherits body type; we just want a consistent gap to
   the next sibling. The DS doesn't style raw <p> inside modals, so we own
   this. */
.modal-lede {
  margin: 0 0 var(--vi-sem-space-stack-md, 1rem) 0;
  color: var(--vi-sem-text-muted);
}

/* Brand lockup — Deal Intelligence wordmark "· by" Vela wordmark. The two
   SVGs are masked so they pick up the current colour via mask-image,
   themeable through the `--logo-color` and `--vi-sem-text-muted` tokens.
   Once vela-ds-source#4 (the `:where(a)` anchor reset) publishes to the
   CDN, the :hover/:focus/:active/:visited variants here can collapse to
   just the base rule — the DS reset will own color: inherit + text-
   decoration: none in every state. */
.topbar__brand,
.topbar__brand:hover,
.topbar__brand:focus,
.topbar__brand:active,
.topbar__brand:visited {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  outline: none;
}
.topbar__lockup {
  display: block;
  height: 24px;
  width: calc(24px * 2379 / 256);
  background-color: var(--logo-color, var(--vi-sem-text-default, #111));
  -webkit-mask: url("/assets/logos/deal-intelligence-lockup.svg") no-repeat left center / contain;
  mask:         url("/assets/logos/deal-intelligence-lockup.svg") no-repeat left center / contain;
}
.topbar__by {
  font-size: 0.72rem;
  color: var(--vi-sem-text-muted, #888);
  margin-left: 4px;
  margin-right: -2px;
}
.topbar__vela {
  display: block;
  height: 12px;
  width: calc(12px * 2498 / 700);
  background-color: var(--vi-sem-text-muted, #888);
  -webkit-mask: url("/assets/logos/vela-wordmark.svg") no-repeat center / contain;
  mask:         url("/assets/logos/vela-wordmark.svg") no-repeat center / contain;
}

/* ── typography ─────────────────────────────────────────────────────────── */

.page-title {
  margin: 0 0 24px 0;
  font-size: 1.75rem;
  font-weight: 600;
}
.section-title {
  margin: 32px 0 12px 0;
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--vi-sem-text-muted, #888);
}
.kv-heading {
  margin: 16px 0 8px 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--vi-sem-text-muted, #888);
}

/* Inline mono span for IDs, paths, code keywords. */
.mono {
  font-family: var(--vi-ref-font-mono, monospace);
  font-size: 0.85em;
}

/* Preformatted code block (e.g. JSON config dumps, copy-paste snippets).
   DS doesn't ship a code/pre primitive. */
.code-dump {
  margin: 8px 0 0 0;
  padding: 12px 14px;
  background: var(--vi-sem-surface-default);
  border: 1px solid var(--vi-sem-border-default);
  font-family: var(--vi-ref-font-mono, ui-monospace, monospace);
  font-size: 0.78rem;
  white-space: pre;
  overflow: auto;
}

/* ── KPI strip on the overview ───────────────────────────────────────────── */

/* Plain CSS grid because <vi-metric-card>s tile better with explicit
   `repeat(4, …)` than with vi-grid's string-based `columns` API for this
   case. Could swap if it ever pays for itself. */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* <vi-metric-card>'s icon slot is sized for a roomy ~28–32px glyph, but
   Font Awesome `<i>` inherits font-size from the slot wrapper (~14px).
   Bump the slotted icon up so it fills the trailing circle. */
vi-metric-card i[slot="icon"] {
  font-size: 1.5rem;
  line-height: 1;
}

/* <vi-empty-state>'s `.icon-wrap` uses default font-size, so a slotted FA
   `<i>` renders at ~16px which reads as a tiny dot above the title. Scale
   it up to match the proportions of the empty-state card. */
vi-empty-state i[slot="icon"] {
  font-size: 2.5rem;
  line-height: 1;
}

/* ── settings page rows ──────────────────────────────────────────────────── */

/* Used by the appearance card on /settings — title + hint on the left,
   <vi-theme-switcher> on the right. */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--vi-sem-border-subtle, #f2f2f2);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row__label { display: flex; flex-direction: column; gap: 2px; }
.settings-row__title { font-size: 0.9rem; font-weight: 500; }
.settings-row__hint  { font-size: 0.8rem; color: var(--vi-sem-text-muted, #888); }

/* ── retention card spacing ─────────────────────────────────────────────── */

.retention-card { margin-bottom: 24px; }
