/* ============================================================
   Cosmyre Nexus — the GUI's own CSS.
   The shared UI (tokens, Bootstrap 5.3.3, buttons, dropdowns, grids, cards, panes, tabs, the
   section card, modals, hints, the throbber) is Photon's photon.tokens.css + photon.css, which
   <PhotonHead /> loads BEFORE this file. What is here belongs to Nexus as a host, exactly as
   Cosmyre's app.css belongs to Cosmyre. Change the shared look in Photon, never here.
   ============================================================ */

/* ---- Host tokens ----
   The shell's fixed brand colours, defined ONCE so no rule below carries a literal colour. The
   sidebar navy, its inks and the crescent's gradient are copied from Cosmyre's NavMenu so the two
   products' shells match; the night sky is Cosmyre's AuthLayout's. */
:root {
    --nexus-sidebar-top: #141f4a;
    --nexus-sidebar-bottom: #0b1330;
    --nexus-sidebar-brand-bg: rgba(0, 0, 0, .25);
    --nexus-sidebar-ink: #8f9bb3;
    --nexus-sidebar-ink-sub: #7d879c;
    --nexus-sidebar-ink-strong: #ffffff;
    --nexus-sidebar-hover: rgba(255, 255, 255, .05);
    --nexus-sidebar-active: rgba(255, 255, 255, .08);
    --nexus-sidebar-active-sub: rgba(255, 255, 255, .06);
    --nexus-sidebar-rule: rgba(255, 255, 255, .08);
    --nexus-sidebar-rule-strong: rgba(255, 255, 255, .1);
    --nexus-sidebar-glow: rgba(168, 131, 246, .32);
    --nexus-moon-top: #784ff7;
    --nexus-moon-bottom: #0549b9;
    --nexus-brand-accent: #a883f6;
    --nexus-auth-sky: #000000;
    --nexus-auth-star: #ffffff;
    --nexus-auth-ink: #ffffff;
    --nexus-auth-glow: rgba(120, 79, 247, .55);
    --nexus-auth-panel-border: rgba(255, 255, 255, .12);
    /* The QR plate is black-on-white in both themes: scanners need the contrast. */
    --nexus-qr-plate: #ffffff;
}

[data-bs-theme="dark"] {
    --nexus-sidebar-bottom: #090e26;
}

/* ---- Header user menu (Cosmyre's) ---- */
.header-user-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    background: var(--bs-body-bg);
}

.header-user-btn .user-avatar {
    display: inline-flex;
    font-size: 1.4rem;
    color: var(--bs-secondary-color);
}

.header-user-btn .user-avatar .bi {
    color: inherit;
}

