@import url('tokens.css');

/* ============================================================================
   settings.css — the Settings page (Template A, ADR 0031 §4/§5). Most of the page
   is calm preference rows (shared Card + SettingRow), and it stays that way. The
   one page-specific surface is the OPC UA server FACEPLATE: the running server
   drawn as an instrument, not a form — a status masthead over a recessed readout
   well of panel meters that present the running server as a single object.

   It borrows the Account page's focal-card idioms so it reads as house style, not
   a bolt-on: the state-tinted inset leading bar (.acct-plate) and the tabular
   readout figure (.acct-seats-number, on --font-size-readout). Colour here is the
   reserved operational green/amber/red only — a running server IS state — never
   the brand accent (docs/brand/brand.md). Every value resolves through var(--…).
   ============================================================================ */

/* ---- Server faceplate — the OPC UA server, at a glance. The leading inset bar is tinted by the
   same ConnectionHealth the lamp + tray read (ServerHealthClass ← HealthDot): green online, amber
   degraded, red offline, neutral stopped — so the bar and the lamp can never disagree. An inset
   box-shadow layered on the card shadow (not a real border), so it never disturbs the card radius —
   the .acct-plate idiom. ---- */
.set-faceplate.is-online   { box-shadow: var(--shadow-card), inset 3px 0 0 var(--color-success); }
.set-faceplate.is-degraded { box-shadow: var(--shadow-card), inset 3px 0 0 var(--color-caution); }
.set-faceplate.is-offline  { box-shadow: var(--shadow-card), inset 3px 0 0 var(--color-critical); }
.set-faceplate.is-idle     { box-shadow: var(--shadow-card), inset 3px 0 0 var(--color-neutral); }

/* Masthead: the identity (lamp + state + endpoint) reads first and grows; the power controls trail
   and hold their width. Wraps on a narrow pane (remote tablet) so the controls drop below. */
.set-faceplate-head {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex-wrap: wrap;
}

