/* =========================================================================
   Operator console refinements layered over the vendored Velzon/Poshesh CSS.

   The first half is the previous console's stylesheet, rule for rule, so every screen keeps its
   exact look. The second half is what this console adds: the motion layer, the top progress bar,
   and the few affordances a server-rendered page needs that React used to provide. Everything
   visual still comes from /assets/velzon/css; anything console-specific is prefixed `panel-`.

   The console's CSP admits no inline style, so nothing here may rely on a style attribute.
   ========================================================================= */

:root {
  --panel-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --panel-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --panel-fast: 120ms;
  --panel-base: 200ms;
  --panel-slow: 320ms;
  --panel-loader: #019c9d;
}

/* Elements toggled with `hidden` must stay hidden whatever a utility class says. */
[hidden] {
  display: none !important;
}

/* ---------- Previous console (globals.css), unchanged ---------- */

/* Toasts (script-driven; Bootstrap's JS animation is not loaded). */
.panel-toast {
  animation: panel-toast-in 0.22s var(--panel-ease-out);
}

.panel-toast-leave {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes panel-toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Persistent copies of toast feedback, rendered directly below every page header. */
.panel-page-alerts {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.panel-page-alert {
  animation: panel-page-alert-in 0.2s ease-out;
  box-shadow: 0 0.35rem 1rem -0.85rem rgba(15, 34, 58, 0.45);
  margin-bottom: 0;
  padding-inline-end: 3rem;
}

@keyframes panel-page-alert-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Sortable table headers. */
th.panel-sortable {
  cursor: pointer;
  user-select: none;
}

.panel-sort-icon {
  font-size: 0.8125rem;
  opacity: 0.55;
}

/* Dashboard KPIs: compact information cards with a stable icon treatment. */
.panel-stat-tile {
  --panel-stat-rgb: var(--vz-primary-rgb, 64, 81, 137);
  isolation: isolate;
  min-height: 8.25rem;
  overflow: hidden;
  position: relative;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.panel-stat-tile[data-tone="success"] {
  --panel-stat-rgb: var(--vz-success-rgb, 10, 179, 156);
}

.panel-stat-tile[data-tone="danger"] {
  --panel-stat-rgb: var(--vz-danger-rgb, 240, 101, 72);
}

.panel-stat-tile[data-tone="warning"] {
  --panel-stat-rgb: var(--vz-warning-rgb, 247, 184, 75);
}

.panel-stat-tile[data-tone="info"] {
  --panel-stat-rgb: var(--vz-info-rgb, 41, 156, 219);
}

.panel-stat-tile[data-tone="secondary"] {
  --panel-stat-rgb: var(--vz-secondary-rgb, 53, 119, 241);
}

.panel-stat-tile::before {
  background: linear-gradient(90deg, rgba(var(--panel-stat-rgb), 0), rgba(var(--panel-stat-rgb), 0.78));
  content: "";
  height: 3px;
  inset-inline: 0;
  position: absolute;
  top: 0;
  z-index: 1;
}

.panel-stat-tile::after {
  background: rgba(var(--panel-stat-rgb), 0.055);
  border-radius: 50%;
  content: "";
  height: 7rem;
  inset-inline-end: -3.3rem;
  pointer-events: none;
  position: absolute;
  top: -3.7rem;
  width: 7rem;
  z-index: -1;
}

.panel-stat-tile:hover {
  border-color: rgba(var(--panel-stat-rgb), 0.28);
  box-shadow: var(--poshesh-ui-shadow-lift, 0 1rem 2rem -1.25rem rgba(15, 34, 58, 0.28));
  transform: translateY(-2px);
}

.panel-stat-tile .card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel-stat-label {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 0.85rem;
}

.panel-stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 0.45rem;
  font-variant-numeric: tabular-nums;
}

.panel-stat-hint {
  font-size: 0.72rem;
}

.panel-stat-icon,
.panel-stat-icon .avatar-title {
  height: 3rem;
  width: 3rem;
}

.panel-stat-icon .avatar-title {
  border: 1px solid rgba(var(--panel-stat-rgb), 0.12);
  border-radius: 0.8rem;
  box-shadow: 0 0.55rem 1.2rem -0.8rem rgba(var(--panel-stat-rgb), 0.85);
  font-size: 1.35rem;
}

/* Shared table empty state; keeps its icon legible in both colour schemes. */
.panel-empty-state {
  align-items: center;
  color: var(--poshesh-ui-muted, #878a99);
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  gap: 0.7rem;
  justify-content: center;
  min-height: 9rem;
  padding: 1.5rem;
  text-align: center;
}

.panel-empty-state-icon {
  align-items: center;
  background: var(--poshesh-brand-50, #eff6f9);
  border: 1px solid rgba(var(--poshesh-brand-rgb, 11, 98, 128), 0.12);
  border-radius: 0.85rem;
  color: var(--poshesh-ui-primary, #0b6280);
  display: inline-flex;
  font-size: 1.5rem;
  height: 3.25rem;
  justify-content: center;
  width: 3.25rem;
}

tr.panel-row-clickable {
  cursor: pointer;
}

/* Monospace snippets (fingerprints, hashes, codes). */
.panel-mono {
  direction: ltr;
  unicode-bidi: embed;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8125rem;
}

/* Issued licence codes are handed on from this one screen — make them legible. */
.panel-code-display {
  direction: ltr;
  font-family: Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
}

/* Login screen (auth pages render outside the shell). */
.panel-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 460px at 85% -10%, rgba(1, 156, 157, 0.14), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(11, 98, 128, 0.16), transparent 55%),
    var(--vz-body-bg, #f3f6f9);
  padding: 2rem 1rem;
}

.panel-auth-card {
  width: 100%;
  max-width: 430px;
  transition: max-width var(--panel-slow) var(--panel-ease-out);
}

/* Enrolling a second factor at sign-in: the QR and the steps side by side need the room. */
.panel-auth-card.panel-auth-card-wide {
  max-width: 760px;
}

/* The enrolment QR, and its placeholder while the service draws it (previously an inline style). */
.panel-totp-qr-frame,
.panel-totp-qr {
  width: 220px;
  height: 220px;
}

/* Public download page (no session; renders outside the shell like the login). */
.panel-download-card {
  width: 100%;
  max-width: 640px;
}

.panel-download-button {
  font-weight: 600;
}

/* A 64-character hash must wrap inside the row rather than widen the card. */
.panel-download-hash {
  overflow-wrap: anywhere;
  word-break: break-all;
}

.panel-download-steps {
  color: var(--vz-body-color, #212529);
  line-height: 2;
  padding-inline-start: 1.25rem;
}

/* One publicly offered mobile app on the download page. */
.panel-download-app {
  border-color: var(--vz-border-color, #e9ebec) !important;
}

.panel-download-app:last-of-type {
  margin-bottom: 1.5rem !important;
}

.panel-release-notes {
  background: var(--vz-light, #f3f6f9);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  white-space: pre-line;
  font-size: 0.875rem;
}

/* Published-version chip in the topbar, and its banner form under the login card. */
.panel-release-chip {
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  align-self: center;
  text-decoration: none;
}

.panel-release-banner {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--vz-border-color, #e9ebec);
  border-radius: 0.5rem;
  background: var(--vz-secondary-bg, #fff);
}

.panel-public-page-links {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--vz-border-color, #e9ebec);
  border-radius: 0.5rem;
  background: var(--vz-card-bg, #fff);
}

/* Detail rows in drawers/detail cards. */
.panel-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--vz-border-color, #e9ebec);
}

.panel-detail-row:last-child {
  border-bottom: 0;
}

.panel-detail-row dt {
  font-weight: 500;
  color: var(--vz-secondary-color, #878a99);
  font-size: 0.8125rem;
  white-space: nowrap;
  margin: 0;
}

.panel-detail-row dd {
  margin: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

/* Guide block editor cards. */
.panel-block-card {
  border: 1px solid var(--vz-border-color, #e9ebec);
  border-radius: 0.5rem;
  background: var(--vz-secondary-bg, #fff);
}

.panel-block-card .panel-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--vz-border-color, #e9ebec);
  background: var(--vz-light, #f3f6f9);
  border-radius: 0.5rem 0.5rem 0 0;
}

/* Floating suggestions do not resize the centered dialog when opened. */
.panel-guide-topic-control {
  position: relative;
}

.panel-guide-topic-menu {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 0.375rem);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--vz-border-color, #e9ebec);
  border-radius: 0.5rem;
  background: var(--vz-secondary-bg, #fff);
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.14);
}

.panel-guide-topic-menu-above {
  top: auto;
  bottom: calc(100% + 0.375rem);
}

.panel-guide-topic-heading {
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--vz-border-color, #e9ebec);
  font-size: 0.75rem;
}

.panel-guide-topic-options {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  outline: none;
}

.panel-guide-topic-options .list-group-item {
  cursor: pointer;
  overflow-wrap: anywhere;
}

.panel-guide-topic-active {
  background-color: var(--vz-light, #f3f6f9);
  box-shadow: inset -3px 0 var(--vz-primary, #405189);
}

/* Modal stacking (the script positions stacked dialogs above this). */
.modal.show.d-block {
  z-index: 1055;
}

/* Which service the session is signed in to (topbar). */
.panel-server-chip {
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  align-self: center;
}

/* Extension icons in listings. */
.panel-ext-icon {
  width: 42px;
  height: 42px;
  border-radius: 0.5rem;
  object-fit: cover;
  background: var(--vz-light, #f3f6f9);
}

/* The package page's larger artwork (an inline 64px size in the previous console). */
.panel-ext-icon-lg {
  width: 64px;
  height: 64px;
}

/* Large, explicit local ZIP chooser used by core and extension release flows. */
.panel-zip-picker {
  padding: 1rem;
  border: 1px dashed var(--vz-border-color, #d8dce1);
  border-radius: 0.625rem;
  background: var(--vz-light, #f3f6f9);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.panel-zip-picker-selected {
  border-color: rgba(var(--vz-primary-rgb, 64, 81, 137), 0.55);
  background: rgba(var(--vz-primary-rgb, 64, 81, 137), 0.06);
}

.panel-zip-picker-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 2.75rem;
  border-radius: 0.625rem;
  color: var(--vz-primary, #405189);
  background: rgba(var(--vz-primary-rgb, 64, 81, 137), 0.12);
  font-size: 1.4rem;
}

/* Deleted records kept as tombstones: readable, obviously not live, and never mistaken for a row
   an operator can still act on. */
.panel-row-deleted > td {
  opacity: 0.78;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(var(--vz-danger-rgb, 240, 101, 72), 0.05) 8px,
    rgba(var(--vz-danger-rgb, 240, 101, 72), 0.05) 16px
  );
}

/* ---------- This console ---------- */

/* The sidebar's scroll container (an inline style in the previous console). */
.panel-sidebar-scroll {
  overflow-y: auto;
}

/* What the previous console set as inline styles, which this console's CSP does not admit. */
.panel-search-select-menu {
  max-height: 220px;
}

.panel-search-select-option {
  cursor: pointer;
}

.panel-chip-close {
  font-size: 9px;
}

.panel-scroll-60vh {
  max-height: 60vh;
}

.panel-scroll-50vh {
  max-height: 50vh;
}

/* An upload's progress: the bar eases between the browser's progress events instead of jumping. */
.panel-upload-progress {
  height: 6px;
}

.panel-upload-progress .progress-bar {
  transition: width var(--panel-base) var(--panel-ease-out);
  width: 0;
}

/* The off-screen buffer a copy falls back to when the clipboard API is unavailable. */
.panel-copy-buffer {
  inset-inline-start: -9999px;
  opacity: 0;
  position: fixed;
  top: 0;
}

/* A listing being re-read for a new filter dims for the moment it takes instead of jumping. */
[data-panel-live] {
  transition: opacity var(--panel-base) ease;
}

[data-panel-live][aria-busy="true"] {
  opacity: 0.55;
}

/* A row that opens a record shows keyboard focus like a link. */
tr.panel-row-clickable:focus-visible {
  outline: 2px solid rgba(var(--vz-primary-rgb, 64, 81, 137), 0.45);
  outline-offset: -2px;
}

/* Top progress bar, in the place and colour of the previous console's. It grows from the start
   edge, which in this right-to-left console is the right. */
.panel-toploader {
  height: 3px;
  inset-inline: 0;
  pointer-events: none;
  position: fixed;
  top: 0;
  z-index: 2000;
}

.panel-toploader-bar {
  background: var(--panel-loader);
  height: 100%;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform var(--panel-base) var(--panel-ease), opacity 300ms ease;
}

.panel-toploader[data-state="loading"] .panel-toploader-bar {
  opacity: 1;
}

/* Dialogs: a softer rise than Bootstrap's 50px drop, and a backdrop that recedes rather than blacks out. */
.modal.fade .modal-dialog {
  transform: translateY(14px) scale(0.98);
  transition: transform var(--panel-slow) var(--panel-ease-out);
}

.modal.show .modal-dialog {
  transform: none;
}

/* The script parks focus on the dialog itself so Tab starts inside it; like Bootstrap's own .modal, the frame shows no ring. */
.modal-dialog:focus {
  outline: 0;
}

.modal-backdrop.fade {
  transition: opacity var(--panel-base) ease;
}

.modal-backdrop.show {
  backdrop-filter: blur(2px);
}

/* The account menu opens instead of appearing. */
.poshesh-user-menu.show {
  animation: panel-menu-in var(--panel-base) var(--panel-ease-out);
  transform-origin: top left;
}

@keyframes panel-menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

/* Tables: rows ease into their hover colour; the sorted column's icon reads at full strength. */
.table-hover > tbody > tr > * {
  transition: background-color var(--panel-fast) ease;
}

th.panel-sortable:hover,
th.panel-sortable:focus-visible {
  color: var(--vz-body-color, #212529);
}

th[aria-sort] .panel-sort-icon {
  opacity: 1;
}

th.panel-sortable:focus-visible {
  outline: 2px solid rgba(var(--vz-primary-rgb, 64, 81, 137), 0.45);
  outline-offset: -2px;
}

.page-link {
  transition: background-color var(--panel-fast) ease, color var(--panel-fast) ease, border-color var(--panel-fast) ease;
}

/* Keyboard focus is always visible, never on a mouse click. */
.nav-link:focus-visible,
.dropdown-item:focus-visible,
.breadcrumb a:focus-visible {
  outline: 2px solid rgba(var(--vz-primary-rgb, 64, 81, 137), 0.55);
  outline-offset: 2px;
}

/* The sign-in card: a deeper, softer surface than a stock card, entering once. */
.panel-auth-surface {
  border: 0;
  box-shadow: 0 1.5rem 3rem -1.5rem rgba(15, 34, 58, 0.28), 0 0.25rem 0.75rem -0.5rem rgba(15, 34, 58, 0.12);
}

.panel-auth-card {
  animation: panel-rise 0.5s var(--panel-ease-out) backwards;
}

/* Overview tiles settle in one after another on first paint — but not on the timed refresh. */
.panel-stat-tile {
  animation: panel-rise 0.42s var(--panel-ease-out) backwards;
}

.row > :nth-child(2) > .panel-stat-tile {
  animation-delay: 40ms;
}

.row > :nth-child(3) > .panel-stat-tile {
  animation-delay: 80ms;
}

.row > :nth-child(4) > .panel-stat-tile {
  animation-delay: 120ms;
}

[data-panel-live-refreshed] .panel-stat-tile {
  animation: none;
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Page navigation: the topbar and sidebar stay put; only the page content moves. */
@view-transition {
  navigation: auto;
}

#page-topbar {
  view-transition-name: panel-topbar;
}

.app-menu {
  view-transition-name: panel-sidebar;
}

.panel-main {
  view-transition-name: panel-main;
}

::view-transition-group(panel-topbar),
::view-transition-group(panel-sidebar) {
  animation: none;
}

::view-transition-old(panel-main) {
  animation: panel-page-out var(--panel-base) var(--panel-ease) both;
}

::view-transition-new(panel-main) {
  animation: panel-page-in var(--panel-slow) var(--panel-ease-out) both;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--panel-base);
}

@keyframes panel-page-out {
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes panel-page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Where view transitions are not supported, the content still eases in on load. */
@supports not (view-transition-name: none) {
  .panel-main {
    animation: panel-page-in var(--panel-slow) var(--panel-ease-out) backwards;
  }
}

/* An operator who asked for less motion gets none. */
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
