/* Responsive overrides for CABRI BPP Dashboard
   Linked AFTER the inline <style> so these rules win at equal specificity. */

@media (max-width: 768px) {
  html, body { height: auto; }

  body {
    flex-direction: column;
    overflow: auto;
  }

  /* Sidebar becomes a stacked, collapsible-feeling panel on top. */
  #sidebar {
    width: 100%;
    max-height: 45vh;
    overflow-y: auto;
    flex-shrink: 0;
  }

  .sb-filter { margin-top: 12px; }
  .cpills { max-height: 80px; }

  /* Main column flows naturally and contributes to page scroll. */
  #main {
    width: 100%;
    overflow: visible;
    min-height: 0;
  }

  #topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    gap: 8px;
  }

  #search-box { width: 100%; order: 3; }
  .view-toggle { order: 2; }
  .tb-title { font-size: 15px; }

  #content {
    overflow: visible;
    padding: 16px 14px 40px;
  }

  /* Hero: stack and shrink. */
  .hero { padding: 20px 18px; gap: 12px; }
  .hero-title { font-size: 20px; }
  .hero-body { font-size: 13.5px; max-width: 100%; }
  .hero-stats { flex-wrap: wrap; gap: 14px; width: 100%; }
  .hstat-n { font-size: 30px; }

  /* Section header */
  .sec-title { font-size: 21px; }
  .sec-desc { font-size: 13.5px; }
  .stats-row { flex-wrap: wrap; }

  /* Tighter card grids on small screens. */
  .theme-grid { grid-template-columns: 1fr; gap: 9px; }
  .compare-grid { grid-template-columns: 1fr 1fr; }

  /* Chart bars: drop the fixed-width label/code columns so rows can breathe. */
  .bar-row { flex-wrap: wrap; }
  .bar-lbl {
    width: 100%;
    text-align: left;
    white-space: normal;
    overflow: visible;
  }
  .bar-codes {
    width: 100%;
    justify-content: flex-start;
  }
  .bar-main { width: 100%; }

  /* Question header: let actions wrap instead of clipping. */
  .q-header { flex-wrap: wrap; }
  .q-actions { margin-left: 0; margin-top: 6px; flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .compare-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 10px; }
  .hstat-n { font-size: 26px; }
  #sidebar { max-height: 40vh; }
}