.set-faceplate-id {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.set-faceplate-id-text { min-width: 0; }

/* State is the focal identity of the card — one step up from body, semibold. */
.set-faceplate-state {
    font-size: var(--font-size-card-title);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

/* The endpoint is the machine address — mono, secondary, one line (it ellipses rather than wraps). */
.set-faceplate-endpoint {
    margin-top: var(--space-1);
    font-size: var(--font-size-description);
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.set-faceplate-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ---- Readout well — the recessed instrument cluster, the page's signature. The well tone is what
   sinks it (surface-alt, one step under the card holding it), so the live counters read as a panel
   of meters rather than as table cells. The inset hairline over it is a DIFFERENT idiom borrowed
   here for edge definition — a ring is how a tile reads as picked out of a well, never how a
   surface reads as a well. The meters auto-fit from a multi-column cluster down to 2-up / 1-up on
   a narrow pane. ---- */
.set-readout-well {
    margin-top: var(--space-5);
    padding: var(--space-6) var(--space-5);
    background: var(--color-surface-alt);
    box-shadow: inset 0 0 0 1px var(--color-stroke);
    border-radius: var(--radius-md);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-6) var(--space-5);
}

.set-meter {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

/* Panel-meter label — a tracked micro-caps gauge label (the eyebrow tracking), so it reads as an
   instrument legend above its figure. */
.set-meter-label {
    font-size: var(--font-size-eyebrow);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

/* The panel-meter figure — the signature. Tabular mono at the readout scale (the digits hold their
   box as they tick), reusing the Account seat-gauge readout treatment. Neutral by default: colour is
   reserved for a meter that MEANS something (Errors/Warnings, below). */
.set-meter-value {
    font-family: var(--font-mono);
    font-size: var(--font-size-readout);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1;
    color: var(--color-text);
    white-space: nowrap;
}

/* Errors / Warnings take their reserved semantic colour ONLY when the count is non-zero — a live
   fault reads at a glance; a clean panel stays quiet, no wall of colour. */
.set-meter-value.is-critical { color: var(--color-critical); }
.set-meter-value.is-caution  { color: var(--color-caution); }

/* Warnings is a button (opens the Events window) rendered as a readout: strip the button frame, keep
   the figure. It underlines on hover — the one actionable meter — and carries the shared focus ring. */
.set-meter-link {
    font-family: var(--font-mono);
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
}

.set-meter-link:hover { text-decoration: underline; }

/* A station-only meter link seen from a remote browser: still a reading, no longer a door. */
.set-meter-link:disabled {
    cursor: default;
    opacity: 0.65;
}

.set-meter-link:disabled:hover { text-decoration: none; }

/* ---- Remote access — the port field and the wait that covers the app while the web server
   restarts. The port is a short number, so the row's control column keeps it short too instead of
   letting the field span a wide card. ---- */
.set-remote-port .ui-setting-row-control { max-width: 140px; }

/* The cover the page raises before it applies a remote-access change (Settings.razor · the
   ganterSettings.beginRestartWait wait). It is deliberately NOT a second screen: it wears the
   reconnection surface's own card (.reconnect-*, appshell.css), because this IS that surface's
   case, the one the app can name — the connection is about to drop, and this screen is what asked
   for it. It stands one step in front of the framework's while it holds the answer, and
   js/settings.js hides it if the address never comes back, leaving the reconnection surface
   underneath to offer the way out. */
.set-restart-wait {
    position: fixed;
    inset: 0;
    /* One step above the reconnection surface (appshell.css 3001): the restart drops the circuit
       too, so both are up at once, and this is the one that knows what is happening. */
    z-index: 3002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: var(--color-scrim);
}

.set-restart-wait[hidden] { display: none; }

/* The card's state block hides itself until the framework names a state; there is one state here,
   and it is the one this page asked for. */
.set-restart-wait .reconnect-state { display: flex; }

/* ---- Client access — an industrial certificate roster. Pending decisions are the focal state;
   the rest stays deliberately dense and neutral. Semantic colour appears only on the thin state
   rails, dots and counts: amber waiting, green live, grey trusted, red blocked. ---- */
.set-client-access-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-5);
}

.set-client-access-heading {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 700px;
}

.set-client-access-title,
.set-client-group-title {
    color: var(--color-text);
    font-weight: var(--font-weight-semibold);
}

.set-client-access-title {
    font-size: var(--font-size-card-title);
    margin-bottom: var(--space-1);
}

.set-client-access-enrollment {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.set-enrollment-time {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--color-caution-bg);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: var(--font-size-description);
    font-variant-numeric: tabular-nums;
    font-weight: var(--font-weight-semibold);
}

.set-enrollment-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-caution);
    box-shadow: 0 0 0 3px var(--color-caution-bg);
}

.set-client-group,
.set-access-network,
.set-blocked-clients {
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--color-stroke-subtle);
}

.set-client-group-pending {
    margin-top: var(--space-4);
    padding-top: 0;
    border-top: 0;
}

.set-client-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.set-client-group-title {
    font-size: var(--font-size-body);
}

/* A group head that carries verbs keeps its count where every other head has it: hard right, so
   the pills still line up down the card. The verbs sit inboard of it, in the bar's order. */
.set-client-group-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* The native file input adopts the standard button surface and stays keyboard reachable. */
.set-client-import {
    position: relative;
    display: inline-flex;
    overflow: hidden;
    cursor: pointer;
}

.set-client-import:focus-within {
    outline: var(--focus-ring-width) solid var(--color-accent);
    outline-offset: var(--focus-ring-offset);
}

.set-client-import-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.set-client-import.is-disabled {
    cursor: default;
    opacity: .55;
}

.set-client-import.is-disabled .set-client-import-input { cursor: default; }

.set-client-group-hint {
    margin-bottom: var(--space-3);
}

