/* TradeFlow standards compatibility layer.
 * Loaded before app-ui.css so sstf-compat is the first named layer.
 * IMPORTANT: iOS/Safari <15.4 does not support cascade layers and is outside
 * the supported browser floor; see verification/MOBILE-COMPAT/STANDARDS.md.
 * 1.29.13: sstf-wizard-contract is declared FIRST so the Product Wizard central contract
 * (central-system.css) outranks every other layer for !important declarations.
 */
@layer sstf-glass,sstf-wizard-contract,sstf-typography,sstf-approved,sstf-ui-contract,sstf-compat,sstf-hotfix,sstf-authoritative,sstf-components,sstf-design;
/* sstf-standards-compat
 * Progressive-enhancement compatibility layer based on WCAG 2.2 reflow/target
 * requirements and WebKit safe-area behavior. Modern browsers retain the
 * existing design; fallbacks are scoped to touch/narrow or feature-missing UAs.
 */
@layer sstf-compat {
  html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
  :root{--sstf-visual-height:100vh;--sstf-visual-width:100vw}

  /* Fixed shell surfaces use the actual visual viewport when browser chrome or
     the software keyboard changes the usable area. 100vh remains the CSS fallback. */
  body.sstf-flow :where(.app-drawer,.app-sidebar,.store-sidebar){height:100vh!important;height:var(--sstf-visual-height,100vh)!important;max-height:var(--sstf-visual-height,100vh)!important}
  body.sstf-flow :where(dialog[open],.app-sheet[open]){max-height:calc(var(--sstf-visual-height,100vh) - 8px)!important}
  body.sstf-customer :where(.recipient-address-dialog,#preview-dialog){max-height:calc(var(--sstf-visual-height,100vh) - 12px)!important}
  body.sstf-flow .chat-overlay{max-height:calc(var(--sstf-visual-height,100vh) - 6px)!important}

  /* The notch/home indicator are layout constraints, not device sniffing. */
  @media(max-width:959px){
    body.sstf-flow .app-header{padding-block-start:calc(7px + env(safe-area-inset-top,0px))!important;padding-inline-start:max(10px,env(safe-area-inset-left,0px))!important;padding-inline-end:max(10px,env(safe-area-inset-right,0px))!important}
    body.sstf-flow .app-drawer{padding-block-start:max(12px,env(safe-area-inset-top,0px))!important;padding-block-end:max(12px,env(safe-area-inset-bottom,0px))!important}
  }

  /* Touch controls: 16px form text avoids iOS focus magnification; 44px is the
     Apple touch-target recommendation. WCAG 2.2 AA requires at least 24px. */
  @media(max-width:900px) and (pointer:coarse){
    :where(body.sstf-flow,body.sstf-admin) :where(input:not([type]),input[type="text"],input[type="search"],input[type="number"],input[type="tel"],input[type="email"],input[type="url"],input[type="password"],input[type="date"],input[type="time"],input[type="datetime-local"],select,textarea){font-size:var(--sstf-t-card)!important}
    :where(body.sstf-flow,body.sstf-admin) :where(button,.button,.flow-button,[role="button"],summary,input[type="submit"],input[type="button"],input[type="reset"]){min-block-size:44px!important;min-inline-size:44px!important}
    :where(body.sstf-flow,body.sstf-admin) input[type="checkbox"],:where(body.sstf-flow,body.sstf-admin) input[type="radio"]{min-width:24px!important;min-height:24px!important;width:24px!important;height:24px!important}
  }

  /* Wide data tables are an allowed two-dimensional-layout exception to WCAG
     reflow; keep their scroll on the table wrapper rather than clipping the page. */
  @media(max-width:700px){
    :where(body.sstf-flow,body.sstf-admin,body.sstf-customer) :where(.sstf-table-scroll,.table,.product-table-fold,.supplier-table-wrap,.supplier-review-wrap,.pricing-table-wrap,.compact-table-wrap,.fund-ledger-table,.account-report-table,.account-fold.sstf-has-account-table){max-width:100%!important;overflow-x:auto!important;overflow-y:visible;-webkit-overflow-scrolling:touch;overscroll-behavior-inline:contain}
  }

  /* sstf-reflow-320 — non-tabular application content must remain operable at
     a 320 CSS-pixel viewport. Do not force true data tables into card layouts. */
  @media(max-width:360px){
    :where(body.sstf-flow,body.sstf-admin,body.sstf-customer) main{max-width:100%!important;padding-inline:var(--sstf-space-2)!important}
    body.sstf-customer #preview-dialog .product-preview-sizes{grid-template-columns:repeat(2,minmax(0,1fr))!important}
    :where(body.sstf-flow,body.sstf-admin,body.sstf-customer) :where(.panel,section,.pricing-panel,.review-panel,.finance-record,.ops-card){max-width:100%!important;min-width:0!important}
    :where(body.sstf-flow,body.sstf-admin,body.sstf-customer) :where(h1,h2,h3,p,strong,small,label,button,a){overflow-wrap:anywhere}
  }

  /* :has() progressive fallback. The JS bootstrap adds these classes only when
     selector(:has()) is unsupported, so modern Android/desktop rules are untouched. */
  html.sstf-no-has.sstf-has-wp-app{margin-top:0!important}
  html.sstf-no-has body.sstf-flow.sstf-has-open-dialog{overflow:hidden!important}
  html.sstf-no-has body.sstf-flow.sstf-has-mobile-nav{--ui-nav-offset:calc(var(--ui-nav-height,62px) + env(safe-area-inset-bottom,0px))}
  html.sstf-no-has body.sstf-flow.sstf-has-mobile-nav main{padding-bottom:90px!important}
  html.sstf-no-has body.sstf-flow label.sstf-has-textarea,
  html.sstf-no-has body.sstf-flow label.sstf-has-full-field,
  html.sstf-no-has body.sstf-admin label.sstf-has-textarea,
  html.sstf-no-has body.sstf-admin label.sstf-has-full-field{grid-column:1/-1!important}
  html.sstf-no-has :where(body.sstf-flow,body.sstf-admin) label.sstf-has-choice{display:flex;align-items:center;gap:10px;min-height:44px}
  html.sstf-no-has body.sstf-flow .review-form.sstf-has-staff-review-actions{padding-bottom:82px!important}
  html.sstf-no-has body.sstf-flow .sstf-table-scroll.sstf-has-account-totals{margin-block:var(--sstf-space-3)}
  html.sstf-no-has :where(body.sstf-flow,body.sstf-admin,body.sstf-customer) .account-fold.sstf-has-account-table{max-width:100%!important;overflow-x:auto!important;border:1px solid var(--sstf-runtime-line)!important;border-radius:var(--sstf-r-m)!important;background:#fff!important}
  html.sstf-no-has :where(body.sstf-flow,body.sstf-admin,body.sstf-customer) .account-fold.sstf-has-account-table>table{display:table!important;width:100%!important;min-width:680px!important}
  html.sstf-no-has body.sstf-flow :where(.supplier-table-wrap,.supplier-review-wrap,.account-report-table).sstf-has-wide-table{overflow-x:auto!important;overscroll-behavior-inline:contain!important}
  html.sstf-no-has body.sstf-flow .accounting-ui .nav-dropdown.sstf-has-current-link>summary{background:#edf4fb;color:#174a87}
  html.sstf-no-has body.sstf-flow .chat-overlay-conversation.sstf-has-active-chat{position:absolute;inset:52px 0 0;background:#fff}
  html.sstf-no-has body.sstf-customer.plain-order-page.sstf-has-plain-order-actions main{padding-block-end:88px!important}
  html.sstf-no-has body.sstf-customer.plain-order-page.sstf-has-customer-bottom-actions main{padding-block-end:132px!important}
  html.sstf-no-has body.sstf-customer.plain-order-page .customer-bottom-stack.sstf-has-order-actions{position:fixed!important;z-index:970!important;inset-inline:0!important;inset-block-end:0!important;display:grid!important;width:100%!important;margin:0!important;padding:0!important;border-block-start:1px solid #dce5ed!important;background:#fff!important;box-shadow:var(--sstf-sh-card)!important}
  html.sstf-no-has body.sstf-flow.sstf-has-attendance-print :where(.app-header,footer,.mobile-nav){display:none!important}
  html.sstf-no-has body.sstf-flow.sstf-has-attendance-print main{padding:0!important;margin:0!important}
  html.sstf-no-has body.sstf-flow.sstf-has-inventory-config dialog.product-wizard{z-index:100001!important;padding:0!important;border-radius:var(--sstf-r-l)!important;background:#fff!important}
  @media(min-width:960px){
    html.sstf-no-has body.sstf-flow.sstf-has-sidebar{--ui-sidebar:232px;--ui-nav-offset:0px}
    html.sstf-no-has body.sstf-flow.sstf-has-sidebar main{margin-inline-start:var(--ui-sidebar)!important;max-width:none!important;padding-inline:28px!important}
  }

  /* Lightweight native-dialog fallback for layer-capable browsers lacking the
     native API. Safari/iOS <15.4 is outside the support floor because it also
     lacks Cascade Layers, which the application stylesheet requires. */
  html.sstf-dialog-fallback dialog:not([open]){display:none!important}
  html.sstf-dialog-fallback dialog[open]{position:fixed;z-index:100000;inset:50% auto auto 50%;transform:translate(-50%,-50%);display:block;max-width:calc(100vw - 20px);max-height:calc(var(--sstf-visual-height,100vh) - 20px);overflow:auto}
  html.sstf-dialog-fallback body.sstf-has-open-dialog::before{content:"";position:fixed;z-index:99999;inset:0;background:rgba(23,35,51,.44)}
  html.sstf-dialog-fallback body.sstf-has-open-dialog{overflow:hidden!important}
}

@layer sstf-compat {
  /* iPhone-class narrow widths: stop compressing five metadata cells into a
     single 375–430px row. Information is preserved and reflows to two columns. */
  @media(max-width:430px){
body.sstf-customer .customer-order-static .order-meta-country [data-country-name]{font-size:var(--sstf-t-small)!important;line-height:1.35!important}
body.sstf-customer .customer-order-static .order-meta-date strong{font-size:var(--sstf-t-small)!important;letter-spacing:normal!important;line-height:1.35!important}
    body.sstf-customer .app-header .company-name-ar{font-size:var(--sstf-t-small)!important;line-height:1.2!important}
  }
}
