/*
 * The small custom layer on top of Pico (CP-9).
 *
 * Pico styles semantic HTML directly — <button>, <input>, <table>, <article>
 * need no classes — so this file only covers what Pico has no opinion about:
 * status badges, compact in-table action buttons, and the server-rendered
 * validation messages ASP.NET emits. Everything here is built from Pico's own
 * custom properties so it tracks the theme (including dark mode) for free.
 *
 * No build step: pico.min.css is vendored (v2.1.1, MIT) and this file is hand
 * written. `dotnet publish` is the entire build.
 */

/*
 * Pico ramps the root font size up at each breakpoint (to 125% on wide
 * screens), which reads oversized for a dense console. Hold it at 100% and
 * cap the container narrower than Pico's 1200px so lines stay scannable.
 */
html {
  font-size: 100%;
}

.container {
  max-width: 64rem;
}

/* Pin the page footer to the bottom on short pages. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > main {
  flex: 1;
}

body > footer {
  border-top: 1px solid var(--pico-muted-border-color);
  padding-block: var(--pico-spacing);
}

/* Nav: tighten Pico's default header padding and de-emphasise the links. */
body > header {
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding-block: calc(var(--pico-spacing) * 0.5);
}

body > header nav a {
  text-decoration: none;
}

/* A <form> is the only way to POST sign-out, but it shouldn't look like one. */
.nav-form {
  margin: 0;
}

.nav-form button {
  background: none;
  border: none;
  padding: 0;
  width: auto;
  color: var(--pico-secondary);
  font-size: inherit;
}

.nav-form button:hover {
  color: var(--pico-secondary-hover);
}

/* Status pills — Pico has no badge primitive. */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid currentColor;
}

.badge-active {
  color: var(--pico-ins-color);
}

.badge-reserved {
  color: #a16207;
}

.badge-revoked,
.badge-muted {
  color: var(--pico-muted-color);
}

.badge-hosted {
  color: var(--pico-primary);
}

.badge-failed {
  color: var(--pico-del-color);
}

/* Compact buttons for the workspace table's per-row actions. */
.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.actions form {
  margin: 0;
}

.actions button {
  margin: 0;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  width: auto;
  white-space: nowrap;
}

/*
 * Destructive actions (destroy a box, revoke a binding, cancel a plan). Pico
 * ships no red variant — `contrast` reads as merely emphatic, which is the
 * wrong signal for an irreversible action sitting next to Stop and Restart.
 */
button.danger,
[role="button"].danger {
  color: var(--pico-del-color);
  border-color: var(--pico-del-color);
  background-color: transparent;
}

button.danger:hover,
[role="button"].danger:hover {
  color: var(--pico-card-background-color);
  background-color: var(--pico-del-color);
  border-color: var(--pico-del-color);
}

/* Keep the workspace table readable on narrow viewports. */
.table-wrap {
  overflow-x: auto;
}

.table-wrap td,
.table-wrap th {
  white-space: nowrap;
}

/* Machine-generated values (enrollment codes, audience ids) want a mono face. */
/* On a wrapping <label> this hits only the control, not the label text. */
.mono textarea,
.mono input,
textarea.mono,
input.mono {
  font-family: var(--pico-font-family-monospace);
}

/* Forms and prose read better constrained; Pico's container is full width. */
.narrow {
  max-width: 30rem;
}

.readable {
  max-width: 42rem;
}

/*
 * Server-rendered validation output. There is no client-side validation
 * library (CP-9, minimal JS) — ASP.NET fills these on POST, so they must be
 * styled here rather than inherited from Pico.
 */
.field-validation-error,
.validation-summary-errors,
/* Pico sets an explicit `color` on <li>, so inheritance alone won't reach it. */
.validation-summary-errors li {
  display: block;
  margin-block: 0.4rem;
  color: var(--pico-del-color);
  font-size: 0.875rem;
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 1.1rem;
}

.validation-summary-errors li {
  display: list-item;
  margin-block: 0;
}

.validation-summary-valid {
  display: none;
}

/* Placeholders that ASP.NET / Stripe fill in later shouldn't reserve space. */
.field-validation-error:empty,
.validation-summary-errors:empty {
  display: none;
}

/* Stripe Elements mount into bare <div>s; make them match Pico's inputs. */
.stripe-field {
  margin-bottom: var(--pico-spacing);
  padding: var(--pico-form-element-spacing-vertical)
    var(--pico-form-element-spacing-horizontal);
  border: var(--pico-border-width) solid var(--pico-form-element-border-color);
  border-radius: var(--pico-border-radius);
  background-color: var(--pico-form-element-background-color);
  line-height: var(--pico-line-height);
}

/* Non-production banner. Sticky rather than fixed: it must stay visible while
   scrolling without the page having to reserve a matching top offset, which
   fixed positioning would silently push under on every page that sets its own
   padding. Loud on purpose — this exists to stop someone mistaking staging for
   production, and a tasteful version would fail at that. */
.env-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  justify-content: center;
  padding: 0.4rem 1rem;
  background: repeating-linear-gradient(
    45deg, #b45309, #b45309 12px, #92400e 12px, #92400e 24px
  );
  color: #fff;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-align: center;
}

.env-banner strong {
  color: #fff;
  font-weight: 700;
}

.env-banner span {
  opacity: 0.9;
}

@media print {
  /* A printed page has no address bar, so the banner is the only thing that
     says which environment a screenshot or PDF came from. */
  .env-banner { position: static; }
}
