/* Admin UI – vanilla CSS */

/* Camera Plain font family */
@font-face {
  font-family: "Camera Plain";
  src: url("/fonts/CameraPlain-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Camera Plain";
  src: url("/fonts/CameraPlain-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Camera Plain";
  src: url("/fonts/CameraPlain-Accent.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Neutral gray ramp (Tailwind neutral palette) */
:root {
  --gray-0: #ffffff;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d4d4d4;
  --gray-400: #a3a3a3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #171717;
  --gray-950: #0a0a0a;

  /* Semantic assignments */
  --color-text: var(--gray-700);
  --color-text-secondary: var(--gray-500);
  --color-text-muted: var(--gray-400);
  --color-bg: var(--gray-0);
  --color-bg-surface: var(--gray-0);
  --color-bg-subtle: var(--gray-50);
  --color-bg-header: var(--gray-800);
  --color-border: var(--gray-200);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Camera Plain", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

a {
  color: #0969da;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Header */
.admin-header {
  background: var(--color-bg-header);
  color: var(--color-bg);
  padding: 10px 20px;
}
.admin-header a {
  color: var(--color-bg);
}

/* Main */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 16px;
}
h2 {
  font-size: 1.1rem;
  margin: 24px 0 8px;
}

/* Flash messages */
.flash {
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
}
.flash.notice {
  background: #dff0d8;
  color: #3c763d;
}
.flash.alert {
  background: #f2dede;
  color: #a94442;
}

/* Tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  margin-bottom: 16px;
  overflow-x: auto;
  display: block;
}
@media (min-width: 800px) {
  .admin-table {
    display: table;
  }
}

/*
 * The frame every table built by admin_table sits in. Cells are nowrap, so one
 * long column (a vendor's event id, an address) makes the table wider than
 * `main` — without this the whole page scrolls sideways and the nav, filters
 * and pagination leave the screen to read one column. Here the overflow is the
 * container's, so the table scrolls inside the page grid instead of moving it.
 *
 * The frame moves off the table and onto the container on purpose: a border on
 * the table scrolls away with it, and the right-hand edge of the box would then
 * fall wherever the widest row happens to end.
 */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 16px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}
.table-scroll > .admin-table {
  /* The container owns the scrolling at every width, so the table is a table
     even on the narrow screens the rule above turns into a block. */
  display: table;
  min-width: 100%;
  margin-bottom: 0;
  border: 0;
  border-radius: inherit;
}
.table-scroll > .admin-table tbody tr:last-child > td {
  border-bottom: 0;
}

/*
 * For a column whose value is long, opaque and only interesting at its head —
 * a transaction hash, a webhook URL. The full value stays in the title, in the
 * copy button and on the detail page, so nothing is lost by clipping it.
 */
.cell-ellipsis {
  display: inline-block;
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.admin-table th,
.admin-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.admin-table thead th {
  background: var(--color-bg-subtle);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table tbody tr:nth-child(even) {
  background: var(--color-bg-subtle);
}

.admin-table .empty {
  text-align: center;
  vertical-align: middle;
  color: var(--color-text-muted);
  height: 165px;
}

/* Attributes table (two-column key-value) */
.attr-table {
  max-width: 700px;
}
.attr-table td:first-child {
  width: 260px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

/* Monospace / tt style */
code,
.short-id {
  font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
}
.short-id {
  cursor: help;
}
a .short-id {
  cursor: pointer;
}
.id-short {
  display: none;
}
.admin-table:not(.attr-table) .id-full {
  display: none;
}
.admin-table:not(.attr-table) .id-short {
  display: inline;
}

/* JSON display */
.json-inline {
  white-space: nowrap;
  color: var(--color-text-secondary);
}
.json-detail {
  margin: 0;
  padding: 8px 12px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow-x: auto;
  max-width: 600px;
}
.json-detail code {
  white-space: pre;
  font-size: 12px;
  color: var(--color-text);
}

.muted {
  color: var(--color-text-secondary);
  font-size: 13px;
}

/* Enum badge */
.enum-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  background: var(--gray-100);
  border: 1px solid var(--color-border);
  cursor: help;
}

/* Copy button */
.btn-copy {
  display: inline-block;
  vertical-align: middle;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  padding: 0;
  border: none;
  background-color: var(--color-text-muted);
  cursor: pointer;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.btn-copy:hover {
  background-color: var(--color-text);
}
.btn-copy.copied {
  background-color: #3c763d;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}
.breadcrumb .btn-copy {
  display: none;
}

/* Abbreviations */
abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 16px;
  margin: 8px 0 24px;
}
.pagination a {
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-surface);
}
.pagination a:hover {
  background: var(--color-bg-subtle);
  text-decoration: none;
}

/* Dev-only action button — hazard stripes */
.btn-danger {
  --stripe-a: rgba(200, 170, 0, 0.35);
  --stripe-b: rgba(40, 30, 0, 0.25);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.15) 0%,
      transparent 40%,
      rgba(0, 0, 0, 0.1) 100%
    ),
    repeating-linear-gradient(
      -45deg,
      var(--stripe-a) 0px,
      var(--stripe-a) 6px,
      var(--stripe-b) 6px,
      var(--stripe-b) 12px
    );
  color: var(--color-text);
  border: 1px solid rgba(180, 150, 0, 0.45);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.btn-danger:hover {
  --stripe-a: rgba(210, 180, 0, 0.5);
  --stripe-b: rgba(40, 30, 0, 0.35);
  border-color: rgba(200, 170, 0, 0.6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Bulk selection */
.col-select {
  width: 32px;
  text-align: center;
}
.col-select input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

/* Bulk actions bar */
.bulk-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--gray-100);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}
.bulk-actions-bar .invisible {
  display: none;
}
.bulk-actions-count {
  margin-right: auto;
}
.bulk-actions-bar .btn-danger {
  font-size: 11px;
  padding: 4px 10px;
}
.bulk-actions-bar .btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Brand logos */
.brand-logo {
  max-height: 64px;
  object-fit: contain;
  vertical-align: middle;
}
.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--color-border);
  vertical-align: middle;
}

/* Photoshop-style transparency checkerboard behind composited previews so
   the parts masked away by the circle read as transparent. */
.transparency-grid,
.admin-table td:has(> .brand-logo),
.admin-table td:has(> .transparency-grid) {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d9d9d9 25%, transparent 25%),
    linear-gradient(-45deg, #d9d9d9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9d9d9 75%),
    linear-gradient(-45deg, transparent 75%, #d9d9d9 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.admin-table td:has(> .brand-logo) {
  width: 88px;
  padding: 12px;
  text-align: center;
  line-height: 0;
}

/* Rain console — application status at a glance. Rain has eleven statuses; what
   matters when scanning a list is only whether one is terminal-good,
   terminal-bad, or waiting on the user. */
.enum-badge.status-ok {
  background: #dff0d8;
  border-color: #b6ddab;
  color: #3c763d;
}
.enum-badge.status-bad {
  background: #f2dede;
  border-color: #e2c2c2;
  color: #a94442;
}
.enum-badge.status-waiting {
  background: #fcf8e3;
  border-color: #e8dfb4;
  color: #8a6d3b;
}

/* One call to Rain, collapsed. Wider than .json-detail's default because these
   are whole API responses rather than one column's value. */
.rain-result summary {
  color: var(--color-text-secondary);
}
.rain-result .json-detail {
  max-width: 100%;
  margin-top: 4px;
}

/* Bridge — one boxed block per mirrored object, so a user page with three KYC
   attempts does not read as one long table. */
.bridge-mirror,
.bridge-endorsement {
  margin: 12px 0 20px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-subtle);
}
.bridge-mirror h4,
.bridge-endorsement h4 {
  margin: 0 0 8px;
}
.bridge-endorsement h5 {
  margin: 16px 0 4px;
}
/* Bridge's own words are long — a requirement name, a note explaining what a
   status actually means, a link carrying a whole Persona inquiry in its query
   string. `.admin-table td` is nowrap, which for these sends the page sideways
   instead of the cell down, so every Bridge table opts out. */
.bridge-mirror .attr-table td,
.bridge-attrs td {
  white-space: normal;
  overflow-wrap: anywhere;
}
.bridge-mirror .attr-table,
.bridge-attrs {
  max-width: 100%;
}
/* The notes explaining Bridge's own vocabulary. Measured for reading rather
   than stretched to the full page. */
.bridge-note {
  max-width: 44rem;
}
td > .bridge-note,
dd > .bridge-note {
  margin: 6px 0 0;
}

/* The sandbox "simulate KYC approval" control, inside the cards-endorsement
   cell. Stacked rather than inline: the note beside it is three lines of why
   the button is safe to press and what it does not prove, and that does not
   belong on one line with a button. */
.bridge-simulate {
  margin: 8px 0 0;
}
.bridge-simulate form {
  display: inline-block;
  margin: 0 0 4px;
}
.bridge-simulate .muted {
  display: block;
  max-width: 44rem;
}

/* A requirement set, label above value rather than beside it. Thirty
   requirement names have nowhere to wrap in a cell next to a 260px label
   column, and the only bucket that is ever long is the one nobody needs to
   read, so `complete` is folded away behind its count. */
.bridge-requirements {
  margin: 0;
}
.bridge-requirements dt {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}
.bridge-requirements dd {
  margin: 4px 0 0;
}
.bridge-requirements summary {
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 13px;
}
.bridge-pill-row {
  margin-top: 6px;
}
/* `cards` is the only endorsement that decides whether a card can be issued;
   the others ride along. Given a left rule so it is the one the eye lands on. */
.bridge-endorsement-cards {
  border-left: 3px solid var(--color-text);
}

/* Requirement names, as Bridge spells them. Colored by which bucket they are
   in, because "complete" and "issue" mean opposite things and a run of 29
   identical-looking names hides the one that matters. */
.bridge-pill {
  display: inline-block;
  overflow-wrap: anywhere;
  padding: 1px 6px;
  margin: 1px 0;
  border-radius: 3px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  background: var(--gray-100);
}
.bridge-pill-complete {
  background: #eef6ec;
  border-color: #cfe4c9;
  color: #3c763d;
}
.bridge-pill-pending {
  background: #fcf8e3;
  border-color: #e8dfb4;
  color: #8a6d3b;
}
.bridge-pill-missing,
.bridge-pill-issue {
  background: #f2dede;
  border-color: #e2c2c2;
  color: #a94442;
}

/* `requirements.missing` is a nested boolean expression. The operator labels
   the group it governs, so `any_of` reads as the alternative it is. */
.bridge-req-group {
  margin: 2px 0;
}
.bridge-req-op {
  display: inline-block;
  font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}
.bridge-req-tree {
  margin: 2px 0 2px 12px;
  padding-left: 12px;
  list-style: none;
  border-left: 1px solid var(--color-border);
}

/* Bridge's links carry the whole inquiry in their query string — long enough to
   need wrapping, and worth having on screen to paste elsewhere. */
.bridge-url {
  margin-top: 4px;
  max-width: 600px;
  word-break: break-all;
  font-size: 11px;
  color: var(--color-text-secondary);
}
.bridge-link-params {
  margin-top: 6px;
  max-width: 600px;
}
.bridge-link-params td {
  white-space: normal;
  word-break: break-all;
  font-size: 12px;
}

.bridge-rejection {
  margin-bottom: 8px;
}
.bridge-rejection-developer {
  color: #a94442;
}

.bridge-raw summary {
  color: var(--color-text-secondary);
  cursor: pointer;
}
.bridge-raw .json-detail {
  max-width: 100%;
  margin-top: 4px;
}

/* A form that sits in a table cell or a line of text (merchant members, ZAY-527). */
.inline-form { display: inline; }
.inline-form select, .inline-form input, .inline-form button { font: inherit; }
