/*
 * PD-732: Operations > Manual labels > PDF label, in the Prometheus Ember look
 * (ADR-4044). Legacy pages must not load Ember UI assets, so the Ember token
 * values are mirrored here as --plx-* and scoped to .plx; keep them in step with
 * the Ember tokens stylesheet.
 */
.plx {
  --plx-surface: #ffffff;
  --plx-surface-2: #f7f8fb;
  --plx-surface-3: #eef1f6;
  --plx-hover: rgba(13, 20, 36, 0.045);
  --plx-line: #e1e6ee;
  --plx-line-strong: #cdd5e1;
  --plx-text: #0d1424;
  --plx-text-2: #435069;
  --plx-text-3: #5b677e;
  --plx-accent: #3057e1;
  --plx-accent-hover: #2446c2;
  --plx-accent-soft: #e9eefd;
  --plx-accent-text: #2446c2;
  --plx-on-accent: #ffffff;
  --plx-ember: #f06a35;
  --plx-ok-text: #11703f;
  --plx-ok-soft: #e2f5e9;
  --plx-warn-text: #8a5400;
  --plx-warn-soft: #fdf1d8;
  --plx-crit-text: #b12218;
  --plx-crit-soft: #fde7e5;
  --plx-neutral-soft: #eceff4;
  --plx-neutral-text: #4a566c;
  --plx-shadow-1: 0 1px 2px rgba(13, 20, 36, 0.06), 0 0 0 1px rgba(13, 20, 36, 0.05);
  --plx-shadow-2: 0 12px 32px -14px rgba(13, 20, 36, 0.24), 0 2px 6px -2px rgba(13, 20, 36, 0.08);
  --plx-scrim: rgba(13, 20, 36, 0.38);
  --plx-font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --plx-r-sm: 8px;
  --plx-r-md: 10px;
  --plx-r-lg: 14px;
  --plx-ctl-h: 36px;

  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--plx-r-lg);
  background: var(--plx-surface-2);
  color: var(--plx-text);
  font-family: var(--plx-font);
  font-size: 14px;
}

html[data-theme="dark"] .plx {
  --plx-surface: #181b20;
  --plx-surface-2: #1e2127;
  --plx-surface-3: #262a31;
  --plx-hover: rgba(255, 255, 255, 0.05);
  --plx-line: #2a2e36;
  --plx-line-strong: #383d47;
  --plx-text: #eceef3;
  --plx-text-2: #a9aeb8;
  --plx-text-3: #8a909b;
  --plx-accent: #4668f0;
  --plx-accent-hover: #5a7af5;
  --plx-accent-soft: rgba(91, 124, 255, 0.14);
  --plx-accent-text: #a3b5ff;
  --plx-ok-text: #62d79c;
  --plx-ok-soft: rgba(52, 194, 122, 0.14);
  --plx-warn-text: #f2c060;
  --plx-warn-soft: rgba(232, 165, 36, 0.14);
  --plx-crit-text: #ff8f86;
  --plx-crit-soft: rgba(240, 86, 76, 0.15);
  --plx-neutral-soft: rgba(255, 255, 255, 0.07);
  --plx-neutral-text: #b6bcc7;
  --plx-shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 2px rgba(0, 0, 0, 0.4);
  --plx-shadow-2: 0 14px 36px -14px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --plx-scrim: rgba(0, 0, 0, 0.55);
}

.plx [hidden] {
  display: none !important;
}

.plx-min0 { min-width: 0; }

/* Header */
.plx-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.plx-eyebrow {
  color: var(--plx-ember);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.plx-head h3 {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.plx-sub {
  margin: 4px 0 0;
  color: var(--plx-text-2);
  font-size: 13.5px;
}

.plx-head-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Pills */
.plx-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.plx-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.plx-pill--neutral { background: var(--plx-neutral-soft); color: var(--plx-neutral-text); }
.plx-pill--accent { background: var(--plx-accent-soft); color: var(--plx-accent-text); }
.plx-pill--ok { background: var(--plx-ok-soft); color: var(--plx-ok-text); }
.plx-pill--warn { background: var(--plx-warn-soft); color: var(--plx-warn-text); }
.plx-pill--crit { background: var(--plx-crit-soft); color: var(--plx-crit-text); }

/* Layout */
.plx-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

@media (max-width: 900px) {
  .plx-grid { grid-template-columns: minmax(0, 1fr); }
}

.plx-card {
  background: var(--plx-surface);
  border-radius: var(--plx-r-lg);
  box-shadow: var(--plx-shadow-1);
  padding: 16px;
}

.plx-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Steps */
.plx-step {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.plx-step:first-child { margin-top: 0; }

.plx-step h4 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 650;
}

.plx-step-n {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--plx-accent-soft);
  color: var(--plx-accent-text);
  font-size: 11.5px;
  font-weight: 700;
}

/* Drop zone */
.plx-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  border: 1.5px dashed var(--plx-line-strong);
  border-radius: var(--plx-r-md);
  background: var(--plx-surface-2);
  color: var(--plx-text-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.plx-drop:hover,
.plx-drop.is-over {
  border-color: var(--plx-accent);
  background: var(--plx-accent-soft);
}

.plx-drop:focus-within {
  outline: 3px solid var(--plx-accent-soft);
  border-color: var(--plx-accent);
}

.plx-drop.has-file {
  border-style: solid;
  border-color: var(--plx-accent);
}

.plx-drop-title {
  color: var(--plx-text);
  font-weight: 600;
}

.plx-drop-title u { color: var(--plx-accent-text); text-underline-offset: 2px; }

.plx-drop-meta {
  font-size: 12.5px;
  color: var(--plx-text-3);
  overflow-wrap: anywhere;
}

.plx-file {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.plx-i {
  width: 18px;
  height: 18px;
  flex: none;
}

.plx-i--lg {
  width: 36px;
  height: 36px;
}

/* Fields */
.plx-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.plx-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.plx-field--wide { grid-column: 1 / -1; }

.plx-field > span {
  color: var(--plx-text-2);
  font-size: 12.5px;
  font-weight: 550;
}

.plx .plx-input {
  width: 100%;
  min-height: var(--plx-ctl-h);
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--plx-line-strong);
  border-radius: var(--plx-r-md);
  background: var(--plx-surface);
  color: var(--plx-text);
  font: inherit;
  font-size: 13.5px;
  box-sizing: border-box;
}

.plx .plx-input:focus {
  outline: 3px solid var(--plx-accent-soft);
  border-color: var(--plx-accent);
}

.plx .plx-input--sm {
  width: auto;
  min-height: 30px;
  font-size: 12.5px;
}

.plx-help {
  margin: 0;
  color: var(--plx-text-3);
  font-size: 12.5px;
  line-height: 1.45;
}

/* Buttons */
.plx .plx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--plx-ctl-h);
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--plx-line-strong);
  border-radius: var(--plx-r-md);
  background: var(--plx-surface);
  color: var(--plx-text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 120ms;
}

