/*
 * Additions the admin template does not have. Built only from the template's tokens (variables.css),
 * so they follow the light/dark theme and the accent colour.
 * Parts: busy button spinner, 20-row pager helper, diff viewer, FROM/TO direction boxes, change list, small helpers.
 */

/* helpers */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.narrow { max-width: 520px; }
.modal-wide { width: min(720px, 100%); }
.pg-hide { display: none; }
tr.click { cursor: pointer; }
tr.click:hover { background: var(--surface-2); }
fieldset.field { border: 0; padding: 0; margin: 0 0 var(--sp-4); min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; font-size: var(--fs-sm); font-weight: 600; }
.ok-text { color: var(--up); }
details > summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-muted); padding: var(--sp-2) 0; }

/* a button that is working shows a spinner and cannot be pressed again */
[aria-busy="true"] { position: relative; cursor: progress; opacity: .75; }
[aria-busy="true"]::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: hub-spin .7s linear infinite;
}
@keyframes hub-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [aria-busy="true"]::before { animation: none; border-right-color: currentColor; } }

/* diff viewer */
.diff { margin: 0; max-height: 520px; overflow: auto; font-family: var(--font-mono); font-size: 12px; background: var(--surface); border-top: 1px solid var(--border); }
.diff .ln { white-space: pre; padding: 0 var(--sp-3); line-height: 1.55; color: var(--text-muted); }
.diff .ln.add { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--text); }
.diff .ln.del { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--text); }
.diff .ln.skip { background: var(--surface-2); color: var(--text-faint); font-style: italic; }
.diff mark { background: color-mix(in srgb, var(--warn) 45%, transparent); color: inherit; border-radius: 2px; }
.diff-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.diff-key { padding: 2px var(--sp-2); border-radius: var(--radius-sm); font-size: var(--fs-xs); }
.diff-key.add { background: color-mix(in srgb, var(--up) 14%, transparent); }
.diff-key.del { background: color-mix(in srgb, var(--down) 14%, transparent); }

/* FROM -> TO direction boxes (sync) */
.flow { display: flex; gap: var(--sp-4); align-items: stretch; flex-wrap: wrap; }
.flow-box { flex: 1 1 0; min-width: 240px; display: flex; flex-direction: column; justify-content: center; padding: var(--sp-4); border: 2px solid; border-radius: var(--radius-lg); }
.flow-box select { width: 100%; margin: var(--sp-2) 0; }
.flow-box.from { border-color: var(--up); background: color-mix(in srgb, var(--up) 8%, transparent); }
.flow-box.to { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.flow-title { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; }
.flow-box.from .flow-title { color: var(--up); }
.flow-box.to .flow-title { color: var(--warn); }
.flow-note { font-size: var(--fs-xs); color: var(--text-muted); }
.flow-arrow { flex: 0 0 auto; min-width: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2); }
.flow-arrow-mark { font-size: 32px; line-height: 1; color: var(--accent); }
.direction { padding: var(--sp-3) var(--sp-4); border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); margin: var(--sp-4) 0 0; }
@media (max-width: 640px) { .flow-arrow-mark { transform: rotate(90deg); } }

/* plain-language list of changes */
.changes { list-style: none; margin: 0 0 var(--sp-3); padding: 0; }
.changes li { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); }
.changes li.skip { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.changes li.warn { background: color-mix(in srgb, var(--down) 12%, transparent); }
pre.script { margin: var(--sp-2) 0 0; padding: var(--sp-3); max-height: 420px; overflow: auto; white-space: pre-wrap; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* button rows wrap on a phone instead of pushing the page sideways */
.page-head .flex, .card-head .flex, .modal-foot { flex-wrap: wrap; }

/* modals fade and rise in; a modal that was just refreshed behind the scenes does not replay it */
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal.open { animation: modal-fade .18s ease-out; }
.modal.open .modal-dialog { animation: modal-rise .22s cubic-bezier(.2, .8, .2, 1); }
.modal.modal-still, .modal.modal-still .modal-dialog { animation: none; }
@media (prefers-reduced-motion: reduce) { .modal.open, .modal.open .modal-dialog { animation: none; } }

/* a table directly inside a card follows the card's rounded corners (header cells and the scroll box were square) */
.card > .table-wrap { border-radius: inherit; overflow-y: hidden; }
.card > .table-wrap .table thead th:first-child { border-top-left-radius: calc(var(--radius-lg) - 1px); }
.card > .table-wrap .table thead th:last-child { border-top-right-radius: calc(var(--radius-lg) - 1px); }
.card > .table-wrap .table tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius-lg) - 1px); }
.card > .table-wrap .table tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius-lg) - 1px); }

