/*
 * Trivsel progressive frontend runtime.
 *
 * This file contains only the infrastructure styles for the
 * modern navigation layer. Existing product styling remains
 * in style.css until individual screens are migrated.
 */

html[data-trivsel-navigating] {
  cursor: progress;
}

html[data-trivsel-navigating] body {
  pointer-events: none;
}

.trivsel-page-progress {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 9999;
  height: 3px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease 100ms;
}

html[data-trivsel-navigating] .trivsel-page-progress {
  opacity: 1;
  transition: opacity 80ms ease;
}

.trivsel-page-progress::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--trivsel-progress-width, 0%);
  background: var(--brand, #2563EB);
  box-shadow: 0 0 8px 1px var(--brand, #2563EB);
  transition: width 200ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .trivsel-page-progress::after {
    transition: none;
  }
}

/* ------------------------------------------------------------
   Progressive dashboard runtime
   ------------------------------------------------------------ */

.dashboard-runtime-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0 0 1rem;
  min-height: 2.25rem;
}

.dashboard-runtime-status {
  font-size: 0.78rem;
  line-height: 1.3;
  opacity: 0.72;
}

.dashboard-runtime-status[data-state="loading"] {
  opacity: 0.58;
}

.dashboard-runtime-status[data-state="success"] {
  opacity: 0.72;
}

.dashboard-runtime-status[data-state="error"],
.dashboard-runtime-status[data-state="auth"] {
  opacity: 1;
}

.dashboard-runtime-refresh {
  appearance: none;
  border: 1px solid currentColor;
  border-radius: 0.55rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.45rem 0.7rem;
}

.dashboard-runtime-refresh:disabled {
  cursor: wait;
  opacity: 0.5;
}

[data-trivsel-dashboard][data-dashboard-loading="true"]
.dashboard-stat {
  transition: opacity 120ms ease;
}

[data-trivsel-dashboard][data-dashboard-loading="true"]
.dashboard-stat-value {
  opacity: 0.62;
}

/* ------------------------------------------------------------
   O4.2.5 dashboard shell
   ------------------------------------------------------------ */

.dashboard-runtime-sections {
  min-height: 18rem;
}

.dashboard-sections-loading {
  display: grid;
  min-height: 12rem;
  place-items: center;
  gap: 0.65rem;
  padding: 2rem;
  border: 1px solid currentColor;
  border-radius: 0.75rem;
  opacity: 0.55;
  text-align: center;
}

.dashboard-sections-loading::after {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: trivsel-dashboard-spinner 700ms linear infinite;
}

.dashboard-noscript {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid currentColor;
  border-radius: 0.75rem;
}

.dashboard-noscript p {
  margin: 0 0 0.75rem;
}

@keyframes trivsel-dashboard-spinner {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-sections-loading::after {
    animation: none;
  }
}

/* ============================================================
   TRIVSEL - CLINICAL LOADING INDICATORS
   Animated SVGs are reserved for genuine async work.
   ============================================================ */

.trivsel-spinner {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  flex: 0 0 auto;
  vertical-align: -0.15em;
  background-image: url("/static/img/spinners/90-ring.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.trivsel-spinner--dots {
  width: 1.15em;
  height: 1.15em;
  background-image: url("/static/img/spinners/3-dots-fade.svg");
}

.trivsel-spinner--list {
  width: 1.25em;
  height: 1.25em;
  background-image: url("/static/img/spinners/6-dots-scale.svg");
}

.trivsel-loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.dashboard-runtime-status[data-state="loading"] {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.dashboard-runtime-status[data-state="loading"]::before {
  content: "";
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  background-image: url("/static/img/spinners/90-ring.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.organization-runtime-status[data-state="loading"] {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.organization-runtime-status[data-state="loading"]::before {
  content: "";
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  background-image: url("/static/img/spinners/90-ring.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

[data-trivsel-loading="true"] {
  cursor: wait;
}

button[data-trivsel-loading="true"],
a[data-trivsel-loading="true"] {
  position: relative;
}

button[data-trivsel-loading="true"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: wait;
}

button[data-trivsel-loading="true"]::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 0.95rem;
  background-image: url("/static/img/spinners/3-dots-fade.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

button[data-trivsel-loading="true"]::after {
  content: none;
}
