/* compliance/style.css — page-specific styling. Header chrome and buttons
 * come from /app.css; only layout + table specifics live here. */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 18px 64px;
}

main h2 {
  font-family: "Playfair Display", serif;
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 12px;
}

/* Heading row: <h2> on the left, optional resource chip on the right.
 * Inherits the h2's bottom margin via the wrapper so the row sits at
 * the same vertical position as a bare <h2>. */
.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.section-heading-row h2 {
  margin: 0;
}

.manual-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--white);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.manual-chip:hover,
.manual-chip:focus-visible {
  background: var(--cream);
  border-color: var(--earth);
}

.manual-chip-glyph {
  opacity: 0.65;
  font-size: 11px;
}

.section-help {
  font-size: 13px;
  color: var(--text);
  opacity: 0.72;
  margin: 0 0 14px;
  line-height: 1.45;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text);
  opacity: 0.72;
  font-size: 14px;
}

/* ── CARDS ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 22px;
}

/* ── DASHBOARD TABLE ─────────────────────────────────────────────────────── */

.standards-legend {
  font-size: 12px;
  color: var(--text);
  opacity: 0.72;
  margin: 0 0 8px;
}

.std-mandatory-marker {
  color: var(--earth);
  font-weight: 600;
}

.standards-table {
  width: 100%;
  border-collapse: collapse;
}

.standards-table th,
.standards-table td {
  padding: 3px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.standards-table th {
  background: var(--cream);
  font-weight: 600;
  font-size: 13px;
}

.standards-table td.std-id {
  font-family: "Source Sans 3", sans-serif;
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}

.std-id-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.std-id-text {
  margin-left: auto;
}

.standards-table th.std-id-header {
  text-align: right;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge.ok {
  background: var(--green-light);
  color: var(--green);
}
.badge.warn {
  background: var(--cream-dark);
  color: var(--earth);
}
.badge.bad {
  background: var(--red-light);
  color: var(--red);
}

/* ── EXPANDABLE ROWS ─────────────────────────────────────────────────────── */
/* Pattern from web/audit/app.js. Whole row is a button; clicking
 * anywhere in the row toggles the paired hidden detail row beneath.
 * tabindex makes it focusable; :focus-visible shows a subtle outline.
 * A12's row is NOT a .report-row — it has no whole-row click handler;
 * only its sub-line buttons trigger expansion. */

.report-row {
  cursor: pointer;
  transition: background-color 120ms ease;
}

.report-row:hover {
  background: var(--cream);
}

.report-row:focus-visible {
  outline: 2px solid var(--sky-light);
  outline-offset: -2px;
}

.report-row-expanded,
.report-row-expanded:hover {
  background: var(--cream-dark);
}

.report-detail-row > td {
  background: var(--cream);
  padding: 14px 16px;
  border-bottom: 2px solid var(--border);
}

/* ── A12 HIERARCHICAL ROWS ───────────────────────────────────────────────── */
/* A12 renders as a 3-row group: a non-clickable header row carrying
 * the id + title, then two indented sub-rows (Riders, Volunteers)
 * that each behave like .report-row (click delegation finds
 * [data-report-key] on the <tr>). Internal borders are suppressed so
 * the group reads as one block; only the last sub-row keeps the
 * standard row-bottom border. Freshness uses the same .badge ok/warn/
 * bad chips as the other status columns — no special A12 styling. */

.a12-header-row > td {
  border-bottom: none;
}

.a12-subrow > td {
  border-bottom: none;
}

.a12-subrow-last > td {
  border-bottom: 1px solid var(--border);
}

.a12-sub-label {
  padding-left: 32px;
  font-weight: 600;
}

/* ── REPORT PANEL ────────────────────────────────────────────────────────── */
/* Panel chrome is built once when the row first opens; toolbar
 * (date inputs + PDF button) lives across refetches, body re-renders
 * on each fetch. */

.report-panel-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.report-range {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin: 0;
}

.report-range label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.report-range input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: "Source Sans 3", sans-serif;
  font-size: 14px;
  background: var(--white);
  color: var(--text);
}

.report-panel-body {
  margin-top: 4px;
}

.report-panel-body table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 14px;
}

.report-panel-body th,
.report-panel-body td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.report-panel-body th {
  background: var(--cream);
  font-weight: 600;
  font-size: 13px;
}

.a12-table th:first-child,
.a12-table td:first-child {
  width: 1%;
  white-space: nowrap;
  padding-right: 32px;
}

