/* SpeedZone Admin - styles for the static account pages (sign-in, invitation, security) and the
   few things MudBlazor does not cover. Colours follow the system light/dark preference here; the
   interactive pages use the MudBlazor theme (MainLayout). */

:root {
    --sz-bg: #f4f6f8;
    --sz-surface: #ffffff;
    --sz-text: #1c2430;
    --sz-muted: #5b6675;
    --sz-border: #d8dee6;
    --sz-primary: #0b6e99;
    --sz-primary-hover: #095a7d;
    --sz-primary-text: #ffffff;
    --sz-danger: #b3261e;
    --sz-danger-bg: #fdecea;
    --sz-success: #1e6b34;
    --sz-success-bg: #e7f5ea;
    --sz-warning: #7a4f01;
    --sz-warning-bg: #fff4e0;
    --sz-info-bg: #e8f3f9;
    --sz-radius: 10px;
    --sz-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --sz-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --sz-bg: #11161c;
        --sz-surface: #1a2129;
        --sz-text: #e6eaef;
        --sz-muted: #9aa5b3;
        --sz-border: #2e3844;
        --sz-primary: #4fb3e0;
        --sz-primary-hover: #74c4e8;
        --sz-primary-text: #06202c;
        --sz-danger: #ffb4ab;
        --sz-danger-bg: #3b1714;
        --sz-success: #9bd8a8;
        --sz-success-bg: #14301c;
        --sz-warning: #ffd08a;
        --sz-warning-bg: #35280f;
        --sz-info-bg: #13303d;
    }
}

html, body {
    margin: 0;
    font-family: var(--sz-font);
}

/* ---- Account layout (static pages) -------------------------------------------------------- */

.account-body {
    min-height: 100vh;
    background: var(--sz-bg);
    color: var(--sz-text);
    display: flex;
    flex-direction: column;
}

.account-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--sz-border);
    background: var(--sz-surface);
}

