/* Shared navy/gold theme for the Projects area's "create" dialogs (Create Project, Create
   Task, Create Report, Create Whiteboard). See
   docs/superpowers/specs/2026-08-20-create-dialogs-navy-gold-restyle-design.md for the full
   design rationale.

   3 of these 4 dialogs (Create Project/Task/Report) render through <FluentDialogProvider />
   (mounted once in MainLayout.razor), outside the DOM subtree of .project-workspace /
   .projects-dashboard -- so the existing --tl-* scoping in project-workspace.css can't reach
   them, and DialogParameters has no Class/Style passthrough to stamp a scoping class onto
   the dialog element from the call site. .tl-dialog is therefore a fully self-contained
   scope (every token defined locally, nothing inherited) applied as a wrapper <div> inside
   each dialog's own content markup. */

.tl-dialog {
    --tl-navy: #0B1F3A;
    --tl-gold: #F4A623;
    --tl-blue: #2D6CDF;
    --tl-bg: #080F1A;
    --tl-surface: #0D1B2E;
    --tl-surface-alt: #152336;
    --tl-border: #1E2F45;
    --tl-text: #FFFFFF;
    --tl-text-2: #CBD5E1;
    --tl-text-muted: #64748B;
    --tl-link: #6C9BFF;
    --tl-gold-button-text: #1a1400;
    --tl-error-fg: #F87171;
    --tl-error-bg: #2A1414;
    --tl-success-fg: #4ADE80;
    --tl-success-bg: #10261A;
    --tl-warning-fg: #F4A623;
    --tl-warning-bg: #2A2110;
    --tl-info-fg: #60A5FA;
    --tl-info-bg: #12203A;
    /* The AI tint project-workspace.css defines, mirrored so the task detail dialog's draft banner,
       "Why Viv suggested this" panel and Draft status chip resolve inside the dialog too. */
    --tl-ai-fg: #A78BFA;
    --tl-ai-bg: #1C1830;
    /* Global Tasks design tokens (values from the Global Tasks mockup). --tl-text-muted-aa is the
       readable muted grey (4.5:1+ on the surface; --tl-text-muted is not). The *-border tints
       outline banners of the matching state; the kind-*-bg fills are the task-kind tiles. */
    --tl-text-muted-aa: #8B9AB1;
    --tl-border-strong: #2B4262;
    --tl-row-hover: #0F2036;
    --tl-today-bg: #111F2F;
    --tl-error-border: #4A2424;
    --tl-ai-border: #352C59;
    --tl-info-border: #1F3A66;
    --tl-success-border: #1E4A2F;
    --tl-kind-personal-bg: #11233D;
    --tl-kind-project-bg: #1D1A10;
    --tl-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

    /* --body-font is the ambient design token Fluent web components actually read for
       their internal (shadow-DOM) typography -- plain font-family only styles light-DOM
       text like the <h2> title below. Without this, FluentTextField/FluentSelect/
       FluentButton etc. inside .tl-dialog fall back to app.css's global --body-font
       ("Open Sans"/"Segoe UI"), mismatching the Inter used everywhere else in the
       navy/gold theme. Same pattern ProjectList.razor already uses for its own scope. */
    --body-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-family: var(--body-font);

    /* Fluent token remap -- same mechanism project-workspace.css already uses for
       .pw-panel fluent-card/fluent-dialog. Fluent web components read these custom
       properties directly, so this recolors every Fluent control inside .tl-dialog
       without touching its markup. */
    --accent-fill-rest: var(--tl-gold);
    --accent-fill-hover: var(--tl-gold);
    --accent-fill-active: var(--tl-gold);
    --foreground-on-accent-rest: var(--tl-gold-button-text);
    --fill-color: var(--tl-surface);
    --neutral-foreground-rest: var(--tl-text);
    --neutral-foreground-hint: var(--tl-text-2);
    --neutral-stroke-rest: var(--tl-border);

    /* FluentCard (used by CreateProject.razor's member-picker rows) paints its background
       from --neutral-layer-1, not --fill-color -- confirmed via devtools per
       project-workspace.css's own .pw-panel fluent-card override, which this mirrors. */
    --neutral-layer-1: var(--tl-surface-alt);

    /* FluentTextField/FluentTextArea/FluentSelect/FluentDatePicker paint their background/
       border from these -input- tokens, not --fill-color -- confirmed against the FAST
       design-token recipe names shipped in the installed
       Microsoft.FluentUI.AspNetCore.Components 4.14.2 package's own lib.module.js
       (neutral-fill-input-rest / neutral-stroke-input-rest recipes). */
    --neutral-fill-input-rest: var(--tl-surface-alt);
    --neutral-fill-input-hover: var(--tl-surface-alt);
    --neutral-fill-input-focus: var(--tl-surface-alt);
    --neutral-fill-input-active: var(--tl-surface-alt);
    --neutral-stroke-input-rest: var(--tl-border);

    /* FluentButton Appearance="Neutral" (the Cancel button on every one of these dialogs)
       paints from these -secondary- tokens, same source. */
    --neutral-fill-secondary-rest: var(--tl-surface-alt);
    --neutral-fill-secondary-hover: var(--tl-surface-alt);
    --neutral-stroke-strong-rest: var(--tl-border);

    background: var(--tl-surface);
    color: var(--tl-text);
}

