/* App-wide styles. Component styling comes from BlazorBlueprint; page styling is still to be chosen by the FE team. */

@font-face {
    font-family: Poppins;
    src: url("/fonts/Poppins-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: Poppins;
    src: url("/fonts/Poppins-Medium.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: Poppins;
    src: url("/fonts/Poppins-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}

/* BlazorBlueprint reads its colours from these variables; without them dialogs and menus have no background.
   They point at the Figma variables (tokens.css, overridden by the tenant's stylesheet), so buttons, inputs, menus, dialogs
   and toasts follow the tenant's branding like the rest of the page. The values after the comma are BlazorBlueprint's
   neutral palette, used only if a token is missing. The sign-in layout sets its own. */
:root {
    --radius: var(--shape-radius-control, .5rem);
    --background: var(--color-bg-surface, oklch(1 0 0));
    --foreground: var(--color-fg-primary, oklch(0.145 0 0));
    --card: var(--color-bg-surface, oklch(1 0 0));
    --card-foreground: var(--color-fg-primary, oklch(0.145 0 0));
    --popover: var(--color-bg-surface-raised, oklch(1 0 0));
    --popover-foreground: var(--color-fg-primary, oklch(0.145 0 0));
    --primary: var(--component-button-primary-bg, oklch(0.205 0 0));
    --primary-foreground: var(--component-button-primary-fg, oklch(0.985 0 0));
    --secondary: var(--component-button-secondary-bg, oklch(0.97 0 0));
    --secondary-foreground: var(--component-button-secondary-fg, oklch(0.205 0 0));
    --muted: var(--color-bg-surface-sunken, oklch(0.97 0 0));
    --muted-foreground: var(--color-fg-secondary, oklch(0.556 0 0));
    /* Opaque (unlike the Figma hover layer), so text on an accent fill keeps its contrast whatever is behind it. */
    --accent: var(--color-bg-canvas, oklch(0.97 0 0));
    --accent-foreground: var(--color-fg-primary, oklch(0.205 0 0));
    --destructive: var(--component-button-destructive-bg, oklch(0.577 0.245 27.325));
    --destructive-foreground: var(--component-button-destructive-fg, oklch(1 0 0));
    --border: var(--color-border-default, oklch(0.922 0 0));
    --input: var(--component-input-border, oklch(0.922 0 0));
    --ring: var(--color-border-focus, oklch(0.556 0 0));

    /* BlazorBlueprint's own type, menu and overlay variables, also from the Figma tokens. */
    --bb-text-sm: var(--type-label-size, .875rem);
    --bb-text-xs: var(--type-label-sm-size, .75rem);
    --bb-font-weight-normal: var(--brand-font-body-style-regular, 400);
    --bb-font-weight-medium: var(--brand-font-body-style-medium, 500);
    --bb-font-weight-semibold: var(--brand-font-body-style-strong, 600);
    --bb-menu-accent: var(--color-state-layer-hover, oklch(0.97 0 0));
    --bb-menu-shadow:
        0 var(--shadow-offset-y-4, 4px) var(--shadow-blur-8, 8px) var(--shadow-spread-neg-2, -2px) var(--color-shadow-key, #0000001f),
        0 var(--shadow-offset-y-2, 2px) var(--shadow-blur-4, 4px) var(--shadow-spread-neg-2, -2px) var(--color-shadow-ambient, #00000014);
}

:root[data-theme="dark"] {
    --component-input-bg: var(--color-bg-surface, #18181b);
    --component-input-border: var(--color-border-strong, #71717b);
    --color-fg-tertiary: var(--color-fg-secondary, #a1a1aa);
    --component-button-primary-bg: var(--color-bg-inverse, #fafafa);
    --component-button-primary-fg: var(--color-fg-inverse, #18181b);
    --component-button-secondary-bg: var(--color-bg-surface-raised, #27272a);
    --component-button-secondary-border: var(--color-border-strong, #71717b);
    --component-button-secondary-fg: var(--color-fg-primary, #fafafa);
}

/* BlazorBlueprint sizes buttons and inputs with its own spacing scale and radius. These rules give them the Figma control
   size, radius, type and colours instead. They are not in a layer, so they win over BlazorBlueprint's utilities.
   BbButton is recognised by classes only its base style combines (gap-2, font-medium, cursor-pointer); its sizes by their
   height and padding classes; its outline variant by border-input with bg-background/100. Other components that reuse some
   of these class names (select trigger, colour picker, cascader) are left alone, and so are the sign-in buttons, whose
   own rules let a long label wrap. */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer:not(.sign-in-action) {
    gap: var(--space-inline-sm, 0.5rem);
    border-radius: var(--component-button-radius, var(--radius));
    line-height: var(--type-label-line-height, 1.25rem);
    letter-spacing: var(--type-label-letter-spacing, normal);
}

:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:h-10.bb\:px-4.bb\:py-2:not(.sign-in-action) {
    height: var(--size-control-md, 2.5rem);
    padding-inline: var(--space-inset-lg, 1rem);
}

:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:h-9.bb\:px-3:not(.sign-in-action) {
    height: var(--size-control-sm, 2.25rem);
    padding-inline: var(--space-inset-md, .75rem);
}

:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:h-9.bb\:w-9:not(.sign-in-action) {
    width: var(--size-control-sm, 2.25rem);
    height: var(--size-control-sm, 2.25rem);
}

:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:border-input.bb\:bg-background\/100:not(.sign-in-action) {
    border-width: var(--shape-border-default, 1px);
    border-color: var(--component-button-secondary-border, var(--input));
    background-color: var(--component-button-secondary-bg, var(--background));
    color: var(--component-button-secondary-fg, var(--foreground));
}

/* Not while focused: the focus ring is a box-shadow too, and this one would replace it. */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:border-input.bb\:bg-background\/100:not(.sign-in-action):not(:focus-visible) {
    box-shadow: 0 var(--shadow-offset-y-1, 1px) var(--shadow-blur-2, 2px) 0 var(--color-shadow-ambient, #0000000d);
}

/* Hover: the Figma state layer drawn over the button's own fill (BlazorBlueprint fades or swaps the fill instead). */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:border-input.bb\:bg-background\/100:not(.sign-in-action):hover {
    background-color: var(--component-button-secondary-bg, var(--background));
    background-image: linear-gradient(var(--color-state-layer-hover, transparent), var(--color-state-layer-hover, transparent));
}

:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:bg-primary:not(.sign-in-action):hover {
    background-color: var(--component-button-primary-bg, var(--primary));
    background-image: linear-gradient(var(--color-state-layer-hover-on-strong, transparent), var(--color-state-layer-hover-on-strong, transparent));
}

:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:bg-destructive:not(.sign-in-action):hover {
    background-color: var(--component-button-destructive-bg, var(--destructive));
    background-image: linear-gradient(var(--color-state-layer-hover-on-strong, transparent), var(--color-state-layer-hover-on-strong, transparent));
}

/* Ghost buttons (e.g. a row's Actions button): no fill, the state layer on hover. */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:hover\:bg-accent:not(.bb\:border-input, .sign-in-action):hover {
    background-color: transparent;
    background-image: linear-gradient(var(--color-state-layer-hover, transparent), var(--color-state-layer-hover, transparent));
}

/* Pressed: the Figma pressed layers. */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer:is(.bb\:border-input, .bb\:hover\:bg-accent):not(.sign-in-action):active {
    background-image: linear-gradient(var(--color-state-layer-pressed, transparent), var(--color-state-layer-pressed, transparent));
}

:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer:is(.bb\:bg-primary, .bb\:bg-destructive):not(.sign-in-action):active {
    background-image: linear-gradient(var(--color-state-layer-pressed-on-strong, transparent), var(--color-state-layer-pressed-on-strong, transparent));
}

/* Disabled: the Figma disabled colours instead of BlazorBlueprint's half opacity. */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer:not(.sign-in-action):is(:disabled, [aria-disabled="true"]) {
    color: var(--color-fg-disabled, var(--muted-foreground));
    opacity: 1;
}

/* Repeats the colour: the outline variant's own colour rule is more specific than the one above. */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer:is(.bb\:bg-primary, .bb\:bg-destructive, .bb\:border-input):not(.sign-in-action):is(:disabled, [aria-disabled="true"]) {
    color: var(--color-fg-disabled, var(--muted-foreground));
    background-color: var(--color-bg-disabled, var(--muted));
    background-image: none;
}

/* A disabled secondary (outline) button keeps the default border colour and drops its shadow, as in the Figma Button. */
:is(button, a).bb\:gap-2.bb\:font-medium.bb\:cursor-pointer.bb\:border-input.bb\:bg-background\/100:not(.sign-in-action):is(:disabled, [aria-disabled="true"]) {
    border-color: var(--color-border-default, var(--input));
    box-shadow: none;
}

/* BbInput and BbTextarea: radius, border, focus ring (read from --ring) and text from the Figma input and body tokens. On
   small screens the text stays at least 16px, or iOS zooms into the field. */
:is(input, textarea).bb\:border-input {
    --ring: var(--component-input-border-focus, var(--color-border-focus));
    background-color: var(--component-input-bg, var(--background));
    color: var(--color-fg-primary, var(--foreground));
    border-width: var(--shape-border-default, 1px);
    border-radius: var(--component-input-radius, var(--radius));
    font-size: max(var(--type-body-size, 1rem), 1rem);
    font-weight: var(--brand-font-body-style-regular, 400);
    line-height: var(--type-body-line-height, 1.5rem);
    letter-spacing: var(--type-body-letter-spacing, normal);
}

@media (min-width: 48.0625rem) {
    :is(input, textarea).bb\:border-input {
        font-size: var(--type-body-sm-size, .875rem);
        line-height: var(--type-body-sm-line-height, 1.25rem);
        letter-spacing: var(--type-body-sm-letter-spacing, normal);
    }
}

input.bb\:h-10.bb\:border-input {
    height: var(--size-control-md, 2.5rem);
}

/* Dialog and sheet overlays: the Figma scrim instead of 80% black. */
.bb\:bg-black\/80 {
    background-color: var(--color-bg-scrim, rgb(0 0 0 / 0.4));
}

/* Dialogs (e.g. the confirmation BlazorBlueprint's DialogService shows): Figma container radius, inset, elevation and type. */
:is([role="dialog"], [role="alertdialog"]).bb\:p-6 {
    max-width: min(30rem, calc(100% - 2 * var(--space-inset-lg, 1rem)));
    gap: var(--space-stack-md, 1rem);
    padding: var(--space-inset-xl, 1.5rem);
    border-width: var(--shape-border-default, 1px);
    border-color: var(--color-border-default, var(--border));
    border-radius: var(--shape-radius-container, .5rem);
    background-color: var(--color-bg-surface-raised, var(--background));
    overflow-wrap: anywhere;
    word-break: break-word;
    box-shadow:
        0 var(--shadow-offset-y-16, 16px) var(--shadow-blur-32, 32px) var(--shadow-spread-neg-8, -8px) var(--color-shadow-key, #0000001f),
        0 var(--shadow-offset-y-4, 4px) var(--shadow-blur-8, 8px) var(--shadow-spread-neg-4, -4px) var(--color-shadow-ambient, #00000014);
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6 > * {
    min-width: 0;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6:not(:has(> .import-flow.is-modal)) h2 {
    min-width: 0;
    font-family: var(--brand-font-title-family, inherit);
    font-size: var(--type-subtitle-size, 1.125rem);
    font-weight: var(--brand-font-body-style-strong, 600);
    line-height: var(--type-subtitle-line-height, 1.75rem);
    letter-spacing: var(--type-subtitle-letter-spacing, normal);
    overflow-wrap: anywhere;
    word-break: break-word;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6:not(:has(> .import-flow.is-modal)) h2 + p,
:is([role="dialog"], [role="alertdialog"]).bb\:p-6:not(:has(> .import-flow.is-modal)) p {
    min-width: 0;
    color: var(--color-fg-secondary, var(--muted-foreground));
    font-size: var(--type-body-sm-size, .875rem);
    line-height: var(--type-body-sm-line-height, 1.25rem);
    overflow-wrap: anywhere;
    word-break: break-word;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6 .bb\:flex-col-reverse {
    row-gap: var(--space-stack-sm, 0.5rem);
}

/* Overlays (menus, dialogs, toasts) render in the portal host outside the admin shell, so the brand font is set here too. */
body {
    font-family: var(--brand-font-body-family, Poppins), system-ui, -apple-system, sans-serif;
    font-weight: var(--brand-font-body-style-regular, 400);
}

/* BlazorBlueprint's CSS reset strips native form controls and links to bare text. The plain (not yet designed) pages use them, so they
   get a minimal look here, in the same layer as the reset. BlazorBlueprint's own elements (bb: classes) are left alone. */
@layer base {
    button:not([class*="bb:"]),
    select:not([class*="bb:"]),
    textarea:not([class*="bb:"]),
    input:not([class*="bb:"]):not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"]) {
        padding: 0.375rem 0.75rem;
        border: 1px solid var(--input);
        border-radius: calc(var(--radius) - 2px);
        background: var(--background);
        color: var(--foreground);
    }

    button:not([class*="bb:"]) {
        border-color: var(--ring);
        background: var(--secondary);
        color: var(--secondary-foreground);
        font-weight: 500;
        cursor: pointer;
    }

    button:not([class*="bb:"]):hover {
        background: var(--border);
    }

    button:not([class*="bb:"]):disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* Not on the sign-in pages, which are designed and style their own links. */
    main:not(.sign-in-layout) a:not([class*="bb:"]) {
        text-decoration: underline;
        text-underline-offset: 2px;
    }

    main:not(.sign-in-layout) a:not([class*="bb:"]):hover {
        text-decoration-thickness: 2px;
    }

    :is(a, button, select, textarea, input):not([class*="bb:"]):focus-visible {
        outline: 2px solid var(--ring);
        outline-offset: 2px;
    }
}

/* Router focuses the page heading after navigation (FocusOnNavigate); no visible ring for that programmatic focus. */
h1:focus {
    outline: none;
}

html:has(#admin-mobile-drawer[open]),
body:has(#admin-mobile-drawer[open]) {
    overflow: hidden;
}

@media (min-width: 48.0625rem) {
    html:has(.admin-shell),
    body:has(.admin-shell) {
        height: 100%;
        margin: 0;
        overflow: hidden;
    }
}

@media (max-width: 48rem) {
    html:has(.admin-shell) {
        scroll-padding-top: 4rem;
    }
}

.app-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #e5e5e5;
}

/* Default <ErrorBoundary> content. */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

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

/* Participant row menu (WAB-28). The menu renders in the portal host, outside the page's scoped CSS. */
.participant-menu-item-danger {
    color: var(--color-status-danger-fg, #b91c1c);
}

.participant-menu-hint {
    max-width: 14rem;
    margin: var(--space-stack-xs, 0.25rem) var(--space-inset-sm, 0.5rem) var(--space-stack-sm, 0.5rem);
    color: var(--color-fg-tertiary, #71717a);
    font-size: var(--type-caption-size, 0.75rem);
    line-height: var(--type-caption-line-height, 1rem);
}

.participant-menu {
    border-width: var(--shape-border-default, 1px);
    border-radius: var(--shape-radius-control, var(--radius));
}

.participant-menu-item {
    padding: var(--space-inset-sm, 0.5rem) var(--space-inset-md, 0.75rem);
    border-radius: var(--shape-radius-small, 0.25rem);
    line-height: var(--type-label-line-height, 1.25rem);
}

.participant-menu-item:is([data-disabled], [aria-disabled="true"]) {
    color: var(--color-fg-disabled, var(--muted-foreground));
    opacity: 1;
}

/* The Figma snackbar (Participants page actions): a light card with a status-coloured icon, the close button always shown.
   BlazorBlueprint's success and destructive toasts are tinted or solid red cards instead. */
.woven-snackbar {
    align-items: center;
    padding: var(--space-inset-sm, 0.5rem) var(--space-inset-md, 0.75rem);
    padding-inline-end: calc(var(--space-inset-md, 0.75rem) + var(--size-icon-md, 1.25rem) + var(--space-inline-sm, 0.5rem));
    border: var(--shape-border-default, 1px) solid var(--color-border-default, var(--border));
    border-radius: var(--shape-radius-control, var(--radius));
    background-color: var(--color-bg-surface-raised, var(--background));
    color: var(--color-fg-primary, var(--foreground));
    box-shadow: var(--bb-menu-shadow);
    font-size: var(--type-body-sm-size, .875rem);
    line-height: var(--type-body-sm-line-height, 1.25rem);
}

.woven-snackbar-success {
    --woven-snackbar-accent: var(--color-status-success-fg, #047857);
}

.woven-snackbar-danger {
    --woven-snackbar-accent: var(--color-status-danger-fg, #b91c1c);
}

.woven-snackbar-warning {
    --woven-snackbar-accent: var(--color-status-warning-fg, #b45309);
}

.woven-snackbar > div:first-child > svg {
    width: var(--size-icon-sm, 1rem);
    height: var(--size-icon-sm, 1rem);
    color: var(--woven-snackbar-accent);
}

.woven-snackbar > div > div {
    font-size: inherit;
    line-height: inherit;
    opacity: 1;
}

.woven-snackbar > button {
    top: 50%;
    inset-inline-end: var(--space-inset-sm, 0.5rem);
    padding: var(--space-inset-xs, 0.25rem);
    color: var(--color-fg-secondary, var(--muted-foreground));
    opacity: 1;
    transform: translateY(-50%);
}

.woven-snackbar > button > svg {
    width: var(--size-icon-sm, 1rem);
    height: var(--size-icon-sm, 1rem);
}

/* The Figma focus colour for both snackbars (BlazorBlueprint gives the destructive one a red ring). */
.woven-snackbar > button:focus-visible {
    outline: 2px solid var(--color-border-focus, var(--ring));
    outline-offset: 2px;
    box-shadow: none;
}

/* BlazorBlueprint sets transition-duration: 0.01ms on * under reduced motion. With the default transition-property: all,
   a portalled menu starts a 0.01ms visibility transition when revealed, so focus() runs at t=0 while visibility is still
   hidden and is dropped. Disabling transitions on the portal and menu keeps reduced motion instant and focusable. */
@media (prefers-reduced-motion: reduce) {
    [data-bb-portal],
    [data-bb-portal] *,
    [role="menu"],
    [role="menu"] * {
        transition-property: none !important;
        transition-duration: 0s !important;
    }
}

/* Participant profile confirmation dialogs (WAB-30). Rendered in the portal host, outside scoped CSS. */
:is([role="dialog"], [role="alertdialog"]).bb\:p-6.participant-confirm-dialog {
    max-width: min(23.5rem, calc(100% - 2 * var(--space-inset-lg, 1rem)));
}

/* CSV participant import dialog (WAB-34): Large 640px Figma dialog, rendered in the portal host. */
:is([role="dialog"], [role="alertdialog"]).bb\:p-6:has(> .import-flow.is-modal) {
    display: flex;
    flex-direction: column;
    max-width: min(40rem, calc(100% - 2 * var(--space-inset-lg, 1rem)));
    width: 100%;
    max-height: calc(100dvh - 2rem);
    gap: var(--space-stack-lg, 1.5rem);
    padding: var(--space-inset-xl, 1.5rem);
    overflow: visible;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6:has(> .import-flow.is-modal) > .import-flow > div:first-child {
    display: flex;
    flex-direction: column;
    gap: var(--space-stack-xs, 0.375rem);
    text-align: left;
    flex-shrink: 0;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6:has(> .import-flow.is-modal) > .import-flow > div:first-child > h2 {
    margin: 0;
    color: var(--color-fg-primary, #18181b);
    font-family: var(--brand-font-title-family, inherit);
    font-size: var(--type-title-sm-size, 1.5rem);
    font-weight: var(--brand-font-title-style-medium, 500);
    line-height: var(--type-title-sm-line-height, 2rem);
    letter-spacing: var(--type-title-sm-letter-spacing, -0.02em);
    overflow-wrap: anywhere;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6:has(> .import-flow.is-modal) > .import-flow > div:first-child > h2:focus:not(:focus-visible),
.import-flow-title:focus:not(:focus-visible) {
    outline: none;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6:has(> .import-flow.is-modal) > .import-flow > div:first-child > p {
    margin: 0;
    color: var(--color-fg-secondary, #52525c);
    font-size: var(--type-body-size, 1rem);
    font-weight: var(--brand-font-body-style-regular, 400);
    line-height: var(--type-body-line-height, 1.5rem);
    overflow-wrap: anywhere;
}

:is([role="dialog"], [role="alertdialog"]).bb\:p-6:has(> .import-flow.is-modal) .engagement-picker-popover[data-modal-floating="true"] {
    z-index: 60;
}

:root[data-theme="dark"] .import-flow-footer button:is(:disabled, [aria-disabled="true"]) {
    background-color: var(--color-bg-surface, #18181b);
    border: var(--shape-border-default, 1px) solid var(--color-state-layer-pressed, rgb(255 255 255 / 0.12));
}

:root[data-theme="dark"] .import-invite-row [role="checkbox"]:is(:disabled, [aria-disabled="true"]) {
    border-color: var(--color-border-strong, #71717b);
    background-color: var(--color-bg-surface, #18181b);
}

:root[data-theme="dark"] .import-dropzone-icon,
:root[data-theme="dark"] .import-file-icon,
:root[data-theme="dark"] .engagement-picker.is-compact-chips .engagement-picker-chip {
    background-color: var(--component-card-bg-sunken, #27272a);
}

@media (max-height: 26rem) {
    :is([role="dialog"], [role="alertdialog"]).bb\:p-6:has(> .import-flow.is-modal) {
        max-height: calc(100dvh - 1rem);
        padding: var(--space-inset-lg, 1rem);
    }
}
