/* GuestSign V70-5.2 — responsive phone/tablet hardening.
   Loaded after app.css. Every rule is mobile/tablet scoped so the proven
   desktop presentation remains unchanged. */

@media (max-width: 900px) {
  /* Final cascade guard: later V58 desktop refinements must never resurrect
     the desktop sidebar or two-column dashboard on phone/tablet widths. */
  body.owner-app-v58 .owner-layout-v58 {
    display: block !important;
    grid-template-columns: minmax(0, 1fr) !important;
    min-width: 0 !important;
  }
  body.owner-app-v58 .owner-sidebar-v58,
  body.owner-app-v58 .owner-topbar-v58 {
    display: none !important;
  }
  body.owner-app-v58 .v50-mobile-bar,
  body.platform-v52 .v50-mobile-bar {
    display: flex !important;
  }
  body.owner-app-v58 .owner-main-v58,
  body.platform-v52 .admin-main-v52 {
    width: 100% !important;
    min-width: 0 !important;
  }
  body.owner-app-v58 .dashboard-grid-v58 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Keep page headers inside the viewport even when titles/actions are long. */
  body.owner-app-v58 .page-title-row,
  body.owner-app-v58 .simple-page-header,
  body.platform-v52 .page-title-row,
  body.platform-v52 .simple-page-header {
    width: 100%;
    min-width: 0;
    align-items: flex-start !important;
  }
  body.owner-app-v58 .page-title-row > *,
  body.owner-app-v58 .simple-page-header > *,
  body.platform-v52 .page-title-row > *,
  body.platform-v52 .simple-page-header > * {
    min-width: 0;
    max-width: 100%;
  }

  /* Mobile navigation should be comfortably tappable and never extend past
     the viewport on 320px phones or landscape tablets. */
  .mobile-bar {
    height: auto;
    min-height: 64px;
    padding: 9px 14px;
  }
  .mobile-bar .brand-lockup {
    min-width: 0;
  }
  .mobile-bar .brand-copy {
    min-width: 0;
  }
  .mobile-bar .brand-copy strong {
    display: block;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-menu {
    flex: 0 0 auto;
    margin-left: auto;
  }
  .mobile-menu summary {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 44px;
    padding: 0 12px;
    font-size: 12px;
  }
  .mobile-menu-panel {
    width: min(290px, calc(100vw - 28px));
    max-height: calc(100dvh - 82px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-menu-panel a,
  .mobile-menu-panel button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 10px;
    font-size: 12.5px;
  }

  /* Wide records remain intentionally scrollable instead of forcing the page
     itself wider than the device. */
  .agreement-table-wrap,
  .data-table-wrap,
  body.owner-app-v58 .agreement-table-wrap-v58 {
    max-width: 100%;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
  body.owner-app-v58 .agreements-panel-v58,
  body.owner-app-v58 .panel,
  body.platform-v52 .panel,
  body.platform-v52 .admin-card {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  body.owner-app-v58 .page-title-row,
  body.owner-app-v58 .simple-page-header,
  body.platform-v52 .page-title-row,
  body.platform-v52 .simple-page-header {
    gap: 12px !important;
  }

  body.owner-app-v58 .page-title-actions,
  body.owner-app-v58 .button-row,
  body.platform-v52 .page-title-actions,
  body.platform-v52 .button-row {
    width: 100%;
    align-items: stretch;
  }
  body.owner-app-v58 .page-title-actions > .button,
  body.platform-v52 .page-title-actions > .button {
    flex: 1 1 100%;
    min-height: 44px;
  }

  body.owner-app-v58 .panel-heading,
  body.platform-v52 .panel-heading,
  body.platform-v52 .admin-card-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  /* 16px form text prevents automatic Safari focus zoom on iPhone while only
     affecting phone-sized layouts. */
  body.owner-app-v58 input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
  body.owner-app-v58 select,
  body.owner-app-v58 textarea,
  body.platform-v52 input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
  body.platform-v52 select,
  body.platform-v52 textarea,
  body.guest-body input:not([type="checkbox"]):not([type="radio"]),
  body.guest-body select,
  body.guest-body textarea,
  body.login-body input,
  body.setup-wizard-body input:not([type="checkbox"]):not([type="radio"]),
  body.setup-wizard-body select,
  body.setup-wizard-body textarea,
  body.onboarding-public input:not([type="checkbox"]):not([type="radio"]),
  body.onboarding-public select,
  body.onboarding-public textarea {
    font-size: 16px !important;
  }

  body.owner-app-v58 .pager-v58 > a,
  body.owner-app-v58 .pager-v58 > .disabled {
    width: 44px;
    height: 44px;
  }
}
