/* CRM tab: Promo codes. Every rule is scoped to pr- classes the promos module creates.
   admin.html's own <style> loads after this file, so overrides of its shared classes use two classes. */

.pr-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.pr-help { max-width: 860px; margin: -8px 0 22px; padding-left: 12px; border-left: 4px solid var(--hivis); color: var(--ink-soft); font-size: 0.98rem; line-height: 1.5; }
.pr-help b { color: var(--ink); font-weight: 600; }
.pr-off.notice { margin-bottom: 22px; }
.pr-body { transition: opacity 0.15s; }
.pr-body[aria-busy="true"] { opacity: 0.6; }

/* Tiles: the shared .stats, three across at every width */
.pr-stats.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.pr-stats .stat { min-width: 0; }
.pr-stats .stat dt { overflow-wrap: anywhere; }
.pr-tools.tools { margin-bottom: 10px; }

/* Empty list and load errors */
.pr-empty { background: #fff; border: 1.5px dashed var(--line); border-top: 4px solid var(--asphalt); padding: 36px 20px 32px; text-align: center; }
.pr-empty p { max-width: 560px; margin: 0 auto 18px; color: var(--ink-soft); }
.pr-empty .pr-empty-title { margin-bottom: 8px; font: 400 1.4rem/1.05 var(--f-display); text-transform: uppercase; color: var(--ink); }
.pr-error { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--error); padding: 16px 18px; }
.pr-error .err { margin: 0 0 12px; }

