/* ============================================================
   RABIES SURVEILLANCE — DASHBOARD CHART/TABLE
   Author: Roberto Flores
   Organization: Los Angeles County Department of Public Health

   Monthly: clearly separated reporting-period cards, four columns
   on wide containers, two on tablets, one on small phones.
   Annual: retains the conventional table.
   Load AFTER the shared rabies view/table styles.
   ============================================================ */

/* 01 — Dashboard controls and visibility */
#rabid-graph .rb-dashboard-view-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 1rem 0;
}

#rabid-graph .rb-dashboard-chart-view[hidden],
#rabid-graph .rb-dashboard-table-panel[hidden] {
  display: none !important;
}

#rabid-graph .rb-dashboard-table-panel {
  min-width: 0;
  max-width: 100%;
  container-type: inline-size;
}

#rabid-graph .rb-dashboard-table-controls {
  margin: 0 0 1rem;
}

#rabid-graph .rb-dashboard-data-table :is(th, td) {
  vertical-align: top;
  overflow-wrap: anywhere;
}

#rabid-graph .rb-dashboard-table-panel[data-period="year"] .rb-dashboard-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

#rabid-graph .rb-dashboard-table-controls .rb-table-clear-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* 02 — PDF export and record summary */
#rabid-graph .rb-dashboard-table-panel .rb-table-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  width: 100%;
  margin: 0 0 1rem;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-results-header .rb-table-export-actions {
  margin: 0;
}

#rabid-graph .rb-dashboard-table-panel .rb-dashboard-table-summary {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 0 auto;
  padding: .25rem 1rem;
  border: 1px solid #b9d6e7;
  border-left: 4px solid #005a9c;
  border-right: 4px solid #005a9c;
  border-radius: 8px;
  background: #eef6fc;
  color: #103e65;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.5;
}

#rabid-graph .rb-dashboard-table-panel .rb-dashboard-table-summary::before {
  content: "\f0ce";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: #005a9c;
  flex-shrink: 0;
}

/* 03 — Monthly-only record cards */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
}

/* Preserve accessible column headings and caption in DOM. */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.35rem;
  width: 100%;
}

/* Each month is a distinct card with a visible outer boundary. */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #b8cfdf;
  border-left: 5px solid #005a9c;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(6, 28, 96, .11);
  transition: box-shadow .18s ease, border-color .18s ease;
}

/* Alternating accent maintains clear separation between months. */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr:nth-child(even) {
  border-left-color: #007c8a;
}

#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr:hover,
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr:focus-within {
  border-color: #005a9c;
  box-shadow: 0 5px 18px rgba(6, 28, 96, .16);
}

/* Override shared striped-row rules: cells remain visually consistent. */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr> :is(th, td) {
  box-sizing: border-box;
  display: block;
  width: auto;
  min-width: 0;
  padding: 1rem .95rem;
  margin: 0;
  border: 0;
  border-top: 1px solid #dce8f0;
  border-right: 1px solid #dce8f0;
  border-radius: 0;
  background: #fff;
  color: #18364a;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
  white-space: normal;
}

#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr> :is(th, td)::before {
  content: attr(data-label);
  display: block;
  margin-bottom: .5rem;
  color: #005a9c;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.4;
}

/* Month is a full-width, high-contrast card heading. */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr>th[scope="row"] {
  grid-column: 1 / -1;
  padding: .85rem 1rem;
  border: 0;
  background: #e2eff8;
  color: #061c60 !important;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.4;
}

#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr:nth-child(even)>th[scope="row"] {
  background: #e4f4f4;
}

#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr>th[scope="row"]::before {
  margin-bottom: .1rem;
  color: #335d78;
  font-size: .72rem;
}

/* Notes form full-width secondary sections, distinct from numeric data. */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr>[data-label$=" Notes"] {
  grid-column: 1 / -1;
  padding: .85rem 1rem;
  border-top: 1px solid #cbdde9;
  border-right: 0;
  background: #f3f8fb;
  color: #314b60;
  font-size: .875rem;
  font-weight: 400;
}

#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr>[data-label$=" Notes"]::before {
  color: #245470;
}

/* Four data cells follow the month header; remove right-edge dividers. */
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr> :is(th, td):nth-child(4n + 1),
#rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr> :is(th, td):last-child {
  border-right: 0;
}

/* 04 — Tablet: two columns per reporting month */
@container (max-width: 800px) {
  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr>td:not([data-label$=" Notes"]) {
    border-right: 1px solid #dce8f0;
  }

  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr> :is(th, td):nth-child(2n + 1),
  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr>[data-label$=" Notes"] {
    border-right: 0;
  }
}

