/* Platform-specific global styles for iOS, Android, and PWA support */

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ============================================================
   SAFE AREA: Applied unconditionally via env() so it works
   without waiting for JS to add a platform class.
   env() returns 0px on desktop/non-notched devices — safe globally.
   Requires: <meta name="viewport" content="viewport-fit=cover">
   ============================================================ */

/* Grow the Radzen header to absorb the top safe area (notch / Dynamic Island).
   The header background already extends behind the status bar thanks to
   viewport-fit=cover + black-translucent. This makes interactive content
   start below the notch rather than being hidden under it. */
.rz-header {
    padding-top: env(safe-area-inset-top, 0px);
    box-sizing: content-box; /* height stays 64px; padding adds to it */
}

/* Neutralise the old class-gated approach — rz-header now handles this */
.platform-ios .header-container,
.platform-ios .mobile-header-container {
    padding-top: 0 !important;
}

/* Bottom safe area: keep content above the home indicator */
.rz-body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
}

/* Left/right safe area (landscape notch) */
.rz-header,
.rz-body {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* ============================================================
   SCROLLBARS: Hide the outer layout scrollbar on mobile.
   Touch scroll still works — the scrollbar just isn't rendered.
   Individual page scroll containers keep their own scrollbars.
   ============================================================ */
@media (max-width: 1024px) {
    .rz-body {
        scrollbar-width: none;        /* Firefox */
        -ms-overflow-style: none;     /* IE / Edge legacy */
    }

    .rz-body::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }
}

/* ============================================================
   iOS Safe Areas (platform-ios set by JS — kept as fallback
   for anything that still needs the class-gated approach)
   ============================================================ */
.platform-ios .rz-layout {
    min-height: calc(100vh - env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - env(safe-area-inset-bottom, 0px));
}

/* Fix mobile dialogs overlapping the top notch/status area.
   Radzen dialogs are fixed-position overlays and don't inherit body safe-area padding.
   The wrapper backdrop stays full-screen (edge-to-edge including safe area) so the
   darkened overlay fills correctly. The dialog card itself is shifted down via
   margin-top so it starts below the notch — users can still tap the backdrop in
   the safe area to dismiss. */
@media (max-width: 1024px) {
    /* Left/right/bottom insets applied to the wrapper are fine — those edges
       don't have interactive backdrop area that users need to tap. */
    .rz-dialog-wrapper {
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        padding-left: env(safe-area-inset-left, 0px) !important;
        padding-right: env(safe-area-inset-right, 0px) !important;
        box-sizing: border-box;
    }

    /* Move the dialog card below the notch/Dynamic Island via margin-top on the
       dialog itself, not padding on the wrapper. The wrapper backdrop remains
       full-screen so the masked safe area stays interactive (tappable to dismiss). */
    .platform-ios .rz-dialog:not(.rz-dialog-confirm):not(.rz-dialog-alert) {
        margin-top: max(16px, env(safe-area-inset-top, 0px)) !important;
        max-height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ============================================================
   Android Device Styles (platform-android set by JS)
   ============================================================ */
.platform-android .rz-layout,
.platform-android .rz-body,
.platform-android .main-content,
.platform-android .rz-row,
.platform-android .rz-column {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    overflow-x: hidden !important;
    margin: 0 auto !important;
    padding: 0 !important;
}

/* Android PWA overrides (fixes edge-to-edge devices like S21+) */
.platform-android.pwa {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.platform-android.pwa,
.platform-android.pwa body,
.platform-android.pwa .rz-layout {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 auto !important;
    overflow-x: hidden !important;
}

/* ANDROID + PWA: Hide scrollbars while preserving scroll behavior */
.platform-android.pwa body {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.platform-android.pwa body::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
    background: transparent !important;
    -webkit-appearance: none !important;
}

/* Prefer container-level control for scrolling regions */
.platform-android.pwa .scroll-container {
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.platform-android.pwa .scroll-container::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
    background: transparent !important;
    -webkit-appearance: none !important;
}

/* ============================================================
   PWA layout container sizing (both platforms when .pwa present)
   ============================================================ */
.pwa .rz-layout {
    position: relative;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    contain: layout paint;
    transform: translateZ(0);
    will-change: transform;
}
