/**
 * HGMS Admin — installed PWA (standalone) UI only.
 * Loaded only with admin-pwa-head; html.hgms-pwa-standalone is set by script when
 * display-mode is standalone/fullscreen or iOS navigator.standalone.
 * Desktop browser tabs never get this class → no layout change in normal use.
 */

html.hgms-pwa-standalone {
  --hgms-safe-top: env(safe-area-inset-top, 0px);
  --hgms-safe-bottom: env(safe-area-inset-bottom, 0px);
  --hgms-safe-left: env(safe-area-inset-left, 0px);
  --hgms-safe-right: env(safe-area-inset-right, 0px);
}

html.hgms-pwa-standalone body {
  padding-top: var(--hgms-safe-top);
  padding-bottom: var(--hgms-safe-bottom);
  padding-left: var(--hgms-safe-left);
  padding-right: var(--hgms-safe-right);
  min-height: 100dvh;
  box-sizing: border-box;
}

/* Orchid shell: prevent horizontal bleed on narrow installed viewports */
html.hgms-pwa-standalone .container-fluid {
  max-width: 100%;
  padding-left: max(0.75rem, var(--hgms-safe-left));
  padding-right: max(0.75rem, var(--hgms-safe-right));
}

html.hgms-pwa-standalone .container-fluid > .row {
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

html.hgms-pwa-standalone .col-xxl,
html.hgms-pwa-standalone .col-xl-9,
html.hgms-pwa-standalone .col-12.mx-auto {
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}

html.hgms-pwa-standalone .workspace,
html.hgms-pwa-standalone .workspace-limit {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

html.hgms-pwa-standalone .layout-wrapper {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Main form wrapper (Orchid screens) */
html.hgms-pwa-standalone #post-form {
  max-width: 100%;
  overflow-x: auto;
}

/* Command bar: wrap actions instead of clipping */
html.hgms-pwa-standalone .command-bar {
  flex-wrap: wrap !important;
  row-gap: 0.5rem;
}

html.hgms-pwa-standalone .command-bar .btn,
html.hgms-pwa-standalone .command-bar .btn-group {
  flex-shrink: 0;
}

html.hgms-pwa-standalone .command-bar .btn {
  min-height: 44px;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

/* Tables: horizontal momentum scroll inside workspace */
html.hgms-pwa-standalone .table-responsive {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

html.hgms-pwa-standalone .layout-wrapper > .table,
html.hgms-pwa-standalone .layout-wrapper .table {
  max-width: 100%;
}

/* Modals: fit viewport + safe areas */
html.hgms-pwa-standalone .modal-dialog {
  margin: 0.5rem auto;
  max-width: min(100%, calc(100vw - var(--hgms-safe-left) - var(--hgms-safe-right) - 1rem));
}

html.hgms-pwa-standalone .modal-content {
  max-height: calc(100dvh - var(--hgms-safe-top) - var(--hgms-safe-bottom) - 1.5rem);
  overflow-y: auto;
}

html.hgms-pwa-standalone .modal-body {
  overflow-y: auto;
}

/* iOS: avoid focus zoom on small form controls in installed app */
html.hgms-pwa-standalone input.form-control,
html.hgms-pwa-standalone select.form-select,
html.hgms-pwa-standalone textarea.form-control,
html.hgms-pwa-standalone .form-control,
html.hgms-pwa-standalone .form-select {
  font-size: 16px !important;
}

/* Heavy custom module roots (scroll + width containment) */
html.hgms-pwa-standalone .checkin-management-container,
html.hgms-pwa-standalone .tickets-v23,
html.hgms-pwa-standalone .room-booking-grid,
html.hgms-pwa-standalone .room-booking-search-section,
html.hgms-pwa-standalone .room-status-management,
html.hgms-pwa-standalone .guest-push-audit-screen,
html.hgms-pwa-standalone .staff-availability-calendar,
html.hgms-pwa-standalone .hgms-dash,
html.hgms-pwa-standalone .nlp-management-container,
html.hgms-pwa-standalone .checkout-summary-page,
html.hgms-pwa-standalone .hgms-checkout-summary,
html.hgms-pwa-standalone .checkout-cart-summary,
html.hgms-pwa-standalone .maintenance-list,
html.hgms-pwa-standalone .category-cards-grid {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

html.hgms-pwa-standalone .guest-chat-messages-scroll {
  max-height: calc(70dvh - var(--hgms-safe-top) - var(--hgms-safe-bottom)) !important;
}

/* Kitchen board (same class hook when installed) */
html.hgms-pwa-standalone .kanban-board-scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding-bottom: max(0.5rem, var(--hgms-safe-bottom));
}

/* Aside footer profile block — clear home indicator */
html.hgms-pwa-standalone .aside footer .bg-dark {
  padding-bottom: max(10px, var(--hgms-safe-bottom)) !important;
}

/* Breadcrumb row: allow wrap */
html.hgms-pwa-standalone .breadcrumb {
  flex-wrap: wrap;
}
