/* Magogi component layer
 * The reusable UI components the Brand Book specifies in prose but mgf-brand
 * ships no CSS for (nav, cards, tables, badges, forms, stat tiles, the Evidence
 * Ledger motif). Authored from the tokens + Brand Book Part VII/VIII so any MGF
 * surface gets a consistent, on-brand component set. Depends on tokens.css.
 *
 * KIT-READY: this is the candidate component layer for a future shared
 * mgf-brand-web package — kept free of console-specific layout (that lives in
 * app.css).
 */

/* --- Eyebrow: mono, uppercase, tracked label (signature MGF micro-type) ---- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-1);
}

/* --- Top navigation (on-dark indigo band) -------------------------------- */
.app-nav {
  background: var(--mgf-indigo);
  color: var(--mgf-mist);
  border-bottom: 1px solid color-mix(in srgb, white 8%, var(--mgf-indigo));
}

.app-nav__inner {
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.app-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--mgf-mist);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.app-nav__brand img {
  height: 1.7rem;
  width: auto;
}

.app-nav__brand-sub {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--mgf-mist) 60%, transparent);
  padding: 0.1rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--mgf-mist) 24%, transparent);
  border-radius: var(--radius-sm);
}

.app-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-left: auto;
}

.app-nav__link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--mgf-mist) 82%, transparent);
  border: 1px solid transparent;
  transition: background-color var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard);
}

.app-nav__link:hover {
  background: color-mix(in srgb, white 8%, transparent);
  color: var(--mgf-mist);
}

/* Active nav item — the one gold signal per chrome (Brand Book "one flame"). */
.app-nav__link[aria-current="page"] {
  color: var(--mgf-paper);
  background: color-mix(in srgb, white 6%, transparent);
  box-shadow: inset 0 -2px 0 var(--color-accent);
}

/* --- Page header (eyebrow + title + actions) ----------------------------- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-block: var(--space-8) var(--space-6);
}

.page-header h1 {
  margin: 0;
}

.page-header__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* --- Card (surface-raised, restrained elevation) ------------------------- */
.card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card + .card,
.stack > * + * {
  margin-top: var(--space-6);
}

.card__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 var(--space-4);
}

/* --- Stat tiles (dashboard resource counts as Evidence Cards) ------------ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: var(--space-4);
}

.stat {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--shadow-sm);
  /* A quiet left rail (slate). Stays neutral so gold can be the ONE accent per
   * view (Brand Book "one flame per room"); promote a single tile with
   * .stat--accent when one figure deserves the gold keystone. */
  border-left: 3px solid var(--color-border-strong);
}

.stat--accent {
  border-left-color: var(--color-accent);
}

/* A clickable stat tile (e.g. dashboard inventory → its list page). */
a.stat {
  text-decoration: none;
  color: inherit;
  transition: transform var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard);
}

a.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
}

.stat__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--color-text);
}

.stat__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* --- Data table ---------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background-color var(--motion-fast) var(--ease-standard);
}

.table tbody tr:hover {
  background: var(--color-bg-soft);
}

/* Numeric cells: monospace, tabular figures, right-aligned. (Use the .mono
 * utility instead for left-aligned identifier cells.) */
.table td.num,
.table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.table .actions form {
  display: inline;
}

.table .actions .button + .button,
.table .actions form + form,
.table .actions form + .button,
.table .actions .button + form {
  margin-left: var(--space-1);
}

/* Compact input for inline table actions (e.g. attach volume → server). */
.input-sm {
  width: auto;
  padding: var(--space-1) var(--space-2);
  font-size: 0.8rem;
}

/* --- Status badge (colour + DOT + label; never colour alone — a11y) ------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.15rem var(--space-3) 0.15rem var(--space-2);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
  background: var(--color-bg-soft);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex: none;
}

.badge-success {
  color: var(--color-success-text);
  background: var(--color-success-tint);
  border-color: color-mix(in srgb, var(--mgf-teal) 45%, transparent);
}
.badge-success::before { background: var(--mgf-teal); }

.badge-info {
  color: var(--color-info-text);
  background: var(--color-info-tint);
  border-color: color-mix(in srgb, var(--mgf-info) 45%, transparent);
}
.badge-info::before { background: var(--mgf-info); }

.badge-warning {
  color: var(--color-warning-text);
  background: var(--color-warning-tint);
  border-color: color-mix(in srgb, var(--mgf-warning) 45%, transparent);
}
.badge-warning::before { background: var(--mgf-warning); }

.badge-danger {
  color: var(--color-error-text);
  background: var(--color-error-tint);
  border-color: color-mix(in srgb, var(--mgf-error) 45%, transparent);
}
.badge-danger::before { background: var(--mgf-error); }

.badge-neutral {
  color: var(--color-text-muted);
}

/* --- Forms --------------------------------------------------------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 12rem;
  flex: 1;
}

.label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.input,
.select,
.textarea {
  font: inherit;
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  transition: border-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard);
}

.textarea {
  min-height: 6rem;
  font-family: var(--font-mono);
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--color-link);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-link) 25%, transparent);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
}

/* --- Empty state (Federation Lattice, diagrammatic — Brand Book Part VII) - */
.empty {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background-image: url("./pattern/pattern-lattice-fine-light.svg");
  background-size: 360px;
  background-position: center;
  background-repeat: repeat;
}

@media (prefers-color-scheme: dark) {
  .empty {
    background-image: url("./pattern/pattern-lattice-fine-dark.svg");
  }
}

.empty__title {
  font-family: var(--font-display);
  color: var(--color-text);
  margin: 0 0 var(--space-2);
}

/* --- Evidence Ledger (calm dark mono panel — system-record rows) --------- */
.ledger {
  background: var(--mgf-ink);
  color: var(--mgf-mist);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, white 10%, var(--mgf-ink));
  padding: var(--space-6);
  font-family: var(--font-mono);
}

.ledger__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid color-mix(in srgb, white 8%, transparent);
  font-size: 0.85rem;
}

.ledger__row:last-child {
  border-bottom: 0;
}

.ledger__key {
  color: color-mix(in srgb, var(--mgf-mist) 65%, transparent);
  letter-spacing: 0.04em;
}

.ledger__val {
  font-variant-numeric: tabular-nums;
  color: var(--mgf-mist);
}

.ledger__val--accent {
  color: var(--color-accent);
}
