/* Tapro HR - phone / tablet layout overrides.
   Loaded after the main stylesheet. Every rule sits inside a max-width media query,
   so screens wider than 900px look exactly as before. */

/* ---------- Tablet and phone (<= 900px): sidebar becomes a top bar ---------- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; min-width: 0; }

  .sidebar {
    position: sticky; top: 0; z-index: 50;
    width: 100%; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 6px 10px; padding: 8px 12px 0;
  }
  .sidebar .brand { flex: 0 0 auto; border: 0; margin: 0; padding: 0; }
  .sidebar .brand img { max-width: 104px; }
  .sidebar .brand .sub { display: none; }

  .sidebar .account {
    order: 2; margin: 0 0 0 auto; padding: 0; border: 0;
    display: flex; align-items: center; gap: 10px; text-align: right; min-width: 0;
  }
  .sidebar .account .who {
    display: block; font-size: 12.5px; max-width: 150px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .sidebar .account .role { display: none; }
  .sidebar .account a.logout {
    display: inline-flex; align-items: center; min-height: 36px;
    padding: 0 12px; border: 1px solid #444; border-radius: 8px; white-space: nowrap;
  }

  .sidebar nav {
    order: 3; flex: 1 0 100%; display: flex; gap: 2px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    margin: 0 -12px; padding: 0 8px;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a {
    flex: 0 0 auto; justify-content: center; white-space: nowrap;
    min-height: 42px; padding: 0 12px; font-size: 14px;
    border-left: 0; border-bottom: 3px solid transparent;
  }
  .sidebar nav a span.label { display: inline; }
  .sidebar nav a.active { border-bottom-color: var(--primary); }

  .main { width: 100%; max-width: 100%; min-width: 0; padding: 18px 16px 36px; }

  /* Wide tables scroll inside their own box instead of widening the page */
  .main table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .main th { white-space: nowrap; }
  .main td { min-width: 100px; }
  /* soft shadow at the edge that still has more columns to scroll to */
  .main table {
    background:
      linear-gradient(to right, #fff 30%, rgba(255,255,255,0)),
      linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) 100% 0,
      radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.16), rgba(0,0,0,0)),
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.16), rgba(0,0,0,0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }

  /* Nothing in the content area may be wider than the screen */
  .main div, .main form, .main input, .main select, .main textarea, .main img { max-width: 100%; }
  /* grid and flex children may shrink below their content width (lets inner tables scroll) */
  .main .grid > *, .main [style*="display: grid"] > *, .main [style*="display: flex"] > * { min-width: 0; }
  .main td:first-child { white-space: nowrap; }
}

/* ---------- Phone (<= 600px) ---------- */
@media (max-width: 600px) {
  .main { padding: 14px 12px 32px; }
  .page-header { margin-bottom: 14px; }
  .page-title { font-size: 20px; }
  .card { padding: 14px; border-radius: 10px; }

  /* Two-column / sidebar style layouts collapse to one column */
  .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .main [style*="grid-template-columns"]:not([style*="auto-fit"]):not([style*="auto-fill"]) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* rows laid out side by side wrap onto the next line instead of running off screen */
  .main [style*="display: flex"] { flex-wrap: wrap; }
  .main [style*="min-width"]:not(td *):not(td) { min-width: 0 !important; }

  /* Forms: full width, 16px text (stops iOS zooming in), comfortable tap size */
  input, select, textarea { font-size: 16px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select { min-height: 44px; }
  .main input:not([type="checkbox"]):not([type="radio"]), .main select, .main textarea { width: 100% !important; }
  /* ...except inside table rows, where they keep a compact size (the table scrolls) */
  .main input:not([type="checkbox"]):not([type="radio"]), .main select, .main textarea { max-width: 100% !important; }
  .main td input:not([type="checkbox"]):not([type="radio"]), .main td select, .main td textarea { width: auto !important; min-width: 130px; }
  .btn { min-height: 42px; justify-content: center; }
  .back-link { min-height: 40px; }

  .toolbar > * { flex: 1 1 100%; }
  .toolbar > .btn { flex: 1 1 auto; }

  /* Dashboard */
  .dash-banner { padding: 18px; gap: 12px; border-radius: 12px; }
  .dash-banner-icon { width: 46px; height: 46px; font-size: 22px; }
  .dash-banner-title { font-size: 20px; }
  .stat-tile { flex-direction: row; align-items: center; gap: 14px; }
  .stat-tile .icon { width: 44px; height: 44px; font-size: 20px; }
  .stat-tile .num { font-size: 24px; }
  .bar-row .bar-label { width: 110px; }
  .dorm-legend, .dorm-table-wrap { min-width: 0; }
  .alert-row { flex-wrap: wrap; }
}
