/*
 * evet-theme-fixes.css — AB#475205.
 *
 * eVet's Covetrus PrimeNG theme (https://evetcdn.blob.core.windows.net/css/theme.css) loads after
 * the shell's own PrimeNG CSS because the MFEs still depend on it. Three of its rules break PrimeNG
 * and Design System components; this file corrects exactly those three, nothing else. Linked in
 * index.ejs IMMEDIATELY after the theme.css <link>, so each selector below is the selector
 * theme.css uses for the rule it corrects (the Bug 2 rule's `[hidden]` is a deliberate superset —
 * see that block) — same specificity, later in the cascade, wins without `!important` — while
 * still leaving room for an MFE's own override (injected later still) to win at equal-or-higher
 * specificity over this file too.
 */

/*
 * Bug 1 — outlined button hover/active render as blue-on-blue (theme.css ~L4135-4144 sets
 * `background: #1474e5; color: #1474E5` for both :enabled:hover and :enabled:active, making the
 * label unreadable against its own background). Resting `.p-button.p-button-outlined` keeps its
 * current transparent background + `--color-interactive-primary` text (untouched here, per spec —
 * only :enabled:hover/:enabled:active are overridden).
 *
 * Replaces the solid fill with the DS's light blue-tint background (`--color-bg-selected`, the same
 * token index.ejs already uses for the left-nav "is-active" state — see #cv-sidenav .is-active
 * there) paired with the DS's darker interactive-primary step for the hover/pressed text, so the
 * two states read as "tint deepens, text darkens" instead of "background and text are the same hue."
 */
