/* Contextual Help drawer (Layout/HelpDrawer.razor) + field highlight + HelpTip / HelpFieldsButton. Global because the drawer pushes
   the page body, sits above Radzen dialogs (non-modal: the user keeps working in the dialog) and pulses inputs outside the component.
   Ported from HarmonyCore (hc-*). Every colour is a Radzen / Px token (app.css redefines them under [data-theme="dark"], so the
   drawer follows ThemeToggle with no rules of its own); hex values appear only as var() fallbacks. */
:root {
    --px-help-width: 440px;
    --px-help-top: 48px;
    --px-help-accent: var(--rz-primary, #e11d48);
    --px-help-on-accent: var(--rz-on-primary, #ffffff);
    --px-help-accent-soft: var(--rz-primary-lighter, #fecdd3);
    --px-help-surface: var(--px-panel, #ffffff);
    --px-help-surface-alt: var(--px-surface, #fef2f4);
    --px-help-ink: var(--px-panel-ink, #263238);
    --px-help-muted: var(--rz-text-secondary-color, #666666);
    --px-help-border: var(--px-border, #f6dce1);
    --px-help-warn: var(--rz-warning-dark, #b45309);
}

.px-help-drawer {
    position: fixed;
    top: var(--px-help-top);
    right: 0;
    bottom: 0;
    width: var(--px-help-width);
    max-width: 100vw;
    /* Above .rz-dialog-wrapper (--rz-dialog-zindex 1001) and its mask (1000) so it stays usable while a dialog is open. */
    z-index: 1105;
    background: var(--px-help-surface);
    color: var(--px-help-ink);
    border-left: 1px solid var(--px-help-border);
    box-shadow: var(--px-shadow-lg);
    display: flex;
    flex-direction: column;
    font-size: 0.875rem;
}

.px-help-drawer__resize {
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
}

.px-help-drawer__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem 0.4rem 1rem;
    border-bottom: 1px solid var(--px-help-border);
}

.px-help-drawer__icon { color: var(--px-help-accent); }

.px-help-drawer__title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 1rem;
    color: var(--px-help-accent);
}

.px-help-drawer__kind {
    font-size: 0.7rem;
    color: var(--px-help-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.px-help-drawer__body {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.px-help-drawer__body .rz-tabview-panels {
    padding: 0.75rem 1rem 1.25rem;
}

.px-help-drawer h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--px-help-muted);
    margin: 1rem 0 0.4rem;
}

.px-help-drawer h4:first-child { margin-top: 0; }
.px-help-drawer p { margin: 0 0 0.5rem; line-height: 1.45; }
.px-help-drawer ul { margin: 0 0 0.5rem; padding-left: 1.1rem; }
.px-help-drawer li { margin-bottom: 0.2rem; line-height: 1.4; }
.px-help-drawer a { color: var(--px-help-accent); }
.px-help-muted { color: var(--px-help-muted); }
.px-help-footer { margin-top: 1rem; font-size: 0.72rem; color: var(--px-help-muted); }
.px-help-orgnote { border-left: 3px solid var(--px-help-accent); padding-left: 0.6rem; }
.px-help-results { padding: 0.75rem 1rem 1.25rem; }

/* Help search box above the tabs; its hits replace the tabs while a query is typed. */
.px-help-search { position: relative; flex: 0 0 auto; display: flex; align-items: center; padding: 0.5rem 0.75rem 0.5rem 1rem; border-bottom: 1px solid var(--px-help-border); }
.px-help-search__icon { position: absolute; left: 1.45rem; font-size: 1.1rem; color: var(--px-help-muted); pointer-events: none; }
.px-help-search__input { width: 100%; padding-left: 2rem !important; padding-right: 1.8rem !important; }
.px-help-search__clear { position: absolute; right: 1.2rem; border: 0; background: none; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--px-help-muted); }
.px-help-search__clear:hover, .px-help-search__clear:focus-visible { color: var(--px-help-accent); outline: none; }
.px-help-hit { display: flex; flex-direction: column; gap: 0.15rem; width: 100%; text-align: left; background: none; border: 1px solid var(--px-help-border);
    border-radius: 6px; padding: 0.5rem 0.65rem; margin-bottom: 0.45rem; cursor: pointer; font: inherit; color: inherit; }
.px-help-hit:hover, .px-help-hit:focus-visible { border-color: var(--px-help-accent); background: var(--px-help-surface-alt); outline: none; }
.px-help-hit__title { font-weight: 600; }
.px-help-hit__where { font-size: 0.75rem; color: var(--px-help-accent); }
.px-help-hit__snippet { font-size: 0.8rem; color: var(--px-help-muted); }
.px-help-guide { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.5rem; font-size: 0.85rem; }
.px-help-guide .rzi { font-size: 1.1rem; color: var(--px-help-accent); }

/* Rights badges: accent = the user holds the right, muted = not. */
.px-help-roles { display: flex; flex-direction: column; gap: 0.35rem; }
.px-help-role { display: flex; gap: 0.5rem; align-items: baseline; }
.px-help-badge {
    display: inline-block;
    flex: none;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
}
.px-help-badge--on { background: var(--px-help-accent); color: var(--px-help-on-accent); }
.px-help-badge--off { background: var(--px-help-surface-alt); color: var(--px-help-muted); border: 1px solid var(--px-help-border); }
.px-help-role--off .px-help-role__text { color: var(--px-help-muted); }

/* Document flow strip: upstream -> this page -> downstream. */
.px-help-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 0.35rem; align-items: center; margin-bottom: 0.5rem; }
.px-help-flow__col { display: flex; flex-direction: column; gap: 0.25rem; }
.px-help-flow__node {
    border: 1px solid var(--px-help-border);
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.25;
    background: var(--px-help-surface-alt);
}
.px-help-flow__node a { color: var(--px-help-accent); text-decoration: none; }
.px-help-flow__node a:hover { text-decoration: underline; }
.px-help-flow__self {
    border: 2px solid var(--px-help-accent);
    background: var(--px-help-accent-soft);
    border-radius: 6px;
    padding: 0.4rem;
    font-weight: 600;
    text-align: center;
    font-size: 0.78rem;
}
.px-help-flow__arrow { color: var(--px-help-muted); }
.px-help-svg-arrow { color: var(--px-help-accent); }

/* Status stepper. */
.px-help-stepper { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0; margin: 0.25rem 0 0.5rem; }
.px-help-step {
    border: 1px solid var(--px-help-accent-soft);
    background: var(--px-help-surface-alt);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: default;
}
.px-help-step--current {
    background: var(--px-help-accent);
    color: var(--px-help-on-accent);
    border-color: var(--px-help-accent);
    box-shadow: 0 0 0 3px var(--px-help-accent-soft);
}
.px-help-step--terminal { border-style: dashed; }
.px-help-arrow { display: inline-flex; flex-direction: column; align-items: center; padding: 0 0.15rem; min-width: 3.2rem; cursor: help; }
.px-help-arrow__label { font-size: 0.62rem; color: var(--px-help-accent); font-weight: 600; text-align: center; line-height: 1.1; }
.px-help-arrow svg { display: block; }
.px-help-gap { width: 1rem; }
.px-help-transitions { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.px-help-transitions td { border-top: 1px solid var(--px-help-border); padding: 0.35rem 0.25rem; vertical-align: top; }
.px-help-transitions td:first-child { white-space: nowrap; font-weight: 600; }

/* Fields table. */
.px-help-fields { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.px-help-fields th { text-align: left; font-size: 0.7rem; color: var(--px-help-muted); text-transform: uppercase; padding: 0.25rem; border-bottom: 1px solid var(--px-help-border); }
.px-help-fields td { padding: 0.35rem 0.25rem; vertical-align: top; }
.px-help-fields tr.px-help-field { cursor: pointer; }
.px-help-fields tr.px-help-field td { border-top: 1px solid var(--px-help-border); }
.px-help-fields tr.px-help-field:hover td, .px-help-fields tr.px-help-field:hover + tr td { background: var(--px-help-surface-alt); }
.px-help-fields tr.px-help-field--active td, .px-help-fields tr.px-help-field--active + tr td { background: var(--px-help-accent-soft); }
.px-help-fields td.px-help-field__name { font-weight: 600; width: 26%; }
.px-help-fields .px-help-field__section { font-weight: 400; }
.px-help-fields td.px-help-field__validation-cell { padding-top: 0; }
.px-help-fields .px-help-validation { color: var(--px-help-warn); margin: 0; padding-left: 1rem; }
.px-help-section-chip { display: inline-flex; gap: 0.25rem; align-items: center; background: var(--px-help-accent-soft); color: var(--px-help-accent); border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.72rem; font-weight: 600; }
.px-help-section-chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 0.9rem; line-height: 1; }

/* Dependencies & effects. */
.px-help-deps li a { color: var(--px-help-accent); }
.px-help-effects { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.px-help-effects td { border-top: 1px solid var(--px-help-border); padding: 0.3rem 0.25rem; vertical-align: top; }
.px-help-effects td:first-child { width: 5.5rem; }
.px-help-effects tr.px-help-effects__action td { background: var(--px-help-surface-alt); font-weight: 600; border-top: 2px solid var(--px-help-border); }

/* Field highlight (help.js highlightField): 2-second pulse in the theme's primary colour. */
@keyframes pxHelpPulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--px-help-accent) 75%, transparent); }
    50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--px-help-accent) 25%, transparent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}
.px-help-pulse {
    animation: pxHelpPulse 0.7s ease-out 3;
    outline: 2px solid var(--px-help-accent) !important;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Wide screens: the page body (and centred dialogs) make room for the drawer so it never hides the form it explains. */
@media (min-width: 992px) {
    body.px-help-open .rz-body { margin-right: var(--px-help-width); }
    body.px-help-open .rz-dialog-wrapper { padding-right: var(--px-help-width); }
}

/* Phone width: full-width overlay. */
@media (max-width: 767px) {
    .px-help-drawer { width: 100vw; left: 0; border-left: 0; }
    .px-help-drawer__resize { display: none; }
    .px-help-flow { grid-template-columns: 1fr; }
    .px-help-flow__arrow { transform: rotate(90deg); justify-self: center; }
}

/* Four tabs in 440 px: compact labels so "Dependencies & effects" fits. */
.px-help-drawer .rz-tabview-nav { flex-wrap: nowrap; }
.px-help-drawer .rz-tabview-nav li > button { padding: 0.6rem 0.55rem; font-size: 0.72rem; white-space: nowrap; }

/* Dialog-title / panel-header "?" (Components/Help/HelpFieldsButton.razor). */
.px-help-fields-btn .rz-button-icon-left { font-size: 1.1rem; }
.px-help-dialog-title { display: inline-flex; align-items: center; gap: 0.25rem; }

/* Header button (MainLayout): on the brand gradient every foreground is white, like ThemeToggle on-brand. */
.px-help-header-btn,
.px-help-header-btn .rzi { color: var(--rz-on-primary, #ffffff); }
.px-help-header-btn:hover { background: color-mix(in srgb, var(--rz-on-primary, #ffffff) 16%, transparent); }

/* Per-field tooltip icon (Components/Help/HelpTip.razor), DESIGN.md §10.16: muted, cursor:help, 18px icon. */
.px-help-tip { display: inline-flex; align-items: center; vertical-align: middle; margin-left: 0.25rem; cursor: help; color: var(--rz-text-secondary-color); border-radius: 50%; }
.px-help-tip:hover, .px-help-tip:focus-visible { color: var(--px-help-accent); outline: none; }
