/* ═══════════════════════════════════════════════════════════════
   WF Portal — App-level overrides
   (root.css provides the design tokens and dark-theme base)
   ═══════════════════════════════════════════════════════════════ */

/* ── Shared Context Menu (ContextMenu.razor) ─────────────────── */
.ctx-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9990;
}

.ctx-menu {
    position: fixed;
    z-index: 9991;
    /* Clamp to the viewport so a right-click near an edge never pushes the menu
       off-screen. --ctx-x / --ctx-y are the raw click coords set inline by the
       component; --ctx-menu-w / --ctx-menu-h are assumed dimensions a caller may
       override. max-width is the hard safety net for unusually wide content. */
    left: clamp(8px, var(--ctx-x, 8px), calc(100vw - var(--ctx-menu-w, 240px)));
    top: clamp(8px, var(--ctx-y, 8px), calc(100vh - var(--ctx-menu-h, 300px)));
    background: var(--theme-background-float, #fff);
    color: var(--theme-text, #212529);
    border: 1px solid var(--theme-border, #e2e6eb);
    border-radius: var(--theme-radius, 8px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    min-width: 190px;
    max-width: calc(100vw - 16px);
    max-height: 80vh;
    overflow-y: auto;
    padding: 0.4rem;
    animation: ctx-appear 0.12s ease-out;
}

@keyframes ctx-appear {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--theme-radius-button, 6px);
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 0.85rem;
    color: var(--theme-text-emphasis, var(--theme-text, #2c3e50));
    text-align: left;
}

.ctx-item:hover {
    background: var(--theme-background-hover, rgba(0,0,0,0.04));
}

.ctx-item i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
/* ── End Context Menu ─────────────────────────────────────────── */

h1:focus {
    outline: none;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: var(--theme-focus-ring);
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--theme-success);
}

.invalid {
    outline: 1px solid var(--theme-danger);
}

.validation-message {
    color: var(--theme-danger);
    font-size: var(--theme-font-size-xs);
    margin-top: 0.25rem;
}

/* THE ERROR TOAST (2026-11-24, replaces the template's "An unhandled error has occurred" bar). Blazor shows #blazor-error-ui by
   setting display: block, so the toast is a centred block; the words and buttons sit inline in it. */
#blazor-error-ui {
    position: fixed;
    bottom: 20px;
    left: 50%;
    z-index: 1000;
    display: none;
    box-sizing: border-box;
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 10px 10px 10px 16px;
    border: 1px solid color-mix(in srgb, var(--theme-danger) 45%, transparent);
    border-radius: var(--wf-radius-pill);
    background: color-mix(in oklab, var(--theme-nav-background) 22%, black);
    box-shadow: 0 10px 30px color-mix(in srgb, black 35%, transparent);
    color: color-mix(in srgb, white 92%, transparent);
    font-size: 14px;
    transform: translateX(-50%);
}

    #blazor-error-ui > * {
        vertical-align: middle;
    }

    #blazor-error-ui .bi-exclamation-circle-fill {
        margin-right: 6px;
        color: color-mix(in oklab, var(--theme-danger) 70%, white);
    }

    #blazor-error-ui .reload {
        display: inline-block;
        margin-left: 12px;
        padding: 6px 14px;
        border-radius: var(--wf-radius-pill);
        background: color-mix(in srgb, white 100%, transparent);
        color: var(--theme-text-emphasis);
        font-weight: 600;
        text-decoration: none;
    }

    #blazor-error-ui .dismiss {
        margin-left: 4px;
        padding: 6px 8px;
        border: 0;
        background: transparent;
        color: color-mix(in srgb, white 62%, transparent);
        cursor: pointer;
    }

    #blazor-error-ui .dismiss:hover {
        color: color-mix(in srgb, white 100%, transparent);
    }

/* A component that failed inside an error boundary: a calm card, not the template's yellow triangle. */
.blazor-error-boundary {
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--theme-danger) 30%, transparent);
    border-radius: var(--wf-radius-md);
    background: var(--wf-danger-soft);
    color: var(--wf-danger-ink);
    font-size: 14px;
}

    .blazor-error-boundary::after {
        content: "Something went wrong in this part of the page. Reload to try again.";
    }

code {
    color: var(--theme-accent);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--theme-text-placeholder);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Spinner for dark theme */
.spinner-border {
    color: var(--theme-primary);
}



/* Surface preview-mode chrome stripping.
   Toggled on body by SurfacePage (?mode=preview) via JSSurfacePreviewChrome
   so the SurfaceBuilder's multi-canvas preview iframes show JUST the surface.
   Lives HERE (globally loaded via index.html) and not in surface-builder.css:
   that stylesheet is page-scoped to the builder/list pages, and the iframes
   load the standalone /s/{name} document which never links it - the strip
   silently never applied inside the iframes. Covers BOTH nav shells: the top
   bar (.wf-navbar) and the side rail (.wf-sidebar + mobile bar/backdrop). */
body.surface-preview-mode .wf-navbar { display: none !important; }
body.surface-preview-mode .wf-sidebar { display: none !important; }
body.surface-preview-mode .wf-sidebar-mobilebar { display: none !important; }
body.surface-preview-mode .wf-sidebar-backdrop { display: none !important; }
body.surface-preview-mode .wf-shellbar { display: none !important; }
body.surface-preview-mode .wf-main { padding: 0 !important; margin: 0 !important; border-radius: 0 !important; box-shadow: none !important; --wf-sticky-top: 0px !important; scroll-padding-top: 0 !important; }
body.surface-preview-mode .wf-main > .wf-page-area { padding: 0 !important; }
body.surface-preview-mode .wf-page-header { display: none !important; }
