/* ============================================================================
   EduArewa Native Mobile App Shell Styles (< 768px Bottom Sheets & Helpers)
   Desktop (>= 768px / >= 992px) is 100% untouched.
   ============================================================================ */

@media (max-width: 767px) {
    /* Convert standard Bootstrap modals into iOS/Android Slide-Up Bottom Sheets.
       Explicitly exclude full-screen PDF Preview Modals, Designer Preview overlays,
       and Image Cropper modals so their full-screen canvas layouts stay intact. */
    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) {
        padding-right: 0 !important;
        overflow: hidden !important;
    }

    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-dialog,
    body.ea-native-mobile-shell #teacherInviteModal .modal-dialog,
    body.ea-native-mobile-shell #modalQuickAddStudent .modal-dialog {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: translate3d(0, 100%, 0) !important;
        -webkit-transform: translate3d(0, 100%, 0) !important;
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1) !important;
        -webkit-transition: -webkit-transform 0.28s cubic-bezier(0.32, 0.72, 0, 1) !important;
    }

    .modal.in:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-dialog,
    .modal.show:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-dialog,
    body.ea-native-mobile-shell #teacherInviteModal.in .modal-dialog,
    body.ea-native-mobile-shell #teacherInviteModal.show .modal-dialog,
    body.ea-native-mobile-shell #modalQuickAddStudent.in .modal-dialog,
    body.ea-native-mobile-shell #modalQuickAddStudent.show .modal-dialog {
        transform: translate3d(0, 0, 0) !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
    }

    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-content {
        border-radius: 22px 22px 0 0 !important;
        border: none !important;
        max-height: 88dvh !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        box-shadow: 0 -10px 32px rgba(15, 23, 42, 0.22) !important;
        background: #FFFFFF;
    }

    /* Native iOS Grabber Pill */
    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-content::before {
        content: "";
        display: block;
        width: 38px;
        height: 4px;
        border-radius: 999px;
        background: rgba(148, 163, 184, 0.45);
        margin: 10px auto 2px;
        flex-shrink: 0;
    }

    /* Ensure form wrappers directly inside .modal-content flex cleanly */
    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-content > form {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-header {
        flex-shrink: 0 !important;
        background: #FFFFFF !important;
        color: #0F172A !important;
        border-bottom: 1px solid #E2E8F0 !important;
        padding: 10px 16px 12px !important;
    }

    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-body {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain;
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }

    .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-footer {
        flex-shrink: 0 !important;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
        border-top: 1px solid #E2E8F0;
    }

    /* Keep Select2 dropdowns above bottom sheets */
    .select2-drop,
    .select2-drop-active,
    .select2-container--open .select2-dropdown {
        z-index: 10060 !important;
    }

    /* Dark Mode Bottom Sheet Support */
    html.dark .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-content,
    body.dark-theme .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-content,
    [data-theme="dark"] .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-content {
        background: #111827 !important;
        color: #F8FAFC !important;
        border-top: 1px solid #1E293B !important;
        box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.55) !important;
    }

    html.dark .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-header,
    body.dark-theme .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-header,
    [data-theme="dark"] .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-header {
        background: #111827 !important;
        border-bottom-color: #1E293B !important;
        color: #F8FAFC !important;
    }

    html.dark .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-title,
    body.dark-theme .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-title {
        color: #F8FAFC !important;
    }

    html.dark .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-footer,
    body.dark-theme .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-footer,
    [data-theme="dark"] .modal:not(#eaBsPdfModal):not(#eaCumPdfModal):not(#eaRcPdfModal):not(.ea-fullscreen-modal):not(.cropper-modal):not(#eaLogoCropperModal):not(#eaSigCropperModal) .modal-footer {
        background: #111827 !important;
        border-top-color: #1E293B !important;
    }
}

/* ============================================================================
   Chunk 3: Cross-Document View Transitions, Tactile Physics & Safe-Area Insets
   ============================================================================ */
@view-transition {
    navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 160ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 991px) {
    a,
    button,
    .btn,
    .ea-bottom-nav-item,
    .ea-m-tile,
    .ea-tm-tile,
    .ea-hub-tile,
    .ea-hub-list-row,
    .ea-native-back-btn,
    .ea-native-avatar-btn {
        -webkit-tap-highlight-color: transparent;
    }

    .ea-bottom-nav-item,
    .ea-hub-tile,
    .ea-hub-close-btn,
    .ea-native-back-btn,
    .ea-native-avatar-btn,
    .ea-m-hero-menu-btn,
    .ea-m-glass-pill,
    button.btn {
        user-select: none;
        -webkit-user-select: none;
    }

    .ea-bottom-nav-item,
    .ea-m-tile,
    .ea-tm-tile,
    .ea-hub-tile {
        transition: transform 110ms ease, background-color 120ms ease, border-color 120ms ease;
    }
    .ea-bottom-nav-item:active,
    .ea-m-tile:active,
    .ea-tm-tile:active,
    .ea-hub-tile:active {
        transform: scale(0.97);
    }

    /* Safe-area insets for iPhone notch / home indicator */
    body.ea-native-mobile-shell .ea-mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        height: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    }
    body.ea-native-mobile-shell .content-body {
        padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Anti-Flash Standalone Mode: Never flash install prompts when opened as installed PWA */
@media (display-mode: standalone), (display-mode: fullscreen) {
    .ea-pwa-install-banner,
    .ea-pwa-install-entry {
        display: none !important;
    }
}
