/* RUYA_V2.4.24.3_HF5_MOBILE_DOC_MESSAGE_DEEPLINK_DATA_PUSH_SAFE
 * Additive UI fix only. No DB, auth, VAPID, push worker or SW transport changes.
 */

/* ---------------------------------------------------------
   Mobile parent messages: one natural scroll flow.
   Composer is part of the thread; it never floats over messages/nav.
   --------------------------------------------------------- */
@media (max-width:900px){
  html.ruyaHf5Messages #root .role-parent .main.parentMain{
    overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:contain!important;touch-action:pan-y!important;
    padding-bottom:calc(106px + env(safe-area-inset-bottom))!important;
    scroll-padding-bottom:calc(106px + env(safe-area-inset-bottom))!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout{
    display:flex!important;flex-direction:column!important;gap:10px!important;
    width:100%!important;min-height:0!important;height:auto!important;overflow:visible!important;
    padding:0 0 8px!important;margin:0!important;box-sizing:border-box!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .conversationList{
    flex:0 0 auto!important;display:block!important;width:100%!important;
    max-height:118px!important;min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;
    -webkit-overflow-scrolling:touch!important;overscroll-behavior:contain!important;margin:0!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .conversationItem{
    min-height:68px!important;padding:9px 11px!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .conversationThread{
    flex:0 0 auto!important;display:flex!important;flex-direction:column!important;
    width:100%!important;height:auto!important;min-height:0!important;max-height:none!important;
    margin:0!important;padding:0!important;overflow:hidden!important;box-sizing:border-box!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .conversationPlaceholder{
    min-height:148px!important;height:auto!important;padding:28px 16px!important;box-sizing:border-box!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .threadHeader{
    flex:0 0 auto!important;padding:10px 13px!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .messageThread{
    flex:0 1 auto!important;width:100%!important;min-height:170px!important;max-height:min(34dvh,300px)!important;
    overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch!important;
    overscroll-behavior:contain!important;touch-action:pan-y!important;padding:12px!important;box-sizing:border-box!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .replyComposer,
  html.ruyaHf5Messages body.ruyaIosDevice #root .role-parent .messagingLayout .replyComposer,
  html.ruyaHf5Messages body.ruyaIosKeyboardOpen #root .role-parent .messagingLayout .replyComposer,
  html.ruyaHf5Messages body.ruyaMobileComposerFocus #root .role-parent .messagingLayout .replyComposer{
    position:relative!important;inset:auto!important;left:auto!important;right:auto!important;top:auto!important;bottom:auto!important;
    flex:0 0 auto!important;display:grid!important;grid-template-columns:minmax(0,1fr) 92px!important;
    align-items:end!important;gap:8px!important;width:100%!important;min-height:0!important;
    margin:0!important;padding:10px!important;box-sizing:border-box!important;
    border:0!important;border-top:1px solid #dfe5ee!important;border-radius:0!important;
    background:#fff!important;box-shadow:none!important;transform:none!important;z-index:6!important;
    scroll-margin-bottom:14px!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .replyComposer textarea{
    width:100%!important;min-width:0!important;min-height:48px!important;max-height:96px!important;
    margin:0!important;padding:11px 12px!important;box-sizing:border-box!important;resize:none!important;
    font-size:16px!important;line-height:1.35!important;
  }
  html.ruyaHf5Messages #root .role-parent .messagingLayout .replyComposer button{
    width:92px!important;min-width:92px!important;height:48px!important;min-height:48px!important;
    margin:0!important;padding:0 9px!important;border-radius:14px!important;font-size:13px!important;
  }
  html.ruyaHf5Messages body.ruyaMobileComposerFocus #root nav.ruya-r793-bottom-nav,
  html.ruyaHf5Messages body.ruyaIosKeyboardOpen #root nav.ruya-r793-bottom-nav{
    display:none!important;visibility:hidden!important;pointer-events:none!important;
  }
  html.ruyaHf5Messages body.ruyaMobileComposerFocus #root .role-parent .main.parentMain,
  html.ruyaHf5Messages body.ruyaIosKeyboardOpen #root .role-parent .main.parentMain{
    padding-bottom:12px!important;scroll-padding-bottom:12px!important;
  }
}
@media (max-width:540px){
  html.ruyaHf5Messages #root .role-parent .messagingLayout .messageThread{min-height:150px!important;max-height:min(31dvh,250px)!important}
  html.ruyaHf5Messages #root .role-parent .messagingLayout .replyComposer,
  html.ruyaHf5Messages body.ruyaIosDevice #root .role-parent .messagingLayout .replyComposer{grid-template-columns:minmax(0,1fr) 84px!important}
  html.ruyaHf5Messages #root .role-parent .messagingLayout .replyComposer button{width:84px!important;min-width:84px!important;font-size:12px!important}
}

/* ---------------------------------------------------------
   Android Documents/Bulletins: restore the main vertical scroll surface.
   --------------------------------------------------------- */
@media (max-width:900px){
  html.ruyaHf5AndroidDocuments,
  html.ruyaHf5AndroidDocuments body,
  html.ruyaHf5AndroidDocuments body #root{
    height:100%!important;min-height:0!important;max-height:100%!important;
    overflow:hidden!important;overscroll-behavior:none!important;
  }
  html.ruyaHf5AndroidDocuments body #root>.shell.role-parent{
    height:100vh!important;height:100dvh!important;min-height:0!important;max-height:100dvh!important;overflow:hidden!important;
  }
  html.ruyaHf5AndroidDocuments body #root>.shell.role-parent>main.main.parentMain{
    height:100vh!important;height:100dvh!important;min-height:0!important;max-height:100dvh!important;
    overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:contain!important;touch-action:pan-y!important;scroll-behavior:auto!important;
    padding-bottom:calc(118px + env(safe-area-inset-bottom))!important;
    scroll-padding-bottom:calc(118px + env(safe-area-inset-bottom))!important;
  }
  html.ruyaHf5AndroidDocuments #root .ruyaContentHubSubView,
  html.ruyaHf5AndroidDocuments #root .ruyaDocumentsPage,
  html.ruyaHf5AndroidDocuments #root .v5DocumentToolbar,
  html.ruyaHf5AndroidDocuments #root .uploadedFileList{
    min-height:0!important;max-height:none!important;overflow:visible!important;touch-action:pan-y!important;
  }
}

