/* ASDHH Staff Portal — responsive foundations (v4.3.169).
 * This is the canonical mobile owner, not an additive patch stack.
 * Shared base components are defined in platform-ui.css and consume the
 * variables declared below. Module-specific exceptions remain in modules.
 */

/* Shared width containment: scoped to the authenticated platform, not html/body.
   Hidden overflow is not a fix for tables or broken page layouts. */
@media (max-width: 980px) {
  .asdhh-app,
  .asdhh-main,
  .asdhh-content { min-width:0; max-width:100%; }
  .asdhh-sidebar { max-width:min(320px,88vw); height:100dvh; overflow-y:auto; overscroll-behavior:contain; }
  .asdhh-sidebar nav { flex:1 1 auto; min-height:0; }
  .asdhh-content :where(.asdhh-card,.asdhh-panel,.asdhh-finance-panel,.asdhh-finance-page,.asdhh-finance-shell) { min-width:0; }
  .asdhh-app :where(.asdhh-docs-builder-columns,.asdhh-advice-overview-grid,.asdhh-ft-two-column,.asdhh-eg-detail-grid,.asdhh-training-overview-grid,.asdhh-finance-summary-grid,.asdhh-finance-record-grid) { grid-template-columns:minmax(0,1fr); }
  .asdhh-content :where(img,video,canvas,iframe,embed) { max-width:100%; }
  .asdhh-content :where(.asdhh-page-heading-actions,.asdhh-page-heading,.asdhh-toolbar) { min-width:0; }
  .asdhh-content :where(.asdhh-form-grid,.asdhh-finance-form-grid,[class$="-form-grid"]) > * { min-width:0; }
}