.tl-dialog :focus-visible {
    outline: 2px solid var(--tl-gold);
    outline-offset: 2px;
}

/* Plain <h2> title used inside .tl-dialog instead of the FluentDialogProvider's own header
   chrome (which we suppress via DialogParameters.ShowTitle = false at each call site --
   that chrome renders outside this scope and can't be recolored from in here). */
.tl-dialog h2 {
    margin: 0 0 4px;
    /* !important needed to beat app.css's global `h1, h2, ... { font-family: 'Cormorant
       Garamond' !important }` Academy-theme rule -- same precedent as ProjectList.razor's
       `.projects-dashboard h1/h2/h3/h4` override and project-workspace.css's
       .project-hero-title. */
    font: 600 20px/1.2 'Inter', sans-serif !important;
    color: var(--tl-text);
}

/* Outer dialog surface, rendered by FluentDialogProvider OUTSIDE the .tl-dialog wrapper (see
   design spec's "How FluentDialog actually renders" section) -- :has() lets this fire only
   for dialogs whose body contains a .tl-dialog, leaving every other dialog in the app
   untouched. Hex values hardcoded (not var()) since custom properties don't inherit upward
   from .tl-dialog to this ancestor selector -- keep in sync with --tl-surface/--tl-border
   above if either changes. */
/* Two selector forms are both required here: :has(.tl-dialog) matches the 3 dialogs where
   .tl-dialog wraps the dialog's inner content (a descendant of fluent-dialog), while
   :has() never matches its own subject element -- so the whiteboard dialog, which puts
   .tl-dialog directly on the <FluentDialog> host itself, needs the second form to match.
   Don't collapse this back to one selector. */
fluent-dialog:has(.tl-dialog)::part(control),
fluent-dialog.tl-dialog::part(control) {
    background: #0D1B2E;
    border: 1px solid #1E2F45;
    border-radius: 12px;
    box-shadow: none;
}

/* SessionScheduleWizard-specific: its own design source (Meeting Creation Wizard.dc.html) draws
   the modal's outer surface a shade DARKER (var(--dark-bg), #080F1A) than the cards inside it
   (var(--dark-surface), #0D1B2E, the same tone .restyled-card/.recurrence-card/.cover-image-card
   already use) specifically so those cards visually separate from the dialog body. The generic
   rule above uses the card tone for every .tl-dialog consumer, which is fine for Create
   Project/Task/Report/Whiteboard (none of them stack bordered sub-cards on the same surface) but
   left this wizard's own cards blending flat into its background with no depth. More specific
   selector (:has(.wizard-scope) is a strict subset of :has(.tl-dialog)) placed after the generic
   rule so source order also favors it. */
