/*
 * Qualis Application Styles
 *
 * Design tokens and structural rules that Tailwind cannot express
 * via utility classes alone. The Tailwind theme in
 * app/assets/tailwind/application.css handles component styling.
 *
 * Google Fonts (Rubik) is loaded via CDN preconnect in the layout.
 */

/* ==========================================================================
   Design Tokens (CSS Custom Properties)
   ========================================================================== */

:root {
  /* Brand Colors — matched to dmeapp's Bootstrap palette */
  --q-color-primary: #428bca;
  --q-color-primary-dark: #3276b1;
  --q-color-success: #5cb85c;
  --q-color-danger: #d9534f;
  --q-color-warning: #f0ad4e;
  --q-color-info: #5bc0de;

  /* Typography */
  --q-font-family: "Rubik", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --q-font-size-base: 14px;
  --q-font-size-sm: 12px;
  --q-font-size-xs: 10px;
}

/* ==========================================================================
   Environment Indicators
   ==========================================================================

   QE-358: staging deliberately carries NO visual environment tint.

   Staging previously had a lavender body background so it was obvious at a
   glance which environment you were in. That was removed so staging renders
   identically to production, because the training materials (screenshots and
   videos) shown to external users ahead of the cutover are captured on
   staging, and a tinted background would not match what those users then see.

   `body_css_classes` still emits `environment-<env>` on the body for every
   non-production environment, so the hook is intact — reintroducing an
   indicator is a rule here, not a code change.

   Worth knowing: with the tint gone there is currently nothing in the UI that
   distinguishes staging from production. Once production is live, consider a
   less intrusive indicator that does not disturb a screenshot — a small
   corner ribbon, or a title-bar suffix.
   ========================================================================== */

/* ==========================================================================
   Print Styles
   ========================================================================== */

body.print {
  padding-top: 0;
}

body.print nav,
body.print footer {
  display: none;
}

/* Browser-native print (the "Print" button calls window.print()). dmeapp's
   Bootstrap print stylesheet stripped the page chrome so only the data table
   printed; mirror that so the ordered-items "Print" output is the breadcrumb
   + table rather than every filter form (parity QE-230). Elements opting out
   carry the +no-print+ class; the rich filter toolbars carry +filter+. */
@media print {
  nav,
  footer,
  .no-print,
  .filter {
    display: none !important;
  }

  /* QE-230 (E4): the sticky-header rule caps table wrappers at max-height:75vh
     with overflow:auto in @layer base, which is NOT media-scoped — so when the
     "Print" button fires window.print(), the printed table is clipped to 75vh
     and the remaining rows are cut off. Unclamp the wrapper for print so the
     FULL table renders across pages (the on-screen 75vh scroll box is unchanged). */
  .overflow-x-auto:has(> table) {
    max-height: none !important;
    overflow: visible !important;
  }

  .overflow-x-auto:has(> table) thead th {
    position: static !important;
  }
}

/* ==========================================================================
   Autocomplete dropdown (search filters: patient / team / vendor / invoice)
   dmeapp's typeahead drops a long list down the page; mirror that height so
   results aren't crammed into a short box (QE-195). The Stimulus controller
   appends <li>s; these rules style the menu and its rows regardless of whether
   Tailwind compiled the arbitrary utilities. The parent field div is
   position:relative, so the menu anchors to it.
   ========================================================================== */
.autocomplete-results {
  max-height: 75vh;
}

.autocomplete-results li:hover {
  background-color: var(--q-color-primary);
  color: #fff;
}

/* Matched-text highlight: bold purple, matching dmeapp's Bootstrap highlight
   (#6f42c1) rather than the blue accent / default yellow <mark> (QE-195). */
.autocomplete-results mark {
  background-color: transparent;
  color: #6f42c1;
  font-weight: 700;
}

/* Keep the highlight readable on the hovered (purple-bg) row. */
.autocomplete-results li:hover mark {
  color: #fff;
}

/* QE-440 item 10: the patient-name list reads on gray rather than white ("gray
   backgrounds instead of white, so easier to read"). QA turned down a purple
   surface as too much. No dropdown on the site has a gray surface today, so
   this uses the gray the site already uses most for panels and read-only
   fields: Tailwind gray-100 (#f3f4f6), class bg-gray-100. Rows keep the
   primary-colour hover and the bold purple match from .autocomplete-results
   above (restated here because the gray row rule outranks the hover). Unlayered,
   so it beats the white background that tailwind/application.css sets on
   [data-autocomplete-target="results"] inside @layer utilities. */
.autocomplete-results.autocomplete-results--gray,
.autocomplete-results.autocomplete-results--gray li {
  background-color: #f3f4f6;
}

.autocomplete-results.autocomplete-results--gray li {
  border-bottom-color: #e5e7eb;
}

.autocomplete-results.autocomplete-results--gray li:hover {
  background-color: var(--q-color-primary);
  color: #fff;
}
