/* ============================================================
   GREEN NAVIGATOR — GLOBAL MOBILE RESPONSIVE OVERRIDE
   Mobile drawer hierarchy fix + site-wide responsive guardrails.
   Loaded last by green_navigator_shell.js.
   ============================================================ */

@media (max-width: 980px) {
    .public-shell .main-navigation .gn-language-switcher select {
        width: 108px !important;
        min-width: 108px !important;
        max-width: 108px !important;
    }
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden !important;
    }

    body {
        background: #f7f9f7;
    }

    /*
     * Keep the application shell as a one-column grid.
     * Do NOT turn it into display:block; the desktop/sidebar
     * shell relies on the grid structure.
     */
    .app-shell {
        display: grid !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        min-height: 100dvh !important;
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .app-main {
        position: relative !important;
        grid-column: 1 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        z-index: 1 !important;
    }

    /* ========================================================
       MOBILE SIDEBAR DRAWER
       The drawer must sit above the backdrop; the backdrop must
       sit above the topbar, AI bottom nav and page content.
       ======================================================== */

    .app-sidebar {
        position: fixed !important;
        inset: 0 auto 0 0 !important;
        display: flex !important;

        width: min(84vw, 320px) !important;
        max-width: 320px !important;
        height: 100dvh !important;
        min-height: 100dvh !important;

        padding: 16px 12px 20px !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch;

        background: #ffffff !important;
        border-right: 1px solid #dfe8e1 !important;

        transform: translate3d(-105%, 0, 0) !important;
        transition: transform .22s ease !important;

        box-shadow: 18px 0 48px rgba(25, 50, 31, .16) !important;

        z-index: 1001 !important;
    }

    body.sidebar-open .app-sidebar {
        transform: translate3d(0, 0, 0) !important;
    }

    .mobile-sidebar-backdrop {
        position: fixed !important;
        inset: 0 !important;

        display: block !important;

        width: 100vw !important;
        height: 100dvh !important;

        margin: 0 !important;
        padding: 0 !important;

        background: rgba(21, 37, 26, .42) !important;
        border: 0 !important;

        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;

        transition:
            opacity .2s ease,
            visibility .2s ease !important;

        z-index: 1000 !important;
    }

    body.sidebar-open .mobile-sidebar-backdrop {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    body.sidebar-open {
        overflow: hidden !important;
    }

    /*
     * Anything fixed/sticky inside a page must stay under the
     * mobile drawer backdrop.
     */
    .app-topbar,
    .ai-mobile-nav,
    .ai-composer-shell,
    .ai-chat-composer,
    .gn-global-search-results {
        z-index: 80 !important;
    }

    body.sidebar-open .ai-mobile-nav,
    body.sidebar-open .ai-composer-shell,
    body.sidebar-open .ai-chat-composer {
        pointer-events: none !important;
    }

    /* Desktop collapse control is not used inside the phone drawer. */
    .gn-sidebar-collapse {
        display: none !important;
    }

    .gn-sidebar-brand-row {
        width: 100% !important;
        min-width: 0 !important;
    }

    .sidebar-brand {
        width: 100% !important;
        min-height: 70px !important;
        margin: 0 0 14px !important;
    }

    .sidebar-primary-action {
        min-height: 48px !important;
        margin-bottom: 20px !important;
    }

    .sidebar-link {
        min-height: 48px !important;
        font-size: .94rem !important;
    }

    /* ========================================================
       TOP BAR
       ======================================================== */

    .app-topbar {
        position: sticky !important;
        top: 0 !important;

        width: 100% !important;
        min-width: 0 !important;
        min-height: 64px !important;

        padding: 9px 12px !important;

        gap: 8px !important;

        background: rgba(255, 255, 255, .97) !important;
        border-bottom: 1px solid #e0e8e2 !important;

        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);

        z-index: 80 !important;
    }

    .topbar-left,
    .topbar-right {
        min-width: 0 !important;
        gap: 7px !important;
    }

    .topbar-left {
        flex: 1 1 auto !important;
        overflow: hidden !important;
    }

    .topbar-right {
        flex: 0 1 auto !important;
        justify-content: flex-end !important;
    }

    .sidebar-toggle {
        display: inline-flex !important;

        width: 44px !important;
        height: 44px !important;
        flex: 0 0 44px !important;

        padding: 0 !important;

        border-radius: 12px !important;
    }

    .topbar-context {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    .topbar-context-title {
        max-width: 235px !important;

        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;

        font-size: .92rem !important;
        font-weight: 800 !important;
    }

    .topbar-company {
        max-width: 128px !important;
        min-width: 0 !important;
        min-height: 40px !important;

        padding: 8px 10px !important;

        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;

        font-size: .76rem !important;
    }

    .gn-language-switcher {
        min-width: 0 !important;
    }

    .gn-language-switcher-label {
        display: none !important;
    }

    .gn-language-switcher select {
        width: 104px !important;
        min-width: 104px !important;
        max-width: 104px !important;
        min-height: 40px !important;

        padding: 7px 8px !important;

        font-size: .78rem !important;
    }

    .topbar-notification {
        width: 44px !important;
        height: 44px !important;
        flex: 0 0 44px !important;
    }

    /* ========================================================
       GLOBAL PAGE CONTENT
       ======================================================== */

    .app-content {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
        padding: 18px 14px 28px !important;

        overflow-x: clip !important;
    }

    .app-content--workspace {
        padding: 0 !important;
        overflow: hidden !important;
    }

    .app-content > *,
    .app-content main,
    .app-content section,
    .app-content article,
    .app-content header,
    .app-content footer,
    .app-content form,
    .app-content fieldset,
    .app-content div {
        min-width: 0;
        max-width: 100%;
    }

    .app-content img,
    .app-content video,
    .app-content canvas {
        max-width: 100% !important;
        height: auto;
    }

    .page-header,
    .page-heading,
    .page-heading-row,
    .page-title-row,
    .header-row,
    .header-actions,
    .page-actions,
    .toolbar,
    .toolbar-actions,
    .filter-bar,
    .filters,
    .filter-actions,
    .form-actions,
    .actions,
    .action-row,
    .actions-row,
    .button-row {
        width: 100% !important;
        max-width: 100% !important;

        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .app-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    .app-content select,
    .app-content textarea {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .form-grid,
    .fields-grid,
    .field-grid,
    .filters-grid,
    .settings-grid,
    .details-grid,
    .detail-grid,
    .dashboard-grid,
    .stats-grid,
    .cards-grid,
    .card-grid,
    .reports-grid,
    .report-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .content-card,
    .card,
    .panel,
    .dashboard-card,
    .stat-card,
    .summary-card,
    .detail-card,
    .settings-card,
    .report-card,
    .form-card {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .table-responsive,
    .table-wrap,
    .table-wrapper,
    .table-container,
    .data-table-wrap,
    .records-table-wrap {
        display: block !important;

        width: 100% !important;
        max-width: 100% !important;

        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .authenticated-footer {
        padding: 12px 14px 22px !important;
        font-size: .72rem !important;
    }
}

@media (max-width: 700px) {
    .app-topbar {
        min-height: 62px !important;
        padding: 8px 9px !important;
    }

    .topbar-context-dot {
        display: none !important;
    }

    .topbar-context-title {
        max-width: 180px !important;
        font-size: .86rem !important;
    }

    .topbar-company {
        max-width: 104px !important;
        padding-left: 9px !important;
        padding-right: 9px !important;
    }

    .gn-language-switcher select {
        width: 104px !important;
        min-width: 104px !important;
        max-width: 104px !important;
    }

    .app-content {
        padding: 15px 10px 26px !important;
    }

    .app-content--workspace {
        padding: 0 !important;
    }

    .app-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    .app-content select,
    .app-content textarea {
        font-size: 16px !important;
    }

    .app-content .btn,
    .app-content .button,
    .app-content button:not(.icon-button):not([aria-label]),
    .app-content input[type="submit"],
    .app-content input[type="button"] {
        min-height: 44px;
    }
}

@media (max-width: 520px) {
    .app-topbar {
        gap: 6px !important;
    }

    .topbar-left,
    .topbar-right {
        gap: 6px !important;
    }

    .sidebar-toggle,
    .topbar-notification {
        width: 42px !important;
        height: 42px !important;
        flex-basis: 42px !important;
    }

    .topbar-context-title {
        max-width: 165px !important;
    }

    .topbar-company {
        display: none !important;
    }

    .gn-language-switcher select {
        width: 104px !important;
        min-width: 104px !important;
        max-width: 104px !important;

        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    .app-content {
        padding-left: 9px !important;
        padding-right: 9px !important;
    }

    .app-content--workspace {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Greenhouse/floor-plan workspace manages its own full-screen geometry. */
.app-main--workspace .app-content--workspace {
    max-width: none !important;
}
