/* static/css/mobile_override.css
   Final mobile safety overrides.
   Load this file after every page-specific stylesheet.
*/

/* Keep the first and last content edges equal on every standard page. */
body:not(.pdf-viewer-page):not(.login-page) .app-main {
    padding-top: var(--page-edge-gap) !important;
    padding-bottom: var(--page-edge-gap) !important;
}

body:not(.pdf-viewer-page):not(.login-page) .app-main > .app-container {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

body:not(.pdf-viewer-page):not(.login-page) .app-main > .app-container > :first-child {
    margin-top: 0 !important;
}

body:not(.pdf-viewer-page):not(.login-page) .app-main > .app-container > :last-child {
    margin-bottom: 0 !important;
}

@media (max-width: 48rem) {
    html {
        scroll-padding-top: 5rem;
    }

    body {
        font-size: 0.8125rem;
        line-height: 1.45;
        overflow-x: hidden;
    }

    .page-eyebrow {
        font-size: 0.6875rem;
    }

    .page-title {
        font-size: 1.125rem;
        line-height: 1.2;
    }

    .page-subtitle {
        font-size: 0.75rem;
        line-height: 1.45;
    }

    .section-title,
    .card-title,
    .aircraft-title {
        font-size: 0.9375rem;
    }

    .portal-card h5,
    .mel-dispatch-results h5 {
        font-size: 1rem;
        line-height: 1.25;
    }

    .section-description,
    .card-description,
    .manual-card-note,
    .text-muted,
    small,
    .small {
        font-size: 0.75rem;
    }

    .form-label {
        font-size: 0.6875rem;
    }

    img,
    svg,
    canvas,
    video,
    iframe {
        max-width: 100%;
    }

    input,
    select,
    textarea {
        font-size: 1rem;
    }

    body:not(.pdf-viewer-page) .btn,
    body:not(.pdf-viewer-page) button,
    body:not(.pdf-viewer-page) [role="button"] {
        min-height: 2.75rem;
        font-size: 0.75rem;
    }

    body:not(.pdf-viewer-page) .nav-link,
    body:not(.pdf-viewer-page) .badge,
    body:not(.pdf-viewer-page) .manual-badge,
    body:not(.pdf-viewer-page) .portal-list-badge,
    body:not(.pdf-viewer-page) .portal-detail-pill,
    body:not(.pdf-viewer-page) .dispatch-status-badge {
        font-size: 0.6875rem !important;
    }

    .portal-card .card-body,
    .portal-detail-card .card-body,
    .manual-group-card .card-body,
    .candidate-card .card-body,
    .portal-list-card .card-body,
    .dispatch-search-card .card-body,
    .dispatch-detail-card .card-body,
    .delete-card .card-body {
        padding: 0.875rem;
    }

    .page-hero {
        align-items: center;
        flex-direction: row;
    }

    .page-hero > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .page-hero .page-actions {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex: 0 0 auto;
        flex-wrap: wrap;
        width: auto;
        margin-left: auto;
        gap: 0.5rem;
    }

    .page-hero .page-actions .btn,
    .page-hero .page-actions .app-action-btn {
        width: auto !important;
        min-width: 4.5rem;
        padding-inline: 0.75rem;
    }

    .page-hero .page-actions .btn-outline-secondary:last-child {
        margin-left: auto;
    }

    .mobile-nav-text {
        font-size: 0.6875rem;
    }

    .app-user-name {
        min-height: 2rem !important;
        height: 2rem !important;
    }

    .app-admin-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-height: 2rem !important;
        height: 2rem !important;
        padding: 0.3rem 0.625rem;
        font-size: 0.6875rem;
        line-height: 1;
        white-space: nowrap;
    }

    .modal-dialog {
        margin: 0.75rem;
    }

    .dropdown-menu {
        max-width: calc(100vw - 1rem);
    }

    /* Shared mobile search layout for Manual and Dispatch Search. */
    body.manual-search-page .mobile-filter-toggle,
    body.dispatch-search-page .mobile-filter-toggle {
        min-height: 2.5rem;
        margin-bottom: 0.75rem !important;
        padding: 0.45rem 0.75rem;
        font-size: 0.75rem;
        font-weight: 750;
        line-height: 1.2;
    }

    body.manual-search-page .page-hero .page-subtitle,
    body.dispatch-search-page .page-hero .page-subtitle {
        display: none;
    }

    body.manual-search-page .mobile-filter-collapse,
    body.dispatch-search-page .mobile-filter-collapse {
        margin-bottom: 0.875rem !important;
        border-radius: 0.75rem;
    }

    body.manual-search-page .mobile-filter-collapse > .card-body,
    body.dispatch-search-page .mobile-filter-collapse > .card-body {
        padding: 0.75rem;
    }

    body.manual-search-page .mobile-filter-collapse form .row,
    body.dispatch-search-page .mobile-filter-collapse form .row {
        --bs-gutter-x: 0.625rem;
        --bs-gutter-y: 0.625rem;
    }

    body.manual-search-page .mobile-filter-collapse .form-label,
    body.dispatch-search-page .mobile-filter-collapse .form-label {
        margin-bottom: 0.25rem;
        font-size: 0.6875rem;
        font-weight: 700;
        line-height: 1.2;
    }

    body.manual-search-page .mobile-filter-collapse .app-form-control,
    body.dispatch-search-page .mobile-filter-collapse .app-form-control {
        min-height: 2.5rem;
        padding-top: 0.375rem;
        padding-bottom: 0.375rem;
        font-size: 1rem;
        line-height: 1.2;
    }

    body.manual-search-page .mobile-filter-collapse .form-select,
    body.dispatch-search-page .mobile-filter-collapse .form-select {
        font-size: 0.875rem;
    }

    body.manual-search-page .mobile-filter-collapse .form-control::placeholder,
    body.dispatch-search-page .mobile-filter-collapse .form-control::placeholder {
        font-size: 0.8125rem;
    }

    body.manual-search-page .mobile-filter-collapse .app-card-btn,
    body.dispatch-search-page .mobile-filter-collapse .app-card-btn {
        min-height: 2.5rem;
        padding: 0.45rem 0.75rem;
        font-size: 0.75rem;
        line-height: 1.2;
    }

    body.manual-search-page .result-tabs,
    body.dispatch-search-page .result-tabs {
        margin-bottom: 0.75rem !important;
    }

    body.manual-search-page .result-tabs .nav-link,
    body.dispatch-search-page .result-tabs .nav-link {
        min-height: 2.25rem;
        padding: 0.4rem 0.625rem;
        font-size: 0.6875rem !important;
        line-height: 1.2;
    }

    body.manual-search-page .result-tabs .nav-link {
        font-size: 0.75rem !important;
    }

    body.manual-search-page .manual-group-info {
        display: none;
    }

    .table-responsive {
        margin-inline: -0.25rem;
    }

    .navbar-collapse {
        max-height: calc(100vh - 5rem);
        overflow-y: auto;
    }
}

@media (hover: none) and (pointer: coarse) {
    .portal-card:hover,
    .portal-detail-card:hover,
    .manual-group-card:hover,
    .candidate-card:hover,
    .portal-list-card:hover,
    .dispatch-ref-card:hover,
    .mel-result-card:hover,
    .dispatch-search-card:hover,
    .boeing-card:hover,
    .airbus-card:hover {
        transform: none !important;
    }
}

/* =========================================================
   PWA standalone footer handling
========================================================= */

@media (max-width: 48rem) {
    body.pwa-standalone .app-footer,
    body.pwa-standalone footer.app-footer {
        display: none !important;
    }

    body.pwa-standalone .app-main {
        padding-bottom: var(--page-edge-gap) !important;
    }

    body.pwa-standalone .mobile-bottom-nav {
        padding-bottom: var(--safe-area-bottom);
    }
}

@media (display-mode: standalone) and (max-width: 48rem) {
    .app-footer,
    footer.app-footer {
        display: none !important;
    }
}