.account-topbar .brand {
    font-weight: 700;
    color: var(--sz-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.account-topbar .spacer {
    flex: 1;
}

.account-topbar a {
    color: var(--sz-primary);
}

.account-main {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem 3rem;
}

.auth-card, .settings-card {
    background: var(--sz-surface);
    border: 1px solid var(--sz-border);
    border-radius: var(--sz-radius);
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.auth-card {
    width: 100%;
    max-width: 26rem;
    align-self: flex-start;
}

.settings-wrap {
    width: 100%;
    max-width: 60rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-card h2 {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
}

.auth-card h1, .settings-wrap h1 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.muted {
    color: var(--sz-muted);
}

.small {
    font-size: 0.875rem;
}

.account-body label {
    display: block;
    font-weight: 600;
    margin: 1rem 0 0.35rem;
}

.account-body input[type=text], .account-body input[type=search], .account-body input:not([type]) {
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--sz-border);
    border-radius: 8px;
    background: var(--sz-bg);
    color: var(--sz-text);
    font: inherit;
}

.account-body input:focus-visible, .account-body button:focus-visible, .account-body a:focus-visible {
    outline: 3px solid var(--sz-primary);
    outline-offset: 2px;
}

.hint {
    font-size: 0.85rem;
    color: var(--sz-muted);
    margin-top: 0.3rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    border: 1px solid var(--sz-border);
    background: var(--sz-surface);
    color: var(--sz-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    border-color: var(--sz-primary);
}

.btn.primary {
    background: var(--sz-primary);
    border-color: var(--sz-primary);
    color: var(--sz-primary-text);
}

.btn.primary:hover {
    background: var(--sz-primary-hover);
}

.btn.danger {
    color: var(--sz-danger);
}

.btn.block {
    width: 100%;
    margin-top: 1.25rem;
}

.btn.small {
    padding: 0.35rem 0.7rem;
    font-size: 0.875rem;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.alert {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: var(--sz-info-bg);
}

.alert.error {
    background: var(--sz-danger-bg);
    color: var(--sz-danger);
}

.alert.success {
    background: var(--sz-success-bg);
    color: var(--sz-success);
}

.alert.warning {
    background: var(--sz-warning-bg);
    color: var(--sz-warning);
}

.alt {
    margin-top: 1.5rem;
    text-align: center;
}

.alt a, .settings-card a {
    color: var(--sz-primary);
}

.radio-row {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.5rem;
}

.account-body .radio-row label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    margin: 0;
}

table.list {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    font-size: 0.925rem;
}

table.list th, table.list td {
    text-align: left;
    padding: 0.55rem 0.5rem;
    border-bottom: 1px solid var(--sz-border);
    vertical-align: middle;
}

table.list th {
    color: var(--sz-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table.list form {
    display: inline;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--sz-info-bg);
    color: var(--sz-text);
}

.badge.ok {
    background: var(--sz-success-bg);
    color: var(--sz-success);
}

.badge.off {
    background: var(--sz-bg);
    color: var(--sz-muted);
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
    margin-top: 1rem;
}

.inline-form > div {
    flex: 1 1 14rem;
}

.account-body .inline-form label {
    margin-top: 0;
}

.code-list {
    columns: 2;
    font-family: var(--sz-mono);
    font-size: 1.05rem;
    padding-left: 1.5rem;
}

.code-list li {
    margin: 0.2rem 0;
}

.qr {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    margin: 1rem 0;
}

.qr .qr-image {
    background: #ffffff;
    padding: 0.5rem;
    border-radius: 8px;
    width: 12rem;
    height: 12rem;
}

.qr .qr-image svg {
    width: 100%;
    height: 100%;
}

.secret {
    font-family: var(--sz-mono);
    font-size: 1.05rem;
    word-break: break-all;
}

.table-scroll {
    overflow-x: auto;
}

/* ---- Interactive pages ---------------------------------------------------------------------- */

.sz-mono {
    font-family: var(--sz-mono);
}

.sz-details {
    font-family: var(--sz-mono);
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
    white-space: normal;
    word-break: break-word;
}

.sz-drawer-footer {
    padding: 1rem;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.logout-form {
    display: inline;
    margin: 0;
}

[data-copied="true"]::after {
    content: " ✓";
}

/* ---- Reconnection dialog (from the ASP.NET Core template) ----------------------------------- */

.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

#components-reconnect-modal {
    background-color: var(--sz-surface);
    color: var(--sz-text);
    width: 20rem;
    margin: 20vh auto;
    padding: 2rem;
    border: 0;
    border-radius: 0.5rem;
    box-shadow: 0 3px 6px 2px rgba(0, 0, 0, 0.3);
}

#components-reconnect-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.4);
}

.components-reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#components-reconnect-modal p {
    margin: 0;
    text-align: center;
}

#components-reconnect-modal button {
    border: 0;
    background-color: var(--sz-primary);
    color: var(--sz-primary-text);
    padding: 0.4rem 1.5rem;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}

.components-rejoining-animation {
    position: relative;
    width: 80px;
    height: 80px;
}

.components-rejoining-animation div {
    position: absolute;
    border: 3px solid var(--sz-primary);
    opacity: 1;
    border-radius: 50%;
    animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.components-rejoining-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes components-rejoining-animation {
    0%, 4.9% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 0;
    }

    5% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 1;
    }

    100% {
        top: 0;
        left: 0;
        width: 80px;
        height: 80px;
        opacity: 0;
    }
}

@media (max-width: 600px) {
    .auth-card, .settings-card {
        padding: 1.25rem;
    }

    .code-list {
        columns: 1;
    }
}

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

/* MudBlazor's CSS reset removes paragraph and list spacing; the static pages need it back. */
.auth-card p, .settings-card p, .settings-wrap > div > p {
    margin: 0.5rem 0;
}

.auth-card ol, .settings-card ol, .auth-card ul, .settings-card ul {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.auth-card ol li, .settings-card ol li {
    margin: 0.2rem 0;
}

.settings-card h2 + p {
    margin-top: 0.25rem;
}

/* FocusOnNavigate moves focus to the page heading for screen readers; no visible ring for that. */
h1:focus, h1:focus-visible {
    outline: none;
}

table.list td:last-child {
    white-space: nowrap;
    text-align: right;
}

.sz-nowrap {
    white-space: nowrap;
}

.sz-details {
    display: inline-block;
    max-width: 22rem;
}

.sz-title {
    white-space: nowrap;
}

@media (max-width: 480px) {
    .sz-title-suffix {
        display: none;
    }
}

/* ---- Monitoring pages (stage A1) -------------------------------------------------------------- */

.sz-tile {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
}

.sz-tile .mud-progress-linear {
    width: 100%;
}

.sz-break {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.sz-kv td:first-child {
    color: var(--mud-palette-text-secondary);
    width: 40%;
    vertical-align: top;
}

/* ---- Data views, maps, search (stage A2) ------------------------------------------------------ */

.sz-min0 {
    min-width: 0;
}

.sz-chip {
    margin: 0 0.25rem 0 0;
}

.sz-map {
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    background: var(--mud-palette-background-gray);
}

.sz-map .maplibregl-ctrl-attrib a {
    color: inherit;
}

.sz-map-popup {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: #1c2430;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.sz-map-popup a {
    color: #0b6e99;
    font-weight: 600;
}

.sz-legend {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
}

.sz-swatch {
    display: inline-block;
    width: 1.2rem;
    height: 0.3rem;
    border-radius: 2px;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.sz-swatch-zone {
    background: #1565c0;
}

.sz-swatch-start {
    background: #2e7d32;
}

.sz-swatch-end {
    background: #c62828;
}

.sz-sort {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    white-space: nowrap;
}

.sz-sort:hover, .sz-sort:focus-visible {
    text-decoration: underline;
}

.sz-sort-active {
    font-weight: 700;
}

.sz-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.4rem;
    padding: 1rem 0.5rem;
}

.sz-page-size {
    max-width: 9rem;
}

.sz-narrow-select {
    max-width: 12rem;
}

.sz-diff {
    margin: 0.25rem 0 0.5rem;
    padding-left: 1.1rem;
    font-size: 0.875rem;
}

.sz-diff li {
    margin: 0.15rem 0;
    overflow-wrap: anywhere;
}

.sz-diff-before {
    text-decoration: line-through;
    color: var(--mud-palette-text-secondary);
}

.sz-diff-after {
    font-weight: 600;
}

.sz-timeline .mud-timeline-item-content {
    min-width: 0;
}

.sz-counts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    gap: 0.75rem;
}

.sz-count {
    display: flex;
    flex-direction: column;
}

.sz-count-value {
    font-family: var(--sz-mono);
    font-size: 1.3rem;
    font-weight: 600;
}

.sz-count-label {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
}

.sz-log {
    font-family: var(--sz-mono);
    font-size: 0.8rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 20rem;
    overflow: auto;
    padding: 0.75rem;
    border-radius: 6px;
    background: var(--mud-palette-background-gray);
}

.sz-plain-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0;
}

.sz-plain-list li {
    margin: 0.25rem 0;
}

.sz-search-button {
    text-transform: none;
}

.sz-kbd {
    font-family: var(--sz-mono);
    font-size: 0.7rem;
    margin-left: 0.5rem;
    padding: 0.05rem 0.35rem;
    border: 1px solid currentColor;
    border-radius: 4px;
    opacity: 0.8;
}

.sz-search-results {
    display: flex;
    flex-direction: column;
    max-height: 60vh;
    overflow-y: auto;
}

.sz-search-hit {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}

.sz-search-hit:focus-visible {
    outline: 3px solid var(--mud-palette-primary);
    outline-offset: -3px;
}

.sz-search-hit-active {
    background: var(--mud-palette-action-default-hover);
}

.sz-search-hit-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sz-search-hit-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.sz-search-hit-subtitle {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .sz-search-label, .sz-kbd {
        display: none;
    }

    .sz-search-button {
        min-width: 0;
    }

    .sz-details {
        max-width: 100%;
    }
}

/* The app bar on a phone: the security page is also in the menu, so its shortcut makes room for search. */
@media (max-width: 480px) {
    .sz-appbar-optional {
        display: none !important;
    }
}

/* Stage A3: Settings, Jobs. */
.sz-muted {
    color: var(--mud-palette-text-secondary);
}

.sz-setting {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    align-items: flex-start;
    padding: 0.75rem 0;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.sz-setting-edited {
    border-left: 3px solid var(--mud-palette-primary);
    padding-left: 0.75rem;
}

.sz-setting-text {
    flex: 1 1 22rem;
    min-width: 0;
}

.sz-setting-value {
    flex: 0 1 18rem;
    min-width: 0;
    max-width: 100%;
}

#job-log .sz-log {
    max-height: 32rem;
}

.sz-log-err {
    color: var(--mud-palette-error);
}

.sz-log-info {
    color: var(--mud-palette-info);
}

.sz-log-time {
    color: var(--mud-palette-text-secondary);
}

.sz-job-action {
    white-space: nowrap;
}

/* Stage A4: zone editing. */
.sz-edit-field {
    margin-bottom: 0.5rem;
    min-width: 0;
}

.sz-edit-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    margin-top: 0.125rem;
    min-width: 0;
}

