/* ===========================================================================
   Palette - the single source of truth for every color in the app. See
   AGENTS.md "Legibility and contrast": no page may hard-code a color literal
   that duplicates one of these; add a token here instead. Every pairing below
   is verified by tests/SafetyIQ.Tests/ContrastPaletteTests.cs, which fails the
   build if any pair in this file drops below its target ratio - that test is
   the standard, this comment is just the map of what it's checking.
   =========================================================================== */
:root {
  /* Explicitly opt OUT of forced/auto dark-mode recoloring on phones (Android
     Chrome, Samsung Internet, etc. all respect this). This is NOT dark mode -
     it's refusing one. Without it, a browser's heuristic re-coloring of an
     undeclared page is a plausible, invisible-in-source-review cause of
     exactly the "black text on an unexpectedly dark/blue background" defect
     this file exists to fix - see AGENTS.md for the full writeup. */
  color-scheme: light only;

  /* Brand anchors - large surfaces, borders, and brand-colored chrome only.
     NEVER use these two directly as small/body text color on a tinted
     background - use the derived, contrast-checked tokens below instead. */
  --brand-navy: #0b2c54;
  --brand-navy-dark: #082140;
  --brand-gold: #f2a900;
  --brand-gold-dark: #cf9000;

  /* Text-safe variant of brand gold - lightened just enough to clear 7:1 on
     navy (6.96:1 -> 7.53:1). Used only where gold is rendered AS TEXT (the
     active top-level nav link); use --brand-gold for fills/borders/outlines. */
  --brand-gold-text: #f4b31f;

  /* Body text - Bootstrap's own default, named here so it's a token like
     everything else. 15.4:1 on white. */
  --text-body: #212529;

  /* Secondary/muted TEXT. Overrides Bootstrap's own --bs-secondary-color
     (default rgba(33,37,41,.75), ~4.7:1 on white - fails the 7:1 floor this
     app requires for anything a user must read). 8.9:1 on white. Riding
     Bootstrap's own variable means every .text-muted, .form-text, and
     form-floating placeholder in the app is fixed by this one line - never
     override .text-muted's color directly in a page. */
  --bs-secondary-color: #4a4a4a;

  /* Solid-fill success/danger/secondary - what .badge/.btn/.text-* /.bg-* use
     for a plain colored fill with Bootstrap's default white text (--bs-badge-
     color/--bs-btn-color: #fff). Bootstrap's own defaults (#198754/#dc3545/
     #6c757d) measure 4.5-4.7:1 with white text - fails the 7:1 floor for
     status/active-inactive badges and buttons a user must read correctly.
     Darkened to the same shades Bootstrap itself already ships as its
     dark-theme "border-subtle" tokens (not arbitrary - these are colors
     Bootstrap's own design system considers accessible pairings), each
     >=7:1 with white text - verified in ContrastPaletteTests.cs.
     Deliberately NOT touching --bs-success-bg-subtle/--bs-success-text-
     emphasis (and the danger/secondary equivalents) - those back
     .alert-success/.bg-success-subtle/.text-success-emphasis, which are
     already light-tint-on-dark-text pairs that pass contrast as shipped;
     overriding them would make alert banners darker for no reason. */
  --bs-success: #0f5132;
  --bs-success-rgb: 15, 81, 50;
  --bs-danger: #842029;
  --bs-danger-rgb: 132, 32, 41;
  --bs-secondary: #495057;
  --bs-secondary-rgb: 73, 80, 87;

  /* Form validation text - overrides Bootstrap's --bs-form-valid-color /
     --bs-form-invalid-color (defaults #198754/#dc3545, 4.5:1 on white) with
     the same darkened colors above so a validation message a user must read
     also clears 7:1. (Border colors for valid/invalid inputs are untouched -
     those only need the lower 3:1 non-text boundary minimum, and already
     clear it at 4.5:1.) */
  --bs-form-valid-color: var(--bs-success);
  --bs-form-invalid-color: var(--bs-danger);
}

/* Badge text floor - Bootstrap's default 0.75em computes to 12px off a 16px
   base, below the 14px minimum for anything a user must read (a status badge
   always is). bg-warning/bg-info badges (Expiring/Due/InProgress) already
   pair text-dark at 7.9-9.5:1 and need no color change, only this. */
.badge {
  font-size: 14px;
}

/* 16px minimum on every viewport, phones included - sunlight on a phone eats
   contrast and size both. Do not reintroduce a smaller mobile size here. */
html {
  font-size: 16px;
}

/* Every interactive control gets a 44x44 CSS px minimum tap target, per
   AGENTS.md. .btn-sm keeps its tighter visual padding/font-size but is
   centered within the same 44px floor. */
.btn,
.btn-sm,
.btn-group-sm > .btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Checkboxes/radios: the glyph itself stays small, but the clickable row
   (glyph + label, already wired together by Bootstrap's for/id pairing) gets
   enough vertical padding to clear 44px. Padding, not min-height/flex - the
   checkbox glyph is positioned by Bootstrap via float+negative margin inside
   this block-level container, which a flex display would break. */
.form-check {
  padding-top: 0.6875rem;
  padding-bottom: 0.6875rem;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--brand-navy);
}

