/*
  The shell: sidebar, top bar, mode pill, status band.

  Global rather than Blazor-scoped, deliberately. Scoped component CSS is served from the build's
  static-web-asset manifest rather than from wwwroot, and the predecessor lost its entire sidebar
  that way outside the Development environment -- the page silently reverted to blue links on white
  and nobody could see why. Global CSS has no such failure mode.

  Loaded after bootstrap.min.css, because .nav-item .nav-link overrides Bootstrap's own .nav-link
  colour variables and the later rule has to win.
*/

/* --- Page frame ------------------------------------------------------------------------- */

.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    /*
      Load-bearing. A flex child defaults to min-width:auto and refuses to shrink below its own
      content. The status band carries a sentence, so without this the main column widens past the
      viewport and the whole page grows a horizontal scrollbar. Every level of the nested flex chain
      needs it, which is why it appears again on .status-band and on its spans.
    */
    min-width: 0;
}

/* --- Sidebar ---------------------------------------------------------------------------- */

.sidebar {
    background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.brand-row {
    height: 3.5rem;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    padding-left: 1rem;
}

.brand {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
}

.brand:hover {
    color: #fff;
    text-decoration: none;
}

/* --- Top bar ---------------------------------------------------------------------------- */

.top-row {
    background-color: #f7f7f7;
    border-bottom: 1px solid #d6d5d5;
    height: 3.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.app-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6c757d;
    white-space: nowrap;
}

.wall-clock {
    margin-left: auto;
    padding-left: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* --- Mode pill ---------------------------------------------------------------------------
   Reports what the store can currently do. Not a control: this API has no route that changes it,
   and a pill that looks clickable and does nothing is worse than a label. */

.mode-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    user-select: none;
    white-space: nowrap;
    flex: none;
}

.mode-pill--live    { background-color: #1e8449; color: #ffffff; }
.mode-pill--degraded { background-color: #d68910; color: #ffffff; }
.mode-pill--down    { background-color: #c0392b; color: #ffffff; }
/* Red like --down, because both mean the screen cannot be trusted to show what is happening. */
.mode-pill--stalled { background-color: #c0392b; color: #ffffff; }
.mode-pill--unknown { background-color: #7f8c8d; color: #ffffff; }

/* --- Status band -------------------------------------------------------------------------
   Four bands, and only four. There is deliberately no "favourable" green for market conditions:
   nothing in this system measures that. The predecessor's green came from a favourability endpoint
   that does not exist here, and a green band with no signal behind it is precisely the dishonesty
   this rebuild is against. When such a contract ships, its colour is added in the same change as
   the code that can reach it. */

.status-band {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    user-select: none;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

.status-band > span {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.status-band .status-icon {
    font-size: 0.95rem;
    flex: none;
}

.status-band--ready    { background-color: #5d6d7e; color: #ffffff; }
.status-band--caution  { background-color: #d68910; color: #ffffff; }
.status-band--fault    { background-color: #c0392b; color: #ffffff; }
.status-band--waiting  { background-color: #4a4a4a; color: #cccccc; }

/* --- Navigation --------------------------------------------------------------------------- */

.navbar-toggler {
    appearance: none;
    cursor: pointer;
    width: 3.5rem;
    height: 2.5rem;
    color: white;
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
}

.navbar-toggler:checked {
    background-color: rgba(255, 255, 255, 0.5);
}

.nav-scrollable {
    display: none;
}

.navbar-toggler:checked ~ .nav-scrollable {
    display: block;
}

.nav-item {
    font-size: 0.9rem;
    padding-bottom: 0.5rem;
}

.nav-item:first-of-type {
    padding-top: 1rem;
}

.nav-item:last-of-type {
    padding-bottom: 1rem;
}

.nav-item .nav-link {
    color: #d7d7d7;
    background: none;
    border: none;
    border-radius: 4px;
    height: 3rem;
    display: flex;
    align-items: center;
    line-height: 3rem;
    width: 100%;
    padding: 0 0.75rem;
    text-decoration: none;
}

.nav-item a.active {
    background-color: rgba(255, 255, 255, 0.37);
    color: #ffffff;
}

.nav-item .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/*
  A destination whose page exists and whose read model does not. Reading the menu should tell you
  what is real before you click it, not after. This chip is driven by the API's own list of pending
  routes, so it disappears on its own when the read model lands.
*/
.nav-pending {
    margin-left: auto;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #b9b9b9;
    background-color: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 1px 5px;
}

/* --- Responsive --------------------------------------------------------------------------- */

@media (max-width: 640.98px) {
    .top-row {
        justify-content: space-between;
    }

    .status-band {
        display: none;
    }
}

@media (min-width: 641px) {
    .page {
        flex-direction: row;
    }

    .sidebar {
        width: 250px;
        height: 100vh;
        position: sticky;
        top: 0;
    }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .navbar-toggler {
        display: none;
    }

    .nav-scrollable {
        display: block;
        height: calc(100vh - 3.5rem);
        overflow-y: auto;
    }

    .top-row,
    article {
        padding-left: 2rem !important;
        padding-right: 1.5rem !important;
    }
}

/* --- Blazor's own error strip --------------------------------------------------------------- */

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
