/* The drill-down pages behind the dashboard cards (/metrics/*), the dashboard cards' motion, and the particle
   layer of js/fx.js. Theme colours come from MudBlazor's variables; every animation stops for reduced motion. */

/* ------------------------------------------------------------------ particles (fx.js) */

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 3000; overflow: hidden; }
.fx-particle {
    position: fixed;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: fx-fly 650ms cubic-bezier(0.18, 0.75, 0.32, 1) forwards;
    filter: brightness(1.25) saturate(1.2);
    box-shadow: 0 0 10px 1px rgba(255, 255, 255, 0.35);
}
.fx-spark { border-radius: 2px; }
@keyframes fx-fly {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    70% { opacity: 0.9; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.25) rotate(90deg); }
}
.fx-ring {
    position: fixed;
    width: 14px;
    height: 14px;
    border: 3px solid;
    box-shadow: 0 0 18px rgba(var(--mud-palette-primary-rgb), 0.55), inset 0 0 12px rgba(var(--mud-palette-primary-rgb), 0.35);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: fx-ring 600ms ease-out forwards;
}
@keyframes fx-ring {
    from { opacity: 0.9; width: 10px; height: 10px; }
    to { opacity: 0; width: 120px; height: 120px; }
}

/* ------------------------------------------------------------------ dashboard cards */

.admin-kpi { transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease; }
.admin-kpi-link:hover .admin-kpi { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(var(--mud-palette-primary-rgb), 0.18); }
.admin-kpi-link:active .admin-kpi { transform: translateY(-1px) scale(0.985); }
.admin-kpi-locked { cursor: not-allowed; }

/* ------------------------------------------------------------------ page */

/* Sections slide in one after another. They start dimmed, never invisible: a page opened in a background tab
   (where the browser holds animations) still shows its numbers. */
.mx-page > * { animation: mx-enter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.mx-page > *:nth-child(2) { animation-duration: 0.48s; }
.mx-page > *:nth-child(3) { animation-duration: 0.56s; }
.mx-page > *:nth-child(n+4) { animation-duration: 0.64s; }
@keyframes mx-enter { from { opacity: 0.35; transform: translateY(12px); } }

.mx-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mx-updated { color: var(--mud-palette-text-secondary); font-size: 0.78rem; display: inline-flex; align-items: center; gap: 6px; }

.mx-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.mx-stat {
    position: relative;
    padding: 14px 16px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-surface);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.mx-stat:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18); border-color: rgba(var(--mud-palette-primary-rgb), 0.5); }
.mx-stat::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(var(--mud-palette-primary-rgb), 0.10) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: mx-shine 1.2s ease 0.25s 1 both;
    pointer-events: none;
}
@keyframes mx-shine { to { transform: translateX(100%); } }
.mx-stat-label { display: flex; align-items: center; gap: 6px; color: var(--mud-palette-text-secondary); font-size: 0.84rem; }
.mx-stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.mx-stat-sub { color: var(--mud-palette-text-secondary); font-size: 0.75rem; }
.mx-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 0.72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; width: fit-content; }
.mx-delta.up { color: var(--mud-palette-success); background: rgba(var(--mud-palette-success-rgb), 0.13); }
.mx-delta.down { color: var(--mud-palette-error); background: rgba(var(--mud-palette-error-rgb), 0.13); }
.mx-delta.flat { color: var(--mud-palette-text-secondary); background: rgba(var(--mud-palette-text-primary-rgb), 0.07); }

.mx-live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--mud-palette-success); position: relative; }
.mx-live::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--mud-palette-success);
    animation: mx-pulse 1.6s ease-out infinite;
}
@keyframes mx-pulse { from { opacity: 0.8; transform: scale(0.6); } to { opacity: 0; transform: scale(1.8); } }

.mx-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.mx-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .mx-grid, .mx-grid-2 { grid-template-columns: minmax(0, 1fr); } }
.mx-card { margin-bottom: 16px; }
.mx-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.mx-card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 650; }

