/* Phone & tablet layout fixes for the Land Marshal app (loaded after master.css on every page). */

/* Installed app: respect the notch / home-bar areas */
.lm-standalone body { padding-bottom: env(safe-area-inset-bottom); }

/* ---------- Touch screens (phones, tablets): nothing may depend on mouse hover ---------- */
.lm-touch-only { display: none; }
@media (hover: none) {
  .lm-touch-only { display: inline; }
  .lm-mouse-only { display: none; }
  /* Project status menu (Active / Frozen / Upcoming) is hover-only on desktop: always visible on touch */
  .bp-project-row .bp-hover-status-wrap { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; }
  /* Bigger tap targets */
  .bp-hover-status-select { font-size: 0.8rem; padding: 5px 4px; }
  .bcf-tick input { width: 22px; height: 22px; }
}

/* ---------- Tablets (up to 1024px) ---------- */
@media (max-width: 1024px) {
  .bp-filter-pills { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .bp-filter-pills::-webkit-scrollbar { display: none; }
  .bp-filter-pills .admin-action-chip { white-space: nowrap; flex: none; }
  /* Portfolio action buttons: two per row, never wider than their column */
  body .bp-table .bp-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body .bp-table .bp-act { min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; font-size: 0.72rem; }
  body .bp-table .bp-act .bp-badge { display: none; }   /* the ticked count is shown inside the QTR Sales pop-up */
  /* Home page: grid columns must not grow to fit wide tables (those scroll inside their own box) */
  body .dossier-layout-grid { grid-template-columns: minmax(0, 1fr); }
  body .dossier-layout-grid > * { min-width: 0; }
}

/* ---------- Phones (up to 600px) ---------- */
@media (max-width: 600px) {
  /* Top bar: both logos + menu must fit the screen */
  .site-nav-header .nav-container { gap: 8px; }
  .site-nav-header .brand-wrap { min-width: 0; flex: 0 1 auto; }
  .site-nav-header .brand-logo-img { max-width: 46vw; height: auto; max-height: 38px; object-fit: contain; }
  #navbar-developer-logo-wrap { max-width: 26vw; min-width: 0; padding: 3px 6px !important; }
  #navbar-developer-logo-img { max-width: 100%; height: auto; max-height: 24px; object-fit: contain; }

  /* Hub header buttons: one compact row */
  body .hub-nav-actions { gap: 6px; }
  body .hub-nav-actions .hub-nav-btn { padding: 8px 11px; font-size: 0.76rem; }

  /* Portfolio table -> stacked cards */
  .bp-table, .bp-table tbody { display: block; width: 100%; }
  .bp-table colgroup, .bp-table thead { display: none; }
  .bp-table tr.bp-project-row { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px 14px 16px; border-bottom: 1px solid #eee7d8; }
  .bp-table tr.bp-project-row td { display: block; padding: 0; border: 0; background: transparent; }
  .bp-table tr.bp-project-row td.bp-num { display: none; }
  .bp-table tr.bp-upcoming-row { background: #f7faff; }
  .bp-name { font-size: 1rem; }
  .bp-sold-track { max-width: none; }
  body .bp-table .bp-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  body .bp-table .bp-actions .bp-link { grid-column: 1 / -1; justify-self: start; padding: 2px 0; }
  body .bp-table .bp-act { height: 42px; font-size: 0.74rem; padding: 0 6px; gap: 4px; }
  body .bp-table .bp-act .bp-badge { display: none; }
  body .bp-table .bp-rera { height: 42px; }

  /* Sales & Marketing: the search bar scrolls away on phones (it isn't pinned below 760px),
     so "jump to results" must not leave room for it */
  body #smx-results-anchor { scroll-margin-top: calc(var(--lm-nav-h, 64px) + 8px); }

  /* Pop-ups (competitors, new RERA registrations, ...): full-screen sheet that scrolls as a whole */
  body .dev-modal-backdrop { padding: 0 !important; align-items: stretch !important; }
  body .dev-modal-box { width: 100% !important; max-width: none !important; max-height: 100% !important; height: 100%; border-radius: 0 !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
  body .dev-modal-box [id$="-modal-body"] { max-height: none !important; height: auto !important; overflow: visible !important; }
  body #bcf-modal-eyebrow, body #bcf-modal-subtitle, body #brr-modal-subtitle { display: none !important; }
  body #bcf-modal-title, body #brr-modal-title { font-size: 1.12rem !important; line-height: 1.3 !important; margin: 0 !important; }
  body .dev-modal-box .sm-report-fmt-btn, body .dev-modal-box .btn-dev-action, body .dev-modal-box .btn-comp-fetch { padding: 7px 10px !important; font-size: 0.72rem !important; }
  /* Wide tables keep their columns and scroll sideways instead of being squeezed */
  body .bcf-table { min-width: 780px; }
  /* Fixed column widths so nothing spills into the next column (tick | project | units | sold | quarterly bars | avg price) */
  body .bcf-table colgroup col:nth-child(1) { width: 56px !important; }
  body .bcf-table colgroup col:nth-child(2) { width: 210px !important; }
  body .bcf-table colgroup col:nth-child(3) { width: 120px !important; }
  body .bcf-table colgroup col:nth-child(4) { width: 120px !important; }
  body .bcf-table colgroup col:nth-child(5) { width: 160px !important; }
  body .bcf-table colgroup col:nth-child(6) { width: 114px !important; }
  body .bcf-table td { overflow-wrap: anywhere; word-break: normal; overflow: hidden; }
  body .bcf-table .bcf-sub { overflow-wrap: anywhere; }   /* long RERA numbers wrap inside their own cell */

  /* Hub "Search competitors around any place": the input must not be wider than its panel */
  body .builder-search-first-box form > div { min-width: 0 !important; flex: 1 1 100% !important; }
  body .builder-search-first-box input { width: 100%; box-sizing: border-box; }
  body #brr-modal-body table { min-width: 660px; }

  /* Upcoming-site form */
  .bp-upcoming-panel { padding: 12px 14px; }
}