.sz-edit-note .mud-button-root {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.sz-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    align-items: center;
}

.sz-review-table td,
.sz-review-table th {
    vertical-align: top;
}

.sz-review-table td:first-child {
    white-space: nowrap;
}

@media (max-width: 599.98px) {
    .sz-review-table td:first-child {
        white-space: normal;
    }
}

/* Stage A5: the Installs page's bar charts - plain HTML (DailyBars.razor), no script, no library. Bars
   are thin with a 2 px surface gap between neighbours and between stacked segments, the top segment
   has 4 px rounded corners, the axis and labels stay recessive. */
.sz-chart-figure {
    margin: 0;
}

.sz-chart-ymax {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    font-family: var(--sz-mono);
}

.sz-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 10rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.sz-chart-dense {
    gap: 0;
}

.sz-chart-col {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
}

.sz-chart-dense .sz-chart-col {
    gap: 0;
}

.sz-chart-col:hover {
    background: var(--mud-palette-action-default-hover);
}

.sz-chart-seg {
    width: 100%;
    flex: 0 0 auto;
}

.sz-chart-col > .sz-chart-seg:last-child {
    border-radius: 4px 4px 0 0;
}

.sz-chart-axis {
    display: flex;
    gap: 2px;
    font-size: 0.7rem;
    color: var(--mud-palette-text-secondary);
    font-family: var(--sz-mono);
    height: 1.1rem;
}