.plx .plx-btn:hover:not(:disabled) { background: var(--plx-surface-2); }
.plx .plx-btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.plx .plx-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.plx .plx-btn:focus-visible { outline: 3px solid var(--plx-accent-soft); outline-offset: 1px; }

.plx .plx-btn--primary {
  min-height: 40px;
  padding: 0 18px;
  border-color: transparent;
  background: var(--plx-accent);
  color: var(--plx-on-accent);
}

.plx .plx-btn--primary:hover:not(:disabled) { background: var(--plx-accent-hover); }

.plx .plx-btn--icon {
  width: var(--plx-ctl-h);
  padding: 0;
}

.plx .plx-btn--sm {
  min-height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: var(--plx-r-sm);
}

.plx-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Pages */
.plx-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--plx-line);
  border-radius: var(--plx-r-md);
}

.plx-pages legend {
  padding: 0 4px;
  color: var(--plx-text-2);
  font-size: 12.5px;
  font-weight: 550;
}

.pdf-label-page-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* Canvas */
.plx-canvas {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 420px;
}

.plx-canvas-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.plx-seg {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--plx-surface-3);
}

.plx .plx-seg button {
  min-height: 30px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: var(--plx-r-sm);
  background: none;
  color: var(--plx-text-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}

.plx .plx-seg button[aria-checked="true"] {
  background: var(--plx-surface);
  color: var(--plx-text);
  box-shadow: var(--plx-shadow-1);
}

.plx .plx-seg button:disabled { opacity: 0.5; cursor: not-allowed; }

.plx-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 340px;
  border-radius: var(--plx-r-md);
  background:
    radial-gradient(circle at 1px 1px, var(--plx-line) 1px, transparent 0) 0 0 / 16px 16px,
    var(--plx-surface-2);
  color: var(--plx-text-3);
  font-size: 13.5px;
}

.plx-stage {
  position: relative;
  align-self: center;
  width: min(100%, 520px);
  overflow: hidden;
  border-radius: var(--plx-r-sm);
  background: #fff;
  box-shadow: var(--plx-shadow-2);
  touch-action: none;
  user-select: none;
}

.plx-stage img {
  display: block;
  width: 100%;
  height: auto;
}

.pdf-label-crop {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--plx-accent);
  border-radius: 2px;
  box-shadow: 0 0 0 9999px var(--plx-scrim);
  cursor: move;
}

.pdf-label-crop:focus-visible {
  outline: 3px solid var(--plx-ember);
  outline-offset: 2px;
}

.pdf-label-crop-handle {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--plx-accent);
  cursor: nwse-resize;
}

.plx-result {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--plx-r-md);
  background: var(--plx-surface-3);
}

.pdf-label-result-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.pdf-label-result-page img {
  display: block;
  max-width: min(100%, 300px);
  height: auto;
  border-radius: 4px;
  background: #fff;
  box-shadow: var(--plx-shadow-2);
  image-rendering: pixelated;
}

.pdf-label-result-page figcaption,
.plx-meta {
  color: var(--plx-text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.plx-meta { text-align: center; }

/* Action bar */
.plx-bar {
  position: sticky;
  bottom: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px 10px 16px;
  border-radius: var(--plx-r-lg);
  background: var(--plx-surface);
  box-shadow: var(--plx-shadow-2);
}

.plx-bar-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plx-status {
  color: var(--plx-text-2);
  font-size: 13px;
}

.plx-status.error { color: var(--plx-crit-text); }

.plx-job {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 560px) {
  .plx { padding: 12px; }
  .plx-fields { grid-template-columns: minmax(0, 1fr); }
  .plx-bar { position: static; }
  .plx-bar .plx-btn--primary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .plx .plx-btn,
  .plx-drop { transition: none; }
}
