/*
 * Billy Bridge on phones and tablets (front-end review Phase 3, owner 2026-09-29: R1-R8, "drawer only, text
 * keyboard for NIPT"). Loaded after billy-theme.css. Below 992px the header, the drawer, the lists and the invoice
 * forms change; wider screens are unchanged, except for touch screens, which get the larger tap targets (R4).
 * mobile.js sets the classes and labels these rules use.
 */

/* ---- R6: phones with a notch. The page is laid out under it (viewport-fit=cover); the bars keep clear --------- */
@supports (padding: env(safe-area-inset-top)) {
    .app-header {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ---- R1: the header below 992px: menu, logo, account ------------------------------------------------------------ */
.bb-account {
    display: none;
}
@media (max-width: 991.98px) {
    .app-header {
        height: calc(60px + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .fixed-header .app-main {
        padding-top: calc(60px + env(safe-area-inset-top, 0px));
    }
    /* its links are in the drawer (R2); language, settings and sign-out are in the account menu */
    .app-header .app-header__content {
        display: none !important;
    }
    .app-header .app-header__mobile-menu {
        display: flex;
        order: 1;
        width: auto;
        padding: 0 4px;
    }
    .app-header .app-header__logo {
        display: flex !important;
        order: 2;
        flex: 0 1 auto;
        width: auto !important;
        padding: 0;
        margin: 0 auto;
    }
    .app-header .app-header__logo .header__pane {
        display: none;
    }
    .app-header .app-header__logo .logo-src {
        margin: 0;
    }
    .bb-account {
        display: flex;
        order: 3;
        padding: 0 4px;
    }
    .bb-account__btn {
        width: 44px;
        height: 44px;
        border: 0;
        border-radius: var(--bb-radius);
        background: transparent;
        color: var(--bb-white);
        font-size: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .bb-account__btn:focus-visible {
        outline: 2px solid var(--bb-accent);
    }
    /* ArchitectUI centres every dropdown on a phone (fixed, 90% wide): the account menu opens under its button */
    .bb-account .dropdown-menu {
        position: absolute !important;
        top: calc(100% + 6px) !important;
        right: 0 !important;
        left: auto !important;
        bottom: auto !important;
        width: auto !important;
        min-width: 240px !important;
        transform: none !important;
        z-index: 1060;
    }
    .bb-account .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    /* the header's links are white; these sit on the white menu */
    .app-header .bb-account .dropdown-item {
        color: var(--bb-primary) !important;
    }
    .app-header .bb-account .dropdown-item:hover,
    .app-header .bb-account .dropdown-item:focus {
        background: var(--bb-tint);
    }
    .bb-account__who {
        white-space: normal;
        color: var(--bb-muted);
        font-size: 13px;
        padding: 8px 16px;
    }
    .bb-account__who strong {
        display: block;
        color: var(--bb-primary);
        font-weight: 600;
    }
    /* the menu button: a 44px target around ArchitectUI's hamburger */
    .app-header .app-header__mobile-menu .hamburger {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    .app-header .app-header__mobile-menu .hamburger-inner,
    .app-header .app-header__mobile-menu .hamburger-inner::before,
    .app-header .app-header__mobile-menu .hamburger-inner::after {
        background-color: var(--bb-white);
    }
}

/* ---- R2: the drawer. The header's links sit at its top, below 992px only --------------------------------------- */
.bb-drawer-only {
    display: none !important;
}
@media (max-width: 991.98px) {
    .bb-drawer-only {
        display: block !important;
    }
    .bb-drawer-only.bb-drawer-last {
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        margin-bottom: 8px;
        padding-bottom: 8px;
    }
    .app-sidebar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .app-sidebar .vertical-nav-menu li a {
        height: 44px;
        line-height: 44px;
    }
}

/* ---- R4: 44px tap targets on phones and touch screens ------------------------------------------------------------ */
@media (max-width: 991.98px), (pointer: coarse) {
    .btn,
    .page-link,
    .input-group-text,
    .form-control,
    .custom-select {
        min-height: 44px;
    }
    .btn-icon-only,
    .btn.btn-sm:not(.btn-block) {
        min-width: 44px;
    }
    .form-control,
    .custom-select,
    .select2-container .select2-search__field {
        font-size: 16px; /* iOS enlarges the page for anything smaller */
    }
    .select2-container .select2-selection--single {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .select2-container .select2-selection--single .select2-selection__arrow {
        height: 42px;
    }
    /* Select2 4.1 puts the "x" first in the box; in this flex row it goes back after the text, clear of the arrow */
    .select2-container .select2-selection--single .select2-selection__rendered {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
    }
    .select2-container .select2-selection--single .select2-selection__clear {
        order: 2;
        margin-right: 2rem;
    }
    .select2-results__option {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    /* !important: the supply-date checkbox sets its size inline; 24px, WCAG 2.2's minimum target */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px !important;
        height: 24px !important;
    }
    /* the "?" help beside a label: a 44px target that does not make its line taller */
    a[data-bs-toggle="tooltip"],
    a[data-toggle="tooltip"] {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        margin-top: -12px !important;
        margin-bottom: -12px;
        vertical-align: middle;
    }
    .dt-container .pagination .page-link {
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .font-icon-wrapper {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
}

/* ---- the page itself below 992px -------------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    /* 15px: the grid's rows reach 15px out on each side */
    .app-main .app-main__inner {
        padding-left: calc(15px + env(safe-area-inset-left, 0px));
        padding-right: calc(15px + env(safe-area-inset-right, 0px));
    }
    .app-page-title {
        margin-left: -15px;
        margin-right: -15px;
    }
    /* the list filters' side drawer: the whole width on a phone */
    .app-drawer-wrapper {
        max-width: 100vw;
    }
    /* ArchitectUI hides the card headers' icons on a phone, the collapse arrow among them, so a folded card
       (carrier, notes, discounts, charges) could not be opened. The arrow is back, as a 44px target */
    .card-header .btn-actions-pane-right .header-icon {
        display: inline-block !important;
    }
    .card-header .btn-actions-pane-right a[data-bs-toggle="collapse"],
    .card-header .btn-actions-pane-right a[data-toggle="collapse"] {
        display: inline-flex;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
    }
}

/* ---- R3: lists as cards below 576px (mobile.js labels the cells and marks their role) --------------------------- */
@media (max-width: 575.98px) {
    table.dataTable.bb-cards thead,
    .dt-scroll-head {
        display: none !important;
    }
    table.dataTable.bb-cards,
    table.dataTable.bb-cards tbody {
        display: block;
        width: 100% !important;
        border: 0 !important;
        margin: 0 !important;
    }
    table.dataTable.bb-cards tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        background: var(--bb-white) !important;
        border: 1px solid var(--bb-border);
        border-radius: var(--bb-radius);
        margin: 0 0 10px;
        padding: 10px 12px;
    }
    table.dataTable.bb-cards tbody td {
        order: 6;
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        width: 100%;
        padding: 3px 0 !important;
        border: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        text-align: right !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }
    table.dataTable.bb-cards tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 45%;
        text-align: left;
        color: var(--bb-muted);
        font-size: 13px;
    }
    table.dataTable.bb-cards tbody td.bb-card-select {
        order: 0;
        width: auto;
        margin-right: 10px;
    }
    table.dataTable.bb-cards tbody td.bb-card-title {
        order: 1;
        flex: 1 1 0;
        width: auto;
        justify-content: flex-start;
        text-align: left !important;
        font-weight: 600;
    }
    table.dataTable.bb-cards tbody td.bb-card-status {
        order: 2;
        width: auto;
        flex: 0 0 auto;
    }
    table.dataTable.bb-cards tbody td.bb-card-party { order: 3; }
    table.dataTable.bb-cards tbody td.bb-card-date { order: 4; }
    table.dataTable.bb-cards tbody td.bb-card-amount { order: 5; font-weight: 600; }
    table.dataTable.bb-cards tbody td.bb-card-amount::before { font-weight: 400; }
    table.dataTable.bb-cards tbody td.bb-card-actions {
        order: 9;
        width: auto;
        flex: 0 0 auto;
        padding-top: 8px !important;
    }
    table.dataTable.bb-cards tbody td.bb-card-actions-first {
        margin-left: auto;
    }
    table.dataTable.bb-cards tbody td.bb-card-select::before,
    table.dataTable.bb-cards tbody td.bb-card-title::before,
    table.dataTable.bb-cards tbody td.bb-card-status::before,
    table.dataTable.bb-cards tbody td.bb-card-actions::before,
    table.dataTable.bb-cards tbody td.dt-empty::before {
        content: none;
    }
    table.dataTable.bb-cards tbody td.dt-empty {
        justify-content: center;
        text-align: center !important;
    }
    .dt-container .dt-length,
    .dt-container .dt-search,
    .dt-container .dt-info,
    .dt-container .dt-paging {
        text-align: left !important;
    }
    .dt-container .pagination {
        flex-wrap: wrap;
        justify-content: flex-start !important;
    }
}

/* ---- R7: the invoice forms. Item lines as cards below 768px, folded to one line; the action bar below 992px ---- */
@media (max-width: 767.98px) {
    table.table-items thead {
        display: none;
    }
    table.table-items,
    table.table-items tbody {
        display: block;
        width: 100% !important;
        border: 0 !important;
    }
    table.table-items tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 8px 10px;
        background: var(--bb-white);
        border: 1px solid var(--bb-border);
        border-radius: var(--bb-radius);
        margin: 0 0 10px;
        padding: 10px 12px;
    }
    /* the currency column is shown and hidden with an inline display: it stays hidden when hidden */
    table.table-items tbody tr > td:not([style*="none"]) {
        display: block !important;
        width: auto !important;
        min-width: 0;
        padding: 0 !important;
        border: 0 !important;
        text-align: left !important;
    }
    table.table-items tbody tr > td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        color: var(--bb-muted);
        font-size: 13px;
    }
    table.table-items tbody tr > td.row-index,
    table.table-items tbody tr > td.bb-line-off {
        display: none !important;
    }
    table.table-items tbody tr > td.bb-line-name,
    table.table-items tbody tr > td.bb-line-actions {
        grid-column: 1 / -1;
    }
    table.table-items tbody tr > td.bb-line-actions {
        text-align: right !important;
    }
    table.table-items tbody tr > td.bb-line-actions::before {
        content: none;
    }
    /* the line's summary heads the card; tapping it folds or opens the line */
    table.table-items tbody tr[data-summary]::before {
        content: attr(data-summary);
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        min-height: 44px;
        padding-right: 28px;
        font-weight: 500;
        color: var(--bb-primary);
        background: no-repeat right 4px center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%235E7079' stroke-width='2' d='M3 6l5 5 5-5'/%3E%3C/svg%3E");
        cursor: pointer;
    }
    table.table-items tbody tr.bb-folded[data-summary]::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%235E7079' stroke-width='2' d='M6 3l5 5-5 5'/%3E%3C/svg%3E");
    }
    table.table-items tbody tr.bb-folded > td {
        display: none !important;
    }
    table.table-items tbody tr:focus-visible {
        outline: 2px solid var(--bb-accent);
        outline-offset: 2px;
    }
}
.bb-action-bar {
    display: none;
}
@media (max-width: 991.98px) {
    .bb-action-bar.bb-on {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000; /* under the dialogs (1050) */
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px calc(12px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px))
            calc(12px + env(safe-area-inset-left, 0px));
        background: var(--bb-white);
        border-top: 1px solid var(--bb-border);
    }
    .sidebar-mobile-open .bb-action-bar.bb-on {
        display: none;
    }
    body.bb-has-action-bar .app-main__outer {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
    .bb-action-bar__total {
        display: flex;
        flex-direction: column;
        line-height: 1.2;
        min-width: 0;
    }
    .bb-action-bar__total span {
        color: var(--bb-muted);
        font-size: 13px;
    }
    .bb-action-bar__total strong {
        font-weight: 600;
        font-size: 16px;
        white-space: nowrap;
    }
    .bb-action-bar__btn {
        min-height: 44px;
        margin-left: auto;
        white-space: nowrap;
    }
}

/* ---- Phase 4: notices under the header (offline, a new version, installing) and the actions offline --------- */
.bb-notices {
    position: fixed;
    top: calc(68px + env(safe-area-inset-top, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    z-index: 1040; /* over the page and the action bar, under the dialogs */
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
@media (min-width: 992px) {
    .bb-notices {
        left: auto;
        width: 440px;
    }
}
.bb-notice {
    pointer-events: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 12px;
    border: 1px solid var(--bb-info);
    border-radius: var(--bb-radius);
    background: var(--bb-info-tint);
    color: var(--bb-primary);
    box-shadow: 0 4px 12px rgba(0, 50, 60, 0.15);
}
.bb-notice--warning {
    border-color: var(--bb-warning);
    background: var(--bb-warning-tint);
}
.bb-notice__text {
    flex: 1 1 200px;
}
.bb-notice .btn {
    min-height: 44px;
}
body.bb-offline [aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 13 Oct 2026: a table column that only fits from tablet width (the console publish table) */
@media (max-width: 767.98px) {
    .bb-wide-only {
        display: none !important;
    }

    /* live pass, 1 Nov 2026: the wide screens' negative margin cut this required field's label on the left */
    .bb-goods-label {
        margin-inline: 0 !important;
    }
}