.eqm5-table th:first-child,
.eqm5-table td:first-child {
  width: 1%;
  white-space: nowrap;
  padding-right: 100px;
  min-width: 165px;
}

.eqm5-table th:nth-child(2),
.eqm5-table td:nth-child(2) {
  width: 1%;
  white-space: nowrap;
  padding-right: 100px;
}

/* EQM6 — all columns center-aligned except Horse name (col 1). */
.eqm6-table th:not(:first-child),
.eqm6-table td:not(:first-child) {
  text-align: center;
}

.report-panel-body .day {
  margin-bottom: 16px;
}

.report-panel-body .day h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.report-panel-body .violation {
  color: var(--red);
  font-weight: 600;
}

.report-panel-body tr.violation td {
  background: var(--red-light);
}

.report-panel-body .missing {
  color: var(--red);
  font-style: italic;
}

.report-panel-body .muted {
  color: var(--text);
  opacity: 0.6;
  font-size: 13px;
}

.report-panel-body .error {
  color: var(--red);
  font-size: 13px;
}

/* ── A14 panel (signed-waiver roster) ────────────────────────────────────
 * Three population sections (riders, volunteers, staff) stacked
 * vertically. Each section has a heading, a one-line summary, and
 * two name groups (signed / missing). The "missing" group's heading
 * gets a red color so an inspector skimming the panel can see at a
 * glance where the gaps are; the names themselves stay neutral
 * (boldening every missing name would just be noise). */

.a14-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.a14-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.a14-section-heading {
  font-family: "Playfair Display", serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.a14-section-summary {
  font-size: 13px;
  margin: 0 0 10px;
  color: var(--text);
}

.a14-missing-count {
  color: var(--red);
  font-weight: 600;
}

/* Expired is also red (the dashboard rolls expired + missing into the
   same red band) but the group below distinguishes it with a softer
   amber band — staff need to tell "needs re-signing" from "never
   collected" at a glance. */
.a14-expired-count {
  color: #b86700;
  font-weight: 600;
}

.a14-name-group {
  margin: 8px 0;
}

.a14-name-group-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  opacity: 0.75;
  margin-bottom: 4px;
}

.a14-name-group-missing .a14-name-group-label {
  color: var(--red);
  opacity: 1;
}

.a14-name-group-expired .a14-name-group-label {
  color: #b86700;
  opacity: 1;
}

/* "signed 2026-07-15" muted helper next to each current/expired name. */
.a14-name-date {
  color: var(--text);
  opacity: 0.55;
  font-size: 11px;
  margin-left: 4px;
}

.a14-name-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px 14px;
  font-size: 13px;
}

.a14-name-list li {
  padding: 2px 0;
}

.a14-name-empty {
  font-size: 13px;
  font-style: italic;
  color: var(--text);
  opacity: 0.6;
}

@media (max-width: 600px) {
  main {
    padding: 12px 12px 64px;
  }
  .card {
    padding: 14px 14px;
  }

  /* ── MOBILE TABLES ─────────────────────────────────────────────────────
   * The standards table and the report-panel tables are wider than a
   * phone viewport at default styling. Two changes make them fit:
   *   1. Relax fixed widths and `white-space: nowrap` rules that pin
   *      columns to their content width.
   *   2. Allow status badges to wrap (the global .badge has `white-space:
   *      nowrap` so labels like "1 staff with current cert" stay on one
   *      line; on phones that single line is wider than the viewport).
   * As a safety net, `.table-wrap` permits horizontal scroll if a future
   * table still overflows. */

  main .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .standards-table th,
  .standards-table td {
    padding: 8px 8px;
    font-size: 13px;
  }
  .standards-table th {
    font-size: 12px;
  }

  .report-panel-body th,
  .report-panel-body td {
    padding: 6px 6px;
    font-size: 13px;
  }

  /* Drop the desktop fixed-width / nowrap rules on report-panel tables —
   * those pad-right values (32px / 100px) push tables far past phone
   * width. */
  .a12-table th:first-child,
  .a12-table td:first-child,
  .eqm5-table th:first-child,
  .eqm5-table td:first-child,
  .eqm5-table th:nth-child(2),
  .eqm5-table td:nth-child(2) {
    width: auto;
    min-width: 0;
    white-space: normal;
    padding-right: 6px;
  }

  /* Allow badge labels to wrap so long status strings flow onto a
   * second line instead of pushing the Status column wider than the
   * viewport. */
  .standards-table .badge,
  .report-panel-body .badge {
    white-space: normal;
    line-height: 1.35;
  }

  .report-panel-toolbar {
    gap: 8px;
  }
}
