/* ============================================================
   _shared/mobile-responsive.css
   Cross-cutting responsive overrides for the Silver Lands /
   Studio 168 AM dashboard + all per-property HTML pages.

   Loaded AFTER page-specific styles so these rules win.
   Breakpoints:
     ≤1024px  tablet
     ≤768px   phone (primary mobile target)
     ≤480px   small phone
   ============================================================ */

/* ─────── TABLET (≤1024px) ─────── */
@media (max-width: 1024px) {
  .container { max-width: 100%; padding: 0 1rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .chart-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
  .fs-4 { grid-template-columns: repeat(2, 1fr); }
  .heatmap-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .vault-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

  /* Property-page sticky header KPI band */
  #mr-kpi-band { grid-template-columns: repeat(4, 1fr) !important; }
}

/* ─────── PHONE (≤768px) ─────── */
@media (max-width: 768px) {

  /* ---- Master dashboard: nav / ticker / tabs ---- */
  .nav { padding: 0 .7rem !important; height: 44px !important; }
  .nav-logo { font-size: .82rem !important; }
  .nav-sub { display: none !important; }
  .nav-right { gap: .4rem !important; }
  .nav-btn { padding: .28rem .5rem !important; font-size: .6rem !important; }

  .spotlight-trigger { max-width: 140px !important; padding: .28rem .5rem !important; font-size: .6rem !important; }
  .spotlight-trigger input { font-size: .62rem !important; padding-left: 1.3rem !important; }
  .spotlight-trigger::before { font-size: .7rem !important; left: .4rem !important; }
  .spotlight-shortcut { display: none !important; }
  .search-box { flex-shrink: 1; min-width: 0; }

  .ticker-wrap { top: 44px !important; height: 22px !important; }
  .ticker-label { height: 22px !important; font-size: .44rem !important; padding: 0 .5rem !important; }
  .tk-item { height: 22px !important; font-size: .5rem !important; padding: 0 .8rem !important; }
  .tk-name { max-width: 100px !important; }

  .main-tabs { top: 66px !important; height: 32px !important; padding: 0 .5rem !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mt-btn { padding: .25rem .55rem !important; font-size: .58rem !important; height: 32px !important; }

  /* ---- Hero + KPI bar ---- */
  .hero { margin-top: 98px !important; height: auto !important; min-height: 180px !important; }
  .kpi-bar {
    position: relative !important; bottom: auto !important; left: auto !important;
    transform: none !important; max-width: 100% !important;
    margin: .6rem 0 0 !important; border-radius: 0 !important;
    flex-wrap: nowrap !important; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .kb-item { min-width: 92px; padding: .55rem .65rem; flex-shrink: 0; }
  .kb-val { font-size: .88rem; }
  .kb-label { font-size: .44rem; }
  .map-grad { height: 40px; }

  /* ---- Container + grids collapse ---- */
  .container { padding: 0 .75rem !important; }
  .card-grid { grid-template-columns: 1fr !important; gap: .75rem !important; }
  .chart-grid { grid-template-columns: 1fr !important; gap: .8rem !important; }
  .vault-grid { grid-template-columns: 1fr !important; }
  .heatmap-grid { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)) !important; }
  .chart-card { padding: 1rem 1.05rem !important; }

  /* ---- Finance + summary cards ---- */
  .fs-2, .fs-3, .fs-4 { grid-template-columns: 1fr !important; }
  .fs-big { font-size: 1.4rem !important; }
  .fs-mid { font-size: .9rem !important; }
  .p-card-metrics { grid-template-columns: repeat(2, 1fr) !important; gap: .3rem !important; }
  .p-card-name { font-size: .8rem !important; }

  /* ---- Section headers + chips row ---- */
  .sec-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .sec-title { font-size: .95rem; }
  .chips { flex-wrap: wrap; }

  /* ---- Tables: always horizontal scroll, smaller text ---- */
  .tbl-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .tbl-wrap table { font-size: .68rem; }
  .tbl-wrap th, .tbl-wrap td { padding: .4rem .55rem !important; white-space: nowrap; }

  /* ---- Property-detail fullscreen modal ---- */
  .pd-banner { padding: .85rem 1rem !important; }
  .pd-name { font-size: 1.1rem !important; }
  .pd-sub { font-size: .6rem !important; gap: .35rem !important; }
  .pd-links { gap: .3rem !important; margin-top: .4rem !important; }
  .pd-link { padding: .25rem .55rem !important; font-size: .55rem !important; }
  .pd-tabs { padding: 0 .5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pd-tab { padding: .45rem .75rem !important; font-size: .6rem !important; }
  .pd-content { padding: 1rem 1rem 2.5rem !important; max-width: 100% !important; }

  /* ---- Spotlight search ---- */
  .spotlight-overlay { padding: .5rem; }
  .spotlight-modal { max-width: 100%; margin: 0; max-height: 92vh; }
  .spotlight-input { padding: .8rem .9rem; font-size: .9rem; }
  .spotlight-result { padding: .55rem .8rem; }
  .spotlight-result-title { font-size: .72rem; }
  .spotlight-result-subtitle { font-size: .56rem; }

  /* ---- Timeline ---- */
  .tl-track { height: auto; min-height: 60px; padding-bottom: 1rem; }
  .tl-item { font-size: .45rem; }

  /* ---- Map pins bigger for touch ---- */
  .map-pin-wrap { width: 22px; height: 22px; }
  .map-pin { width: 20px; height: 20px; }

  /* ---- Doc manager ---- */
  .dm-doc { grid-template-columns: 28px 1fr 70px !important; font-size: .68rem; }
  .dm-doc-cat, .dm-doc-actions { display: none !important; }
  .dm-stats { grid-template-columns: repeat(2, 1fr) !important; }

  /* ---- Doc vault ---- */
  .doc-file-meta { font-size: .45rem; }
  .doc-file-btn { padding: .18rem .35rem; font-size: .5rem; }

  /* ---- Property page (monthly-review) topbar ---- */
  .topbar { padding: 10px 12px !important; }
  .topbar-inner { flex-wrap: wrap; gap: 8px; }
  .brand-title { font-size: 12px !important; }
  .brand-sub { font-size: 9.5px !important; }
  .back-link, .detail-link { padding: 5px 10px !important; font-size: 11px !important; margin-left: auto; }

  /* ---- Property page sticky MR header (inline styles need !important) ---- */
  #mr-sticky-header {
    top: 52px !important;
    padding: .55rem .7rem .6rem !important;
    margin: 0 -.75rem .75rem !important;
  }
  #mr-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: .55rem !important;
    padding: .7rem .85rem !important;
  }
  #mr-header > div { min-width: 0 !important; }
  #mr-prop-select, #mr-month-select {
    width: 100% !important; min-width: 0 !important;
    padding: .45rem .6rem !important;
    font-size: .78rem !important;
  }
  #mr-manager-chips {
    margin-left: 0 !important;
    gap: .3rem !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    padding-bottom: .2rem;
  }
  #mr-kpi-band {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: .4rem !important;
  }

  /* Collapsible section headers */
  .mr-sec-head { padding: .65rem .85rem; font-size: .82rem; }

  /* ---- Footer ---- */
  .foot, .footer { padding: 1rem 1rem 1.5rem !important; font-size: 11px !important; }

  /* ---- Charts: canvases shouldn't exceed container ---- */
  .chart-card canvas, .chart-grid canvas, .chart-wrap canvas { max-width: 100% !important; height: auto !important; }

  /* ---- Prevent horizontal page scroll from stray wide elements ---- */
  html, body { overflow-x: hidden; }
}