/* Codes table */
.pr-table tbody tr { cursor: default; }
.pr-table tbody tr:hover { background: #FAFBF6; }
.pr-table th.pr-r, .pr-table td.pr-r { text-align: right; }
.pr-table td.pr-c { vertical-align: middle; }
.pr-codecell { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
@media (min-width: 761px) {
  .pr-codecell { flex-wrap: nowrap; }
  .pr-table td.pr-nowrap { white-space: nowrap; }
}
.pr-code {
  display: inline-block;
  font: 500 0.95rem/1.2 var(--f-mono);
  letter-spacing: 0.05em;
  white-space: nowrap;
  padding: 4px 8px;
  background: var(--chalk);
  border: 1.5px dashed var(--asphalt-3);
  color: var(--ink);
}
.pr-copy {
  font: 600 0.78rem/1 var(--f-cond);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 6px 8px;
  border: 1.5px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.pr-copy:hover { border-color: var(--asphalt); }
.pr-copy.pr-copied { background: var(--asphalt); border-color: var(--asphalt); color: var(--hivis); }
.pr-table small.pr-added { display: block; margin-top: 5px; font: 400 0.72rem/1.3 var(--f-mono); color: var(--ink-soft); }
.pr-disc { font-weight: 600; white-space: nowrap; }
.pr-free { display: inline-block; margin-left: 4px; padding: 3px 6px; font: 500 0.62rem/1 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; background: var(--asphalt); color: var(--hivis); vertical-align: 2px; white-space: nowrap; }
.pr-table td.pr-used { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.pr-of { font: 400 0.78rem/1 var(--f-mono); color: var(--ink-soft); }
.pr-table td.pr-when { font: 400 0.82rem/1.4 var(--f-mono); white-space: nowrap; }
.pr-table td.pr-note { min-width: 160px; max-width: 300px; overflow-wrap: anywhere; }
.pr-never { color: var(--ink-soft); }
.pr-table tr.pr-dim .pr-code { border-color: var(--line); color: var(--ink-soft); text-decoration: line-through; text-decoration-color: rgba(79, 85, 90, 0.5); }
.pr-table tr.pr-dim .pr-disc, .pr-table tr.pr-dim td.pr-used { color: var(--ink-soft); }

.pr-b-active { background: var(--hivis); color: var(--asphalt); }
.pr-b-off { background: var(--chalk-2); color: var(--ink-soft); }
.pr-b-expired { background: #FFE2D4; color: #8A2F0A; }
.pr-b-used { background: var(--asphalt); color: var(--on-dark); }

/* On / off switch: square, like the rest of the Hi-Vis kit */
.pr-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--ink);
  font: 600 0.85rem/1 var(--f-cond);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.pr-track { position: relative; display: inline-block; width: 42px; height: 24px; border: 2px solid var(--asphalt-3); border-radius: 2px; background: var(--chalk-2); transition: background 0.15s, border-color 0.15s; }
.pr-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 1px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.pr-switch[aria-checked="true"] .pr-track { background: var(--asphalt); border-color: var(--asphalt); }
.pr-switch[aria-checked="true"] .pr-knob { transform: translateX(18px); background: var(--hivis); }
.pr-switch:hover .pr-track { border-color: var(--asphalt); }
.pr-switch-text { min-width: 3.4em; }
.pr-switch[aria-disabled="true"] { cursor: not-allowed; opacity: 0.45; }
.pr-switch[aria-disabled="true"]:hover .pr-track { border-color: var(--asphalt-3); }
.pr-switch[aria-busy="true"] { opacity: 0.7; cursor: progress; }

/* The row just created */
.pr-table tr.pr-flash { animation: pr-flash 2.6s ease-out; }
@keyframes pr-flash { 0%, 30% { background: rgba(229, 242, 48, 0.55); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .pr-table tr.pr-flash { animation: none; } .pr-track, .pr-knob { transition: none; } }

/* Narrow screens: each code becomes a card, its details in a two-column grid of label-over-value cells */
@media (max-width: 760px) {
  .pr-wrap.table-wrap { overflow: visible; background: none; border: 0; }
  .pr-table thead { display: none; }
  .pr-table, .pr-table tbody { display: block; width: 100%; }
  .pr-table tr.pr-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--hivis); margin-bottom: 12px; padding: 0 14px 4px; }
  .pr-table tr.pr-row.pr-dim { border-top-color: var(--line); }
  .pr-table tr.pr-row td.pr-c { display: block; min-width: 0; max-width: none; padding: 8px 0; border-bottom: 1px dashed var(--line); text-align: left; white-space: normal; }
  .pr-table tr.pr-row td.pr-c[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; font: 500 0.64rem/1.3 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
  .pr-table tr.pr-row td.pr-c .pr-v { min-width: 0; overflow-wrap: anywhere; }
  .pr-table tr.pr-row td.pr-c.pr-c-code, .pr-table tr.pr-row td.pr-c.pr-note { grid-column: 1 / -1; }
  .pr-table tr.pr-row td.pr-c.pr-c-code { padding: 12px 0 10px; }
  .pr-table tr.pr-row .pr-code { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .pr-table tr.pr-row td.pr-c:nth-last-child(-n+2) { border-bottom: 0; }
  .pr-table tr.pr-row td.pr-c-switch .pr-switch { padding: 2px 0; }
  .pr-table tr.pr-row .pr-switch-text { min-width: 0; }
}
@media (max-width: 760px) {
  .pr-table tr.pr-none-row, .pr-table tr.pr-none-row td { display: block; }
  .pr-table tr.pr-none-row td { background: #fff; border: 1px solid var(--line); }
}

/* New code sheet */
dialog.sheet.pr-sheet { width: min(640px, calc(100vw - 24px)); }
.pr-sheet .pr-sheet-sub { margin-top: 6px; }
.pr-coderow { display: flex; gap: 8px; }
.pr-coderow .pr-code-input { flex: 1 1 auto; min-width: 0; font: 500 1.1rem/1.2 var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.pr-coderow .pr-code-input::placeholder { color: #A3A89F; letter-spacing: 0.08em; }
.pr-coderow .btn { flex: none; }
.pr-fhint { margin: 6px 0 0; font-size: 0.85rem; line-height: 1.4; color: var(--ink-soft); }
.field label .pr-opt-tag { margin-left: 4px; font-weight: 400; letter-spacing: 0.02em; text-transform: none; color: #7A8085; }

fieldset.pr-kind { margin: 0; padding: 0; border: 0; min-width: 0; }
.pr-kind legend { display: block; padding: 0; margin-bottom: 6px; font: 500 0.74rem/1.2 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.pr-seg { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--line); border-radius: 2px; background: var(--chalk); }
.pr-seg .pr-opt { position: relative; display: block; margin: 0; font: 600 0.95rem/1 var(--f-cond); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink); cursor: pointer; }
.pr-seg .pr-opt + .pr-opt { border-left: 1.5px solid var(--line); }
.pr-seg .pr-radio { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; }
.pr-seg .pr-opt span { display: block; padding: 12px 10px; text-align: center; }
.pr-seg .pr-opt:hover span { background: #fff; }
.pr-seg .pr-radio:checked + span { background: var(--asphalt); color: var(--hivis); }
.pr-seg .pr-radio:focus-visible + span { outline: 3px solid var(--sky); outline-offset: -3px; }

.pr-affix { display: flex; }
.pr-affix .pr-pre, .pr-affix .pr-suf { display: flex; align-items: center; padding: 0 12px; background: var(--chalk-2); border: 1.5px solid var(--line); font: 500 0.95rem/1 var(--f-mono); color: var(--ink-soft); }
.pr-affix .pr-pre { border-right: 0; }
.pr-affix .pr-suf { border-left: 0; }
.pr-affix input { flex: 1 1 auto; min-width: 0; }

.pr-summary { margin: 18px 0 0; padding: 10px 12px; background: #fff; border-left: 4px solid var(--hivis); font-size: 0.95rem; line-height: 1.5; overflow-wrap: anywhere; }
.pr-summary-code { display: inline-block; margin-right: 6px; padding: 2px 7px; font: 500 0.85rem/1.4 var(--f-mono); letter-spacing: 0.05em; background: var(--asphalt); color: var(--hivis); }
