/* ui.css — shared UI pieces for the Admin Portal (portal.html) and the
   Platform Console (index.html). Paired with ui.js. Design audit Batch 1
   (decision 1, 2026-09-24): one shared file, not a mirrored copy.

   Every rule is namespaced .pd-ui-* so nothing here can restyle a page's own
   elements, and every colour is a locked design-system value from
   DESIGN_STANDARD.md, defined once below. Fonts are inherited: both pages
   already self-host Public Sans (fontSrc 'self' in the CSP). */

:root {
  --pd-ui-navy:     #0F1B2E;
  --pd-ui-red:      #7C1D1D;
  --pd-ui-ink:      #121B29;
  --pd-ui-cream:    #F1F4F8;
  --pd-ui-white:    #FFFFFF;
  --pd-ui-dim:      #55606E;  /* 5.80:1 on cream, 6.39:1 on white */
  --pd-ui-line:     #D8DEE6;
  --pd-ui-gold:     #D6A83E;  /* focus ring on navy 7.83:1, on red 4.65:1 */
  --pd-ui-gold-ink: #7F5F1A;  /* focus ring on light surfaces: 5.91:1 on white */
  --pd-ui-radius:   8px;
}

/* ── Toast ───────────────────────────────────────────────────────────────
   Shown in the browser's top layer (popover="manual", re-shown on every
   message) so it always sits above an open <dialog> or modal backdrop.
   Success: navy + white (17.26:1). Error: stamp red + white (10.24:1). */
.pd-ui-toast {
  position: fixed;
  inset: auto 24px 24px auto;
  margin: 0;
  z-index: 2147483000;           /* fallback only; the top layer needs none */
  max-width: min(420px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 12px 12px 12px 18px;
  border: 0;
  border-radius: var(--pd-ui-radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--pd-ui-white);
  background: var(--pd-ui-navy);
  display: none;
  align-items: flex-start;
  gap: 12px;
  overflow: visible;
}
.pd-ui-toast.is-shown { display: flex; }
.pd-ui-toast.is-error { background: var(--pd-ui-red); }
.pd-ui-toast:popover-open { display: flex; }
.pd-ui-toast-msg:empty { display: none; }
.pd-ui-toast-text { flex: 1; min-width: 0; padding-top: 2px; }
.pd-ui-toast-btn {
  flex: none;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 6px;
  background: transparent;
  color: var(--pd-ui-white);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 10px;
  cursor: pointer;
}
.pd-ui-toast-btn:hover { background: rgba(255, 255, 255, .12); }
.pd-ui-toast-btn:focus-visible,
.pd-ui-toast-close:focus-visible { outline: 2px solid var(--pd-ui-gold); outline-offset: 2px; }
.pd-ui-toast-btn[hidden] { display: none; }
.pd-ui-toast-close {
  flex: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--pd-ui-white);
  font-size: 20px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
}
.pd-ui-toast-close:hover { background: rgba(255, 255, 255, .12); }

@media (max-width: 600px) {
  .pd-ui-toast { inset: auto 16px 16px 16px; max-width: none; width: auto; } /* [popover] defaults to fit-content */
}

/* ── Confirm dialog (built in ui.js; not yet used by any screen) ──────── */
.pd-ui-confirm {
  margin: auto;        /* a page-wide "* { margin: 0 }" reset (portal.html) would pin it top-left */
  border: 0;
  border-radius: 12px;
  padding: 24px;
  width: min(440px, calc(100vw - 32px));
  box-sizing: border-box;
  color: var(--pd-ui-ink);
  background: var(--pd-ui-white);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  font-family: inherit;
}
.pd-ui-confirm::backdrop { background: rgba(15, 27, 46, .55); }
.pd-ui-confirm-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.pd-ui-confirm-msg { margin: 0 0 20px; font-size: 14px; line-height: 1.5; color: var(--pd-ui-ink); white-space: pre-line; }
.pd-ui-confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.pd-ui-btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 7px;
  padding: 8px 16px;
  cursor: pointer;
  border: 1px solid var(--pd-ui-line);
  background: var(--pd-ui-white);
  color: var(--pd-ui-ink);
}
.pd-ui-btn.is-primary     { background: var(--pd-ui-gold); border-color: var(--pd-ui-gold); color: var(--pd-ui-ink); }
.pd-ui-btn.is-destructive { background: var(--pd-ui-red); border-color: var(--pd-ui-red); color: var(--pd-ui-white); }
.pd-ui-btn:focus-visible  { outline: 2px solid var(--pd-ui-gold-ink); outline-offset: 2px; }

/* ── Empty state (built in ui.js; not yet used by any screen) ─────────── */
.pd-ui-empty { padding: 32px 24px; text-align: center; color: var(--pd-ui-dim); font-size: 14px; line-height: 1.5; }
.pd-ui-empty-msg { margin: 0; }
.pd-ui-empty .pd-ui-btn { margin-top: 14px; }

/* ── Empty value ("Not set") ──────────────────────────────────────────── */
.pd-ui-not-set { color: var(--pd-ui-dim); }
