/* =====================================================================
   Phone app-style layer
   =====================================================================
   Loaded only while Settings -> "App-style layout on phones" is on, and
   every rule is under `body.mapp` inside a max-width media query. Above
   760px nothing here matches, so a desktop or tablet is not touched.

   It is additive: the existing header, drawer, forms and tables all stay
   and keep working. This file adds a bottom tab bar, bigger touch targets,
   card-style surfaces and a sticky action bar for the application steps.
   ===================================================================== */

.mtabs, .minstall { display: none; }

@media (max-width: 760px) {

  body.mapp {
    --tab-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    background: #f4f6f9;
    padding-bottom: calc(var(--tab-h) + var(--safe-b) + 8px);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
  }

  /* ---- the tab bar ------------------------------------------------- */
  body.mapp .mtabs {
    display: flex; gap: 2px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tab-h) + var(--safe-b));
    padding: 6px 6px calc(8px + var(--safe-b));
    box-sizing: border-box;
    background: #fff; border-top: 1px solid #e3e8ef;
    box-shadow: 0 -4px 16px rgba(16,21,28,.05);
  }
  body.mapp .mtab {
    flex: 1; min-width: 0; min-height: 48px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border-radius: 14px; color: #5b6778; text-decoration: none;
    font-size: 12px; font-weight: 600; line-height: 1.1; cursor: pointer;
  }
  body.mapp .mtab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.mapp .mtab.on { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }
  body.mapp .mtab:active { background: #eef1f6; }

  /* ---- top bar: slimmer, app-like ---------------------------------- */
  body.mapp .site-header { background: #fff; backdrop-filter: none; }
  
  body.mapp .admin-top { background: #fff; }

  /* ---- surfaces as cards -------------------------------------------- */
  body.mapp .card, body.mapp .panel { border-radius: 18px; box-shadow: 0 1px 2px rgba(16,21,28,.06); }

  /* ---- buttons and fields: thumb sized ------------------------------ */
  body.mapp .btn { min-height: 48px; border-radius: 14px; font-weight: 700; }
  body.mapp .btn-primary { border-radius: 16px; }
  body.mapp .input, body.mapp .select, body.mapp .textarea,
  body.mapp input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
  body.mapp select { border-radius: 14px; font-size: 16px; /* 16px stops iOS zooming on focus */ }

  /* ---- application steps: Back / Continue stay under the thumb ------ */
  body.mapp .step-nav {
    position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 8px); z-index: 30;
    background: #fff; margin: 1rem -1rem -1rem; padding: .75rem 1rem;
    border-top: 1px solid #e3e8ef; border-radius: 0 0 18px 18px;
    display: flex; gap: .6rem;
  }
  body.mapp .step-nav .btn { flex: 1; }

  /* ---- staff area: the page is a stack of cards ---------------------- */
  body.mapp .admin-body { padding-bottom: 1rem; }

  /* ---- sign-in screens (no tab bar there) ---------------------------- */
  body.mapp.mauth { padding-bottom: 0; }

  /* ---- install banner ------------------------------------------------ */
  body.mapp .minstall {
    position: fixed; left: 10px; right: 10px; z-index: 45;
    bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
    display: flex; align-items: center; gap: 10px;
    padding: 10px 10px 10px 14px; border-radius: 18px;
    background: #10261f; color: #fff; box-shadow: 0 8px 24px rgba(16,21,28,.25);
  }
  body.mapp .minstall[hidden] { display: none; }
  body.mapp.mauth .minstall { bottom: 12px; }
  body.mapp .minstall-text { flex: 1; min-width: 0; font-size: 13px; line-height: 1.3; }
  body.mapp .minstall-text strong { display: block; font-size: 14px; }
  body.mapp .minstall-go {
    min-height: 44px; padding: 0 16px; border: 0; border-radius: 14px;
    background: var(--accent, #F0A202); color: #10151c; font: inherit; font-weight: 700; cursor: pointer;
  }
  body.mapp .minstall-x {
    min-width: 44px; min-height: 44px; border: 0; background: transparent; color: #fff;
    font-size: 24px; line-height: 1; cursor: pointer;
  }
}

/* Opened from the home screen: no browser bar, so respect the notch. */
@media (max-width: 760px) and (display-mode: standalone) {
  body.mapp .site-header, body.mapp .admin-top { padding-top: env(safe-area-inset-top, 0px); }
}

@media print { .mtabs, .minstall { display: none !important; } body.mapp { padding-bottom: 0; } }
