/* Reconnect dialog and error bar adapted from DIGI-FRAME. */
.reconnect-overlay {
    display: none;                     /* hidden until Blazor adds a state class */
    position: fixed;
    inset: 0;
    z-index: 20000;                    /* above MudBlazor overlays/dialogs */
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(16, 24, 40, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* Any active state shows the overlay; .components-reconnect-hide keeps it none. */
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

.reconnect-dialog {
    width: min(440px, 100%);
    box-sizing: border-box;
    padding: 2rem 2rem 1.75rem;
    text-align: center;
    background: var(--mud-palette-surface, #fff);
    color: var(--mud-palette-text-primary, #1a1a1a);
    border: 1px solid var(--mud-palette-lines-default, rgba(0, 0, 0, 0.1));
    border-radius: var(--df-radius-lg);
    box-shadow: 0 24px 60px rgba(16, 24, 40, 0.35);
    animation: reconnect-pop 0.18s ease-out;
}

@keyframes reconnect-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Only the state matching Blazor's current class is visible. */
.reconnect-state { display: none; }
#components-reconnect-modal.components-reconnect-show   .reconnect-state--show,
#components-reconnect-modal.components-reconnect-failed .reconnect-state--failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-state--rejected {
    display: block;
}

.reconnect-title {
    margin: 0.75rem 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.reconnect-text {
    margin: 0 0 0.25rem;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--mud-palette-text-secondary, #555);
}

.reconnect-attempt {
    margin: 0.75rem 0 0;
    font-size: 0.8125rem;
    color: var(--mud-palette-text-disabled, #888);
}

.reconnect-spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto;
    border: 3px solid color-mix(in srgb, var(--mud-palette-primary, #047d59) 25%, transparent);
    border-top-color: var(--mud-palette-primary, #047d59);
    border-radius: 50%;
    animation: reconnect-spin 0.8s linear infinite;
}

@keyframes reconnect-spin {
    to { transform: rotate(360deg); }
}

.reconnect-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 50%;
    color: var(--mud-palette-warning, #ff9800);
    background: color-mix(in srgb, var(--mud-palette-warning, #ff9800) 15%, transparent);
}

.reconnect-btn {
    margin-top: 1.25rem;
    padding: 0.6rem 1.4rem;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--mud-palette-primary-text, #fff);
    background: var(--mud-palette-primary, #047d59);
    border: none;
    border-radius: var(--df-radius);
    cursor: pointer;
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.reconnect-btn:hover  { filter: brightness(1.06); box-shadow: 0 6px 16px rgba(16, 24, 40, 0.25); }
.reconnect-btn:active { filter: brightness(0.95); }

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
    .reconnect-dialog  { animation: none; }
    .reconnect-spinner { animation-duration: 1.6s; }
}

/* =========================================================================
 * Unhandled-error bar (#blazor-error-ui in Components/App.razor)
 * -------------------------------------------------------------------------
 * Blazor unhides the element by writing display:block on it directly, which is
 * why the rule below hides it with display:none and every layout property is
 * one display:block tolerates - a flex container the framework sets to block
 * would drop its own alignment the moment it is needed.
 * A bar at the bottom edge rather than a modal: the state on the page is gone
 * either way, but a modal over it takes the last thing the operator saw with
 * it, and that is what they will be asked about.
 * ========================================================================= */
#blazor-error-ui {
    display: none;                     /* Blazor writes display:block when a circuit fails */
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20001;                    /* above the reconnect overlay */
    padding: 0.875rem 1.25rem;
    text-align: left;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--mud-palette-text-primary, #1a1a1a);
    background: var(--mud-palette-surface, #fff);
    border-top: 3px solid var(--mud-palette-error, #f44336);
    box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.25);
}

.error-bar__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 0.625rem;
    vertical-align: middle;
    font-weight: 700;
    line-height: 1;
    border-radius: 50%;
    color: var(--mud-palette-error, #f44336);
    background: color-mix(in srgb, var(--mud-palette-error, #f44336) 15%, transparent);
}

.error-bar__text {
    vertical-align: middle;
    color: var(--mud-palette-text-secondary, #555);
}

.error-bar__btn {
    margin-left: 1rem;
    padding: 0.4rem 1rem;
    font: inherit;
    font-weight: 600;
    vertical-align: middle;
    color: var(--mud-palette-primary-text, #fff);
    background: var(--mud-palette-primary, #047d59);
    border: none;
    border-radius: var(--df-radius);
    cursor: pointer;
}

.error-bar__btn:hover { filter: brightness(1.06); }

