/* Global button styling
   v5 buttons are styled on the host element (v4 used ::part(control)). Appearance mapping from v4:
   Neutral -> Default (no attribute), Accent -> primary, Lightweight -> transparent,
   Stealth -> subtle, Outline -> outline. */

:is(fluent-button, fluent-anchor-button) {
    white-space: nowrap;
    border-radius: 9999px !important;
    font-weight: 700;
    line-height: 1;
    min-width: 0;
}

/* Icon-only buttons are v5's own (dialog close, toast dismiss, ...) or use .icon-only below. */
:is(fluent-button, fluent-anchor-button):not([icon-only]) {
    height: 40px;
    padding: 0 40px;
}

:is(fluent-button, fluent-anchor-button):focus:active {
    box-shadow: inset 0 0 0 1px white;
}

:is(fluent-button, fluent-anchor-button):disabled,
:is(fluent-button, fluent-anchor-button)[disabled] {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}

:is(fluent-button, fluent-anchor-button):not([appearance]) {
    background: var(--orange);
    border-color: transparent;
    color: white;
}

:is(fluent-button, fluent-anchor-button):not([appearance]):hover {
    background: var(--orange-hover);
}

:is(fluent-button, fluent-anchor-button):not([appearance]):active {
    background: var(--orange-active);
}

:is(fluent-button, fluent-anchor-button)[appearance="primary"] {
    background: var(--deep-grey);
    color: white;
}

:is(fluent-button, fluent-anchor-button)[appearance="primary"]:hover {
    background: var(--charcoal);
}

:is(fluent-button, fluent-anchor-button)[appearance="primary"]:active {
    background: var(--charcoal);
}

:is(fluent-button, fluent-anchor-button)[appearance="transparent"]:not([icon-only]) {
    color: var(--orange);
    padding: 0;
    font-weight: bold;
    height: auto;
    background: none;
    border: none;
}

/* The one link style: bold orange text, darker on hover, never underlined. An <a href> for a route
   and a transparent FluentButton for an in-place action (back, open a dialog, toggle) both carry
   .link-action so they read the same. Icons are optional per use, placed by the call site. */
fluent-button.link-action[appearance="transparent"] {
    height: auto;
    font-size: 0.9rem;
    letter-spacing: normal;
    --icon-spacing: 0.35rem;
}

a.link-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--orange);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: normal;
    text-decoration: none;
    flex-shrink: 0;
}

/* !important to beat app.css's a:hover underline */
a.link-action:hover {
    color: var(--orange-hover);
    text-decoration: none !important;
}

/* As .header-nav-link: text and icon ease to the hover colour together. The icon's fill is forced
   because call sites colour it with CustomColor, which would otherwise hold it on hover. */
a.link-action,
fluent-button.link-action[appearance="transparent"] {
    transition: color 0.2s;

    svg {
        transition: fill 0.2s ease-in-out;
    }

    &:hover svg {
        fill: var(--orange-hover) !important;
        color: var(--orange-hover) !important;
    }
}

fluent-button.tall {
    height: 48px;
    width: 100%;
}

/* The same height for a button that sits in a row rather than filling its column */
fluent-button.tall.inline {
    width: auto;
}

/* An input with its action button beside it. The field takes the free width and the button keeps
   its content width at the field's 48px height, aligned to the field rather than its label. When
   the column is too narrow for both (a 12rem field plus the button) the button wraps below and
   fills the line: the 999:1 grow ratio leaves it no meaningful share of the space while they
   share a line. .stacked always puts the button below. */
.input-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    width: 100%;
}

.input-action-row > :not(fluent-button) {
    flex: 999 1 12rem;
    min-width: 0;
}

.input-action-row > fluent-button {
    flex: 1 0 auto;
    width: auto;
    height: 48px;
}

.input-action-row.stacked {
    flex-direction: column;
    align-items: stretch;
}

.input-action-row.stacked > :not(fluent-button) {
    flex: none;
}

:is(fluent-button, fluent-anchor-button)[appearance="transparent"]:not([icon-only]):hover {
    color: var(--orange-hover);
}

:is(fluent-button, fluent-anchor-button)[appearance="outline"] {
    border-color: #DADADA;
    color: #212121;
}

:is(fluent-button, fluent-anchor-button)[appearance="outline"]:hover {
    background: var(--pale-grey) !important;
}

:is(fluent-button, fluent-anchor-button)[appearance="subtle"] {
    color: var(--neutral-foreground-rest);
}

/* v4 let a button's icon overflow its padding when the column was narrow; v5 shrinks it away. */
:is(fluent-button, fluent-anchor-button) > svg[slot] {
    flex-shrink: 0;
}

:is(fluent-button, fluent-anchor-button).icon-only {
    border-radius: 1rem;
    background: transparent !important;
    border-color: transparent;
    height: 40px;
    width: 40px;
    padding: 0;
}

/* Accordion (v5 parts: heading, button, content; v4's "region" part is now "content") */
fluent-accordion {
    display: flex;
    flex-direction: column;
}

fluent-accordion-item {
    border: 1px solid #EFEFEF;
    border-radius: 8px;
    background: white;
}

/* A minimum rather than a height, so a heading that wraps (long questions on a phone) grows instead of
   clipping its second line. The library fixes both the heading and its button at 44px. */
fluent-accordion-item::part(heading) {
    height: auto;
    min-height: 48px;
    padding-inline: 0 14px;
    color: var(--all-white);
    background: var(--mid-grey);
    border-color: var(--mid-grey);
    border-radius: 5px;
    transition: all 0.3s ease-in-out;
}

fluent-accordion-item::part(button) {
    height: auto;
    padding: 12px 0 12px 16px;
    margin: 0;
}

fluent-accordion-item::part(button):focus-within {
    border: unset;
}

