/* Nimbus CRM — mobile / tablet behaviour (Salesforce mobile app patterns) */

@media (max-width: 1024px) {
  .record-grid { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  body { font-size: 14px; }

  /* --- header collapses to logo + search + avatar --- */
  .global-header { padding: 0 .5rem; gap: .35rem; }
  .gh-logo b { display: none; }
  .gh-search input { font-size: 16px; } /* prevents iOS zoom on focus */
  .gh-icon-btn.hide-mobile, .gh-launcher.hide-mobile { display: none; }

  /* --- app nav becomes a scrollable strip; tab bar takes over --- */
  .app-nav { display: none; }

  .page { padding: .5rem .5rem calc(4.25rem + env(safe-area-inset-bottom)); }

  /* --- bottom tab bar --- */
  .tab-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
    background: var(--surface); border-top: 1px solid var(--border-weak);
    display: flex; padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 6px rgba(0,0,0,.08);
  }
  .tab-bar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem;
    border: 0; background: transparent; padding: .4rem 0 .35rem; color: var(--text-weak);
    font-size: 10px; min-height: 3.25rem;
  }
  .tab-bar button.active { color: var(--brand); }
  .tab-bar button .icon { width: 1.35rem; height: 1.35rem; }

  /* --- floating action button --- */
  .fab {
    display: flex; position: fixed; right: 1rem;
    bottom: calc(4.25rem + env(safe-area-inset-bottom)); z-index: 590;
    width: 3.25rem; height: 3.25rem; border-radius: 50%; border: 0;
    background: var(--brand); color: #fff; align-items: center; justify-content: center;
    box-shadow: var(--shadow-3);
  }
  .fab .icon { width: 1.5rem; height: 1.5rem; }

  /* --- tables become cards --- */
  .table-wrap.responsive table.data { display: block; }
  .table-wrap.responsive table.data thead { display: none; }
  .table-wrap.responsive table.data tbody { display: block; }
  .table-wrap.responsive table.data tr {
    display: block; background: var(--surface); border: 1px solid var(--border-weak);
    border-radius: var(--radius-lg); margin-bottom: .5rem; padding: .6rem .7rem;
    box-shadow: var(--shadow-1);
  }
  .table-wrap.responsive table.data td {
    display: flex; justify-content: space-between; gap: .75rem; border: 0;
    padding: .18rem 0; max-width: none; text-align: right;
  }
  .table-wrap.responsive table.data td::before {
    content: attr(data-label); color: var(--text-weak); font-size: 12px;
    text-align: left; flex: none; max-width: 45%;
  }
  .table-wrap.responsive table.data td:first-of-type {
    font-size: 15px; font-weight: 600; padding-bottom: .35rem;
  }
  .table-wrap.responsive table.data td:first-of-type::before { display: none; }
  .table-wrap.responsive table.data td.row-check { justify-content: flex-start; }
  .table-wrap.responsive table.data td.row-check::before { display: none; }
  .cell-edit { display: none; }

  /* --- list view header --- */
  .lv-header { flex-direction: column; gap: .35rem; }
  .lv-actions { margin-left: 0; width: 100%; }
  .lv-actions .btn { flex: 1; }
  .lv-search input { width: 100%; }
  .lv-toolbar { flex-wrap: wrap; }

  /* --- record page --- */
  .rh-top { flex-wrap: wrap; }
  .rh-actions { width: 100%; justify-content: flex-start; }
  .rh-actions .btn { flex: 1 0 auto; }
  .rh-fields { gap: .75rem 1.5rem; }
  .path { padding: .5rem; }
  .path-item { min-width: 8.5rem; }
  .section-body.cols-2 { grid-template-columns: 1fr; }

  /* --- modals become full-screen sheets --- */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.sm, .modal.lg {
    width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0;
  }
  .modal-foot { border-radius: 0; padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; min-height: 2.5rem; }
  .form-grid { grid-template-columns: 1fr; }

  /* --- launcher --- */
  .launcher-panel { padding: 0; align-items: stretch; }
  .launcher-card { width: 100%; max-height: 100dvh; border-radius: 0; }
  .launcher-grid { grid-template-columns: 1fr; }

  /* --- kanban --- */
  .kanban-col { min-width: 82vw; flex: 0 0 82vw; max-height: none; }

  /* --- reports / setup --- */
  .report-builder, .setup-grid { grid-template-columns: 1fr; }
  .rb-panel { max-height: none; }

  /* --- tap targets --- */
  .btn { min-height: 2.35rem; }
  .menu-item { padding: .6rem .85rem; }
  .nav-tab { padding: 0 .9rem; }
  .input, .select, .textarea { min-height: 2.35rem; font-size: 16px; }

  .cal-cell { min-height: 3.5rem; }
  .cal-event { display: none; }
  .cal-cell .dot { display: inline-block; width: .35rem; height: .35rem; border-radius: 50%;
    background: var(--brand); margin: .1rem .05rem 0; }
}

@media (min-width: 768px) {
  .tab-bar { display: none; }
  .mobile-only { display: none !important; }
}
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
}

/* landscape phones: keep the bottom bar compact */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 480px) {
  .tab-bar button { min-height: 2.5rem; font-size: 9px; }
  .tab-bar button .icon { width: 1.1rem; height: 1.1rem; }
  .fab { width: 2.75rem; height: 2.75rem; }
}
