/* meso.ui: what MesoSim's and MesoLive's portals share in the browser. Each host page links this file after the Radzen
   theme and Bootstrap, as the theme's variables (--rz-*) feed its rules, and before its own site.css and scoped CSS
   bundle, so that a page's or component's own rule wins over a shared one of the same specificity (MesoSim's _Host
   order). The page writes meso.lib's ChartStyle.Stylesheet (the --chart-* tokens and the theme's colours) after them.
   Only rules for what renders outside a component's scoped CSS live here: Radzen's popups, messages, toasts and tabs,
   the crash card, ErrorBoundary's default message and the error page. */

/* Radzen's popups (<Popup class="meso-popup">), such as MesoSim's Backtests filters. Radzen moves a popup to the end of
   the page as it opens, out of reach of the components' scoped styles: their panels style themselves, and this keeps
   the popup's own element hidden until it opens. The panels render while hidden, so Radzen measures them as it
   places the popup inside the window. On phones a sheet sits at the bottom of the screen. */
.meso-popup {
    display: none;
    position: absolute;
}

@media (max-width: 640px) {
    .meso-popup--sheet {
        position: fixed !important;
        top: auto !important;
        right: 0.5rem !important;
        bottom: 0.5rem !important;
        left: 0.5rem !important;
    }
}

/* Messages: alerts, toasts, run outcomes and the app's own failures, in one family
   (docs/mockups/mesosim-error-messages). Text keeps the page's inks in the theme's font; a message's status colour
   (Radzen's theme colours, which meso.lib ChartStyle sets) goes only on its icon, a wash and a toast's 3 px edge. A
   page-wide or centred card takes no edge: its icon sits on the wash instead. */

/* Alerts: Flat with the lighter shade, which nearly all of them use. The wash and the icon keep the alert's colour. */
.rz-alert.rz-variant-flat.rz-shade-lighter {
    --rz-alert-color: var(--rz-text-color);
    --rz-alert-title-color: var(--rz-text-title-color);
    --rz-alert-padding: 0.75rem 1rem;
    --rz-alert-gap: 0.75rem;
    --rz-alert-message-margin: 0;
    --rz-alert-icon-margin: 0.05rem 0 0;
    --rz-alert-icon-size: 1.25rem;
    border-radius: 6px;
    font-family: var(--rz-text-font-family);
    font-size: 0.875rem;
    line-height: 1.43;
}

.rz-alert.rz-variant-flat.rz-shade-lighter .rz-alert-icon {
    --rz-icon-fill: 1;
}

.rz-alert.rz-variant-flat.rz-shade-lighter .rz-alert-title {
    margin-bottom: 0.1rem;
    font-size: inherit;
    font-weight: 600;
    line-height: inherit;
    letter-spacing: 0;
}

/* A neutral note (Light): nothing is wrong, so its icon is grey. */
.rz-alert.rz-light.rz-variant-flat.rz-shade-lighter {
    --rz-alert-icon-color: var(--rz-text-tertiary-color);
}

/* On the wash, Light and Base buttons are white with a hairline, as the Problems list's fix buttons. */
.rz-alert.rz-variant-flat.rz-shade-lighter .rz-button.rz-light,
.rz-alert.rz-variant-flat.rz-shade-lighter .rz-button.rz-base {
    background-color: var(--rz-base-background-color);
    box-shadow: inset 0 0 0 1px var(--rz-base-300);
}

/* The close button is quiet, never in the alert's colour. */
.rz-alert.rz-variant-flat.rz-shade-lighter > .rz-button.rz-variant-text {
    color: var(--rz-text-tertiary-color);
    border-radius: 999px;
}

/* In dialogs and side panels an alert is a step smaller. */
.rz-dialog-content .rz-alert.rz-variant-flat.rz-shade-lighter,
.rz-alert.rz-variant-flat.rz-shade-lighter.message-compact {
    --rz-alert-padding: 0.5rem 0.75rem;
    --rz-alert-gap: 0.5rem;
    --rz-alert-icon-size: 1.05rem;
    border-radius: var(--rz-border-radius);
    font-size: 0.8125rem;
}

/* A run's outcome in place of its results (a failed backtest, a Merlin run's state): a page-wide white card with its
   icon on the state's wash, as on the load-failure card. The wash is the one Radzen gives the alert's style. */
.rz-alert.rz-variant-flat.rz-shade-lighter.run-outcome {
    --rz-alert-padding: 1rem 1.25rem;
    --rz-alert-icon-margin: 0;
    --rz-alert-message-margin: 0.4rem 0 0;
    background-color: var(--rz-base-background-color);
    box-shadow: var(--rz-card-shadow);
    border-radius: var(--rz-border-radius);
}

.rz-alert.rz-variant-flat.rz-shade-lighter.run-outcome .rz-alert-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--rz-alert-background-color);
}

/* Waiting: the chart style's grey for nothing yet. */
.rz-alert.run-outcome.rz-light { --rz-alert-background-color: var(--chart-idle); }

.rz-alert.rz-variant-flat.rz-shade-lighter.run-outcome .rz-alert-title {
    font-size: 1rem;
}