/* v5 only moves its default chevrons for MarkerPosition=End; custom (slotted) markers stay at
   the start of the heading grid, so they are placed after the button here. */
fluent-accordion-item[marker-position="end"] > :is([slot="marker-collapsed"], [slot="marker-expanded"]) {
    grid-column: 5 / span 1;
    grid-row: 1;
    padding-inline: 0;
}

fluent-accordion-item > [slot="heading"] {
    line-height: 1.2;
    font-weight: bold;
}

fluent-accordion-item[expanded] {
    &::part(heading) {
        background: var(--charcoal);
        border-radius: 5px 5px 0 0;
    }

    &::part(content) {
        background: transparent !important;
        border: unset;
        position: relative;
    }
}

fluent-accordion-item::part(content) {
    margin: 0;
    padding: 8px;
    border-left: 1px solid var(--pale-grey);
    border-bottom: 1px solid var(--pale-grey);
    border-right: 1px solid var(--pale-grey);
}

/* Tabs: v5 renders a fluent-tablist of light-DOM fluent-tab elements, followed by the panels */
fluent-tablist {
    background-color: var(--light-grey);
    border-radius: 9999px;
    gap: 4px;
    display: flex;
    width: 100%;
    /* the tab list won't shrink below the tabs' min-content width without this */
    min-width: 0;
}

/* v5 draws the selected-tab underline as the tab list's ::after (or each tab's, without anchor
   positioning support); v4's pill tabs hid it. */
fluent-tablist::after,
fluent-tablist fluent-tab::before,
fluent-tablist fluent-tab::after {
    display: none;
}

/* Reuse the tab list's ::after as the white pill, anchored to the selected tab, so it slides
   between tabs instead of jumping. Only browsers that transition anchor() insets when the anchor
   moves to another element get this; Safari supports anchor positioning but just jumps. The
   text-size-adjust test is v5's own way of singling those browsers out for its sliding indicator. */
@supports (anchor-name: --a) and (text-size-adjust: auto) {
    fluent-tablist {
        anchor-scope: --pdp-active-tab;
    }

    fluent-tablist fluent-tab[aria-selected="true"] {
        anchor-name: --pdp-active-tab;
    }

    fluent-tablist::after {
        content: "";
        display: block;
        position-anchor: --pdp-active-tab;
        position: absolute;
        inset-inline: anchor(start) auto;
        inset-block: anchor(start) auto;
        width: anchor-size(width);
        height: anchor-size(height);
        transform: none;
        background-color: white;
        border-radius: 9999px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
        transition-property: inset-inline, inset-block, width, height;
        /* slight overshoot on the slide so the pill settles onto the new tab */
        transition-duration: 0.45s;
        transition-timing-function: cubic-bezier(0.34, 1.25, 0.64, 1);
        z-index: 0;
    }

    /* keeps the overshoot on the first/last tab inside the rounded track */
    fluent-tablist {
        overflow: clip;
    }

    fluent-tablist fluent-tab {
        position: relative;
        z-index: 1;
    }

    fluent-tablist fluent-tab[aria-selected="true"] {
        background-color: transparent !important;
        box-shadow: none !important;
    }
}

/* Elsewhere nothing can slide after the selected tab, so each tab draws its own pill (its ::before)
   instead: the old tab's shrinks away as the new tab's grows in. */
@supports not ((anchor-name: --a) and (text-size-adjust: auto)) {
    fluent-tablist fluent-tab {
        position: relative;
        z-index: 1;
    }

    fluent-tablist fluent-tab::before {
        content: "";
        display: block;
        position: absolute;
        inset: 0;
        height: auto;
        margin: 0;
        background-color: white;
        border-radius: 9999px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
        opacity: 0;
        transform: scale(0.8);
        transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.34, 1.25, 0.64, 1);
        z-index: -1;
    }

    fluent-tablist fluent-tab[aria-selected="true"]::before {
        opacity: 1;
        transform: scale(1);
    }

    fluent-tablist fluent-tab[aria-selected="true"] {
        background-color: transparent !important;
        box-shadow: none !important;
    }
}

fluent-tablist fluent-tab {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 10px;
    justify-content: center;
    border-radius: 9999px;
    font-size: var(--type-ramp-base-font-size);
    line-height: var(--type-ramp-base-line-height);
    font-weight: 700;
    color: var(--mid-grey);
    cursor: pointer;
    margin: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
    display: flex;
    gap: 0.5rem;
}

fluent-tablist fluent-tab > span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    /* labels wrap onto two lines when the tabs get narrow (mobile), as v4's did */
    white-space: normal;
    text-align: center;
    line-height: 1.2;
}

fluent-tablist fluent-tab > span > svg {
    flex-shrink: 0;
}

fluent-tablist fluent-tab svg {
    fill: var(--charcoal) !important;
    width: 18px !important;
    height: 18px;
    transition: fill 0.2s ease-in-out;
}

fluent-tablist fluent-tab:hover {
    color: var(--orange);

    span svg {
        fill: var(--orange) !important;
    }
}

fluent-tablist fluent-tab[aria-selected="true"] {
    background-color: white;
    color: var(--orange);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    
    span svg {
        fill: var(--orange) !important;
    }
}

@media (max-width: 768px) {
    fluent-tablist fluent-tab {
        font-size: 14px;
    }

    fluent-tablist fluent-tab svg {
        display: none;
    }
}

.fluent-tabs .fluent-tab-panel {
    display: block;
    margin-top: 16px;
    padding: 0 6px;
}

.quiet-accordion fluent-accordion-item::part(heading) {
    height: 50px;
    padding-inline-end: 19px;
    background: transparent;
    color: var(--charcoal);
    border: 1px solid var(--border-grey);
    border-radius: 8px;
}

.quiet-accordion fluent-accordion-item::part(heading):hover {
    background: var(--off-white);
}

