/* =========================================================
   PHASE 15C - RESPONSIVE DASHBOARDS AND NAVIGATION
   ========================================================= */

@media (max-width: 991.98px) {
    .app-topbar {
        min-height: 68px;
        padding-inline: .8rem;
        gap: .55rem;
    }

    .topbar-left,
    .topbar-right {
        gap: .45rem;
        min-width: 0;
    }

    .topbar-page-context {
        min-width: 0;
    }

    .topbar-section-label {
        display: none;
    }

    .topbar-page-title {
        overflow: hidden;
        max-width: min(42vw, 240px);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-menu-button,
    .topbar-icon-button,
    .global-search-mobile-trigger {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .dashboard-hero {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.1rem;
        padding: 1.35rem;
        border-radius: 20px;
    }

    .dashboard-hero-actions {
        padding: .8rem;
    }

    .dashboard-content > .row,
    .dashboard-page .row {
        --bs-gutter-x: .85rem;
    }

    .dashboard-page .widget-card .card-header {
        gap: .75rem;
        align-items: flex-start !important;
        flex-wrap: wrap;
    }

    .dashboard-page .widget-card .card-header .btn {
        min-height: 40px;
    }

    .dashboard-page .list-group-item > .d-flex {
        align-items: flex-start;
        flex-direction: column;
    }

    /* Keep the business notification menu below the sticky topbar on tablet/mobile.
       Bootstrap Popper may otherwise flip the tall menu above the bell, leaving only
       the footer visible. The menu itself scrolls because durable server-rendered
       notifications are direct children, not only items inside .notification-list. */
    .notification-dropdown {
        position: fixed !important;
        top: calc(var(--bm-topbar-height) + .5rem) !important;
        right: .75rem !important;
        bottom: auto !important;
        left: .75rem !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100dvh - var(--bm-topbar-height) - 1.25rem);
        overflow-x: hidden;
        overflow-y: auto;
        transform: none !important;
        border-radius: 18px;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        z-index: 1085;
    }

    .notification-list,
    .notification-dropdown-body {
        overflow-y: visible;
        max-height: none;
    }

    .global-search.is-open .global-search-shell,
    .global-search[data-mobile-open="true"] .global-search-shell {
        position: fixed;
        z-index: 1100;
        inset: 0;
        padding: 1rem;
        background: rgba(248, 250, 252, .98);
    }

    .global-search.is-open .global-search-input,
    .global-search[data-mobile-open="true"] .global-search-input {
        min-height: 48px;
        padding-right: 3rem;
        background: #fff;
    }

    .global-search.is-open .global-search-panel,
    .global-search[data-mobile-open="true"] .global-search-panel {
        position: absolute;
        z-index: 1101;
        top: 4.9rem;
        right: 1rem;
        bottom: 1rem;
        left: 1rem;
        max-height: none;
        border-radius: 16px;
    }

    .global-search.is-open .global-search-panel:not(.d-none),
    .global-search[data-mobile-open="true"] .global-search-panel:not(.d-none) {
        display: flex !important;
        flex-direction: column;
        overflow: hidden;
    }

    .global-search.is-open [data-global-search-results],
    .global-search[data-mobile-open="true"] [data-global-search-results] {
        min-height: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .global-search.is-open .global-search-results-scroll,
    .global-search[data-mobile-open="true"] .global-search-results-scroll {
        height: 100%;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .global-search-result {
        grid-template-columns: 44px minmax(0, 1fr);
        min-height: 60px;
        padding: .75rem;
    }

    .global-search-result-meta {
        display: none;
    }

    .global-search-result-title,
    .global-search-result-subtitle {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .bm-schedule-toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .85rem;
    }

    .bm-schedule-filter-actions,
    .bm-schedule-filter-actions .btn {
        width: 100%;
    }

    .bm-calendar-shell {
        overflow: hidden;
    }

    .bm-calendar-shell .fc-header-toolbar {
        gap: .75rem;
        align-items: stretch;
        flex-direction: column;
    }

    .bm-calendar-shell .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
    }

    .bm-calendar-shell .fc-button {
        min-height: 42px;
    }

    .bm-calendar-shell .fc-toolbar-title {
        font-size: 1.15rem;
        text-align: center;
    }

    .bm-calendar-shell .fc-list-event-time,
    .bm-calendar-shell .fc-list-event-title {
        padding-block: .8rem;
    }

    .report-toolbar,
    .report-filters,
    .report-filter-grid,
    .report-actions,
    .business-settings-toolbar,
    .business-settings-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: .75rem !important;
    }

    .report-toolbar .btn,
    .report-actions .btn,
    .business-settings-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    .report-summary-grid,
    .configuration-summary-grid,
    .business-settings-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .report-table-wrap,
    .table-responsive {
        max-width: 100%;
    }

    .settings-nav,
    .business-settings-nav {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: .35rem;
        scrollbar-width: thin;
        scroll-snap-type: x proximity;
    }

    .settings-nav > *,
    .business-settings-nav > * {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }
}

@media (max-width: 575.98px) {
    .bm-page-container {
        padding-inline: .75rem;
    }

    .dashboard-hero {
        margin-inline: -.15rem;
        padding: 1.1rem;
        border-radius: 17px;
    }

    .dashboard-title {
        font-size: 1.8rem;
    }

    .dashboard-subtitle {
        font-size: .92rem;
        line-height: 1.5;
    }

    .dashboard-hero-actions-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .dashboard-quick-action {
        min-height: 58px;
    }

    .dashboard-hero-badges {
        align-items: flex-start;
        flex-direction: column;
        gap: .5rem;
    }

    .dashboard-page .widget-card {
        border-radius: 16px;
    }

    .dashboard-page .widget-card .card-header,
    .dashboard-page .widget-card .card-body {
        padding-inline: .9rem;
    }

    .notification-dropdown {
        top: calc(var(--bm-topbar-height) + .35rem) !important;
        right: .5rem !important;
        left: .5rem !important;
        max-height: calc(100dvh - var(--bm-topbar-height) - .85rem);
        border: 1px solid var(--bm-border, #dfe5ef);
        border-radius: 16px;
    }

    .report-summary-grid,
    .configuration-summary-grid,
    .business-settings-summary-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .bm-calendar-shell .fc-dayGridMonth-button,
    .bm-calendar-shell .fc-timeGridWeek-button {
        display: none;
    }

    .bm-calendar-shell .fc-list-table td,
    .bm-calendar-shell .fc-list-day-cushion {
        padding-inline: .65rem;
    }
}
