/* =========================================================
   MOBILE CONSISTENCY SWEEP
   Final mobile overrides for operational lists and dashboard
   collections. Loaded after module styles to prevent desktop-sized
   action controls and column widths from leaking into phone layouts.
   ========================================================= */

@media (max-width: 767.98px) {
    html,
    body,
    .app-shell,
    .app-main,
    .app-content,
    .app-page {
        max-width: 100%;
        overflow-x: hidden;
    }

    .bm-table-shell,
    .table-responsive,
    .card,
    .widget-card {
        min-width: 0;
        max-width: 100%;
    }

    /* Operational card rows must not retain desktop cell widths. */
    .bm-operational-list,
    .bm-operational-list tbody,
    .bm-operational-list tr,
    .bm-operational-list td {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .bm-operational-list td {
        width: 100% !important;
    }

    .bm-operational-list td > *,
    .bm-operational-list td a,
    .bm-operational-list td button,
    .bm-operational-list td form,
    .bm-operational-list td span,
    .bm-operational-list td div {
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    /* Actions are full-width controls, never 42px desktop icon squares. */
    .bm-operational-list td.bm-table-actions-cell {
        clear: both;
        width: 100% !important;
    }

    .bm-operational-list .bm-table-actions,
    .operations-crud-page .bm-operational-list .bm-table-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        gap: .55rem;
        width: 100% !important;
        white-space: normal;
    }

    .bm-operational-list .bm-table-actions form,
    .operations-crud-page .bm-operational-list .bm-table-actions form {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .bm-operational-list .bm-table-actions .ops-action-btn,
    .bm-operational-list .bm-table-actions .btn,
    .operations-crud-page .bm-operational-list .bm-table-actions .ops-action-btn,
    .operations-crud-page .bm-operational-list .bm-table-actions .btn {
        display: inline-flex !important;
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: var(--bm-grid-action-size-mobile);
        flex: 1 1 auto !important;
        align-items: center;
        justify-content: center;
        gap: .45rem;
        padding: .65rem .75rem !important;
        line-height: 1.2;
        white-space: normal !important;
        text-align: center;
        overflow-wrap: normal !important;
        word-break: normal !important;
    }

    .bm-operational-list .bm-table-actions .visually-hidden {
        display: inline !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        clip: auto !important;
        white-space: normal !important;
    }

    /* Dashboard tables become true stacked cards rather than clipped tables. */
    .bm-dashboard-mobile-list,
    .bm-dashboard-mobile-list tbody,
    .bm-dashboard-mobile-list tr,
    .bm-dashboard-mobile-list td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .bm-dashboard-mobile-list thead {
        display: none;
    }

    .bm-dashboard-mobile-list tbody {
        display: grid;
        gap: .75rem;
        padding: .75rem;
        background: var(--bm-surface-soft, #f7f9fc);
    }

    .bm-dashboard-mobile-list tbody tr {
        overflow: hidden;
        border: 1px solid var(--bm-border, #dfe5ef);
        border-radius: .9rem;
        background: #fff;
    }

    .bm-dashboard-mobile-list td {
        display: grid;
        grid-template-columns: minmax(5.75rem, .34fr) minmax(0, .66fr);
        gap: .65rem;
        padding: .65rem .8rem !important;
        border: 0;
        border-bottom: 1px solid var(--bm-border-light, #edf1f6);
        text-align: left !important;
        overflow-wrap: anywhere;
    }

    .bm-dashboard-mobile-list td:last-child {
        border-bottom: 0;
    }

    .bm-dashboard-mobile-list td::before {
        content: attr(data-label);
        color: var(--bm-muted, #667085);
        font-size: .67rem;
        font-weight: 800;
        letter-spacing: .05em;
        text-transform: uppercase;
    }

    .bm-dashboard-mobile-list td:first-child {
        display: block;
        padding: .8rem !important;
        background: #fbfcff;
    }

    .bm-dashboard-mobile-list td:first-child::before {
        display: none;
    }

    .widget-card .card-header {
        gap: .75rem;
        flex-wrap: wrap;
    }

    .widget-card .card-header .btn {
        flex: 0 0 auto;
        min-height: var(--bm-grid-action-size-mobile);
    }
}

@media (max-width: 575.98px) {
    .bm-operational-list .bm-table-actions,
    .operations-crud-page .bm-operational-list .bm-table-actions {
        grid-template-columns: 1fr !important;
    }

    .bm-dashboard-mobile-list td {
        display: block;
    }

    .bm-dashboard-mobile-list td::before {
        display: block;
        margin-bottom: .25rem;
    }

    .bm-dashboard-mobile-list td:first-child::before {
        display: none;
    }
}