.quiet-accordion fluent-accordion-item[expanded]::part(heading) {
    background: var(--off-white);
    color: var(--deep-grey);
    border-radius: 8px 8px 0 0;
}

.quiet-accordion fluent-accordion-item::part(content) {
    border-color: var(--border-grey);
    border-radius: 0 0 8px 8px;
}

.cart-accordion {
    border-radius: 0;
    border-bottom: 1px solid var(--border-grey);
    border-top: 1px solid var(--border-grey);
}

.cart-accordion fluent-accordion-item {
    border-radius: 0;
    border: none;
}

.cart-accordion fluent-accordion-item::part(heading) {
    background-color: #f9fafb;
    color: var(--charcoal);
    border-radius: 0;
}

.cart-accordion fluent-accordion-item::part(heading-content) {
    font-weight: normal;
}

.cart-accordion fluent-accordion-item::part(region) {
    border-left: none;
    border-bottom: none;
    border-right: none;
    padding: 0.75rem 1.75rem;
    background-color: #f9fafb;
}

.cart-accordion fluent-accordion-item::part(button) {
    padding: 12px 0 12px 1.75rem;

}

.cart-accordion fluent-accordion-item::part(icon) {
    margin-right: 1.4rem;
}

.cart-accordion fluent-accordion-item::part(heading):hover {
    background-color: #f3f4f6;
}

/* Input fields
   v5 wraps every input in a fluent-field. Text and number inputs are both fluent-text-input
   (style through ::part(root), as v4's fluent-text-field); FluentSelect is a fluent-dropdown,
   whose control is not exposed as a part, so its border lives on the host instead. */
fluent-field:has(> fluent-text-input, > fluent-textarea, > fluent-dropdown),
fluent-text-input,
fluent-textarea,
fluent-dropdown {
    width: 100%;
    min-width: 0;
    max-width: none;
    row-gap: 0 !important;
}

fluent-field:has(> fluent-text-input, > fluent-textarea, > fluent-dropdown) {
    display: grid;
}

fluent-text-input::part(root) {
    border: 1px solid var(--pale-grey);
    border-radius: 25px;
    line-height: 1.2;
    height: 48px;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Greyed out while disabled, so a field waiting on another choice (a quantity before its product is
   ticked) reads as unavailable rather than empty */
fluent-text-input:is([disabled], :disabled)::part(root) {
    background-color: var(--light-grey);
    border-color: var(--light-grey);
}

fluent-dropdown {
    border: 1px solid var(--pale-grey);
    border-radius: 25px;
    line-height: 1.2;
    height: 48px;
    overflow: hidden;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    background: white;
}

/* The dropdown's control is a light-DOM <button>, so reboot's button border would reach it. */
fluent-dropdown > [slot="control"] {
    align-self: center;
    border: 0;
    background: none;
    padding: 0;
    outline: none;
}

/* The chevron is coloured from this token inside the dropdown's shadow DOM. Selects use the
   filled-lighter appearance, which (unlike outline) draws no inner border or focus underline. */
fluent-dropdown {
    --colorNeutralForeground3: var(--orange);
    --colorStrokeFocus1: transparent;
    --colorStrokeFocus2: transparent;
    --colorCompoundBrandStroke: transparent;
    color: var(--neutral-foreground-rest);
}

fluent-dropdown:has(> [slot="control"]:focus-visible) {
    border-color: var(--orange);
}

fluent-listbox {
    border: 1px solid var(--pale-grey);
    border-radius: 4px;
    padding: 4px;
    row-gap: 0;
}

fluent-option {
    position: relative;
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 3px;
    column-gap: 0;
    grid-template-columns: 0 auto 1fr;
    color: transparent;
}

fluent-option::part(content) {
    color: var(--neutral-foreground-rest);
    line-height: 1.2;
}

fluent-option:hover,
fluent-option:state(active) {
    background-color: var(--neutral-fill-hover);
}

fluent-option:state(selected) {
    background-color: var(--light-grey);
}

fluent-option:state(selected)::before {
    content: "";
    position: absolute;
    left: 3px;
    margin-left: -1px;
    top: calc(50% - 8px);
    width: 3px;
    height: 16px;
    border-radius: 2px;
    background: var(--orange);
}

/* Spacing inside the field as v4 laid it out: 12px either side of a start/end adornment and
   9px of padding on the text itself (v5 uses a 2px gap and 2px padding). */
fluent-text-input::part(root) {
    gap: 0;
}

fluent-text-input::part(control) {
    padding: 0 9px;
}

fluent-text-input > [slot="start"] {
    display: flex;
    margin-inline-start: 12px;
}

fluent-text-input > [slot="end"] {
    display: flex;
    margin-inline-end: 12px;
}

/* Remove the default focus underline */
fluent-text-input::part(root)::after {
    content: none !important;
    transition: none !important;
}

fluent-text-input,
fluent-textarea {
    --colorNeutralBackgroundInverted: #3367D1;
    --colorNeutralForegroundInverted: #FFFFFF;
}

:root[data-window-inactive] :is(fluent-text-input, fluent-textarea) {
    --colorNeutralBackgroundInverted: #C8C8C8;
    --colorNeutralForegroundInverted: #323232;
}

/* Checkboxes and radios (v5 styles the host itself) */
fluent-checkbox,
fluent-radio {
    --size: 24px;
    --polygon-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12.5l3.75 3.75L17.5 8.5' fill='none' stroke='white' stroke-width='2.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    border: 1px solid var(--pale-grey);
    background: white;
}

fluent-checkbox {
    border-radius: 2px;
    --colorNeutralForegroundInverted: transparent;
}

fluent-checkbox:state(checked),
fluent-radio:state(checked) {
    background-color: var(--tangerine);
    border-color: var(--tangerine);
}

fluent-checkbox:state(checked) {
    background-image: var(--polygon-tick);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100%;
}

fluent-radio::part(checked-indicator) {
    width: 100%;
    border-radius: 0;
}

fluent-radio:state(checked)::part(checked-indicator) {
    background: var(--polygon-tick) center / 100% no-repeat;
}

fluent-checkbox:is([disabled], :disabled),
fluent-radio:is([disabled], :disabled) {
    opacity: 0.5;
    cursor: default;
}

fluent-field[label-position="after"] > [slot="label"] {
    margin-bottom: 0;
    font-weight: normal !important;
    cursor: pointer !important;
}

fluent-field[label-position="after"] > [slot="input"] {
    margin-inline-end: 10px;
}

/* Cards (v5 renders a div, not a web component). The library's stylesheet loads after this one
   (through PDP.Web.styles.css), so these need to out-rank its .fluent-card:not([appearance]). */
body .fluent-card:not([appearance]) {
    /* v4 cards filled their container's height (v5: fit-content) */
    height: 100%;
    box-shadow: none;
    border: 1px solid var(--pale-grey);
    border-radius: 8px;
    padding: 24px !important;
}

body .fluent-card[selectable]:not([appearance]):hover {
    background-color: var(--off-white);
    border-color: var(--pale-grey);
    box-shadow: none;
}

/* Input labels: v4's FluentInputLabel markup, and the label v5 fields slot in */
.fluent-input-label,
fluent-field > [slot="label"] {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    font-size: var(--type-ramp-base-font-size);
    line-height: var(--type-ramp-base-line-height);
    color: var(--charcoal) !important;
    font-weight: bold !important;
    cursor: default !important;
}

/* Gap below a field's label, as v4 spaced it (v5's field adds 2px of row gap on top) */
fluent-field > [slot="label"] {
    margin-bottom: 7px;
}

fluent-field:has(> fluent-dropdown) > [slot="label"] {
    margin-bottom: 12px;
}

fluent-badge.chip {
    height: auto;
    padding: 5px 10px;
    border-radius: 6px;
    border: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--light-grey);
    color: var(--mid-grey);
}