/* ------------------------------------------------------------------ chart */

.mx-chart { width: 100%; height: auto; display: block; overflow: visible; }
.mx-chart text { font-size: 11px; fill: var(--mud-palette-text-secondary); font-family: inherit; }
.mx-gridline { stroke: var(--mud-palette-lines-default); stroke-width: 1; }
.mx-bar { transform-box: fill-box; transform-origin: 50% 100%; animation: mx-grow 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes mx-grow { from { transform: scaleY(0); } }
.mx-line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: mx-draw 1.1s ease forwards; }
@keyframes mx-draw { to { stroke-dashoffset: 0; } }
.mx-area { opacity: 0.16; animation: mx-fade 0.9s ease both; }
@keyframes mx-fade { from { opacity: 0; } }
.mx-dot { stroke: var(--mud-palette-surface); stroke-width: 1.5; animation: mx-fade 0.6s ease 0.6s both; }
.mx-static .mx-bar, .mx-static .mx-line, .mx-static .mx-area, .mx-static .mx-dot { animation: none; }
.mx-static .mx-line { stroke-dashoffset: 0; }
.mx-static .mx-area { opacity: 0.16; }
.mx-hover { fill: transparent; }
.mx-hover:hover { fill: rgba(var(--mud-palette-text-primary-rgb), 0.06); }
.mx-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mx-legend button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--mud-palette-lines-default);
    background: transparent;
    color: var(--mud-palette-text-secondary);
    border-radius: 999px;
    padding: 3px 10px;
    font: inherit;
    font-size: 0.76rem;
    cursor: pointer;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}
.mx-legend button:hover { border-color: var(--mud-palette-primary); color: var(--mud-palette-text-primary); }
.mx-legend button.off { opacity: 0.45; text-decoration: line-through; }
.mx-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ------------------------------------------------------------------ bar lists */

.mx-bars { display: flex; flex-direction: column; gap: 8px; }
.mx-bars-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 0.84rem; }
.mx-bars-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-bars-track { height: 10px; border-radius: 6px; background: rgba(var(--mud-palette-text-primary-rgb), 0.07); overflow: hidden; }
.mx-bars-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--mud-palette-primary), var(--mud-palette-tertiary)); transform-origin: left; animation: mx-widen 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes mx-widen { from { transform: scaleX(0); } }
.mx-bars-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.mx-bars-value small { color: var(--mud-palette-text-secondary); font-weight: 500; margin-left: 4px; }

/* ------------------------------------------------------------------ tables */

.mx-table .mud-table-row { cursor: default; }
.mx-table.mx-clickable .mud-table-body .mud-table-row { cursor: pointer; }
.mx-table .mud-table-body .mud-table-row { transition: background-color 0.12s ease; }
.mx-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mx-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: rgba(var(--mud-palette-text-primary-rgb), 0.07); color: var(--mud-palette-text-secondary); white-space: nowrap; }
.mx-chip.good { color: var(--mud-palette-success); background: rgba(var(--mud-palette-success-rgb), 0.13); }
.mx-chip.bad { color: var(--mud-palette-error); background: rgba(var(--mud-palette-error-rgb), 0.13); }
.mx-chip.warn { color: var(--mud-palette-warning); background: rgba(var(--mud-palette-warning-rgb), 0.15); }
.mx-chip.info { color: var(--mud-palette-info); background: rgba(var(--mud-palette-info-rgb), 0.13); }

@media (prefers-reduced-motion: reduce) {
    .mx-page > *, .mx-bar, .mx-line, .mx-area, .mx-dot, .mx-bars-fill, .mx-stat::after, .mx-live::after { animation: none !important; }
    .mx-line { stroke-dashoffset: 0; }
    .admin-kpi, .mx-stat { transition: none; }
    .admin-kpi-link:hover .admin-kpi, .mx-stat:hover { transform: none; }
}
