/* ============================================================
   Connecticut Fair Housing Center — Design System
   Consolidated from schema/design_system/tokens/*.css for production.
   Source of truth for the token VALUES is schema/design_system/ — update
   there first, then re-sync this file. Not @import'd to avoid the extra
   round trips six separate token files would cost on every page load.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Roboto+Slab:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;

  /* --- Primary brand colors --- */
  --cfhc-teal:        #00BFB2;
  --cfhc-navy:        #1B365D;
  --cfhc-yellow:      #FFC845;
  --cfhc-white:       #FFFFFF;

  --cfhc-navy-tint:   #E8F0FD;
  --cfhc-teal-tint:   #E6F8F6;
  --cfhc-yellow-tint: #FFF4D6;

  /* Deeper variants of the two tints above, used only for the inquiry
     list's Fair Housing/Foreclosure row shading -- kept separate from
     --cfhc-yellow-tint/--cfhc-teal-tint themselves so darkening these
     doesn't also darken every badge/hover-state/etc. that reuses those
     shared tokens elsewhere in the app. */
  --cfhc-yellow-tint-strong: #FFE5A3;
  --cfhc-teal-tint-strong:   #96E4DE;

  /* Orange -- deliberately pulled toward red (not a mid-tone amber, which
     read too close to --cfhc-yellow at a glance) so a do-not-serve
     highlight stays visually distinct from a Fair Housing flag highlight
     on the same list. */
  --cfhc-orange:      #E8503D;
  --cfhc-orange-tint: #FBDCD5;

  /* Purple -- Foreclosure flag badge. A 4th inquiry-list marker (Fair
     Housing = yellow row, do-not-serve = orange/red row, Urgent reuses
     the existing danger red as a badge) needs its own hue; purple is the
     one clearly-distinct color left in this family that doesn't already
     carry a meaning elsewhere in the app. */
  --cfhc-purple:      #7C5CBF;
  --cfhc-purple-tint: #EAE3F7;

  --gray-050:  #FAFAFA;
  --gray-100:  #F5F5F5;
  --gray-200:  #EEEEEE;
  --gray-300:  #DDDDDD;
  --gray-500:  #999999;
  --text-body:    #444444;
  --text-caption: #666666;

  --callout-fairhousing-fill:   #FDE8E8;
  --callout-fairhousing-accent: #C0392B;
  --callout-general-fill:       #E8F5E9;
  --callout-general-accent:     #27AE60;
  --callout-form-fill:          #E8F0FD;
  --callout-form-accent:        #1B365D;

  --color-bg:            var(--cfhc-white);
  --color-surface:       var(--cfhc-white);
  --color-surface-tint:  var(--gray-100);
  --color-border:        var(--gray-300);
  --color-border-strong: var(--cfhc-navy);

  --text-heading:  var(--cfhc-navy);
  --text-subhead:  var(--cfhc-teal);
  --text-default:  var(--text-body);
  --text-on-dark:  var(--cfhc-white);
  --text-link:     var(--cfhc-teal);

  --color-primary:        var(--cfhc-teal);
  --color-primary-strong: var(--cfhc-navy);
  --color-accent:         var(--cfhc-yellow);

  --teal-hover:   #00A89C;
  --teal-press:   #008F85;
  --navy-hover:   #16294A;
  --navy-press:   #0F1E37;
  --yellow-hover: #F2B82E;

  /* --- Families --- */
  --font-display: 'Roboto Slab', 'Times New Roman', Georgia, serif;
  --font-sans:    'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  --fs-chapter:  2.25rem;
  --fs-section:  1.625rem;
  --fs-subhead:  1.125rem;
  --fs-lead:     1.25rem;
  --fs-body:     1rem;
  --fs-small:    0.9375rem;
  --fs-caption:  0.8125rem;
  --fs-overline: 0.75rem;

  --lh-tight:   1.15;
  --lh-snug:    1.3;
  --lh-normal:  1.55;
  --lh-relaxed: 1.7;

  --ls-tight:    -0.01em;
  --ls-normal:   0;
  --ls-overline: 0.08em;

  /* --- Spacing scale (4px base) --- */
  --space-0:   0;
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-5:   20px;
  --space-6:   24px;
  --space-8:   32px;
  --space-10:  40px;
  --space-12:  48px;
  --space-16:  64px;
  --space-20:  80px;
  --space-24:  96px;

  --radius-sm:   3px;
  --radius-md:   6px;
  --radius-lg:   10px;
  --radius-pill: 999px;

  --border-hairline: 1px;
  --border-thin:     1.5px;
  --border-accent:   4px;

  --shadow-xs: 0 1px 2px rgba(27, 54, 93, 0.06);
  --shadow-sm: 0 1px 3px rgba(27, 54, 93, 0.08), 0 1px 2px rgba(27, 54, 93, 0.06);
  --shadow-md: 0 4px 12px rgba(27, 54, 93, 0.10);
  --shadow-lg: 0 12px 32px rgba(27, 54, 93, 0.14);
  --shadow-focus: 0 0 0 3px rgba(0, 191, 178, 0.35);

  --container-max: 1200px;
  --content-max:   760px;
  --transition-fast: 140ms ease;
  --transition-base: 220ms ease;
}