/* For names and other free text, which read badly in capitals */
fluent-badge.chip.normal-case {
    text-transform: none;
    letter-spacing: normal;
    border: 1px solid var(--pale-grey);
}

/* the remove icon on staff name chips */
fluent-badge.chip.normal-case svg {
    margin-inline-start: 8px;
}

fluent-badge.chip.success {
    background: var(--success-light);
    color: var(--success-dark);
}

/* A suggestion rather than a state, e.g. SupportedBadge's "Best practices" */
fluent-badge.chip.recommended {
    background: var(--tangerine-light);
    color: var(--orange-hover);
}

/* Something to fix, e.g. an overdue ETA. The badge fills its icon in its brand foreground, so the fill
   needs !important to follow the text instead. */
fluent-badge.chip.danger {
    background: var(--danger-light);
    color: var(--danger);
}

fluent-badge.chip.danger svg {
    fill: currentColor !important;
    margin-inline-end: 4px;
}

/* Toasts: v5's toast is a fluent-toast-b whose ::part(dialog) is the card, with media (icon),
   title, action (dismiss) and body/subtitle slots. Laid out as the portal's v4 toast. */
fluent-toast-b::part(dialog) {
    width: max-content !important;
    min-width: 360px;
    max-width: calc(100vw - 40px);
    padding: 14px 16px 14px 64px;
    align-items: center;
    background-color: var(--all-white);
    border: 1px solid var(--pale-grey);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(48, 48, 48, 0.16);
}

fluent-toast-b > [slot="media"] {
    position: absolute;
    top: 50%;
    left: 16px;
    display: flex;
    padding: 8px;
    border-radius: 50%;
    background: var(--light-grey);
    transform: translateY(-50%);
}

fluent-toast-b > [slot="media"] svg {
    width: 16px !important;
    height: 16px;
}

fluent-toast-b[intent="success"] > [slot="media"] {
    background: var(--success-light);
}

fluent-toast-b[intent="error"] > [slot="media"] {
    background: var(--danger-light);
}

fluent-toast-b[intent="warning"] > [slot="media"] {
    background: var(--warning-light);
}

fluent-toast-b[intent="info"] > [slot="media"] {
    background: var(--info-light);
}

fluent-toast-b > [slot="title"] {
    font-size: 15px;
    font-weight: 700;
    line-height: 21px;
    color: var(--deep-grey);
}

fluent-toast-b > :is(:not([slot]), [slot="subtitle"]) {
    width: 100%;
    font-size: 13px;
    color: var(--charcoal);
}

fluent-toast-b > [slot="action"] {
    min-width: 0;
    height: auto;
    padding: 0;
    color: #131313;
}

fluent-toast-b > [slot="action"] svg {
    width: 12px !important;
}

@media (max-width: 768px) {
    fluent-button:not([appearance="transparent"], [icon-only], .icon-only) {
        padding: 0 32px;
    }

    fluent-accordion-item::part(button) {
        padding: 15px 0 15px 16px;
    }

    fluent-accordion-item::part(heading) {
        min-height: 54px;
    }
}

fluent-text-input::part(control):-webkit-autofill,
fluent-text-input::part(control):autofill {
    box-shadow: 0 0 0px 1000px white inset !important;
    border-radius: 16px;
}

fluent-text-input::part(control):-webkit-autofill::first-line,
fluent-text-input::part(control):autofill::first-line {
    font-family: var(--fontFamilyBase);
    font-size: var(--fontSizeBase300);
}

fluent-text-input > [slot="end"] > svg {
    fill: var(--orange) !important;
}

fluent-text-input > [slot="end"] > svg:focus:not(:focus-visible) {
    outline: none;
}

/* Invalid fields (v5 marks the wrapping fluent-field): v4 outlined the input in the error colour,
   and the portal gave selects a red border. */
