/* ============================================================
   Global Mobile Responsiveness â€” Internet Portal
   Include AFTER Tailwind CDN on every page.
   ============================================================ */

/* ---- Base mobile fixes ---- */
@media (max-width: 1023px) {

  /* --- Header --- */
  header .text-2xl { font-size: 1.25rem; }                /* Shrink page title */
  header .space-x-4 { gap: 0.5rem; }                      /* Tighten header controls */

  /* --- Tables: readable on phones --- */
  table { font-size: 0.75rem; }                            /* Smaller table text */
  table th { font-size: 0.65rem; padding: 0.4rem 0.5rem; white-space: nowrap; }
  table td { padding: 0.4rem 0.5rem; }
  table th:last-child,
  table td:last-child { position: sticky; right: 0; background: inherit; z-index: 1; }
  /* Sticky action column so Edit/Delete buttons are always reachable */

  /* Scroll hint: subtle gradient shadow on the right edge */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;        /* Smooth iOS momentum scroll */
    scrollbar-width: thin;                    /* Firefox thin scrollbar */
    position: relative;
  }
  .overflow-x-auto::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 24px;
    background: linear-gradient(to left, rgba(0,0,0,0.04), transparent);
    pointer-events: none;
    z-index: 2;
  }

  /* --- Modals: full-width on small screens --- */
  .fixed.inset-0 > div {                     /* Modal inner container */
    max-width: 100% !important;
    margin: 0.5rem;
    border-radius: 0.75rem;
  }

  /* --- Forms: fix cramped grids on mobile --- */
  .grid.grid-cols-3 { grid-template-columns: 1fr !important; }  /* Stack 3-col grids */
  .grid.grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

  /* --- Touch targets: minimum 44px --- */
  button, a, select, input[type="checkbox"] {
    min-height: 36px;
  }
  table button, table a {
    min-height: 28px;                         /* Smaller in tables to save space */
    min-width: 28px;
  }

  /* --- Toast notifications: full width on mobile --- */
  #notificationContainer {
    left: 1rem !important;
    right: 1rem !important;
    max-width: none !important;
  }

  /* --- Sidebar: ensure it covers full height --- */
  #sidebar {
    height: 100vh;
    height: 100dvh;   /* dynamic viewport height for iOS */
  }
}

/* ---- Extra small screens (< 480px) ---- */
@media (max-width: 479px) {

  /* Even tighter table sizing */
  table { font-size: 0.7rem; }
  table th,
  table td { padding: 0.3rem 0.35rem; }

  /* Stack header title + controls vertically */
  header .flex.items-center.justify-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  /* Badges / status pills: smaller */
  .px-2.py-1.rounded-full,
  span[class*="rounded-full"] {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
  }

  /* Charts: prevent overflow on tiny screens */
  canvas {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* ---- Landscape phones ---- */
@media (max-width: 1023px) and (orientation: landscape) {
  /* Limit modal height so keyboard doesn't push it off */
  .fixed.inset-0 > div {
    max-height: 80vh !important;
  }
}

/* ---- Print: hide sidebar and mobile elements ---- */
@media print {
  #sidebar,
  #mobileMenuBtn,
  #mobileMenuOverlay,
  #notificationContainer { display: none !important; }
  main { margin: 0; padding: 0; }
}
