/* Tablet layout (≤ 1024px; the breakpoint must match kx-layout.js).
   The 260px sidebar would take a third of a portrait tablet, so below 1024px it starts collapsed to its
   52px rail (MainLayout) and, when opened, slides OVER the page instead of squeezing it. The page keeps
   the rail's width as a margin, so nothing jumps when the sidebar opens or closes. */

.kx-sidebar-backdrop {
    display: none;
}

@media (max-width: 1024px) {
    /* Less padding round the page: every pixel counts on a portrait tablet. */
    .app-layout-row.row .main-content {
        padding: 1rem;
    }

    /* Open sidebar = overlay. A fixed element with no top/left keeps its normal (static) position, so it
       still starts right under the header and keeps its own height. */
    /* Opaque: the sidebar's own background (var(--dxbl-bg)) is not declared at this level, so it
       renders transparent — invisible on a docked sidebar, see-through as an overlay. */
    .app-layout-row .left-sidebar:not(.sidebar-collapsed) {
        position: fixed;
        z-index: 1040;
        background-color: var(--bs-body-bg);
        box-shadow: 4px 0 16px color-mix(in srgb, var(--bs-body-color) 25%, transparent);
    }

    .app-layout-row:has(> .left-sidebar:not(.sidebar-collapsed)) > .main-content {
        margin-left: 52px;
    }

    /* Detail-page button strips (Customer / Account / Stock / Supplier … cards): the page CSS gives every
       button an equal share of ONE row, which on a tablet cuts the captions to "Prin…". Let them wrap
       instead, each button at least wide enough for its caption. !important: the page rules are scoped
       (::deep) and as specific as these. */
    /* Desktop keeps the one-row equal-width strip the user chose on 2026-09-01 (see the HISTORY note
       in ProjectDetailPage.razor.css); only tablets wrap. The order and purchase strips already wrap. */
    .main-button-container,
    .supplier-header-buttons,
    .project-detail-toolbar {
        flex-wrap: wrap !important;
    }

    .main-button-container > *,
    .supplier-header-buttons > *,
    .project-detail-toolbar > * {
        flex: 1 1 140px !important;
    }

    .main-button-container > .dxbl-btn-dropdown > .dxbl-btn,
    .supplier-header-buttons > .dxbl-btn-dropdown > .dxbl-btn,
    .project-detail-toolbar > .dxbl-btn-dropdown > .dxbl-btn {
        width: 100%;
    }

    .kx-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1039;
        background: color-mix(in srgb, var(--bs-body-color) 20%, transparent);
    }
}

/* Portrait tablet: detail cards laid out side by side (col-8 + col-4, col-md-8 + col-md-4, col-6 + col-6 …)
   leave the narrow card too small for its label + field rows. Stack those cards full width. Only columns
   that directly hold a .card are touched, so label/field rows (col-3 + col-9 inside a card) keep their
   layout. */
@media (max-width: 900px) {
    .tab-content .row > [class*="col-"]:has(> .card) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}