/* the tab row scrolls sideways only; it showed a small vertical scrollbar */
.tabs { overflow-y: hidden; }

[hidden] { display: none !important; }

.table-click tbody tr[data-href] { cursor: pointer; }
h1:focus { outline: none; }

form.inline { display: inline; }
.text-danger { color: var(--down, #e5484d); }

.er-wrap { overflow-x: auto; border-top: 1px solid var(--border); background: var(--surface); }
.er { display: block; font-size: 12px; max-width: none; height: auto; }
.er-box { fill: var(--surface); stroke: var(--border); }
.er-head { fill: var(--accent); }
.er-name { fill: #fff; font-weight: 600; }
.er-col { fill: var(--text); }
.er-type { fill: var(--text-muted); }
.er-line { fill: none; stroke: var(--text-muted); stroke-width: 1.4; opacity: .5; transition: opacity .15s, stroke .15s; }
.er-line, .er-dot { pointer-events: none; }
.er-dot { fill: var(--text-muted); opacity: .6; }
.er-dot-src { opacity: .35; }
.er a, .er a:hover { text-decoration: none; }
.er-pk { font-weight: 600; }
.er-fk { fill: var(--accent); }
.er.hl .er-line, .er.hl .er-dot { opacity: .08; }
.er.hl .er-line.on { opacity: 1; stroke: var(--accent); stroke-width: 2.2; }
.er.hl .er-dot.on { opacity: 1; fill: var(--accent); }
.er.hl .er-t { opacity: .35; }
.er.hl .er-t.on { opacity: 1; }
.er a { cursor: pointer; }
.er .er-t:hover .er-box { stroke-width: 2.5; }
.er .er-t.st-none:hover .er-box, .er .er-t.st-same:hover .er-box { stroke: var(--accent); } /* tables with a status keep their own colour */
.struct-table { scroll-margin-top: 80px; }

.page-loading { opacity: .55; pointer-events: none; cursor: progress; transition: opacity .15s; }
.page-loading::before { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 40%; background: var(--accent); z-index: 100; animation: hub-bar 1s ease-in-out infinite; }
@keyframes hub-bar { 0% { left: -40%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .page-loading::before { animation: none; width: 100%; left: 0; } }

.er-t.st-del .er-head { fill: var(--down, #e5484d); }
.er-t.st-add .er-head { fill: var(--up, #30a46c); }
.er-t.st-chg .er-head { fill: var(--warn, #f5a623); }
.er-t.st-del .er-box { stroke: var(--down, #e5484d); stroke-width: 2; }
.er-t.st-add .er-box { stroke: var(--up, #30a46c); stroke-width: 2; }
.er-t.st-chg .er-box { stroke: var(--warn, #f5a623); stroke-width: 2; }
.er-t.st-same { opacity: .45; }
.er.hl .er-t.st-same.on { opacity: 1; }
.er-c-add { fill: var(--up, #30a46c); font-weight: 600; }
.er-c-del { fill: var(--down, #e5484d); font-weight: 600; text-decoration: line-through; }
.er-c-chg { fill: var(--warn, #b7791f); font-weight: 600; }
.diff-key.chg { background: color-mix(in srgb, var(--warn, #f5a623) 25%, transparent); }
.er-t.st-same .er-head { fill: var(--text-muted); }

.compare-row { grid-template-columns: 1fr auto 1fr; align-items: end; }
.compare-arrow { font-size: 22px; line-height: 1; color: var(--accent); padding-bottom: calc(var(--sp-4) + 8px); font-weight: 700; }
@media (max-width: 640px) { .compare-row { grid-template-columns: 1fr; } .compare-arrow { padding: 0; text-align: center; transform: rotate(90deg); } }