/* Brand overrides - deliberately global, not layout-scoped CSS, since every layout
   (_Layout, _PortalLayout, _AuthLayout, _PrintLayout) loads this file directly. See
   the navbar-color comment further down for why a scoped .cshtml.css is the wrong
   place for anything color-related in this app. */
a {
  color: var(--brand-navy);
}

.btn-primary {
  color: #fff;
  background-color: var(--brand-navy);
  border-color: var(--brand-navy);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  color: #fff;
  background-color: var(--brand-navy-dark);
  border-color: var(--brand-navy-dark);
}

/* Navbar background AND text live under the SAME .bg-brand-prefixed selectors on
   purpose - every rule below that colors navbar text requires .bg-brand as an
   ancestor in its own selector, so it is structurally impossible for a
   navbar-text rule to apply anywhere the navy background isn't also present.
   A previous version of this file set background here and text color via a
   bare ".navbar-dark .navbar-nav .nav-link" selector with no dependency on
   .bg-brand at all - two rules that happened to agree, with nothing requiring
   them to. That produced a real regression (white text with no confirmed navy
   background - reported on _Layout.cshtml/Admin pages) for reasons that
   weren't fully pinned down even after direct live-server verification; rather
   than ship a fix whose correctness depends on correctly diagnosing exactly
   why the old version broke, this version makes the failure mode impossible
   regardless of the mechanism: delete .bg-brand from an element and every
   navbar-text rule below stops matching it too, instead of leaving white text
   stranded on whatever background happens to remain.
   .navbar-brand (the "SafetyIQ" wordmark) is included here too - it was never
   explicitly covered before (only .nav-link was), relying entirely on
   Bootstrap's own .navbar-dark cascade. */
.bg-brand {
  background-color: var(--brand-navy) !important;
  border-bottom: 3px solid var(--brand-gold);
}

.bg-brand .navbar-brand,
.bg-brand .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.85);
}

.bg-brand .navbar-brand:hover,
.bg-brand .navbar-brand:focus,
.bg-brand .navbar-nav .nav-link:hover,
.bg-brand .navbar-nav .nav-link:focus {
  color: #fff;
}

.bg-brand .navbar-nav .nav-link.active,
.bg-brand .navbar-nav .show > .nav-link {
  color: var(--brand-gold-text);
}

.bg-brand .dropdown-menu .dropdown-item.active,
.bg-brand .dropdown-menu .dropdown-item:active {
  background-color: var(--brand-navy);
  color: #fff;
}

/* Below the navbar-expand-lg breakpoint: dropdowns expand in place inside the
   collapsed panel instead of floating, and every tappable row is full-width
   with a 44px minimum touch target. Still .bg-brand-prefixed throughout - the
   collapsed dropdown sits on the navy background (background-color:
   transparent reveals it), so its text needs the same binding. */
@media (max-width: 991.98px) {
  .bg-brand .navbar-nav .dropdown-menu {
    position: static;
    float: none;
    width: 100%;
    border: 0;
    box-shadow: none;
    background-color: transparent;
    padding-left: 1rem;
  }

  .bg-brand .navbar-nav .dropdown-menu .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
  }

  .bg-brand .navbar-nav .dropdown-menu .dropdown-item:hover,
  .bg-brand .navbar-nav .dropdown-menu .dropdown-item:focus {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
  }

  .bg-brand .navbar-nav .nav-link,
  .bg-brand .navbar-nav .dropdown-item,
  .bg-brand .navbar-nav form {
    min-height: 44px;
  }

  .bg-brand .navbar-nav .nav-link,
  .bg-brand .navbar-nav .dropdown-item {
    display: flex;
    align-items: center;
  }

  .bg-brand .navbar-nav form select {
    width: 100% !important;
  }
}

.navbar-brand img {
  height: 32px;
  width: 32px;
  margin-right: 0.5rem;
}

.brand-logo-lg {
  height: 72px;
  width: 72px;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* <help> tag helper trigger (SafetyIQ.Web.TagHelpers.HelpTagHelper) - a clearly visible
   circled "?" next to a label/column header/heading that shows a Bootstrap tooltip or
   popover. Deliberately NOT text-muted/tiny - a help affordance nobody notices might as
   well not exist. Visible circle is 24px (14px minimum text floor at an 18px/bold "?"),
   not 44px - a 44px dot inline in a label/column header would wreck every layout it
   appears in - but it's tabindex=0 and tap-activated, so the ::after pseudo-element
   below expands the actual tappable/clickable region to 44x44 without changing what's
   drawn. Clicks anywhere in the pseudo-element land on this element since generated
   content is part of its own box, not a separate overlapping one. */
.safetyiq-help {
  cursor: help;
  margin-left: 0.3rem;
  vertical-align: middle;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--brand-navy);
  border-radius: 50%;
  color: var(--brand-navy);
  background-color: #fff;
}

.safetyiq-help::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}

.safetyiq-help:hover, .safetyiq-help:focus-visible {
  color: #fff;
  background-color: var(--brand-navy);
  outline: 2px solid var(--brand-gold);
  outline-offset: 1px;
}