/* 05 — Small phones: single-column monthly cards */
@container (max-width: 440px) {
  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr {
    grid-template-columns: minmax(0, 1fr);
  }

  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr> :is(th, td) {
    border-right: 0;
    padding: .8rem .9rem;
  }

  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr>th[scope="row"] {
    font-size: 1.1rem;
  }
}

/* 06 — Small screen controls and results row */
@media (max-width: 550px) {
  #rabid-graph .rb-dashboard-table-panel .rb-table-results-header {
    flex-direction: column;
    align-items: stretch;
  }

  #rabid-graph .rb-dashboard-table-panel .rb-table-results-header .rb-table-export-actions,
  #rabid-graph .rb-dashboard-table-panel .rb-table-results-header .rb-table-export-btn,
  #rabid-graph .rb-dashboard-table-panel .rb-table-results-header .rb-dashboard-table-summary {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  #rabid-graph .rb-dashboard-table-panel .rb-dashboard-table-summary {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  #rabid-graph .rb-dashboard-view-toggle {
    width: 100%;
    justify-content: stretch;
  }

  #rabid-graph .rb-dashboard-view-toggle .rb-view-button {
    flex: 1 1 0;
    min-width: 0;
  }

  #rabid-graph .rb-dashboard-table-controls .rb-table-clear-btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr {
    transition: none;
  }
}

/* 07 — Additional WCAG keyboard focus, contrast and responsive safeguards
   These preserve the existing monthly visual cards. The companion JS
   explicitly reinforces the table/row/cell accessibility relationships. */
#rabid-graph .rb-dashboard-table-panel :is(button, input, select, .rb-dashboard-table-scroll):focus-visible,
#rabid-graph .rb-dashboard-view-toggle .rb-view-button:focus-visible {
  outline: 3px solid #823600;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px #ffffff;
  position: relative;
  z-index: 2;
}

#rabid-graph .rb-dashboard-table-panel .rb-dashboard-table-scroll:focus-visible {
  outline-offset: -3px;
  /* prevents clipping at the scroll viewport edge */
  box-shadow: inset 0 0 0 2px #ffffff;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-scroll-instructions {
  margin: .35rem 0 .6rem;
  color: #314b60;
  font-size: .875rem;
  line-height: 1.5;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-scroll-instructions[hidden] {
  display: none !important;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-page-btn:not(:disabled) {
  border: 2px solid #526b80;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-page-btn:not(:disabled):hover {
  border-color: #005a9c;
}

#rabid-graph .rb-dashboard-table-panel :is(.rb-table-field, .rb-table-controls) {
  min-width: 0;
}

#rabid-graph .rb-dashboard-table-panel :is(input, select) {
  max-width: 100%;
  margin-bottom: 0.5rem;
}

@media (max-width: 400px) {
  #rabid-graph .rb-dashboard-table-panel .rb-table-pagination {
    flex-wrap: wrap;
    max-width: 100%;
    gap: .35rem;
  }

  #rabid-graph .rb-dashboard-table-panel .rb-table-page-btn {
    min-width: 40px;
    min-height: 44px;
  }
}

@media (forced-colors: active) {

  #rabid-graph .rb-dashboard-table-panel :is(button, input, select, .rb-dashboard-table-scroll):focus-visible,
  #rabid-graph .rb-dashboard-view-toggle .rb-view-button:focus-visible {
    outline-color: Highlight;
    box-shadow: none;
  }

  #rabid-graph .rb-dashboard-table-panel[data-period="month"] .rb-dashboard-data-table tbody tr {
    border-color: CanvasText;
  }
}


/* ============================================================
   08 — DASHBOARD TABLE SEARCH FEEDBACK AND FILTER ALIGNMENT
   Keep every control top-aligned when inline messages appear.
   Scoped to the Dashboard Table; Map Table styles are unchanged.
   ============================================================ */

#rabid-graph .rb-dashboard-table-panel .rb-dashboard-table-controls {
  align-items: start;
}

#rabid-graph .rb-dashboard-table-panel .rb-dashboard-table-controls .rb-table-field {
  align-self: start;
  min-width: 0;
  max-width: 100%;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-search-feedback:not([hidden]) {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: .3rem 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a12622;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-search-feedback[hidden] {
  display: none !important;
}


/* ============================================================
   09 — WCAG INLINE SEARCH FEEDBACK / REFLOW
   ============================================================ */
#rabid-graph .rb-dashboard-table-panel .rb-dashboard-table-controls {
  align-items: start;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-field {
  align-self: start;
  min-width: 0;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-search-feedback:not([hidden]) {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: .3rem 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #812500;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#rabid-graph .rb-dashboard-table-panel .rb-table-search-feedback[hidden] {
  display: none !important;
}  