.sz-chart-tick {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
    display: flex;
    justify-content: center;
}

.sz-chart-axis .sz-chart-tick:first-child {
    justify-content: flex-start;
}

.sz-chart-axis .sz-chart-tick:last-child {
    justify-content: flex-end;
}

.sz-hbars {
    display: grid;
    grid-template-columns: minmax(4rem, max-content) minmax(0, 1fr) max-content;
    gap: 0.35rem 0.75rem;
    align-items: center;
}

.sz-hbar-track {
    height: 0.75rem;
}

.sz-hbar {
    height: 100%;
    border-radius: 0 4px 4px 0;
    min-width: 2px;
}

/* Stage A5: the phone log viewer. */
.sz-logline-fields {
    font-family: var(--sz-mono);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
}

.sz-logline-fields summary {
    cursor: pointer;
    color: var(--mud-palette-text-secondary);
}

.sz-digest {
    font-family: var(--sz-mono);
    font-size: 0.8rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 40rem;
    overflow: auto;
    padding: 0.75rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
}

/* Stage A5: the gate measurements and the log line fields get room of their own. */
/* Only in the table layout: below MudBlazor's Sm breakpoint the rows become cards of full width. */
@media (min-width: 600px) {
    .sz-wide-cell {
        min-width: 16rem;
    }
}

.sz-gate-line {
    font-family: var(--sz-mono);
    font-size: 0.78rem;
    color: var(--mud-palette-text-secondary);
    overflow-wrap: anywhere;
}

/* Several lines in one cell: stacked, and allowed to shrink in the phone card layout (a flex row there). */
.sz-cell-stack {
    display: block;
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

/* Stage A8: an alert message as the phone showed it (line breaks kept, long words wrapped). */
.sz-prewrap {
    white-space: pre-wrap;
}