.header-user-btn .user-name {
    font-size: .9rem;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

h1:focus {
    outline: none;
}

/* ---- Sign-in pages (AuthLayout) ----
   A translucent panel on the night sky; the shell carries data-bs-theme="dark", so every
   Bootstrap control inside takes the dark tokens. */
.auth-panel {
    padding: 1.75rem 1.75rem 1.5rem;
    border: 1px solid var(--nexus-auth-panel-border);
    border-radius: var(--cosmyre-card-radius);
    background: color-mix(in srgb, var(--bs-body-bg) 84%, transparent);
    backdrop-filter: blur(2px);
}

.auth-title {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

.auth-lead {
    color: var(--bs-secondary-color);
    margin-bottom: 1rem;
}

.auth-note {
    margin: 1.25rem 0 0;
    font-size: .85rem;
    color: var(--bs-secondary-color);
    text-align: center;
}

.auth-note a {
    color: var(--cosmyre-accent-text);
}

.setup-steps {
    padding-left: 1.25rem;
    margin-bottom: 0;
}

.setup-steps > li {
    margin-bottom: 1.1rem;
}

.qr-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    margin-top: .75rem;
}

.qr-code {
    flex: 0 0 auto;
    width: 12rem;
    padding: .5rem;
    background: var(--nexus-qr-plate);
    border-radius: var(--cosmyre-card-radius);
}

.qr-code svg {
    display: block;
    width: 100%;
    height: auto;
}

.qr-manual {
    flex: 1 1 14rem;
    min-width: 0;
}

.qr-key {
    display: inline-block;
    margin-top: .35rem;
    font-size: 1rem;
    letter-spacing: .05em;
    user-select: all;
    word-break: break-all;
}

.recovery-codes {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem .75rem;
}

.recovery-codes code {
    display: block;
    padding: .35rem .6rem;
    border-radius: .35rem;
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    font-size: .95rem;
    letter-spacing: .04em;
    text-align: center;
    user-select: all;
}

/* ---- KPI tiles (Mission Control): the gallery's stat-tile shape ---- */
.kpi-row {
    --bs-gutter-x: 0;
    --bs-gutter-y: 0;
}

.kpi-tile {
    height: 100%;
    padding: .85rem 1rem;
}

.kpi-label {
    font-size: .78rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

.kpi-value {
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    font-size: .75rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

/* Stacked cards on a scrolling page are parted by a hairline (photon page-layout: card gaps). */
.nx-stack {
    margin-top: 2px;
}

.nx-fill-card {
    min-height: 22rem;
}

/* A stacked pane that keeps its natural height while its sibling fills the rest (a short form
   above a list), and the body of a card whose PhDataTable fills it. */
.list-page-col > .list-page-list.nx-col-fixed {
    flex: 0 0 auto;
}

.nx-fill-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---- Inline two-step confirm (Shared/InlineConfirm.razor) ---- */
.inline-confirm {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem;
}

.inline-confirm-question {
    font-size: .8rem;
    color: var(--bs-danger-text-emphasis);
    white-space: normal;
}

/* A grid's leading column of row controls: eye, verbs, trash on one line — an armed confirm
   included, so a row never grows a second line under its question. */
.row-actions {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    white-space: nowrap;
}

.row-actions .inline-confirm {
    flex-wrap: nowrap;
}

.row-actions .inline-confirm-question {
    white-space: nowrap;
}

/* The left end of a modal's action row (a hint) — it is also what keeps a dialog's one button at
   the right when it has no Cancel (Photon right-aligns through Cancel's margin). */
.md-foot-note {
    font-size: .8125rem;
    color: var(--bs-secondary-color);
}

/* ---- Modal bodies: the shell gives the height; the body scrolls itself ---- */
.nx-modal-body {
    height: 100%;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

/* A secret shown exactly once (a client key, a one-time password). */
.secret-reveal {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .75rem;
    border: 1px dashed var(--cosmyre-accent);
    border-radius: .5rem;
    background: var(--bs-tertiary-bg);
}

.secret-reveal code {
    flex: 1 1 18rem;
    min-width: 0;
    font-size: .95rem;
    color: var(--bs-body-color);
    word-break: break-all;
    user-select: all;
}

/* Read-only values in a settings-shaped form (an immutable identity field). */
.setting-static {
    display: inline-block;
    padding: .375rem 0;
    font-family: var(--bs-font-monospace);
    font-size: .875rem;
    word-break: break-all;
}

/* The allowed-models picker on a client's Overview. */
.model-picks {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 18rem;
    max-height: 16rem;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .5rem .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    overflow-wrap: anywhere;
}

.model-picks .form-check {
    margin-bottom: 0;
}

/* Page-level scoping controls above a grid (History's date range): pinned, never scrolled. */
.scope-bar {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    padding: .6rem var(--cosmyre-tab-bleed);
    border-bottom: 1px solid var(--bs-border-color);
}

.scope-bar .form-control {
    width: auto;
}

.scope-bar-label {
    font-size: .8125rem;
    color: var(--bs-secondary-color);
}

/* JSON details in History's event dialog. */
.json-details {
    margin: 0;
    padding: .75rem;
    border-radius: .375rem;
    background: var(--bs-tertiary-bg);
    font-size: .8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-list {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: .35rem 1rem;
    margin-bottom: 1rem;
    font-size: .875rem;
}

.detail-list dt {
    font-weight: 600;
    color: var(--bs-secondary-color);
}

.detail-list dd {
    margin: 0;
    word-break: break-word;
}

/* A KPI tile whose value is an identifier (an endpoint, a key) rather than a number. */
.kpi-value.nx-kpi-small {
    font-size: .95rem;
    line-height: 1.9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A compact read-only table inside a record dialog (a node's GPUs, deployments, commands). */
.nx-mini-table {
    font-size: .82rem;
    margin-bottom: 1.25rem;
}

.nx-mini-table th {
    color: var(--bs-secondary-color);
    font-weight: 600;
    white-space: nowrap;
}

/* ---- The Constellation (Mission Control) -------------------------------------------------------
   The sky is the Navigator's dark sky in BOTH themes, so its colours are not themed: the workload
   hues (validated all-pairs for colour-vision deficiency on #10173d) and the status rings live in
   js/constellation.js. These rules are the frame, the tooltip, the "gateway unreachable" note and
   the legend, whose swatches repeat those same values. */
.nx-sky {
    position: relative;
    height: 26rem;
    background: #10173d;
    overflow: hidden;
}

.nx-sky canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.nx-sky-tip {
    position: absolute;
    z-index: 2;
    max-width: 17rem;
    padding: .4rem .6rem;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: .4rem;
    background: rgba(12, 16, 44, .94);
    box-shadow: 0 .4rem 1.1rem rgba(0, 0, 0, .35);
    color: #eef0ff;
    font-size: .78rem;
    line-height: 1.45;
    pointer-events: none;
}

.nx-sky-state {
    display: none;
    position: absolute;
    left: .75rem;
    bottom: .6rem;
    color: #eef0ff;
    font-size: .78rem;
}

.nx-sky:has(canvas[data-gateway="unreachable"]) .nx-sky-state {
    display: block;
}

.nx-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem 1.1rem;
    padding: .55rem .9rem;
    border-top: 1px solid var(--cosmyre-card-border);
    color: var(--bs-secondary-color);
    font-size: .78rem;
}

.nx-legend > span {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.nx-swatch,
.nx-ring {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    border-radius: 50%;
}

.nx-ring {
    border: 1.5px dashed;
}

.nx-kind-text { background: #3987e5; }
.nx-kind-dictation { background: #d95926; }
.nx-kind-vision { background: #199e70; }
.nx-ring-warning { border-color: #fab219; }
.nx-ring-critical { border-color: #d03b3b; }

@media (max-width: 575.98px) {
    .nx-sky { height: 34rem; }
}

@media print {
    .sidebar, .app-header, .nav-throb { display: none !important; }
}

/* ---- Jobs: each deployment's background lane, a read-down roster above the queue ---- */
.nx-lanes {
    list-style: none;
    margin: 0;
    padding: .25rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
}

.nx-lane {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
}

.nx-hold-input {
    width: auto;
    min-width: 13rem;
}
