/* MillPulse Global Mobile CSS — v1
   Single file fix for ALL pages. Edit here, deploy once, everything updates.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV — hidden by default, shown on mobile
   ═══════════════════════════════════════════════════════════════ */
.global-mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface, #f9f8f5);
  border-top: 1px solid var(--border, #d4d1ca);
  z-index: 500;
  align-items: stretch;
}
[data-theme="dark"] .global-mobile-nav {
  background: #1c1b19;
  border-color: #2d2d2d;
}
.global-mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 3px;
  text-decoration: none;
  color: var(--muted, #6f6d67);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.3rem 0.2rem;
  font-family: 'General Sans', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
  border: none;
  background: none;
}
.global-mobile-nav a.active { color: var(--primary, #1F3A5F); }
[data-theme="dark"] .global-mobile-nav a.active { color: #8ab4d8; }
.global-mobile-nav a .gmn-icon { font-size: 1.2rem; line-height: 1; display: block; }
.global-mobile-nav a .gmn-label { font-size: 0.62rem; line-height: 1; display: block; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE — max-width 640px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* Show bottom nav */
  .global-mobile-nav { display: flex !important; }

  /* ── Layout: collapse all 2-col grids ─────────────────────── */
  .app,
  .page-shell,
  .da-shell,
  .shell,
  .app-layout,
  .ws-layout,
  .workspace-layout {
    display: block !important;
    grid-template-columns: 1fr !important;
  }

  /* ── Hide ALL static sidebars (sidebar.js drawer handles mobile) */
  aside.sidebar,
  .sidebar,
  nav.sidebar,
  .ws-sidebar,
  .workspace-sidebar {
    display: none !important;
  }

  /* ── Main content: full width, breathable padding ─────────── */
  .main,
  .main-content,
  .main-wrap,
  .content,
  .page-content,
  .inner,
  .da-main,
  .ws-main,
  .ws-content,
  .workspace-content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 0.85rem !important;
    padding-bottom: 80px !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* ── Topbars: compact ─────────────────────────────────────── */
  .top, .topbar, header.top, .navbar, .mp-topnav {
    padding: 0.55rem 0.85rem !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
  }

  /* ── Typography ───────────────────────────────────────────── */
  h1, .page-title { font-size: 1rem !important; }
  h2 { font-size: 0.95rem !important; }
  h3 { font-size: 0.88rem !important; }

  /* ── Tables: scroll horizontally ─────────────────────────── */
  .table-wrap,
  .table-container,
  .ws-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  table { font-size: 0.78rem !important; min-width: 480px; }
  th, td { padding: 0.4rem 0.6rem !important; white-space: nowrap !important; }

  /* ── Cards and grids: single column ──────────────────────── */
  .card-grid, .cards-container, .stats-grid,
  .kpi-grid, .report-type-grid, .form-grid-2,
  .two-col, .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }
  .card, .kpi-card, .stat-card {
    padding: 0.85rem !important;
    border-radius: 12px !important;
  }

  /* ── Modals: slide up from bottom like native iOS ─────────── */
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important; left: 0 !important; right: 0 !important; top: auto !important;
    max-height: 90dvh !important;
    overflow-y: auto !important;
    padding: 1.25rem 1rem !important;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* ── Forms: prevent iOS zoom, full width ─────────────────── */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="search"], input[type="date"],
  select, textarea {
    font-size: 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .field, .form-group, .form-field { width: 100% !important; }

  /* ── Buttons: comfortable touch targets ───────────────────── */
  .btn, button.btn { min-height: 42px !important; font-size: 0.85rem !important; }
  .modal-actions, .action-row, .btn-row {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
  .modal-actions .btn { flex: 1 !important; justify-content: center !important; }

  /* ── User management specific ─────────────────────────────── */
  .search-wrap { flex-direction: column !important; align-items: stretch !important; }
  .search-input { min-width: 0 !important; width: 100% !important; }
  .mill-pills { flex-wrap: wrap !important; gap: 0.25rem !important; }

  /* ── Workspace specific ───────────────────────────────────── */
  .ws-file-item, .file-card {
    padding: 0.65rem !important;
    font-size: 0.82rem !important;
  }

  /* ── Toast: above bottom nav ──────────────────────────────── */
  .toast {
    bottom: 70px !important;
    left: 0.75rem !important;
    right: 0.75rem !important;
    width: auto !important;
  }

  /* ── Hide desktop-only clutter ────────────────────────────── */
  .desktop-only,
  .lang-switcher,
  .lang-pills,
  #installAppBtn,
  #themeToggle { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET — 641px to 1024px
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 641px) and (max-width: 1024px) {
  .app, .app-layout {
    grid-template-columns: 200px 1fr !important;
  }
  .card-grid, .cards-container, .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