/* A failure reason is the card's text, in the page's font; an engine message keeps its line breaks and indentation. A
   failure code or a pointer to more detail follows it in the secondary ink. */
.rz-alert.run-outcome .run-outcome__reason {
    color: var(--rz-text-title-color);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.rz-alert.run-outcome .run-outcome__hint {
    color: var(--rz-text-secondary-color);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

/* Toasts: white and raised, with the status colour on a 3 px edge and the icon. */
:root {
    --rz-notification-padding: 0.7rem 0.5rem 0.7rem 1rem;
    --rz-notification-gap: 0.65rem;
    --rz-notification-border-radius: 6px;
    --rz-notification-error-background-color: var(--rz-base-background-color);
    --rz-notification-error-color: var(--rz-text-color);
    --rz-notification-error-icon-color: var(--rz-on-danger-lighter);
    --rz-notification-warning-background-color: var(--rz-base-background-color);
    --rz-notification-warning-color: var(--rz-text-color);
    --rz-notification-warning-icon-color: var(--rz-on-warning-lighter);
    --rz-notification-info-background-color: var(--rz-base-background-color);
    --rz-notification-info-color: var(--rz-text-color);
    --rz-notification-info-icon-color: var(--rz-on-info-lighter);
    --rz-notification-success-background-color: var(--rz-base-background-color);
    --rz-notification-success-color: var(--rz-text-color);
    --rz-notification-success-icon-color: var(--rz-on-success-lighter);
}

.rz-notification {
    font-family: var(--rz-text-font-family);
    font-size: 0.875rem;
    line-height: 1.43;
}

.rz-notification-item-wrapper {
    width: min(23rem, calc(100vw - 2rem));
    min-width: 0;
    margin: 0.5rem 0;
}

.rz-notification-item {
    --toast-edge: var(--rz-info);
    box-shadow: inset 3px 0 0 var(--toast-edge), 0 0 0 1px var(--rz-base-200), var(--rz-shadow-3);
}

.rz-notification-error .rz-notification-item { --toast-edge: var(--rz-danger); }
.rz-notification-warn .rz-notification-item { --toast-edge: var(--rz-warning); }
.rz-notification-success .rz-notification-item { --toast-edge: var(--rz-success); }

.rz-notification-icon {
    --rz-icon-fill: 1;
    font-size: 1.25rem;
}

.rz-notification-title {
    color: var(--rz-text-title-color);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.rz-notification-title a {
    font-weight: 600;
}

.rz-notification-content {
    margin: 0.1rem 0 0;
    color: var(--rz-text-secondary-color);
    font-size: 0.8125rem;
}

.rz-notification-content:empty {
    display: none;
}

.rz-notification-close {
    display: grid;
    flex: none;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.2rem 0;
    border-radius: 999px;
    color: var(--rz-text-tertiary-color);
    opacity: 1;
    font-size: 1.1rem;
}

.rz-notification-close:hover {
    background: var(--rz-base-100);
    color: var(--rz-text-title-color);
}

@media (max-width: 480px) {
    .rz-notification {
        inset-inline: 1rem;
    }

    .rz-notification-item-wrapper {
        width: 100%;
    }
}

/* When the app itself fails (Pages/_Host.cshtml): a raised card at the bottom centre, its icon on the error wash.
   Blazor shows it with display: block. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 50%;
    bottom: 1rem;
    /* Above Radzen's dialogs (--rz-dialog-zindex, 1001) and toasts (1002): a handler that fails in a dialog leaves
       the dialog's full-window wrapper open over the card. */
    z-index: 1003;
    width: min(42rem, calc(100vw - 2rem));
    transform: translateX(-50%);
    border-radius: 8px;
    background: var(--rz-base-background-color);
    box-shadow: 0 0 0 1px var(--rz-base-200), var(--rz-shadow-3);
    color: var(--rz-text-color);
    font-family: var(--rz-text-font-family);
    font-size: 0.875rem;
    line-height: 1.43;
}

.blazor-error-ui__card {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.6rem 0.75rem;
    padding: 0.85rem 0.6rem 0.85rem 1rem;
}

.blazor-error-ui__icon {
    --rz-icon-fill: 1;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--rz-danger-lighter);
    color: var(--rz-on-danger-lighter);
    font-size: 1.25rem;
}

/* The title's first line and the buttons sit on the icon's middle, as on the run outcome card. */
.blazor-error-ui__title {
    margin-top: 0.5rem;
    color: var(--rz-text-title-color);
    font-weight: 600;
}

.blazor-error-ui__help {
    margin-top: 0.2rem;
    color: var(--rz-text-secondary-color);
    font-size: 0.8125rem;
}

.blazor-error-ui__link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--rz-link-color);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.blazor-error-ui__link:hover {
    text-decoration: underline;
}

.blazor-error-ui__end {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 2.25rem;
}

#blazor-error-ui .dismiss {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--rz-text-tertiary-color);
    cursor: pointer;
}

#blazor-error-ui .dismiss:hover {
    background: var(--rz-base-100);
    color: var(--rz-text-title-color);
}