fluent-dialog:has(.wizard-scope)::part(control) {
    /* VETI-8192: the Meetings design's panel is --surface (dark #0D1B2E / light #FFFFFF), with the
       fields one step darker on --bg; the wizard's own tokens (SessionScheduleWizard.razor.css)
       follow suit. The light pair is keyed on .wizard-light, which the wizard sets from
       ThemeStateService. Literals here because fluent-dialog sits outside .tl-dialog, so no
       --tl-* token reaches this element. */
    background: #0D1B2E;
    border: 1px solid #1E2F45;
    border-radius: 12px;
}

/* The dialog's own scroll region reported ~14px of sideways overflow on a phone with nothing
   visibly outside it, which showed a horizontal scrollbar; only vertical scrolling is wanted. */
fluent-dialog:has(.wizard-scope)::part(positioning-region) {
    overflow-x: hidden;
}

fluent-dialog:has(.wizard-scope.wizard-light)::part(control) {
    background: #FFFFFF;
    border-color: #E2E6EB;
}

/* VETI-8192: the Create meeting dialog's header ("Create meeting" beside the close button) as the
   Meetings design draws it -- sans-serif title, hairline under the header. !important only on the
   font: app.css forces its serif face on every h1-h6 with !important, and this h4 is FluentDialog's
   own, outside any component scope that could out-specify it. */
fluent-dialog:has(.wizard-scope) .fluent-dialog-header {
    padding-bottom: 16px;
    border-bottom: 1px solid #1E2F45;
}

fluent-dialog:has(.wizard-scope) .fluent-dialog-header h4 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #FFFFFF;
}

/* The design's close button: a 36px square with a hairline border. */
fluent-dialog:has(.wizard-scope) #dialog_close {
    width: 36px;
    height: 36px;
    border: 1px solid #1E2F45;
    border-radius: 8px;
}

fluent-dialog:has(.wizard-scope.wizard-light) .fluent-dialog-header {
    border-bottom-color: #E2E6EB;
}

fluent-dialog:has(.wizard-scope.wizard-light) .fluent-dialog-header h4 {
    color: #0B1F3A;
}

fluent-dialog:has(.wizard-scope.wizard-light) #dialog_close {
    border-color: #E2E6EB;
}

fluent-dialog:has(.wizard-scope.wizard-light) #dialog_close svg {
    fill: #555555 !important;
}

/* FluentDialog's own overlay (exposed as ::part(overlay), confirmed live via the rendered shadow
   DOM: <div class="overlay" part="overlay">) ships with rgba(0,0,0,0.3) and no blur at all.
   Canvas's own wizard modal backdrop is rgba(8,15,26,.72) with backdrop-filter:blur(2px) --
   scoped to this wizard only, not every .tl-dialog consumer, since nothing else asked for it.
   VETI-8192: in light mode the design dims with a lighter navy wash. */
fluent-dialog:has(.wizard-scope)::part(overlay) {
    background: rgba(8, 15, 26, 0.72);
    backdrop-filter: blur(2px);
}

fluent-dialog:has(.wizard-scope.wizard-light)::part(overlay) {
    background: rgba(11, 31, 58, 0.55);
}

/* MeetingDetailsDialog supplies its own header/body padding (meeting-details-header,
   .meeting-details-dialog .fluent-dialog-body above) so the FluentDialogProvider's default
   ::part(control) padding (used unmodified by CreateProject/CreateTask/CreateReport, which have
   no padding of their own) just doubles up as unwanted outer whitespace here -- zeroed out only
   for this dialog. !important is required: the library's own scoped rule
   (fluent-dialog[b-xxxxx]::part(control) { padding: var(--dialog-padding) }, --dialog-padding:
   24px) ships inside Microsoft.FluentUI.AspNetCore.Components' bundled scoped CSS, which Blazor
   CSS isolation folds into timeline-it.Client.styles.css -- loaded AFTER this file in index.html,
   so at equal selector specificity it wins on source order alone without !important here. */