.p-button.p-button-outlined:enabled:hover {
  background: var(--color-bg-selected, #E8F7FF);
  color: var(--color-interactive-primary-hover, #0E59C4);
  border: none;
}
.p-button.p-button-outlined:enabled:active {
  /* No DS semantic token exists yet for an outlined button's "pressed" background (only
     --color-bg-selected exists, used above for hover) — closest existing is the next primitive step
     up the same utility-default ramp (--utility-default-200), one notch more saturated than the
     hover tint. Flagged in the PR per the missing-token rule; not invented, not written to tokens.json. */
  background: var(--utility-default-200, #B3E0FF);
  color: var(--color-interactive-primary-active, #0A3FA2);
  border: none;
}

/*
 * Bug 1b — the same blue-on-blue defect recurs, independently, in the SEVERITY-variant outlined
 * buttons (secondary, info, success, warning, help, danger). Each variant's hover/active rule is
 * `.p-button.p-button-{severity}.p-button-outlined:enabled:{hover,active}` PLUS the matching
 * `.p-buttonset`/`.p-splitbutton` forms — three selectors per rule, specificity (0,5,0) for the
 * `.p-button` form and (0,6,0) for the `.p-buttonset`/`.p-splitbutton` forms — above the base rule
 * above (0,4,0: no `.p-button-{severity}` class), so the base fix above does not reach them. Resting state is untouched (not in scope, per spec); only
 * :enabled:hover/:enabled:active are overridden, selector lists copied verbatim from theme.css so
 * this file wins on specificity + later source order without `!important`.
 *
 * Same "tint deepens, text darkens" shape as Bug 1, chosen per variant:
 *   - danger: DS destructive/error family — tint background (--color-feedback-danger-bg) with the
 *     DS destructive text step for hover (--color-interactive-destructive) and its darker step for
 *     active (--color-interactive-destructive-hover), deepening the tint to the next danger
 *     primitive (--utility-danger-200) for active.
 *   - success / warning / info: each has a matching DS semantic family
 *     (--color-feedback-{success,warning,info}-bg/-text), used directly for hover; active deepens
 *     the tint to the next primitive step in the same family.
 *   - help: theme.css gives help the identical #191919-on-transparent resting rule as info/success/
 *     warning, but the DS has no "help" semantic family — falls back to a neutral tint
 *     (--color-bg-subtle / --color-bg-muted) with the resting text colour (--color-text-default),
 *     per the documented family-doesn't-exist fallback.
 *   - secondary: resting outlined text is white on transparent (theme.css L4272, pre-existing, out
 *     of scope). No DS token family matches white-on-light, so hover/active keep the resting white
 *     text and use a dark neutral tint (--neutral-700 / --neutral-800) behind it instead of a light
 *     one, so the glyph stays readable.
 * Contrast (own text colour on its own background), computed via WCAG relative luminance — all
 * comfortably above the 4.5:1 AA floor for normal text:
 *   secondary hover 9.15:1, active 13.97:1 | danger hover 6.34:1, active 6.72:1
 *   success hover 7.26:1, active 10.28:1   | warning hover 6.80:1, active 5.90:1
 *   info hover 8.54:1, active 8.82:1       | help hover 16.41:1, active 14.35:1
 */
.p-button.p-button-secondary.p-button-outlined:enabled:hover,
.p-buttonset.p-button-secondary > .p-button.p-button-outlined:enabled:hover,
.p-splitbutton.p-button-secondary > .p-button.p-button-outlined:enabled:hover {
  background: var(--neutral-700, #484848);
  color: var(--neutral-white, #FFFFFF);
  border: none;
}
.p-button.p-button-secondary.p-button-outlined:enabled:active,
.p-buttonset.p-button-secondary > .p-button.p-button-outlined:enabled:active,
.p-splitbutton.p-button-secondary > .p-button.p-button-outlined:enabled:active {
  background: var(--neutral-800, #2C2C2C);
  color: var(--neutral-white, #FFFFFF);
  border: none;
}

.p-button.p-button-info.p-button-outlined:enabled:hover,
.p-buttonset.p-button-info > .p-button.p-button-outlined:enabled:hover,
.p-splitbutton.p-button-info > .p-button.p-button-outlined:enabled:hover {
  background: var(--color-feedback-info-bg, #E8F7FF);
  color: var(--color-feedback-info-text, #0A3FA2);
  border: none;
}
.p-button.p-button-info.p-button-outlined:enabled:active,
.p-buttonset.p-button-info > .p-button.p-button-outlined:enabled:active,
.p-splitbutton.p-button-info > .p-button.p-button-outlined:enabled:active {
  background: var(--utility-default-200, #B3E0FF);
  color: var(--utility-default-800, #00307A);
  border: none;
}

.p-button.p-button-success.p-button-outlined:enabled:hover,
.p-buttonset.p-button-success > .p-button.p-button-outlined:enabled:hover,
.p-splitbutton.p-button-success > .p-button.p-button-outlined:enabled:hover {
  background: var(--color-feedback-success-bg, #EAF6F3);
  color: var(--color-feedback-success-text, #015C43);
  border: none;
}
.p-button.p-button-success.p-button-outlined:enabled:active,
.p-buttonset.p-button-success > .p-button.p-button-outlined:enabled:active,
.p-splitbutton.p-button-success > .p-button.p-button-outlined:enabled:active {
  background: var(--utility-success-200, #CCF2D9);
  color: var(--utility-success-900, #133A33);
  border: none;
}

.p-button.p-button-warning.p-button-outlined:enabled:hover,
.p-buttonset.p-button-warning > .p-button.p-button-outlined:enabled:hover,
.p-splitbutton.p-button-warning > .p-button.p-button-outlined:enabled:hover {
  background: var(--color-feedback-warning-bg, #FFFCEF);
  color: var(--color-feedback-warning-text, #7C5000);
  border: none;
}
.p-button.p-button-warning.p-button-outlined:enabled:active,
.p-buttonset.p-button-warning > .p-button.p-button-outlined:enabled:active,
.p-splitbutton.p-button-warning > .p-button.p-button-outlined:enabled:active {
  background: var(--utility-warning-300, #FFEBAC);
  color: var(--color-feedback-warning-text, #7C5000);
  border: none;
}

.p-button.p-button-help.p-button-outlined:enabled:hover,
.p-buttonset.p-button-help > .p-button.p-button-outlined:enabled:hover,
.p-splitbutton.p-button-help > .p-button.p-button-outlined:enabled:hover {
  background: var(--color-bg-subtle, #F7F7F7);
  color: var(--color-text-default, #191919);
  border: none;
}
.p-button.p-button-help.p-button-outlined:enabled:active,
.p-buttonset.p-button-help > .p-button.p-button-outlined:enabled:active,
.p-splitbutton.p-button-help > .p-button.p-button-outlined:enabled:active {
  background: var(--color-bg-muted, #E8E8E8);
  color: var(--color-text-default, #191919);
  border: none;
}

.p-button.p-button-danger.p-button-outlined:enabled:hover,
.p-buttonset.p-button-danger > .p-button.p-button-outlined:enabled:hover,
.p-splitbutton.p-button-danger > .p-button.p-button-outlined:enabled:hover {
  background: var(--color-feedback-danger-bg, #FEF0EE);
  color: var(--color-interactive-destructive, #B01332);
  border: none;
}
.p-button.p-button-danger.p-button-outlined:enabled:active,
.p-buttonset.p-button-danger > .p-button.p-button-outlined:enabled:active,
.p-splitbutton.p-button-danger > .p-button.p-button-outlined:enabled:active {
  background: var(--utility-danger-200, #FFCAC7);
  color: var(--color-interactive-destructive-hover, #890F28);
  border: none;
}

/*
 * Bug 2 — theme.css's `.ds-helper-text { display: flex }` (~L10772) beats the native `hidden`
 * attribute on the same element, so a helper-text node authored as hidden renders anyway. Adding the
 * `[hidden]` attribute to the selector raises specificity above the bare class rule it corrects
 * (0,2,0 vs 0,1,0), so this wins the cascade without `!important` regardless of source order.
 */
.ds-helper-text[hidden] {
  display: none;
}

/*
 * Bug 3 — lopsided dialogs. theme.css's dialog box model (verified against the neighbouring
 * `.p-dialog-header` / `.p-dialog-footer` rules, ~L6001-6050 and ~L9228-9324):
 *   - `.p-dialog` itself owns 1.5rem of left/right padding (shared by all three children) plus
 *     1.5rem bottom (no top — the header supplies its own 1.5rem top padding instead).
 *   - `.p-dialog-header` and `.p-dialog-footer` both carry ZERO horizontal padding of their own —
 *     they rely entirely on `.p-dialog`'s shared 1.5rem inset, landing both at a 1.5rem total
 *     left/right indent.
 *   - `.p-dialog-content` (~L9291) is the outlier: `padding: 0 0 0 2.5rem` adds its OWN 2.5rem on
 *     the left on top of the dialog's 1.5rem (4rem total left vs 1.5rem total right) — the lopsided
 *     look. `.p-dialog`'s own padding is NOT the bug (it is already left/right-symmetric, and its
 *     vertical asymmetry is the intentional complement to the header's own top padding and the
 *     footer's own zero-bottom padding, both landing at 1.5rem outer whitespace) — left unchanged.
 * Note: theme.css declares `.p-dialog .p-dialog-content` TWICE at equal specificity: ~L6036 (`padding: 0`,
 * inert) and ~L9291 (`0 0 0 2.5rem`, which wins by source order and is the one this file corrects). Re-check
 * the later one if theme.css is re-versioned.
 * Fix: drop `.p-dialog-content`'s own horizontal padding entirely, so it relies on the same shared
 * 1.5rem inset as the header and footer.
 *
 * REVERTED from a `padding: 0 0.25rem; margin: 0 -0.25rem;` gutter (commit a94802d0, PR-Owl F-02)
 * back to plain `padding: 0` (commit 0e8710ca's shape) — that gutter regressed, and worse than the
 * defect it fixed. `.p-dialog-content` is a scroll container (PrimeNG dialog.css: `overflow-y:
 * auto`), and per the CSS overflow spec a non-`visible` value on one axis forces the other axis to
 * compute to `auto` too; `auto` on either axis clips a child's box-shadow to the padding box. The DS
 * gives a focused `p-inputtext`/`p-dropdown` a 0.25rem focus-ring box-shadow (theme.css
 * L7784-7785, L7717-7719), so a full-width input's ring can still be clipped up to 0.25rem on the
 * LEFT under plain `padding: 0` — no worse than today: theme.css already clips it on the top and
 * right (its own padding is 0 on those sides), so this trades "clipped on 3 sides" for "clipped on
 * 1 side," not a clean fix. A `margin: 0 -0.25rem` was added to carve out that room without moving
 * the visible content edge — but this selector (`.p-dialog .p-dialog-content`, specificity 0,2,0)
 * only wins the PADDING half of that pair wherever nothing more specific intervenes. Plenty of
 * sites DO win the padding at higher specificity while setting no margin of their own: theme.css's
 * own `.p-dialog.ds-modal .p-dialog-content` (~L9315, padding-only), every MFE `!important` padding
 * override (e.g. client-general-info/patient-general-info confirm dialogs), MR basket dialogs
 * (`medical-record-workspace` global styles), and Accounting's `ab-dialog`/`tc-dialog`. At every one
 * of those, this rule's negative margin still applied on its own — because nothing in theme.css,
 * PrimeNG's dialog.css, or any local shell stylesheet sets a margin on `.p-dialog-content` to
 * override it (confirmed by direct read of theme.css L6036/L9291/L9315 and PrimeNG 12.2.4
 * dialog.css, which set `overflow-y: auto` only) — so the content shifted 3.5px off the header/
 * footer and, where the dialog's own outer padding is also 0 (Accounting `ab-dialog`/`tc-dialog`,
 * PaymentVault's Stripe onboarding dialog, Settings' discounting dialog, the AI supervisor chat
 * dialog), its white background overhung the dialog's rounded border past the box-shadow. 48
 * dialogs shifted, 31 of those overhung. A margin-based gutter can only be safe bundled with
 * whatever rule wins the padding at each site — i.e. it isn't expressible as one shell-level rule
 * without `!important` (ruled out) or duplicating every MFE override here (not self-contained,
 * defeats the point of this file). So: back to the minimal, self-contained `padding: 0`, accepting
 * the up-to-0.25rem left-edge ring clip as the lesser, pre-existing-shaped defect, instead of a
 * fix that regresses 48 dialogs this file doesn't own. (`.p-dialog.ds-modal .p-dialog-content` is a
 * separate, more specific selector for the large modal variant — untouched, not in scope here.)
 *
 * Exception — icon-header dialogs (PR-Owl F-01). In a DS dialog whose header leads with an icon
 * (`.ds-dialog-title` > `.ds-dialog-header-icon`, ~91 dialogs across the MFEs, e.g. Settings
 * tax-type-delete), theme.css's 2.5rem is not stray: it is exactly the icon's box (1.5rem glyph +
 * 2 x 0.25rem padding + 0.5rem margin, theme.css L9244-9249), so it puts the body text under the
 * title text. The DS ModalDialog does the same (body `paddingLeft: 36` = 24px icon + 12px gap).
 * Those dialogs keep theme.css's 2.5rem, i.e. look exactly as they do today. `:where()` keeps the
 * selector at (0,2,0), the same as the rule above and theme.css's, so it wins only by source order
 * and an MFE's own padding override still wins over it. Without `:has` support the `:where` list
 * matches nothing and those dialogs fall back to the rule above.
 */
.p-dialog .p-dialog-content {
  padding: 0;
}
.p-dialog:where(:has(> .p-dialog-header .ds-dialog-header-icon)) .p-dialog-content {
  padding-left: 2.5rem;
}