@media (max-width: 520px) {
    .blazor-error-ui__card {
        grid-template-columns: 2.25rem minmax(0, 1fr) 1.75rem;
    }

    .blazor-error-ui__end {
        display: contents;
    }

    #blazor-error-ui .dismiss {
        grid-column: 3;
        grid-row: 1;
    }

    .blazor-error-ui__end .rz-button {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
    }
}

/* A component that broke (ErrorBoundary's default content): a quiet message in its place. */
.blazor-error-boundary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 7.5rem;
    padding: 1rem;
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-100);
    color: var(--rz-text-secondary-color);
    font-family: var(--rz-text-font-family);
    font-size: 0.875rem;
}

.blazor-error-boundary::before {
    content: "error";
    color: var(--rz-on-danger-lighter);
    font-family: var(--rz-icon-font-family);
    font-size: 1.25rem;
    font-feature-settings: "liga";
    font-variation-settings: "FILL" 1;
    line-height: 1;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* The error page: both portals' Pages/Error.cshtml with ErrorPageCard. */
.error-page {
    min-height: 100vh;
    margin: 0;
    background: var(--rz-body-background-color);
    color: var(--rz-text-color);
    font-family: var(--rz-text-font-family);
}

.error-page__main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 3rem 1rem;
}

.error-page__logo {
    height: 2rem;
    width: auto;
}

.error-page__card {
    width: 100%;
    max-width: 34rem;
    padding: 1.5rem;
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
    box-shadow: var(--rz-card-shadow);
    text-align: center;
}

.error-page__icon {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    margin: 0 auto 0.75rem;
    border-radius: 50%;
    background: var(--rz-danger-lighter);
    color: var(--rz-on-danger-lighter);
}

.error-page__icon .rzi {
    --rz-icon-fill: 1;
    font-size: 1.4rem;
}

.error-page__card h1 {
    margin: 0 0 0.25rem;
    color: var(--rz-text-title-color);
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.error-page__card p {
    margin: 0;
    font-size: 0.9375rem;
}

.error-page__card .error-page__request {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.25rem 0.5rem;
    max-width: 100%;
    margin-top: 0.9rem;
    padding: 0.3rem 0.35rem 0.3rem 0.6rem;
    border-radius: 8px;
    background: var(--rz-base-100);
    box-shadow: inset 0 0 0 1px var(--rz-base-200);
    color: var(--rz-text-secondary-color);
    font-size: 0.8125rem;
}

.error-page__request-id {
    padding: 0.05rem 0.45rem;
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
    color: var(--rz-text-title-color);
    overflow-wrap: anywhere;
}

/* Tabs, site-wide: underlined tabs on a hairline instead of Radzen's boxed tabs, and the tab's content straight on the
   page under them, as in the Backtest Overview mockup. A page can still set its own panel spacing. RadzenTabs renders
   outside a page's CSS isolation boundary, so this lives here. */
.rz-tabview.rz-tabview-top > .rz-tabview-nav {
    /* The tabs don't widen the page; a narrow window scrolls the strip instead. */
    contain: inline-size;
    gap: 0.15rem;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    box-shadow: inset 0 -1px 0 var(--rz-base-300);
    scrollbar-width: none;
}

.rz-tabview.rz-tabview-top > .rz-tabview-nav::-webkit-scrollbar {
    display: none;
}

.rz-tabview.rz-tabview-top > .rz-tabview-nav li {
    flex: 0 0 auto;
    height: 2.6rem;
    margin: 0;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background-color: transparent;
    color: var(--rz-text-secondary-color);
}

.rz-tabview.rz-tabview-top > .rz-tabview-nav li > button {
    gap: 0.4rem;
    height: 100%;
    padding: 0 0.9rem;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.rz-tabview.rz-tabview-top > .rz-tabview-nav .rz-tabview-icon {
    margin-inline: 0;
    font-size: 1.1rem;
    color: var(--rz-text-tertiary-color);
}

.rz-tabview.rz-tabview-top > .rz-tabview-nav li:hover:not(.rz-tabview-selected):not(.rz-state-disabled),
.rz-tabview.rz-tabview-top > .rz-tabview-nav li.rz-state-focused:not(.rz-tabview-selected):not(.rz-state-disabled) {
    border-color: transparent;
    background-color: rgba(255, 255, 255, 0.6);
    color: var(--rz-text-title-color);
}

.rz-tabview.rz-tabview-top > .rz-tabview-nav li.rz-tabview-selected {
    border-bottom-color: var(--rz-primary);
    color: var(--rz-text-title-color);
}

.rz-tabview.rz-tabview-top > .rz-tabview-nav li.rz-tabview-selected .rz-tabview-icon {
    color: var(--rz-primary);
}

.rz-tabview.rz-tabview-top > .rz-tabview-panels {
    min-width: 0;
    max-width: 100%;
    padding: 1rem 0 0;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    box-shadow: none;
}

.rz-tabview.rz-tabview-top > .rz-tabview-panels > .rz-tabview-panel {
    padding: 0;
}