fluent-dialog:has(.meeting-details-dialog)::part(control) {
    padding: 0 !important;
}

/* FluentSelect's dropdown popup (the ::part(listbox) FAST renders when open) is NOT themed by
   the token remap above -- FAST's DesignToken system computes an entire dark-theme token set
   (--fill-color, --neutral-fill-stealth-*, --accent-fill-rest, etc., ~50 properties) from its
   own default neutral-base-color/baseLayerLuminance recipe and writes them as a literal INLINE
   style directly on the listbox element every time it opens. An inline style beats any inherited
   custom property from our token remap above, so plain var() overrides never reach it -- only a
   stylesheet rule targeting the same node with !important can win (confirmed via devtools
   against a running Create Task dialog: without this, the popup renders FAST's default dark
   gray (#333/#272727) instead of the navy/gold theme). fluent-option elements read most of these
   same custom properties by inheritance (they have no inline override of their own), so
   overriding them here on the listbox also recolors the options list. */
.tl-dialog fluent-select::part(listbox) {
    --fill-color: var(--tl-surface-alt) !important;
    --neutral-stroke-divider-rest: var(--tl-border) !important;
    background: var(--tl-surface-alt) !important;
    border: 1px solid var(--tl-border) !important;
    box-shadow: none !important;
}

/* The CLOSED select's own control -- confirmed via devtools this is NOT themed correctly by the
   token remap regardless of whether a value is selected: FAST paints ::part(control) via a
   background-image (an opaque solid layer plus a decorative highlight gradient underneath),
   using literal resolved grey values (#333/#505050/#383838) baked in at the component's own
   design-token defaults rather than reading our --neutral-fill-input-* remap. A plain
   background/background-color override can't win against an existing background-image on the
   same declaration unless it also clears background-image, so both are set explicitly here. */
.tl-dialog fluent-select::part(control) {
    background-image: none !important;
    background-color: var(--tl-surface-alt) !important;
}

/* fluent-option's actual custom-property inheritance breaks here: once the listbox opens, Fluent
   promotes it (and the fluent-option elements slotted into it) into the browser's top layer --
   the same mechanism <dialog>.showModal() uses -- which resets computed-value inheritance to
   come from the document root instead of the light-DOM ancestor chain (confirmed via devtools:
   fluent-option's computed --accent-fill-rest matched <body>'s default, not .tl-dialog's gold
   remap, even though selector matching like ".tl-dialog fluent-option" still works fine since
   that's DOM-tree based, not inheritance-based). So these have to be set directly on
   fluent-option itself rather than relying on them cascading down from an ancestor. */
.tl-dialog fluent-option {
    --neutral-fill-stealth-rest: var(--tl-surface-alt) !important;
    --neutral-fill-stealth-hover: var(--tl-surface) !important;
    --neutral-fill-stealth-active: var(--tl-surface) !important;
    --neutral-fill-stealth-focus: var(--tl-surface-alt) !important;
    --neutral-fill-secondary-rest: var(--tl-surface) !important;
    --neutral-fill-secondary-hover: var(--tl-surface) !important;
    --neutral-fill-secondary-active: var(--tl-surface) !important;
    --neutral-foreground-rest: var(--tl-text) !important;
    --neutral-foreground-hover: var(--tl-text) !important;
    --accent-fill-rest: var(--tl-gold) !important;
    --accent-fill-hover: var(--tl-gold) !important;
    --accent-fill-active: var(--tl-gold) !important;
}

/* FluentCard (CreateProject.razor's member-picker rows) does not actually inherit
   --neutral-layer-1/--fill-color from the .tl-dialog remap above -- confirmed via devtools
   against a running Create Project dialog: the card's own computed --neutral-layer-1/
   --fill-color still read FAST's defaults (#272727/#333333), not this scope's navy remap,
   even though the card is a plain light-DOM descendant with no top-layer promotion involved.
   Needs the same direct-selector-plus-!important treatment as the fluent-select listbox/
   option overrides above, for the same underlying reason: FAST resolves these tokens per
   custom element rather than relying on plain CSS custom-property inheritance. */
