/* ==========================================================================
   QA / Regression area styles — floating button + test-case component.
   Reuses the --sun-* brand tokens defined in extra.css (does NOT redefine them).
   Component blocks: .qa-footer-entry, .qa-case, .qa-checklist, .qa-tools.
   ========================================================================== */

/* ---------- QA entry link (in the footer "Made with Material for MkDocs" bar) ----------
   Injected by javascripts/qa-gate.js into .md-footer-meta__inner on every page. Replaces
   an earlier floating button (which collided with the results toolbar). The footer meta
   bar is dark in both light and dark mode, so white text + a translucent border reads on
   both. `margin-left: auto` right-aligns it within the flex footer row. */
.qa-footer-entry {
  margin-left: auto;
  align-self: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 14px;
  background: transparent;
  color: var(--sun-white);
  font-family: var(--sun-font-text);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 12px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, background-color 0.15s, border-color 0.15s;
}
.qa-footer-entry:hover,
.qa-footer-entry:focus-visible {
  opacity: 1;
  background: var(--sun-red);
  border-color: var(--sun-red);
  outline: none;
}

/* ---------- Test-case block ----------
   Usage (raw HTML inside markdown, md_in_html enabled):
   <div class="qa-case" id="TC-RO-01" markdown>
   #### TC-RO-01 — Create a Repair Order
   <p class="qa-case-meta"><strong>Precondition / test data:</strong> …</p>
   Steps:
   1. …
   <p class="qa-expected"><strong>Expected result:</strong> …</p>
   <p class="qa-result">☐ PASS &nbsp; ☐ FAIL &nbsp; Notes: __________</p>
   </div>
*/
.qa-case {
  border: 1px solid var(--sun-grey-light);
  border-left: 4px solid var(--sun-red);
  border-radius: 6px;
  padding: 0.6rem 1rem 0.8rem;
  margin: 1.1rem 0;
  background: var(--sun-white);
}
.md-typeset .qa-case > :first-child {
  margin-top: 0.2rem;
}
.md-typeset .qa-case h4 {
  font-family: var(--sun-font-code);
  font-weight: 700;
  letter-spacing: 0;
}
.md-typeset .qa-case-meta {
  font-size: 0.82rem;
  color: var(--sun-grey-dark);
  margin: 0.2rem 0 0.5rem;
}
.md-typeset .qa-expected {
  background: var(--sun-red-tint);
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  margin: 0.5rem 0;
}
.md-typeset .qa-result {
  font-family: var(--sun-font-code);
  font-size: 0.85rem;
  color: var(--sun-black);
  border-top: 1px dashed var(--sun-grey-light);
  padding-top: 0.5rem;
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.md-typeset .qa-result-label {
  font-weight: 700;
  color: var(--sun-grey-dark);
}

/* Segmented PASS / FAIL toggle (interactive, set by qa-results.js) */
.qa-seg {
  display: inline-flex;
  border: 1px solid var(--sun-grey-medium);
  border-radius: 4px;
  overflow: hidden;
}
.qa-seg-btn {
  border: none;
  background: transparent;
  color: var(--sun-grey-dark);
  font-family: var(--sun-font-text);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  padding: 4px 14px;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}
.qa-seg-btn + .qa-seg-btn {
  border-left: 1px solid var(--sun-grey-medium);
}
.qa-seg-btn:hover {
  background: var(--sun-grey-light);
}
.qa-seg-pass.is-active {
  background: var(--sun-green);
  color: var(--sun-white);
}
.qa-seg-fail.is-active {
  background: var(--sun-red);
  color: var(--sun-white);
}
.qa-notes {
  flex: 1 1 240px;
  min-width: 160px;
  font-family: var(--sun-font-text);
  font-size: 0.82rem;
  padding: 5px 8px;
  border: 1px solid var(--sun-grey-light);
  border-radius: 4px;
  background: var(--sun-white);
  color: var(--sun-black);
}
.qa-notes:focus {
  outline: none;
  border-color: var(--sun-red);
}

/* Fixed results toolbar (QA pages only) */
.qa-tools {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 24px;
  background: var(--sun-black);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}
.qa-progress {
  color: var(--sun-white);
  font-family: var(--sun-font-code);
  font-size: 0.72rem;
  padding: 0 4px;
  white-space: nowrap;
}
.qa-tools-btn {
  border: none;
  border-radius: 16px;
  background: var(--sun-red);
  color: var(--sun-white);
  font-family: var(--sun-font-text);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.4;
  transition: background-color 0.12s;
}
.qa-tools-btn:hover {
  background: var(--sun-red-dark);
}
/* QA Home is a link (<a>) styled as a button; keep it neutral so Export stays primary. */
.qa-tools-home,
.qa-tools-home:visited {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: var(--sun-white);
}
.qa-tools-home:hover {
  background: rgba(255, 255, 255, 0.14);
}
.qa-tools-clear {
  background: var(--sun-grey-dark);
}
.qa-tools-clear:hover {
  background: var(--sun-gray);
}

/* Dark mode for the interactive bits */
[data-md-color-scheme="slate"] .md-typeset .qa-notes {
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  border-color: var(--md-default-fg-color--lightest);
}
[data-md-color-scheme="slate"] .qa-seg {
  border-color: var(--md-default-fg-color--lighter);
}
[data-md-color-scheme="slate"] .qa-seg-btn + .qa-seg-btn {
  border-left-color: var(--md-default-fg-color--lighter);
}
[data-md-color-scheme="slate"] .qa-seg-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Dark mode */
[data-md-color-scheme="slate"] .qa-case {
  background: var(--md-default-bg-color);
  border-color: var(--md-default-fg-color--lightest);
  border-left-color: var(--sun-red);
}
[data-md-color-scheme="slate"] .md-typeset .qa-case-meta {
  color: var(--md-default-fg-color--light);
}
[data-md-color-scheme="slate"] .md-typeset .qa-expected {
  background: rgba(232, 163, 164, 0.12);
}
[data-md-color-scheme="slate"] .md-typeset .qa-result {
  color: var(--md-default-fg-color);
  border-top-color: var(--md-default-fg-color--lightest);
}

/* ---------- Master checklist ----------
   A plain markdown table works; this just tightens it and colours the status column. */
.md-typeset .qa-checklist table {
  font-size: 0.85rem;
}
.md-typeset .qa-checklist td:first-child {
  font-family: var(--sun-font-code);
  white-space: nowrap;
}
/* Result cell reflects stored Pass/Fail (set by qa-results.js syncChecklist) */
.md-typeset .qa-checklist td:last-child {
  text-align: center;
  font-size: 1rem;
  width: 4rem;
}
.md-typeset .qa-checklist td.qa-cell-pass {
  color: var(--sun-green);
}
.md-typeset .qa-checklist td.qa-cell-fail {
  color: var(--sun-red);
}

/* Print: expand everything, drop the floating button and chrome. */
@media print {
  .qa-footer-entry,
  .qa-tools {
    display: none;
  }
  .qa-case {
    break-inside: avoid;
  }
  /* Keep the notes text visible on paper */
  .qa-notes {
    border: none;
    padding-left: 0;
  }
}
