/* RADHA on Android: the desktop stylesheet (styles.css) plus these phone adjustments.
   Phones (< 900 px): the sidebar becomes a slide-in menu, grids stack, wide tables scroll sideways. */

body.android { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body.android main { height: 100dvh; padding-top: env(safe-area-inset-top); }
body.android .view { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
body.android .btn, body.android #nav button, body.android .link { min-height: 40px; }
body.android .btn.small { min-height: 34px; }
body.android input, body.android select, body.android textarea { font-size: 16px; } /* no zoom-on-focus */
body.android .dropzone { padding: 28px 16px; }
body.android .dropzone .big { font-size: 34px; }

/* Tablets and browser windows narrower than the desktop app's minimum (1100 px): the top bar wraps. */
@media (min-width: 900px) and (max-width: 1399px) {
  body.android .topbar { flex-wrap: wrap; }
  body.android .topbar-actions { flex-wrap: wrap; justify-content: flex-end; min-width: 0; margin-left: auto; }
  body.android .topbar-actions select { max-width: 240px; }
}

@media (max-width: 899px) {
  body.android { display: block; }
  body.android .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 84vw); overflow-y: auto;
    transform: translateX(-105%); transition: transform 0.2s ease; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  body.android.nav-open .sidebar { transform: none; }
  body.android .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(10, 15, 20, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  body.android.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.android #nav { flex: none; }
  body.android #nav button { padding: 11px 10px; font-size: 15px; }

  body.android .menu-btn { display: grid; place-items: center; flex-shrink: 0; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 20px; cursor: pointer; }
  body.android .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; justify-content: flex-start; }
  body.android .topbar-title { flex: 1; min-width: 0; }
  body.android .topbar h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.android .patient-chip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.android .topbar-actions { width: 100%; gap: 8px; }
  body.android .topbar-actions .lang { flex: 1; min-width: 0; gap: 4px; }
  body.android .topbar-actions .lang span { display: none; }
  body.android .topbar-actions select { width: 100%; min-width: 0; }
  body.android #exportBtn { padding: 8px 10px; }

  body.android .view { padding: 14px 12px 40px; }
  body.android .banner { margin: 10px 12px 0; }
  body.android .card { padding: 14px; }
  body.android .grid.cols-2, body.android .grid.cols-3, body.android .cols-2, body.android .cols-3 { grid-template-columns: minmax(0, 1fr); }
  body.android .cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.android .engine-grid, body.android .engine-grid.wide { grid-template-columns: minmax(0, 1fr); }
  body.android .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.android .cond-grid, body.android .tune-grid, body.android .sponsor-grid { grid-template-columns: minmax(0, 1fr); }
  body.android .lib-grid { grid-template-columns: minmax(0, 1fr); }
  body.android .lc-grid { grid-template-columns: minmax(0, 1fr); }
  body.android .panel-bars .pb { grid-template-columns: 110px 1fr 44px; }
  body.android .profile dl { grid-template-columns: 96px 1fr; }
  body.android .row { flex-wrap: wrap; }
  /* Grids whose columns are set inline (dashboard cards, trends, verify + report text, AI provider rows) stack too. */
  body.android .grid[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  body.android .form-grid[style*="1.2fr"] { grid-template-columns: minmax(0, 1fr) !important; }

  /* Wide tables scroll inside their card instead of widening the page. */
  body.android table { display: block; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
  body.android th { position: static; }
  body.android .rangebar { width: 80px; }

  body.android .modal-backdrop { padding: 0; place-items: stretch; }
  body.android .modal-wrap { width: 100%; height: 100%; max-height: 100%; }
  body.android .modal-wrap.narrow { width: 100%; }
  body.android .modal-close { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 10px; z-index: 2; margin: 0; }
  body.android .modal { max-height: none; height: 100%; border-radius: 0; padding-top: calc(52px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

  body.android .toast { left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: none; }
  body.android .update-bar { flex-wrap: wrap; padding: 10px 12px; }
  body.android .pin-pad { grid-template-columns: repeat(3, 72px); }
  body.android .pin-key { height: 64px; }
}