/* ============================================================
   User-facing appearance options (Options page → Appearance)
   Applied server-side as attributes on <html> (see includes/shell-head.inc)
   so there's no flash of the wrong theme/size on load. Brand colors
   (navy sidebar, teal/yellow accents) stay the same in both themes —
   only the neutral surface/border/text scale and semantic tints invert.
   ============================================================ */
:root[data-theme="dark"] {
  color-scheme: dark;

  --gray-050:  #12161D;
  --gray-100:  #1A2029;
  --gray-200:  #232A35;
  --gray-300:  #333C4A;
  --gray-500:  #8891A0;
  --text-body:    #E6E8EC;
  --text-caption: #9AA1AC;

  --cfhc-navy-tint:   #1C2A42;
  --cfhc-teal-tint:   #12312D;
  /* Translucent rather than a flat pre-mixed dark shade -- a solid
     #3A2F10 read as barely-there brown against the near-black dark
     surfaces below it. An alpha overlay keeps an actual visible yellow
     cast regardless of which surface it sits on. */
  --cfhc-yellow-tint: rgba(255, 200, 69, 0.28);
  --cfhc-orange-tint: rgba(232, 80, 61, 0.30);
  --cfhc-purple-tint: rgba(124, 92, 191, 0.30);
  --cfhc-yellow-tint-strong: rgba(255, 200, 69, 0.40);
  --cfhc-teal-tint-strong:   rgba(0, 191, 178, 0.32);

  --callout-fairhousing-fill: #3A1F1C;
  --callout-general-fill:     #1A3323;
  --callout-form-fill:        #1C2A42;

  --color-bg:      var(--gray-050);
  --color-surface: var(--gray-100);
  --color-surface-tint: var(--gray-200);
  --color-border:  var(--gray-300);

  /* --cfhc-navy itself stays the same dark shade in both themes -- it's
     still exactly right as a background (sidebar, table headers, badges,
     tiles) on a near-black dark-mode page. But that same dark navy used as
     TEXT on a neutral surface (headings, active nav/tab labels) would be
     unreadable on a dark surface, so headings/borders go through these two
     separate semantic tokens instead of --cfhc-navy directly. */
  --text-heading:        #8FB4E8;
  --color-border-strong: #4A6D9E;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* The CoreUI/Bootstrap build vendored here (includes/css/coreui.min.css) has
   no dark-mode variant of its own -- .form-control/.form-select/.table/.card
   etc. are hardcoded to a white/light palette with no [data-coreui-theme] or
   --cui-*-dark hooks to redefine. Pages already converted to this app's own
   .crm-field/.crm-table/.crm-card classes pick up dark mode automatically
   (those are built on the tokens above), but the many pages still on plain
   Bootstrap markup (timesheets-find.php, leave.php, contact-enter.php,
   intake-enter.php, test-find.php, the reports-* pages, and others) would
   otherwise keep white inputs/tables/cards even with dark mode turned on.
   These overrides target the raw Bootstrap classes directly so those pages
   go dark too, without needing every one of them individually converted. */
:root[data-theme="dark"] {
  /* Redefining CoreUI's own root variables first covers every utility class
     built on them in one shot -- .text-muted, .text-secondary, .border,
     .bg-light/.bg-white, table borders, etc. -- without needing a dedicated
     override rule per class. The explicit component rules below (form
     controls, cards, tables...) still exist for the classes that don't read
     these vars, or that need more than a color swap (e.g. table striping). */
  --cui-body-bg: var(--color-bg);
  --cui-body-color: var(--text-body);
  --cui-secondary-color: var(--text-caption);
  --cui-tertiary-color: var(--text-caption);
  --cui-border-color: var(--gray-300);
  --cui-border-color-translucent: var(--gray-300);
  --cui-secondary-bg: var(--color-surface-tint);
  --cui-tertiary-bg: var(--color-surface-tint);
  --cui-light: var(--color-surface-tint);
  --cui-light-rgb: 35, 42, 53;
  --cui-dark: var(--text-body);
  /* .bg-white (e.g. leave.php's read-only Total/Requested/Balance fields)
     reads this var with !important, so redefining it here is enough --
     no need to fight the !important with a more specific selector. */
  --cui-white-rgb: 35, 42, 53;
  --cui-card-bg: var(--color-surface);
  --cui-card-border-color: var(--gray-300);
  --cui-card-cap-bg: var(--color-surface-tint);

  .form-control, .form-select {
    background-color: var(--color-surface-tint);
    border-color: var(--gray-300);
    color: var(--text-body);
  }
  .form-control:focus, .form-select:focus {
    background-color: var(--color-surface-tint);
    color: var(--text-body);
  }
  .form-control::placeholder { color: var(--text-caption); opacity: 1; }
  .form-control:disabled, .form-control[readonly],
  .form-select:disabled {
    background-color: var(--gray-200);
    color: var(--text-caption);
  }
  /* Native date/time picker icon is drawn dark-on-dark otherwise */
  .form-control[type="date"]::-webkit-calendar-picker-indicator,
  .form-control[type="datetime-local"]::-webkit-calendar-picker-indicator,
  .form-control[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
  }

  .card {
    background-color: var(--color-surface);
    border-color: var(--gray-300);
    color: var(--text-body);
  }
  .card-header, .card-footer {
    background-color: var(--color-surface-tint);
    border-color: var(--gray-300);
    color: var(--text-body);
  }

  .table {
    color: var(--text-body);
    border-color: var(--gray-300);
  }
  .table > :not(caption) > * > * {
    background-color: var(--color-surface);
    color: var(--text-body);
    border-bottom-color: var(--gray-300);
    box-shadow: none;
  }
  .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--color-surface-tint);
  }
  .table-hover > tbody > tr:hover > * {
    background-color: var(--cfhc-teal-tint);
  }
  .table thead.table-light th, .table .table-light {
    background-color: var(--gray-200);
    color: var(--text-body);
  }
  /* Legacy tables built with the bgcolor="lightgrey"/"white" HTML attribute
     (pre-dates .table-striped on these older pages) -- same idea, dark tint
     instead of literal white/lightgrey. Presentational attributes lose to
     any CSS rule, so this is enough to override them. */
  table[bgcolor], td[bgcolor], th[bgcolor], tr[bgcolor] { background-color: var(--color-surface) !important; }
  td[bgcolor="white"], tr[bgcolor="white"] { background-color: var(--color-surface) !important; }
  td[bgcolor="lightgrey"], tr[bgcolor="lightgrey"] { background-color: var(--color-surface-tint) !important; }

  .modal-content {
    background-color: var(--color-surface);
    color: var(--text-body);
  }
  .modal-header, .modal-footer { border-color: var(--gray-300); }

  /* DataTables (test-projects.php drill-down, etc.) ships its own CSS with
     hardcoded light-mode colors for the search box label and pager. */
  .dataTables_wrapper .dataTables_filter label,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_length label {
    color: var(--text-body);
  }
  .dataTables_wrapper .paginate_button {
    color: var(--text-body) !important;
  }
  .dataTables_wrapper .paginate_button.disabled,
  .dataTables_wrapper .paginate_button.disabled:hover {
    color: var(--text-caption) !important;
  }
  .dataTables_wrapper .paginate_button.current,
  .dataTables_wrapper .paginate_button.current:hover {
    background: var(--cfhc-teal) !important;
    border-color: var(--cfhc-teal) !important;
    color: #fff !important;
  }
  .dataTables_wrapper .paginate_button:hover {
    background: var(--color-surface-tint) !important;
    border-color: var(--gray-300) !important;
    color: var(--text-body) !important;
  }

  .dropdown-menu {
    background-color: var(--color-surface);
    border-color: var(--gray-300);
    color: var(--text-body);
  }
  .dropdown-item { color: var(--text-body); }
  .dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--color-surface-tint);
    color: var(--text-body);
  }

  /* select2-bootstrap-5-theme (loaded from a CDN on pages that use
     theme:'bootstrap-5' in their .select2() init, e.g. intake-java.inc's
     client/attorney/paralegal pickers) is a separate stylesheet built on
     standard Bootstrap --bs-* variables, not this app's --cui-*/--color-*
     tokens, so none of the overrides above reach it. The plain
     .select2-container--default rules elsewhere in crm-shell.css are a
     different theme variant and don't match these elements either. */
  .select2-container--bootstrap-5 .select2-selection__rendered {
    color: var(--text-body) !important;
  }
  .select2-container--bootstrap-5 .select2-selection__placeholder {
    color: var(--text-caption) !important;
  }
  .select2-container--bootstrap-5 .select2-selection__clear {
    color: var(--text-caption) !important;
  }
  .select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--color-surface) !important;
    border-color: var(--gray-300) !important;
    color: var(--text-body) !important;
  }
  .select2-container--bootstrap-5 .select2-search__field {
    background-color: var(--color-surface-tint) !important;
    border-color: var(--gray-300) !important;
    color: var(--text-body) !important;
  }
  .select2-container--bootstrap-5 .select2-results__option {
    background-color: var(--color-surface) !important;
    color: var(--text-body) !important;
  }
  .select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--cfhc-teal-tint) !important;
    color: var(--text-body) !important;
  }
  .select2-container--bootstrap-5 .select2-results__option--selected {
    background-color: var(--color-surface-tint) !important;
  }
}
/* Written as a standalone (non-nested) rule -- for reasons unclear, Chrome's
   CSS-nesting parser silently drops this exact selector (base
   .select2-selection, no __suffix) when nested inside the
   :root[data-theme="dark"] block above, even though every other selector of
   the same shape (.select2-selection__rendered etc., right next to it)
   nests and applies fine. Confirmed via document.styleSheets: nested, this
   rule never showed up in the parsed CSSOM at all. Not worth chasing further
   given nesting isn't required here -- the explicit selector works. */
