/* Shared responsive rules for every page (loaded after the Tailwind CDN script).
   Phones are the target: nothing may force the page wider than the screen; wide tables scroll inside their own box. */

html, body { max-width: 100%; overflow-x: hidden; }
img, video { max-width: 100%; height: auto; }

/* Dialogs: taller than the screen -> the dialog area scrolls (centered when short, from the top when tall). */
div.fixed.inset-0:not(.pointer-events-none) { overflow-y: auto; align-items: flex-start !important; justify-content: flex-start !important; padding: .75rem; }
div.fixed.inset-0 > div { margin: auto; }
div.fixed.inset-0 > div { max-width: 100%; }

/* Wide tables always scroll sideways inside their own box instead of widening the page. */
div:has(> table) { overflow-x: auto !important; }

@media (max-width: 1023px) {
  main { padding: .75rem !important; }
  header.flex, main .flex.justify-between, div.fixed .flex.justify-between { flex-wrap: wrap; gap: .5rem; }
  header .flex.items-center, header .flex.gap-3 { flex-wrap: wrap; }
  header.px-6 { padding-left: 1rem; padding-right: 1rem; }
  .max-w-7xl { padding-left: .75rem; padding-right: .75rem; }

  /* search boxes and filters use the full width */
  main input[class*="w-72"], main input[class*="w-64"], main input[class*="w-80"], main input[class*="w-96"] { width: 100% !important; }
  main .flex.gap-2:has(> input[class*="w-"]) { width: 100%; }
  main .flex.gap-2 > input { flex: 1 1 10rem; min-width: 0; }

  main .flex.gap-2, main .flex.gap-3, main .flex.items-center.gap-2, main .flex.items-center.gap-3 { flex-wrap: wrap; }
  main select { max-width: 100%; }

}

@media (max-width: 767px) {
  /* tables keep a readable width and scroll */
  table { min-width: 36rem; }
  table td button, table td a { padding: .3rem .35rem; }

  /* 16px text in fields stops phones from zooming the page when a field is focused */
  input, select, textarea { font-size: 16px !important; }
  input[type="checkbox"], input[type="radio"] { font-size: inherit !important; }

  /* big headings */
  h1 { font-size: 1.125rem; }
}

/* forms inside dialogs: one column on small phones */
@media (max-width: 560px) {
  div.fixed .grid-cols-2, div.fixed .grid-cols-3, div.fixed .grid-cols-4 { grid-template-columns: minmax(0, 1fr) !important; }
  div.fixed .col-span-2, div.fixed .col-span-3 { grid-column: auto !important; }
  div.fixed.inset-0 > div { padding: 1rem !important; }
}
