'use client' import { useCallback, useSyncExternalStore } from 'react' // Hydration-safe media query (house pattern, see sidebar's section store): // the server snapshot is always `false` so SSR markup matches the desktop // default; after hydration the real viewport decides. Components use it to // swap whole layouts (table vs cards, rail vs master-detail) rather than // duplicating both in the DOM — duplicate hidden markup breaks Playwright // strict-mode text locators in the browser suites. export function useMediaQuery(query: string): boolean { const subscribe = useCallback((onChange: () => void) => { const mql = window.matchMedia(query) mql.addEventListener('change', onChange) return () => mql.removeEventListener('change', onChange) }, [query]) const getSnapshot = useCallback(() => window.matchMedia(query).matches, [query]) const getServerSnapshot = useCallback(() => false, []) return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) } // The app's mobile breakpoint: below Tailwind `sm` (640px) surfaces swap to // phone layouts; the navigation drawer breakpoint is `lg` (see app-shell). export function useIsMobile(): boolean { return useMediaQuery('(max-width: 639px)') }