/* ─────── SMALL PHONE (≤480px) ─────── */
@media (max-width: 480px) {
  .kb-item { min-width: 78px; padding: .45rem .5rem; }
  .kb-val { font-size: .78rem; }
  .kb-label { font-size: .4rem; }

  .p-card-metrics { grid-template-columns: repeat(2, 1fr) !important; }
  .p-card-name { font-size: .75rem !important; }
  .p-card-narrative { font-size: .58rem !important; padding: .2rem .8rem .35rem !important; }

  .fs-big { font-size: 1.18rem !important; }
  .fs-mid { font-size: .82rem !important; }

  .chart-card { padding: .85rem .9rem !important; }
  .chart-title { font-size: .82rem !important; }
  .chart-sub { font-size: .58rem !important; }
  .sec-title { font-size: .86rem !important; }

  .tbl-wrap table { font-size: .62rem; }
  .tbl-wrap th, .tbl-wrap td { padding: .35rem .45rem !important; }

  .hm-cell { padding: .4rem .5rem; }
  .hm-cell-val { font-size: .8rem; }

  /* Tracker / KPI grids shrink further */
  #mr-kpi-band { grid-template-columns: 1fr 1fr !important; }

  .back-link, .detail-link { padding: 4px 8px !important; font-size: 10.5px !important; }
}

/* ─────── TOUCH TARGET SIZING (all mobile) ─────── */
@media (max-width: 768px) {
  button, .chip, .nav-btn, .mt-btn, .pd-tab, .pd-link, .regional-chip, .view-toggle .vt-btn {
    min-height: 32px;
  }
  select, input[type="text"], input[type="number"], input[type="search"] {
    min-height: 36px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  /* Re-override small compact selectors that are sized via their own rule */
  #mr-prop-select, #mr-month-select { font-size: 16px !important; }
}

/* ─────── PRINT: unchanged ─────── */
