/* ==========================================================================
   PIMS_Web - Responsive / mobile visual overrides

   Visual-only adjustments. This file is rendered LAST so that its rules
   override the theme, developer and dashboard stylesheets. All behaviour
   lives inside media queries, so wide-screen rendering is unchanged.
   ========================================================================== */

/* The drawer toggle and its backdrop are unavailable on wide screens. */
.mobile-menu-toggle {
    display: none !important;
}

.sidebar-backdrop {
    display: none;
}

/* --------------------------------------------------------------------------
   Tablet and narrower: let the page scroll naturally and stop wide tables /
   images from forcing horizontal overflow.
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    html,
    body {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto !important;
    }

    .body-contain {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: visible;
    }

    .app-content {
        overflow: visible;
    }

    .main-contain {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        width: 100%;
        overflow-x: auto;
        overflow-y: visible;
    }

    /* Flex rows otherwise shrink to their content width on small screens. */
    .main-contain .row {
        width: 100%;
    }

    /* Wide grids and tables scroll inside their own container. */
    .main-contain-content-area,
    .table-responsive,
    .grid-table,
    .action-grid-table-section,
    .data-table-container {
        max-width: 100%;
        overflow-x: auto;
    }

    img {
        max-width: 100%;
    }

    /* Modals with inline max-width values must still fit the viewport. */
    .modal-dialog {
        width: calc(100% - 1rem);
        max-width: none !important;
        margin: 0.5rem auto;
    }
}

/* --------------------------------------------------------------------------
   Phones: turn the fixed sidebar into an off-canvas drawer and make the
   header / login / standalone pages fit a narrow viewport.
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    /* Off-canvas sidebar. translateX(-100vw) hides the whole drawer
       regardless of how wide the expanded second-level menu becomes. */
    .app-sidebar {
        -webkit-transform: translateX(-100vw);
        transform: translateX(-100vw);
        -webkit-transition: -webkit-transform 0.25s ease;
        transition: transform 0.25s ease;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
    }

    body.sidebar-open .app-sidebar {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 999;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* Reveal the hamburger button. */
    .mobile-menu-toggle {
        display: inline-flex !important;
    }

    /* The views are built with col-md / col-lg only, so below the md
       breakpoint their columns have no width and do not stack cleanly.
       Force a single column on phones. */
    .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Header: allow the action icons to wrap and remove the large
       percentage offsets used by the desktop logo / classification row. */
    .nav-right {
        flex-wrap: wrap;
        white-space: normal;
        padding-right: 0 !important;
    }

    .nav-right > li {
        margin-bottom: 2px;
    }

    .header-back-btn-div {
        display: inline-flex;
        align-items: center;
    }

    .header-back-img {
        margin-right: 6px !important;
    }

    .iris-header-table td {
        padding-left: 0 !important;
    }

    .search-input {
        margin-top: 6px;
    }

    /* Login page. */
    .iframe {
        width: 100vw !important;
        margin-left: 0;
    }

    .login-content-div {
        position: relative;
        bottom: auto;
        padding-left: 0;
        margin-bottom: 20px;
    }

    .right-side-login-bar {
        float: none;
        max-width: 100%;
        height: auto;
        min-height: 100vh;
    }

    .login_details_div {
        margin: 0 10px;
        padding: 30px 15px 50px;
    }

    .login_details_div [style*="position: absolute"] {
        position: static !important;
        margin-left: 0 !important;
        bottom: auto !important;
    }

    /* Standalone reset / policy / authenticator pages. */
    .fdiv-bg {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .fdiv-content {
        width: calc(100% - 20px);
        padding: 20px 15px;
        margin-top: 0;
    }
}

/* --------------------------------------------------------------------------
   Small phones: tighten spacing a little further.
   -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .main-contain {
        padding: 6px 6px 0;
    }

    .page-title {
        font-size: 16px;
    }

    .login_details_div {
        margin: 0;
        padding: 24px 12px 32px;
    }
}