/* ---------------------------------------------------------
   Document viewer: fit first, then allow content pinch.
   Native iOS PDF plug-in tends to render wider than its iframe; scale the
   plug-in surface only, not the application UI.
   --------------------------------------------------------- */
body.ruyaDocumentViewerOpen{overflow:hidden!important}
.ruyaDocumentViewerOverlay{width:100vw!important;height:100dvh!important;max-width:100vw!important;max-height:100dvh!important;overflow:hidden!important}
.ruyaDocumentViewerStage{
  width:100%!important;min-width:0!important;min-height:0!important;max-width:100%!important;
  overflow:auto!important;padding:0!important;box-sizing:border-box!important;
  touch-action:pinch-zoom!important;overscroll-behavior:contain!important;background:#eef2f7!important;
}
.ruyaDocumentViewerStage>iframe{
  display:block!important;border:0!important;margin:0!important;background:#fff!important;
  width:100%!important;height:100%!important;min-width:0!important;min-height:100%!important;
  transform-origin:0 0!important;touch-action:pinch-zoom!important;
}
body.ruyaIosDevice .ruyaDocumentViewerStage>iframe{
  width:100%!important;height:100%!important;max-width:100%!important;max-height:100%!important;
  transform:none!important;transform-origin:0 0!important;
}
.ruyaDocumentViewerStage>.ruyaDocumentViewerImage{
  max-width:100%!important;max-height:100%!important;width:auto!important;height:auto!important;object-fit:contain!important;
  margin:auto!important;touch-action:pinch-zoom!important;
}

/* App UI remains locked; only dedicated viewer surfaces accept pinch. */
.ruyaDocumentViewerOverlay,.ruyaDocumentViewerStage,.ruyaDocumentViewerImage,
.ruyaDeepDocumentViewer,.ruyaDeepDocumentBody,.ruyaPinchZoomSurface{
  touch-action:pinch-zoom!important;-ms-touch-action:pinch-zoom!important;
}

/* RUYA PDFJS VIEWER V1 */
.ruyaDocumentViewerStage.ruyaPdfJsStage{
  display:block!important;
  overflow:auto!important;
  padding:6px!important;
  -webkit-overflow-scrolling:touch!important;
  overscroll-behavior:contain!important;
  background:#dfe5ec!important;
}
.ruyaPdfJsSurface{
  display:block;
  margin:0 auto;
  min-width:0;
}
.ruyaPdfJsPage{
  display:block;
  max-width:none!important;
  height:auto;
  margin:0 auto 8px;
  background:#fff;
  box-shadow:0 2px 10px rgba(20,40,70,.12);
}
.ruyaPdfJsLoading{
  padding:24px;
  text-align:center;
  color:#52627a;
  font-size:14px;
}

/* RUYA PDFJS TOUCH SCROLL FIX V1 */
body.ruyaDocumentViewerOpen{
  touch-action:auto!important;
}
.ruyaDocumentViewerOverlay{
  touch-action:auto!important;
}
.ruyaDocumentViewerStage.ruyaPdfJsStage{
  overflow:auto!important;
  -webkit-overflow-scrolling:touch!important;
  touch-action:pan-x pan-y!important;
  overscroll-behavior:contain!important;
}
.ruyaPdfJsSurface,
.ruyaPdfJsPage{
  touch-action:pan-x pan-y!important;
}