@media (max-width: 760px) {
  /* These feed the original declarations in platform-ui.css; there are no
     competing high-specificity action, header, filter or input overrides. */
  body:is(.asdhh-portal-service-ui,.asdhh-portal-core-ui) .asdhh-app {
    --asdhh-ui-button-height:44px;
    --asdhh-ui-tab-height:44px;
    --asdhh-ui-control-height:44px;
    --asdhh-ds-control-height:44px;
    --asdhh-ui-actions-wrap:wrap;
    --asdhh-ui-actions-overflow:visible;
    --asdhh-ui-heading-wrap:wrap;
    --asdhh-ui-heading-action-flex:1 1 100%;
    --asdhh-ui-heading-action-whitespace:normal;
    --asdhh-ui-filters-wrap:wrap;
    --asdhh-ui-filters-overflow:visible;
    --asdhh-ui-filter-child-flex:1 1 100%;
    --asdhh-ui-field-font-size:1rem;
  }

  .asdhh-header { min-height:60px; height:auto; padding:9px 12px; gap:8px; }
  .asdhh-header-user { min-width:0; gap:6px; }
  .asdhh-header-user :where(button,a) { flex-shrink:0; }
  .asdhh-content { padding:14px 12px 32px; min-width:0; }
  .asdhh-welcome { padding:18px; }
  .asdhh-content h1 { overflow-wrap:break-word; word-break:normal; hyphens:manual; font-size:clamp(1.35rem,5vw,1.9rem); }
  .asdhh-content :where(h2,h3,p,dd,dt,li) { overflow-wrap:break-word; word-break:normal; hyphens:manual; }
  .asdhh-content :where(.asdhh-grid,.asdhh-task-list,.pf-fields,.pf-meta-grid,.pf-mini-form,.asdhh-docs-form-grid,.asdhh-docs-create-person-grid,.asdhh-advice-grid,.asdhh-communication-fields,.asdhh-st-form-grid,.field-grid,.asdhh-ft-form-grid,.asdhh-eg-grid,.asdhh-training-form-grid,.registration-grid,.asdhh-form-grid,.asdhh-finance-grid,.asdhh-finance-record-grid,.asdhh-finance-form-grid,.asdhh-finance-details,.asdhh-finance-customer-grid,.asdhh-training-grid,.asdhh-case-layout,.asdhh-case-summary-grid,.asdhh-link-grid,.asdhh-pip-staff-summary,.asdhh-pip-stat-grid,.asdhh-pip-data-grid,.asdhh-pip-original dl,.asdhh-pip-upload,.asdhh-pip-compact-progress,.asdhh-finance-contract-dashboard,.asdhh-finance-contract-sidebar,[class$="-form-grid"],[class$="-summary-grid"],[class$="-detail-grid"]) { grid-template-columns:minmax(0,1fr); }
  .asdhh-content :where(.asdhh-form-grid,.asdhh-finance-form-grid,[class$="-form-grid"]) > * { min-width:0; }
  .asdhh-content :where(.asdhh-page-actions,.asdhh-actions,.asdhh-toolbar-actions,.asdhh-page-heading-actions) { max-width:100%; }
  .asdhh-content :where(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea) { max-width:100%; min-width:0; }
  .asdhh-content input[type=file] { width:100%; }
  .asdhh-content :where(.pf-form-actions,.asdhh-docs-form-actions,.asdhh-ft-form-actions,.asdhh-ft-report-actions,.asdhh-finance-form-actions) { flex-wrap:wrap; }
  .asdhh-content :where(.asdhh-sticky-actions,.asdhh-page-actions) { padding-bottom:max(8px,env(safe-area-inset-bottom)); }

  /* Record navigation follows one rule: horizontal scroll with all tabs
     accessible. Do not wrap some tabs and clip others. */
  .asdhh-content :where(.asdhh-plugin-tabs,.asdhh-tabs,.asdhh-record-tabs,.nav-tab-wrapper,.asdhh-st-tabs,.asdhh-eg-main-tabs,.asdhh-finance-subnav) {
    min-width:0; max-width:100%; overflow-x:auto; overflow-y:hidden;
    -webkit-overflow-scrolling:touch; scrollbar-width:thin;
  }
  .asdhh-content :where(.asdhh-plugin-tabs,.asdhh-tabs,.asdhh-record-tabs,.nav-tab-wrapper,.asdhh-st-tabs,.asdhh-eg-main-tabs,.asdhh-finance-subnav) > :where(a,button) {
    flex:0 0 auto; white-space:nowrap;
  }

  /* Unconverted data tables scroll inside their own wrapper; never clip
     information. Simple lists are turned into cards by mobile-workspace.js. */
  .asdhh-content :where(.table-responsive,.table-wrap,.asdhh-table-wrap,.asdhh-mobile-table-scroll,.asdhh-finance-table-wrap,.asdhh-training-table-wrap,.asdhh-advice-table-wrap,.asdhh-docs-table-wrap,[class$="-table-wrap"],[class$="-table-wrapper"],[class$="-table-scroll"],.wp-list-table-wrap) {
    max-width:100%; min-width:0; overflow-x:auto; -webkit-overflow-scrolling:touch;
  }
  .asdhh-content table:not(.asdhh-mobile-card-table) { max-width:none; }
  .asdhh-content table.asdhh-mobile-card-table { display:block; width:100%; min-width:0; max-width:100%; border:0; background:transparent; }
  .asdhh-content table.asdhh-mobile-card-table thead { display:none; }
  .asdhh-content table.asdhh-mobile-card-table tbody { display:grid; gap:12px; width:100%; }
  .asdhh-content table.asdhh-mobile-card-table tr { display:grid; width:100%; min-width:0; margin:0; padding:8px 12px; border:1px solid #dce8e3; border-radius:13px; background:#fff; box-shadow:0 2px 9px rgba(22,61,70,.04); }
  .asdhh-content table.asdhh-mobile-card-table tr[hidden],.asdhh-content table.asdhh-mobile-card-table td[hidden] { display:none!important; }
  .asdhh-content table.asdhh-mobile-card-table td { display:grid; grid-template-columns:minmax(92px,34%) minmax(0,1fr); gap:12px; align-items:start; width:100%; min-width:0; max-width:100%; padding:9px 0; border:0; border-bottom:1px solid #edf1f3; overflow-wrap:break-word; word-break:normal; hyphens:manual; white-space:normal; text-align:left; }
  .asdhh-content table.asdhh-mobile-card-table td:last-child { border-bottom:0; }
  .asdhh-content table.asdhh-mobile-card-table td::before { content:attr(data-mobile-label); font-size:.79rem; color:#59717b; font-weight:700; line-height:1.35; }
  .asdhh-content table.asdhh-mobile-card-table td :where(input,select,textarea,button,a) { max-width:100%; min-width:0; }
  @media (max-width:520px) {
    .asdhh-content table.asdhh-mobile-card-table td { grid-template-columns:minmax(0,1fr); gap:4px; }
  }

  .asdhh-content :where(.asdhh-modal,.asdhh-modal-dialog,[role="dialog"],[aria-modal="true"],[class$="-modal-dialog"],[class$="-modal__content"]) {
    max-width:calc(100vw - 20px); max-height:calc(100dvh - 24px); min-width:0;
  }
  .asdhh-content :where(.asdhh-modal-body,[class$="-modal-body"],[class$="-modal__body"]) {
    max-height:calc(100dvh - 128px); overflow-y:auto; overscroll-behavior:contain;
  }
  .asdhh-email-modal { max-width:100vw; max-height:100dvh; }
  .asdhh-workspace-dock { max-width:calc(100vw - 20px); }

  /* Proven service-specific layout needs, shared here while full module
     ownership is audited. Avoid global suffix selectors for panels/cards. */
  .asdhh-app .asdhh-pip-compact-progress :where(progress,label) { grid-column:1; grid-row:auto; }
  .asdhh-app :where(.asdhh-pip-voice-list,.asdhh-pip-staff-voice-list) article { grid-template-columns:minmax(0,1fr); }
  .asdhh-app :where(.asdhh-pip-record-head,.asdhh-pip-panel-head,.asdhh-pip-secure-head,.asdhh-pip-question-head,.asdhh-pip-case-row,.asdhh-pip-document-list a) { flex-wrap:wrap; }
  .asdhh-app .asdhh-pip-case-row > div:last-child { text-align:left; }
  .asdhh-app .asdhh-case-sticky { position:static; }
  .asdhh-app :where(.asdhh-pip-stage-track,.asdhh-stage-track) { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .asdhh-app :where(.asdhh-pip-stage-track,.asdhh-stage-track) > * { min-width:80px; }
  .asdhh-content :where(.asdhh-finance-line,.asdhh-training-line) { grid-template-columns:minmax(0,1fr); }
}

@media (max-width:520px) {
  .asdhh-content :where(.asdhh-card,.asdhh-panel) { padding:14px; }
  .asdhh-content :where(.asdhh-page-heading-actions,.asdhh-toolbar) { flex-direction:column; align-items:stretch; }
  .asdhh-content :where(.asdhh-button,button.button,a.button) { white-space:normal; text-align:center; }
  .asdhh-login-wrap { padding:12px; }
  .asdhh-login-card { padding:20px 16px; }
}
