/* ═════════════════════════════════════════════════════════════════════════════
   Task #1386480: Crisp Chat Widget Contrast Fix
   Date: May 5, 2026

   Root cause: Broad selectors in contrast-fix-1385782.css (and others) bleed
   into the Crisp chat widget's parent-DOM elements, overriding Crisp's native
   colors with site-wide contrast rules. This causes low-contrast text in the
   chat launcher, chat bubbles, input field, and tooltips.

   Fix: Reset ALL Crisp-owned DOM elements to their native styles using high-
   specificity selectors that override the broad !important rules. This file
   MUST be loaded AFTER all contrast-fix CSS files in layout-head.ejs.

   Scope: Only affects elements inside .crisp-client / #crisp-chatbox containers.
   Does NOT touch any other site elements.
═════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   1. UNIVERSAL RESET — Undo all inherited site-wide overrides inside Crisp
────────────────────────────────────────────────────────────────────────────── */

/* Reset color, background, outline, border, font-weight overrides from broad
   selectors like `a { color: !important }`, `button { }`, `label { }`, etc. */
.crisp-client *,
.crisp-client *::before,
.crisp-client *::after,
#crisp-chatbox *,
#crisp-chatbox *::before,
#crisp-chatbox *::after,
[data-id*="crisp"] *,
[data-id*="crisp"] *::before,
[data-id*="crisp"] *::after {
  color: revert !important;
  background-color: revert !important;
  background: revert !important;
  border-color: revert !important;
  outline: revert !important;
  outline-offset: revert !important;
  font-weight: revert !important;
  opacity: revert !important;
  fill: revert !important;
  -webkit-text-fill-color: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. LINKS — Undo `a:not(...) { color: #1e40af !important }` from contrast fix
────────────────────────────────────────────────────────────────────────────── */
.crisp-client a,
.crisp-client a:link,
.crisp-client a:visited,
.crisp-client a:hover,
.crisp-client a:active,
.crisp-client a:focus,
#crisp-chatbox a,
#crisp-chatbox a:link,
#crisp-chatbox a:visited,
#crisp-chatbox a:hover,
#crisp-chatbox a:active,
#crisp-chatbox a:focus {
  color: revert !important;
  outline: revert !important;
  outline-offset: revert !important;
  text-decoration: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   3. BUTTONS — Undo broad button/CTA styling
────────────────────────────────────────────────────────────────────────────── */
.crisp-client button,
.crisp-client [role="button"],
#crisp-chatbox button,
#crisp-chatbox [role="button"] {
  color: revert !important;
  background-color: revert !important;
  background: revert !important;
  border-color: revert !important;
  font-weight: revert !important;
  opacity: revert !important;
  fill: revert !important;
  -webkit-text-fill-color: revert !important;
  outline: revert !important;
  outline-offset: revert !important;
}

.crisp-client button:hover,
.crisp-client button:focus,
.crisp-client button:active,
#crisp-chatbox button:hover,
#crisp-chatbox button:focus,
#crisp-chatbox button:active {
  opacity: revert !important;
  outline: revert !important;
  outline-offset: revert !important;
  color: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. FORM INPUTS — Undo forced input/textarea color overrides
────────────────────────────────────────────────────────────────────────────── */
.crisp-client input,
.crisp-client select,
.crisp-client textarea,
#crisp-chatbox input,
#crisp-chatbox select,
#crisp-chatbox textarea {
  color: revert !important;
  border-color: revert !important;
  outline: revert !important;
  outline-offset: revert !important;
  background: revert !important;
  background-color: revert !important;
}

.crisp-client input::placeholder,
.crisp-client textarea::placeholder,
#crisp-chatbox input::placeholder,
#crisp-chatbox textarea::placeholder {
  color: revert !important;
  opacity: revert !important;
}

.crisp-client input:focus,
.crisp-client select:focus,
.crisp-client textarea:focus,
#crisp-chatbox input:focus,
#crisp-chatbox select:focus,
#crisp-chatbox textarea:focus {
  outline: revert !important;
  outline-offset: revert !important;
  border-color: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. LABELS — Undo `label, [class*="label"] { color: !important }` leak
────────────────────────────────────────────────────────────────────────────── */
.crisp-client label,
.crisp-client [class*="label"],
#crisp-chatbox label,
#crisp-chatbox [class*="label"] {
  color: revert !important;
  font-weight: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   6. FOCUS STATES — Undo universal `*:focus { outline: !important }` leak
────────────────────────────────────────────────────────────────────────────── */
.crisp-client *:focus,
.crisp-client *:focus-visible,
#crisp-chatbox *:focus,
#crisp-chatbox *:focus-visible {
  outline: revert !important;
  outline-offset: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   7. BADGES/ALERTS — Undo `[role="alert"], [class*="error"]` etc. leak
────────────────────────────────────────────────────────────────────────────── */
.crisp-client [role="alert"],
.crisp-client [class*="error"],
.crisp-client [class*="warning"],
.crisp-client [class*="alert"],
.crisp-client [class*="status"],
.crisp-client [class*="badge"],
#crisp-chatbox [role="alert"],
#crisp-chatbox [class*="error"],
#crisp-chatbox [class*="warning"],
#crisp-chatbox [class*="alert"],
#crisp-chatbox [class*="status"],
#crisp-chatbox [class*="badge"] {
  color: revert !important;
  background-color: revert !important;
  font-weight: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   8. SVG/ICONS — Undo fill overrides that break Crisp icons
────────────────────────────────────────────────────────────────────────────── */
.crisp-client svg,
.crisp-client svg *,
.crisp-client path,
.crisp-client circle,
.crisp-client rect,
#crisp-chatbox svg,
#crisp-chatbox svg *,
#crisp-chatbox path,
#crisp-chatbox circle,
#crisp-chatbox rect {
  fill: revert !important;
  color: revert !important;
  stroke: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   9. IMAGES — Undo any max-width/height overrides from mobile fixes
────────────────────────────────────────────────────────────────────────────── */
.crisp-client img,
.crisp-client video,
.crisp-client iframe,
#crisp-chatbox img,
#crisp-chatbox video,
#crisp-chatbox iframe {
  max-width: revert !important;
  height: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   10. NAVIGATION — Undo `nav a { min-height: 44px }` etc. from touch targets
────────────────────────────────────────────────────────────────────────────── */
.crisp-client nav,
.crisp-client nav a,
.crisp-client [role="navigation"],
#crisp-chatbox nav,
#crisp-chatbox nav a,
#crisp-chatbox [role="navigation"] {
  color: revert !important;
  min-height: revert !important;
  display: revert !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   11. POSITIONING — Preserve existing positioning rules (from qa-fixes)
   These are intentional and should NOT be reverted.
────────────────────────────────────────────────────────────────────────────── */
.crisp-client,
[class*="crisp-client"],
#crisp-chatbox,
[data-id*="crisp"] {
  position: fixed !important;
  bottom: 16px !important;
  right: 16px !important;
  left: auto !important;
  top: auto !important;
  max-width: 360px !important;
  z-index: 999990 !important;
}

@media (min-width: 1024px) {
  .crisp-client,
  [class*="crisp-client"],
  #crisp-chatbox {
    bottom: 24px !important;
    right: 24px !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   12. FONT SMOOTHING — Let Crisp use its own rendering
────────────────────────────────────────────────────────────────────────────── */
.crisp-client *,
#crisp-chatbox * {
  -webkit-font-smoothing: revert !important;
  -moz-osx-font-smoothing: revert !important;
}