:root[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
  background-color: var(--color-surface-tint) !important;
  border-color: var(--gray-300) !important;
  color: var(--text-body) !important;
}

/* Shared box for the "Holidays in this period" <details> JS builds as an
   HTML string on reports-hours.php and reports-kpi.php (identical markup,
   copy-pasted between the two) -- was inline-styled with a hardcoded light
   background and no explicit text color, which read as white-on-white in
   dark mode. */
.holiday-list-box {
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 6px 10px;
  background: var(--color-surface-tint);
  color: var(--text-body);
}
.holiday-list-box th, .holiday-list-box td { border-bottom-color: var(--gray-300) !important; }

/* Text size: default (unset) = browser default (16px). Scales every
   rem-based token (--fs-*, and anything sized in rem) proportionally. */
html[data-fontsize="sm"] { font-size: 15px; }
html[data-fontsize="lg"] { font-size: 18px; }

/* Small text reads noticeably smaller on a phone screen than the same rem
   value does on a desktop monitor -- bump every size tier up 1px on mobile
   widths, on top of whichever Font_size preference is already in effect,
   same breakpoint the rest of the app's mobile layout switches at. */
@media (max-width: 768px) {
  html:not([data-fontsize]) { font-size: 17px; }
  html[data-fontsize="sm"]  { font-size: 16px; }
  html[data-fontsize="lg"]  { font-size: 19px; }
}