.tl-dialog fluent-card {
    --neutral-layer-1: var(--tl-surface-alt) !important;
    --fill-color: var(--tl-surface-alt) !important;
}

/* FluentInputFile's drop zone (UploadedImageDialog's upload area) renders as a plain
   (non-shadow-DOM) div with this class, defaulting to FAST's generic dark gray -- same fix
   project-workspace.css already applies to .pw-panel's own upload area. */
.tl-dialog .fluent-inputfile-container {
    background: var(--tl-surface-alt) !important;
    border-color: var(--tl-border) !important;
    color: var(--tl-text) !important;
}

/* FluentDataGrid (UploadedImageDialog's list view) -- same token remap
   project-workspace.css already applies to .pw-panel fluent-data-grid. */
.tl-dialog .fluent-data-grid,
.tl-dialog fluent-data-grid {
    --neutral-layer-1: var(--tl-surface);
    --neutral-layer-2: var(--tl-surface-alt);
    --neutral-layer-3: var(--tl-surface-alt);
    --neutral-stroke-rest: var(--tl-border);
    --neutral-foreground-rest: var(--tl-text);
    --neutral-foreground-hint: var(--tl-text-2);
}

/* The data grid's sortable column-header buttons (fluent-button appearance="stealth") paint
   their ::part(control) background directly from FAST's own default (#272727), not from the
   --neutral-fill-stealth-* remap -- confirmed via devtools against the running Select Image
   dialog's list view. Same root cause as the fluent-select/fluent-card overrides above (FAST
   resolves this per-element rather than via custom-property inheritance), so it needs the same
   direct-part-selector treatment. Made transparent (not surface-alt) since the header row
   itself already has no background of its own -- a solid fill here would paint each header
   button as a separate grey chip instead of blending into the row. */
.tl-dialog .fluent-data-grid fluent-button::part(control),
.tl-dialog fluent-data-grid fluent-button::part(control) {
    background: transparent !important;
}

/* Dark surface card, matching Education_Learning_Phase1.dc.html's card treatment
   (background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:24px) --
   used by the assignment dialogs (Submission, CreateView, SubmissionFeedback) in place of
   app.css's global .card, which is a plain white Bootstrap-ish card unrelated to this design
   and only readable there via a bolted-on `color:#1f2937 !important` hack. */
.tl-dialog .tl-card {
    background: var(--tl-surface);
    border: 1px solid var(--tl-border);
    border-radius: 12px;
    padding: 24px;
    color: var(--tl-text);
}

/* MeetingDetailsDialog.razor's own body content (meeting-details-meta/address/actions/close) has
   no padding of its own -- it's a plain child of <FluentDialogBody>, which renders a bare
   .fluent-dialog-body div with zero padding by default. That div is rendered by FluentDialogBody
   itself, not authored in MeetingDetailsDialog.razor's own markup, so CSS isolation's scope
   attribute never reaches it and a scoped rule in that component's .razor.css can't target it --
   same reason the fluent-select/fluent-card overrides above live here instead. Without this, the
   body content sits flush against the header (0px gap) and flush against the dialog's own left/
   right edges while the header's title sits 16px in from its own padding -- a visible
   misalignment plus a cramped transition right under the header. Scoped to
   .meeting-details-dialog specifically so it doesn't touch CreateProject/CreateTask/CreateReport/
   CreateWhiteboard's own FluentDialogBody spacing. */
.meeting-details-dialog .fluent-dialog-body {
    padding: 12px 16px 16px;
}

.tl-dialog-field {
    width: 100%;
}

.tl-dialog-person-list {
    flex: 1;
    min-height: 0;
    max-height: 40vh;
    overflow-y: auto;
}