/* The identity the operator is asked to recognize, inside the notice that asks. */
.set-identity-check {
    margin-top: var(--space-3);
}

.set-client-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    font-size: var(--font-size-description);
    font-variant-numeric: tabular-nums;
    font-weight: var(--font-weight-semibold);
}

.set-client-count.is-caution {
    background: var(--color-caution-bg);
    color: var(--color-caution);
}

.set-client-count.is-live {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.set-client-count.is-blocked {
    margin-left: var(--space-2);
    background: var(--color-critical-bg);
    color: var(--color-critical);
}

.set-client-list {
    border-top: 1px solid var(--color-stroke-subtle);
}

.set-client-row {
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-stroke-subtle);
}

.set-client-row.is-pending { box-shadow: inset 3px 0 0 var(--color-caution); }
.set-client-row.is-trusted { box-shadow: inset 3px 0 0 var(--color-neutral); }
.set-client-row.is-blocked { box-shadow: inset 3px 0 0 var(--color-critical); }

.set-client-row.is-review-target {
    background: var(--color-caution-bg);
    box-shadow:
        inset 3px 0 0 var(--color-caution),
        inset 0 0 0 1px var(--color-caution);
    scroll-margin-block: var(--space-7);
}

.set-client-row.is-review-target:focus { outline: none; }

.set-client-row-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}

.set-client-identity {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.set-client-identity .ui-state-dot {
    flex: 0 0 auto;
    margin-top: var(--space-2);
}

.set-client-name {
    color: var(--color-text);
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-semibold);
    overflow-wrap: anywhere;
}

.set-client-claim,
.set-client-meta {
    margin-top: var(--space-1);
    color: var(--color-text-secondary);
    font-size: var(--font-size-description);
    line-height: 1.4;
}

.set-client-review-marker {
    display: inline-flex;
    margin-left: var(--space-2);
    color: var(--color-caution);
    font-weight: var(--font-weight-semibold);
}

.set-client-review-marker::before {
    margin-right: var(--space-2);
    content: "\00b7";
}

.set-client-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.set-client-fingerprint {
    margin-top: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    font-size: var(--font-size-description);
    line-height: 1.4;
    overflow-wrap: anywhere;
    user-select: text;
}

.set-client-details {
    margin-top: var(--space-3);
}

.set-certificate-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3) var(--space-5);
    margin: var(--space-3) 0 0;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-surface-alt);
}

.set-certificate-grid > div { min-width: 0; }

.set-certificate-grid dt {
    margin: 0 0 var(--space-1);
    color: var(--color-text-secondary);
    font-size: var(--font-size-eyebrow);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.set-certificate-grid dd {
    margin: 0;
    color: var(--color-text);
    font-size: var(--font-size-description);
    line-height: 1.4;
    overflow-wrap: anywhere;
    user-select: text;
}

.set-endpoint-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
}

.set-endpoint-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.set-endpoint-field .ui-input {
    width: 100%;
    font-size: var(--font-size-description);
}

.set-firewall-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-stroke-subtle);
}

.set-firewall-state {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.set-firewall-state .ui-state-dot {
    flex: 0 0 auto;
    margin-top: var(--space-2);
}

.set-client-empty {
    padding: var(--space-4) 0;
}

.set-live-sessions .set-live-state {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-success);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.set-blocked-clients > summary {
    color: var(--color-text);
    font-weight: var(--font-weight-semibold);
}

.set-blocked-clients .set-client-list {
    margin-top: var(--space-3);
}

@media (max-width: 760px) {
    .set-client-access-head,
    .set-client-row-head,
    .set-client-group-head,
    .set-firewall-row {
        align-items: stretch;
        flex-direction: column;
    }

    .set-client-access-enrollment,
    .set-client-group-actions,
    .set-client-actions {
        justify-content: flex-start;
    }

    .set-certificate-grid,
    .set-endpoint-grid {
        grid-template-columns: 1fr;
    }
}