/* Density: tightens the shared spacing scale, so every component built on
   var(--space-*) (card padding, table cells, form gaps, nav rows) gets more
   compact automatically -- no per-component overrides needed. */
:root[data-density="compact"] {
  --space-2:  6px;
  --space-3:  9px;
  --space-4:  12px;
  --space-5:  15px;
  --space-6:  18px;
}

/* ---- Base element styles ---- */
.cfhc-root, body.cfhc {
  margin: 0;
  background: var(--color-bg);
  color: var(--text-default);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.cfhc h1, .cfhc h2, .cfhc h3, .cfhc-root h1, .cfhc-root h2, .cfhc-root h3 {
  font-family: var(--font-display);
  color: var(--text-heading);
  line-height: var(--lh-tight);
  margin: 0 0 var(--space-4);
  font-weight: var(--fw-bold);
  text-wrap: balance;
}
.cfhc h1, .cfhc-root h1 { font-size: var(--fs-chapter); }
.cfhc h2, .cfhc-root h2 { font-size: var(--fs-section); }
.cfhc h4, .cfhc-root h4 {
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-subhead);
  color: var(--text-subhead);
  margin: 0 0 var(--space-2);
}
.cfhc p, .cfhc-root p { margin: 0 0 var(--space-4); text-wrap: pretty; }
.cfhc a, .cfhc-root a {
  color: var(--text-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}
.cfhc a:hover, .cfhc-root a:hover { color: var(--teal-press); }
.cfhc small, .cfhc-root small { font-size: var(--fs-caption); color: var(--text-caption); }

/* ---- Interaction states ---- */
.cfhc-btn { -webkit-tap-highlight-color: transparent; }
.cfhc-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.cfhc-btn:not(:disabled):active { transform: translateY(1px); }
.cfhc-btn--primary:not(:disabled):hover { background: var(--teal-hover) !important; border-color: var(--teal-hover) !important; }
.cfhc-btn--primary:not(:disabled):active { background: var(--teal-press) !important; border-color: var(--teal-press) !important; }
.cfhc-btn--navy:not(:disabled):hover { background: var(--navy-hover) !important; border-color: var(--navy-hover) !important; }
.cfhc-btn--accent:not(:disabled):hover { background: var(--yellow-hover) !important; border-color: var(--yellow-hover) !important; }
.cfhc-btn--outline:not(:disabled):hover { background: var(--cfhc-navy) !important; color: #fff !important; }
.cfhc-btn--ghost:not(:disabled):hover { background: var(--cfhc-teal-tint) !important; }
.cfhc-link { color: var(--text-link); text-decoration: underline; text-underline-offset: 2px; transition: color var(--transition-fast); }
.cfhc-link:hover { color: var(--teal-press); }
.cfhc-card--interactive { transition: box-shadow var(--transition-base), transform var(--transition-base); cursor: pointer; }
.cfhc-card--interactive:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cfhc-input:focus { outline: none; border-color: var(--cfhc-teal) !important; box-shadow: var(--shadow-focus); }
.cfhc-tab { transition: color var(--transition-fast), border-color var(--transition-fast); }
.cfhc-tab:hover { color: var(--cfhc-teal); }
