/* AquaFlow V30.1 — Android phone UX layer.
   Scoped by mobile-platform.js so the existing iPhone viewport fixes stay untouched. */
html[data-platform="android"]{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  color-scheme:light;
}
html[data-platform="android"] body{
  min-height:100dvh;
  -webkit-tap-highlight-color:transparent;
}
html[data-platform="android"][data-app-mode="standalone"] body{
  overscroll-behavior-y:none;
}
html[data-platform="android"] :is(button,a,input,select,textarea,summary,[role="button"]){
  -webkit-tap-highlight-color:transparent;
}
html[data-platform="android"] :is(button,a,summary,[role="button"]){touch-action:manipulation}
html[data-platform="android"] :is(input,select,textarea){min-width:0}

@media(max-width:980px){
  /* Chromium honors interactive-widget=resizes-content; this is a safe fallback
     for older Android WebViews/PWAs using the measured visual viewport. */
  html[data-platform="android"] dialog:not(#chat-message-menu){
    max-height:min(var(--af-android-vh,100dvh),calc(100dvh - 8px));
    overscroll-behavior:contain;
  }
  html[data-platform="android"] dialog::backdrop{
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }

  /* Fixed bottom navigation: solid surface is cheaper to composite than blur,
     scrollbar is hidden, and horizontal swipes stay inside the nav. */
  html[data-platform="android"] body.unified-shell .tabs{
    height:72px!important;
    padding:5px 5px max(6px,env(safe-area-inset-bottom,0px))!important;
    background:#fff!important;
    box-shadow:0 -3px 16px rgba(20,48,79,.08)!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
    scrollbar-width:none;
    overscroll-behavior-x:contain;
    touch-action:pan-x;
  }
  html[data-platform="android"] body.unified-shell .tabs::-webkit-scrollbar{display:none}
  html[data-platform="android"] body.unified-shell .tab{
    flex:0 0 72px!important;
    min-width:72px!important;
    height:58px!important;
    min-height:58px!important;
    scroll-snap-align:center;
  }
  html[data-platform="android"] body.unified-shell .shell{
    padding-bottom:calc(88px + env(safe-area-inset-bottom,0px))!important;
    scroll-padding-bottom:calc(92px + env(safe-area-inset-bottom,0px));
  }

  /* Driver/staff has only the working tabs: fit them across common
     360–430 px Android screens instead of forcing a horizontal swipe. */
  html[data-platform="android"] body.staff-mode .tabs .tab:not(.is-hidden){
    flex:1 1 0!important;
    min-width:56px!important;
    max-width:none!important;
  }
  html[data-platform="android"] body.staff-mode .tabs .tab-copy{font-size:9.5px!important}

  /* When Android raises its keyboard, Chromium moves fixed bars above it.
     Hide the navigation temporarily so forms/chat get the full resized area. */
  html[data-platform="android"][data-android-keyboard-open] body.unified-shell .tabs{display:none!important}
  html[data-platform="android"][data-android-keyboard-open] body.unified-shell .shell{
    padding-bottom:18px!important;
    scroll-padding-bottom:18px!important;
  }

  /* More Android-friendly tap targets without inflating dense data rows. */
  html[data-platform="android"] :is(
    #workspace-header button,
    #workspace-daybar .af-daybar-controls button,
    .dialog-actions .btn,
    .payment-enterprise-actions .btn,
    .expense-enterprise-actions .btn,
    .order-card-actions .mini-btn,
    .assistant-date-controls button,
    .assistant-close-shift,
    .assistant-shift-dialog footer button
  ){min-height:44px}

  html[data-platform="android"] #workspace-header{
    background:#f3f6fb!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  html[data-platform="android"] .dialog-actions,
  html[data-platform="android"] .payment-enterprise-actions,
  html[data-platform="android"] .expense-enterprise-actions{
    background:#fff;
    padding-bottom:max(10px,env(safe-area-inset-bottom,0px));
  }

  /* Long lists remain fluid on mid-range Android phones. */
  html[data-platform="android"] :is(
    .aquaflow-order-card,
    .staff-delivery-compact,
    .debt-row,
    .customer-row,
    .operation-row,
    .plan-row,
    .work-row,
    .week-row,
    .assistant-advance-row
  ){
    content-visibility:auto;
    contain-intrinsic-size:auto 84px;
  }
}

@media(max-width:600px){
  html[data-platform="android"] body.unified-shell .shell{padding-left:9px!important;padding-right:9px!important}
  html[data-platform="android"] #workspace-header{padding-inline:2px!important}
  html[data-platform="android"] #workspace-header :is(.logo,.assistant-logo){width:38px!important;height:38px!important;flex-basis:38px!important}
  html[data-platform="android"] #workspace-header :is(.brand,.assistant-brand) h1{font-size:16px!important}
  html[data-platform="android"] #workspace-header :is(.brand,.assistant-brand) small{font-size:7.5px!important}
  html[data-platform="android"] #workspace-header .account-button{max-width:98px!important}

  html[data-platform="android"] dialog:not(#internal-chat):not(#chat-message-menu):not(#push-settings):not(#customer-dialog):not(#customer-history-dialog){
    width:calc(100% - 8px)!important;
    max-width:none!important;
    margin:auto!important;
    border-radius:20px!important;
  }
  html[data-platform="android"] .assistant-shift-dialog{
    width:100vw!important;
    max-width:none!important;
    height:var(--af-android-vh,100dvh)!important;
    max-height:var(--af-android-vh,100dvh)!important;
    margin:0!important;
    border-radius:0!important;
  }
  html[data-platform="android"] .assistant-shift-dialog form{
    height:100%!important;
    max-height:100%!important;
  }

  /* Keep native date/select controls usable with larger Android font settings. */
  html[data-platform="android"] :is(
    #workspace-daybar input,
    .order-filter-tools input,
    dialog input,
    dialog select,
    dialog textarea,
    .assistant-date-controls input
  ){font-size:16px}
}

@media(max-width:370px){
  html[data-platform="android"] body.staff-mode .tabs .tab:not(.is-hidden){min-width:52px!important}
  html[data-platform="android"] body.staff-mode .tab-icon{font-size:18px!important}
  html[data-platform="android"] body.staff-mode .tab-copy{font-size:9px!important}
  html[data-platform="android"] #workspace-header :is(.brand,.assistant-brand) small{display:none!important}
  html[data-platform="android"] #workspace-header .account-button{max-width:86px!important;padding-inline:6px!important}
}

/* V32.9 — delivery list stability wins over long-list virtualization.
   Delivery cards are small enough to paint normally, and this avoids flashes
   on devices whose browser compositor repaints content-visibility children. */
@media(max-width:980px){
  html[data-platform="android"] #deliveries .staff-delivery-compact,
  html[data-platform="android"] #delivery-list .staff-delivery-compact{
    content-visibility:visible!important;
    contain-intrinsic-size:none!important;
    transform:none!important;
    will-change:auto!important;
  }
}