fluent-field.invalid fluent-text-input::part(root) {
    outline: 1px solid var(--error);
}

fluent-field.invalid fluent-dropdown {
    border: 1px solid var(--delete-red) !important;
}

/* Placeholder styling when the placeholder (null value) is selected, and for the null option */
fluent-dropdown:state(placeholder-shown) > [slot="control"],
fluent-option:not([value])::part(content),
fluent-option[value=""]::part(content) {
    color: var(--neutral-foreground-hint, var(--mid-grey));
}


.stepper fluent-button {
    border-radius: 0 !important;
}

.stepper fluent-button:hover {
    background-color: var(--light-grey);;
}

.stepper fluent-button::part(control) {
    padding: 0;
}

fluent-tooltip > div {
    max-width: min(500px, 60vw) !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

.page-header {
    max-width: 900px;
    padding: 0.5rem 1.5rem;
}

/* Button Radio Group Section */
/* A FluentRadioGroup as a row of pills on a grey track, built as the tab list is: the chosen option a white
   pill with the tabs' shadow, or tangerine for an option marked .emphasis. v5 renders each FluentRadio as a
   fluent-field holding its label and the fluent-radio (the circle, styled on its host), so the field is
   the pill and the circle is laid invisibly over it - still the focusable, clickable radio, so Fluent's
   own keyboard handling and checked state carry on underneath. */
.polygon-button-radio-group {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    max-width: 100%;
    border-radius: 9999px;
    background-color: var(--light-grey);
    isolation: isolate; /* prevent bleed */
}

/* When the class lands on the group's wrapping field rather than the group itself */
.polygon-button-radio-group fluent-radio-group {
    display: contents;
}

.polygon-button-radio-group fluent-field {
    flex: 1;
    position: relative;
    margin: 0;
    border-radius: 9999px;
    background-color: transparent;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.polygon-button-radio-group fluent-radio {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    opacity: 0;
    cursor: pointer;
}

/* The label is the segment's face */
.polygon-button-radio-group fluent-field > [slot="label"] {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    margin: 0 !important;
    padding: 0 16px;
    color: var(--charcoal);
    font-size: 14px;
    font-weight: 700 !important;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

/* Selected state: the tabs' white pill */
.polygon-button-radio-group fluent-field:has(fluent-radio:state(checked)) {
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.polygon-button-radio-group fluent-field:has(fluent-radio:state(checked)) > [slot="label"] {
    color: var(--neutral-foreground-rest);
}

/* An option that moves things furthest (e.g. Stock's "Handed over") is tangerine once chosen, as a ticked
   checkbox. FluentRadio's Class may land on the field or on the radio, so both are matched. */
.polygon-button-radio-group fluent-field.emphasis:has(fluent-radio:state(checked)),
.polygon-button-radio-group fluent-field:has(fluent-radio.emphasis:state(checked)) {
    background-color: var(--tangerine);
}

/* The label's colour comes from Fluent's foreground token as well as from the label, so both are set, and
   !important to win over the white pill's label colour whichever order they're matched in */
.polygon-button-radio-group fluent-field.emphasis:has(fluent-radio:state(checked)),
.polygon-button-radio-group fluent-field:has(fluent-radio.emphasis:state(checked)) {
    --colorNeutralForeground1: white;
    --colorNeutralForeground2: white;
}

.polygon-button-radio-group fluent-field.emphasis:has(fluent-radio:state(checked)) > [slot="label"],
.polygon-button-radio-group fluent-field.emphasis:has(fluent-radio:state(checked)) > [slot="label"] *,
.polygon-button-radio-group fluent-field:has(fluent-radio.emphasis:state(checked)) > [slot="label"],
.polygon-button-radio-group fluent-field:has(fluent-radio.emphasis:state(checked)) > [slot="label"] * {
    color: white !important;
}

/* Hover state */
.polygon-button-radio-group fluent-field:not(:has(fluent-radio:state(checked))):hover {
    background-color: var(--pale-grey);
}

.polygon-button-radio-group fluent-field:not(:has(fluent-radio:state(checked))):hover > [slot="label"] {
    color: var(--deep-grey);
}

/* The radio itself is invisible, so its focus shows on the pill */
.polygon-button-radio-group fluent-field:has(fluent-radio:focus-visible) {
    outline: 2px solid var(--orange);
    outline-offset: 1px;
}

/* Button Radio Group Section */

/* Option pills: each radio or checkbox in a group drawn as its own pill, bordered like the portal's
   fields, with the control left visible inside it (unlike the segmented .polygon-button-radio-group). A
   chosen pill takes .highlighted-card's tangerine border and tint. Works on a FluentRadioGroup (the
   class may land on its wrapping field or on the group itself) or on any element holding FluentCheckboxes
   (Joint campaigns). An option is the fluent-field directly holding the control. */
.option-pills fluent-radio-group,
fluent-radio-group.option-pills,
div.option-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* A one-row grid on the field's own "input label" areas: flex would lay its slots out in source order,
   putting the control after the label, and the library's message row would push the control off-centre */
.option-pills fluent-field:has(> fluent-radio, > fluent-checkbox) {
    display: inline-grid;
    grid-template-areas: "input label";
    grid-template-columns: auto auto;
    grid-template-rows: auto;
    align-items: center;
    gap: 0 8px;
    height: 48px;
    margin: 0;
    padding: 0 24px 0 16px;
    border: 1px solid var(--pale-grey);
    border-radius: 9999px;
    background-color: var(--all-white);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.option-pills fluent-field:has(> fluent-radio, > fluent-checkbox) > [slot="input"] {
    margin: 0;
}

/* The group shows one message under all its pills, not one per option */
.option-pills fluent-field:has(> fluent-radio, > fluent-checkbox) > [slot="message"] {
    display: none;
}

.option-pills fluent-field:has(> fluent-radio, > fluent-checkbox) > [slot="label"] {
    margin: 0;
    color: var(--charcoal) !important;
    font-weight: 400 !important;
    white-space: nowrap;
    cursor: pointer !important;
}

.option-pills fluent-field:has(> fluent-radio, > fluent-checkbox):hover {
    border-color: var(--tangerine);
}

.option-pills fluent-field:has(> fluent-radio, > fluent-checkbox):has(fluent-radio:state(checked), fluent-checkbox:state(checked)) {
    border-color: var(--tangerine);
    background-color: var(--tangerine-faint);
}

.option-pills fluent-field:has(> fluent-radio, > fluent-checkbox):has(fluent-radio:focus-visible, fluent-checkbox:focus-visible) {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
}

.fluent-month-view .month[selected],
.fluent-calendar .day[selected] {
    border: 1px solid var(--orange) !important;
    color: var(--orange) !important;
}

.fluent-calendar .day:not([selected]):not([multi-day])[today] {
    background: var(--orange) !important;
}

/* FluentDatePicker: v5 strikes through disabled days; v4 only greyed them */
/*body .fluent-day-view .day[disabled]::before {*/
/*    content: none;*/
/*}*/

.fluent-day-view .day:has(> .day-disabled) {
    position: relative;
}

.fluent-day-view .day:has(> .day-disabled)::before {
    content: "";
    display: inline-block;
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(var(--calendar-cell-size) * .8);
    height: var(--strokeWidthThin);
    background-color: currentcolor;
    transform: translate(-50%, -50%) rotate(45deg);
    z-index: 1;
}

.fluent-messagebar.fluent-messagebar-message {
    font-size: 14px !important;
}

/* v5's textarea draws its border on ::part(root) and is sized through custom properties; the
   height comes from the component's Height (v4 used Rows). */
fluent-textarea {
    --inline-size: 100%;
    --block-size: 100%;
    --line-height: 1.2;
    --border-color: var(--pale-grey);
    --border-block-end-color: var(--pale-grey);
    --padding-block: 0.75rem;
    --padding-inline: 1.25rem;
    --control-padding-inline: 0;
}

fluent-textarea::part(root) {
    border-radius: 25px;
}

fluent-textarea::part(root)::after {
    content: none;
}

.fluent-inputfile-container {
    border: 2px dashed var(--orange) !important;
    border-radius: 10px !important;
    background-color: color-mix(in srgb, var(--orange) 10%, transparent) !important;
    width: 100%;
}

.fluent-inputfile-container:hover {
    border: 2px dashed var(--orange-hover) !important;
}

.inputfile-content {
    padding-top: 50px !important; /*Matches height of progress*/
}

fluent-progress-bar::part(indicator) {
    background-color: var(--orange);
}

a:not([href]):not([class]) {
    color: var(--orange);
}

/* Number inputs: v4 always showed its step arrows, in orange; v5 fades them in on hover/focus.
   (Skipped where the input is disabled, where v4 hid them.) */
body fluent-text-input[inputmode="numeric"]:not([disabled]) > div[slot="end"]:last-child > div[auto-hide] {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    opacity: 1;
}

fluent-text-input[inputmode="numeric"] div[button-step] > svg {
    fill: var(--orange) !important;
}

.body-content {
    overflow-x: clip !important;
    overflow-y: visible !important;
}

fluent-dialog {
    fluent-tooltip {
        display: none;
    }
}

/* Dialogs, laid out as v4's: 24px padding, a 24px regular-weight title with 24px below it, the
   footer 24px below the content, and the close button as a wide borderless button. */
fluent-dialog::part(dialog) {
    border-radius: 8px;
    max-height: calc(100dvh - 4px);
}

fluent-dialog::part(dialog):focus-visible {
    outline: 2px solid var(--colorStrokeFocus2);
    outline-offset: 0;
}

fluent-dialog-body {
    --dialog-background: #FBFBFB;
    background: var(--dialog-background);
    padding: 24px;
    gap: 0;
}

fluent-dialog-body::part(title) {
    background: var(--dialog-background);
    /* v5 pulls the content up under the title by its 8px gap, which is removed above */
    margin-block-end: 0;
    padding-bottom: 24px;
    font-size: 24px;
    font-weight: 400;
    line-height: 32px;
    color: var(--deep-grey);
}

/* A custom title (TitleTemplate) spans the header and uses body text, as v4's dialog header did;
   only a plain Header.Title gets the 24px title style. */
fluent-dialog-body > [slot="title"]:has(> *) {
    flex: 1;
    min-width: 0;
    font-size: var(--type-ramp-base-font-size);
    line-height: var(--type-ramp-base-line-height);
    font-weight: 400;
    color: var(--charcoal);
}

/* v5 scrolls the content area on its own, which shows a scrollbar for sub-pixel overflow (e.g.
   the enlarged list markers). As in v4, the dialog itself scrolls instead; the title and actions
   stay sticky. */
body fluent-dialog-body::part(content) {
    overflow: visible;
    /* see the actions below */
    padding-bottom: 1px;
}

/* ...and the content row takes its content's height rather than squeezing into minmax(0, 1fr). */
body fluent-dialog[fuib] fluent-dialog-body[fuib]:not([scrollable]) {
    grid-template-rows: min-content auto min-content;
}

fluent-dialog-body::part(actions) {
    background: var(--dialog-background);
    padding-top: 23px;
    margin-top: 0;
    padding-bottom: 23px;
    margin-bottom: -23px;
}

/* The actions area lines its content up at the end, so a footer that splits into a left group (e.g.
   "Back to All jobs") and a right group has to fill the row itself - its slotted wrapper included -
   or both groups bunch up on the right. */
fluent-dialog-body > [slot]:has(> .dialog-footer-split),
.dialog-footer-split {
    flex: 1 1 auto;
    width: 100%;
}

/* On a phone the footer's text buttons ("Back to All jobs", "Skip for now") keep the 40px button
   padding, which alone can push the row past the screen; trim it so the row fits before it wraps. */
@media (max-width: 768px) {
    .dialog-footer-split fluent-button[appearance="transparent"] {
        padding: 0 8px;
    }
}

body fluent-dialog-body[fuib] > [slot="title-action"] fluent-button {
    width: 91px;
    max-width: none;
    height: 40px;
    padding: 0 30px 0 0;
    justify-content: flex-end;
    color: var(--neutral-foreground-rest);
}

/* Carried over from v4 components that v5 removed, whose markup the portal now renders itself
   (FluentLayout, FluentHeader, FluentBodyContent, FluentFooter, FluentValidationMessage). */
.layout {
    min-height: 100dvh;
    width: 100%;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    z-index: 10;
    flex-shrink: 0;
    font-weight: bold;
    font-size: 16px;
    line-height: 22px;
    color: #FBFBFB;
}

.header .header-gutters {
    display: flex;
    position: relative;
    align-items: center;
    width: 100%;
    margin: 0.5rem 1.5rem;
}

.body-content {
    margin: 0;
    align-items: flex-start;
    height: 100%;
    width: 100%;
    font-weight: normal;
    font-size: var(--type-ramp-base-font-size);
    line-height: var(--type-ramp-base-line-height);
}

.footer {
    display: flex;
    z-index: 10;
    flex-direction: row;
    font-weight: normal;
    font-size: 12px;
    line-height: 16px;
}

.validation-message {
    color: var(--error);
    font-size: 12px;
    display: flex;
    align-items: center;
    column-gap: 4px;
}

/* Header styling overrides */
.header {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e2e8f0;
    height: var(--header-height) !important;
    z-index: 1000;
    top: 0;
    position: sticky !important;


    @media (min-width: 768px) {
        /* stick effect is only applicable on desktop */
        transition: box-shadow .2s;

        &.is-stuck {
            box-shadow: 0 0 5px 5px #0000001a;
        }
    }
}

/* Zero-height marker above the sticky header; NavigationBar.razor.js watches it to set .is-stuck */
.header-sentinel {
    height: 1px;
    margin-bottom: -1px;
    pointer-events: none;
}

.header-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-logo {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.header-logo img {
    height: 50px;
}

.header-logo img.header-logo-mobile {
    display: none;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 500;
    color: var(--charcoal);
    padding: 8px 4px;
    transition: color 0.2s, border-color 0.2s;

    svg {
        transition: fill 0.2s ease-in-out;
    }

    &.logout {
        color: var(--delete-red);

        &:hover {
            cursor: pointer;
            text-decoration: none !important;
        }
    }

    &:not(.logout):hover {
        color: var(--deep-grey);
        cursor: pointer;
        text-decoration: none !important;

        svg {
            fill: var(--deep-grey) !important;
            color: var(--deep-grey) !important;
        }
    }

    &.active {
        color: var(--orange);
        font-weight: 700;
    }

    &:not(.active):hover {
        color: var(--orange);
        cursor: pointer;
        text-decoration: none !important;

        svg {
            fill: var(--orange) !important;
            color: var(--orange) !important;
        }
    }

    @media (max-width: 960px) {
        svg {
            display: none !important;
        }
    }
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;

    .header-controls-mobile {
        display: none;
    }

    .header-controls-desktop {
        display: flex;
        align-items: center;
        gap: 24px;
        
        /* Matches where the create button drops to its icon. */
        @media (max-width: 1199.98px) {
            gap: 6px;
        }
    }
}

fluent-button.header-create {
    padding: 0 14px 0 16px;
    --icon-spacing: 6px;
}

/* Below 1200px the five nav links leave no room for the label: the button stays orange but drops
   to its icon. */
@media (max-width: 1199.98px) {
    fluent-button.header-create {
        width: 40px;
        padding: 0;
        --icon-spacing: 0;

        /* The label's (now empty) content span keeps its margin and pushes the icon off centre. */
        &::part(content),
        .header-create-chevron {
            display: none;
        }

        /* The button's own --icon-spacing still reaches the icon, leaving it 4px left of centre. */
        > svg[slot="start"] {
            margin: 0;
        }
    }
}

/* Five nav links only fit at the full gap on a wide screen: in between, they draw closer. */
@media (min-width: 769px) and (max-width: 1199px) {
    .header-nav {
        gap: 16px;
    }
}

.dev-state {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    padding: 8px 10px;
    background-color: #f1f5f9;
    border-radius: 6px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    cursor: default;
    user-select: none;

    .dev-state-text {
        display: flex;
        flex-direction: column;
    }

    .dev-state-label {
        color: #475569;
        font-size: 13px;
        font-weight: 600;
    }
}

@media (max-width: 768px) {
    .header {
        background-color: var(--orange) !important;
        height: 50px !important;
        transition: box-shadow 0.3s ease;
        border-bottom: unset;

        .header-logo {
            img {
                display: none;
            }

            img.header-logo-mobile {
                display: flex;
                height: 40px;
            }
        }

        .header-nav {
            display: none;
        }

        .header-controls {
            .header-nav,
            .header-controls-desktop {
                display: none;
            }

            .header-controls-mobile {
                display: flex;
            }
        }
    }

    .nav-menu-popover {
        display: none;
    }
}

/* v4's settings menu opened below the gear, right-aligned to it. v5's popover places itself from
   script, left-aligned; anchor positioning puts it back. The create menu (HeaderMenu too) does the
   same under its own button. */
#btnSettings {
    anchor-name: --settings-anchor;
}

#btnCreate {
    anchor-name: --create-anchor;
}

.nav-menu-popover.create-menu-popover::part(dialog) {
    position-anchor: --create-anchor;
}

.nav-menu-popover::part(dialog) {
    position-anchor: --settings-anchor;
    /* A small gap between the button and the panel. */
    top: calc(anchor(bottom) + 6px) !important;
    right: anchor(right) !important;
    left: auto !important;
    bottom: auto !important;
}

.settings-button {
    color: #64748b;
}

/* v5's provider renders an empty container when there are no notices; v4 rendered nothing. */
.fluent-message-bar-provider.promo-messagebar:empty {
    display: none;
}

.promo-messagebar {
    margin-bottom: 1rem;
    margin-top: -1rem;
    
    .promo-body {
        display: flex;
        justify-content: space-between;
        gap: 16px;
    }
}

/* The AppForm offline banner (MainLayout). */
.offline-banner-slot {
    margin-bottom: 1.5rem;
}

/* The Home notices (AlertBar) and the offline banner, which shows as a system notice. A pale tint
   of the notice's colour with no outline, so a notice reads as information rather than an alert box. */
:is(.promo-messagebar, .offline-banner-slot) fluent-message-bar {
    --notice-colour: var(--tangerine);

    border-color: transparent !important;
    background: color-mix(in srgb, var(--notice-colour) 10%, var(--all-white)) !important;
    color: var(--deep-grey);
    border-radius: 8px;
    padding: 8px 16px;

    svg {
        fill: var(--notice-colour) !important;
    }

    &.error {
        --notice-colour: var(--error);
    }

    &.info {
        --notice-colour: var(--info);
    }

    &.warning {
        --notice-colour: var(--warning);
    }
}

/* Scoped to the table: v5 also puts the grid's class on its header cells, and v4 kept the
   min-width off those with an inline min-width that v5 no longer renders. */
table.apps-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 700px;
}

.apps-table th {
    border-bottom: 2px solid var(--light-grey);
    color: var(--mid-grey);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-row {
    border-bottom: 1px solid var(--light-grey);
    font-size: 14px;
    color: var(--charcoal);
    transition: background-color 0.15s;
    box-sizing: unset !important;
    padding: 12px !important;
    overflow: unset !important;
    text-overflow: unset !important;
    height: auto !important;
    align-self: stretch;
}


.app-row-id {
    max-width: 100px;
}

.app-row-update {
    color: var(--mid-grey);
}

.app-row-action {
    text-align: right;
}

.process-button {
    font-size: 13px !important;
    height: 32px !important;
    padding: 0 16px !important;
}

.group-header-approved {
    background-color: #F0FDF4;
    border-top: 3px solid #22C55E;
}

.group-header-approved td {
    padding: 12px 16px;
    font-weight: 700;
    color: #166534;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.group-header-in-progress {
    background-color: #FFF7ED;
    border-top: 3px solid var(--orange);
}

.group-header-in-progress td {
    padding: 12px 16px;
    font-weight: 700;
    color: var(--orange-hover);
    font-size: 12px;
    letter-spacing: 0.5px;
}

.group-header-rejected {
    background-color: var(--off-white);
    border-top: 3px solid var(--deep-grey);
}

.group-header-rejected td {
    padding: 12px 16px;
    font-weight: 700;
    color: var(--mid-grey);
    font-size: 12px;
    letter-spacing: 0.5px;
}

.status-badge {
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    display: inline-block;
}

.status-badge-not-started {
    color: var(--charcoal);
    background: var(--light-grey);
}

.status-badge-pending {
    color: var(--warning);
    background: var(--warning-light);
}

.status-badge-pre-approved {
    color: var(--success);
    background: var(--success-light);
}

.status-badge-approved {
    color: var(--success-dark);
    background: var(--success-medium);
}

.status-badge-fulfillment {
    color: var(--info);
    background: var(--info-light);
}

.status-badge-delivered {
    color: var(--success-darker);
    background: var(--success-light);
}

.status-badge-rejected {
    color: var(--danger);
    background: var(--danger-light);
}

.no-results {
    padding: 24px !important;
    text-align: center !important;
    color: var(--mid-grey) !important;
    font-style: italic !important;
}

/* Fluent Wizard overrides */
.fluent-wizard-button-template {
    padding-top: 20px;
}

#customized-wizard li[status="current"] > div {
    font-weight: bold;
}

#customized-wizard {
    --accent-fill-rest: white;
    --fluent-wizard-circle-size: 32px !important;
}

#customized-wizard > ol > li[status="previous"] > div.fluent-wizard-icon > svg {
    --accent-fill-rest: var(--orange) !important;
}

#customized-wizard > ol > li[status="current"] > div.fluent-wizard-icon > svg {
    --accent-fill-rest: white !important;
    border-radius: 999px;
    border: 2px solid var(--orange);
}

#customized-wizard > ol > li[status="next"] > div.fluent-wizard-icon > svg {
    border-radius: 999px;
    border: 2px solid var(--pale-grey);
}

#customized-wizard li[status="current"] .fluent-wizard-icon-number {
    color: var(--orange);
}

#customized-wizard li[status="next"] .fluent-wizard-icon-number {
    color: var(--mid-pale-grey);
}

#customized-wizard .fluent-wizard-icon-number {
    font-size: 1em;
    font-weight: 700;
}

#customized-wizard .fluent-wizard-title {
    text-transform: uppercase;
}

#customized-wizard li[status="next"] .fluent-wizard-title {
    color: var(--mid-pale-grey);
    font-weight: 600;
}

/* v4's skeleton fill (v5 uses the darker --colorNeutralBackground6). v5 also makes a skeleton
   transparent once it has content (the video placeholders), where v4 kept the fill. */
body .fluent-skeleton {
    --fluentSkeletonBackground: #F3F3F3;
    background-color: var(--fluentSkeletonBackground) !important;
}

body .fluent-skeleton.skeleton-example {
    --fluentSkeletonBackground: var(--light-grey);
}
