/**
 * Dashboard responsive overrides (tables, charts, stat grids, staff tools).
 */

/* ── Small phones ── */
@media (max-width: 639px) {
    .pmts-dashboard-page .stats-grid,
    .dashboard-page-root .stats-grid,
    .dashboard-container .stats-grid,
    .pmts-dashboard-page dl.grid,
    .dashboard-page-root dl.grid,
    .dashboard-container dl.grid {
        gap: 1rem;
    }

    .timeframe-filter form {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .timeframe-filter select {
        width: 100%;
    }

    .dashboard-page-header {
        padding: 1rem 1.125rem;
    }

    .dashboard-toolbar,
    .dashboard-actions-strip {
        padding: 0.875rem 1rem;
    }

    .notify-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .notify-toolbar__actions {
        width: 100%;
    }

    .notify-toolbar__actions .dashboard-btn {
        flex: 1 1 calc(50% - 0.25rem);
        justify-content: center;
        min-width: 0;
    }
}

/* ── Tablets & below ── */
@media (max-width: 767px) {
    .dashboard-table-wrap,
    .dashboard-section .overflow-x-auto,
    .projects-table-scroll {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .dashboard-table-wrap {
        border-radius: 0.625rem;
    }

    .dashboard-table-wrap table thead th:first-child,
    .dashboard-table-wrap table tbody td:first-child {
        position: sticky;
        left: 0;
        z-index: 3;
        background: #f9fafb;
        box-shadow: 1px 0 0 rgb(226 232 240);
    }

    .dashboard-table-wrap table tbody td:first-child {
        background: #fff;
    }

    .dashboard-table-wrap table tbody tr:nth-child(even) td:first-child {
        background: #fafafa;
    }

    .qa-inbox-toolbar__status {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        padding-bottom: 0.25rem;
        margin-left: -0.25rem;
        margin-right: -0.25rem;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    .qa-inbox-toolbar__status::-webkit-scrollbar {
        display: none;
    }

    .qa-inbox-toolbar__status .dashboard-btn {
        flex-shrink: 0;
        scroll-snap-align: start;
    }

    /* Bulk edit — keep essential columns on phones */
    .bulk-grid-table th:nth-child(2),
    .bulk-grid-table td:nth-child(2),
    .bulk-grid-table th:nth-child(3),
    .bulk-grid-table td:nth-child(3),
    .bulk-grid-table th:nth-child(6),
    .bulk-grid-table td:nth-child(6),
    .bulk-grid-table th:nth-child(7),
    .bulk-grid-table td:nth-child(7),
    .bulk-grid-table th:nth-child(8),
    .bulk-grid-table td:nth-child(8),
    .bulk-grid-table th:nth-child(9),
    .bulk-grid-table td:nth-child(9),
    .bulk-grid-table th:nth-child(10),
    .bulk-grid-table td:nth-child(10),
    .bulk-grid-table th:nth-child(11),
    .bulk-grid-table td:nth-child(11) {
        display: none;
    }

    .bulk-page-wrapper {
        padding: 0.5rem;
    }

    .bulk-panel__body {
        padding: 0.75rem;
    }

    .bulk-form-input,
    .bulk-form-select {
        font-size: 16px;
        min-height: 2.75rem;
    }

    .custom-button-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        width: 100%;
    }

    .custom-button-group .action-button {
        width: 100%;
        justify-content: center;
    }

    .progress-photo {
        width: 100%;
        max-width: 280px;
        height: auto;
        aspect-ratio: 1;
    }
}

/* ── Medium screens ── */
@media (max-width: 1023px) {
    .pmts-dashboard-page table,
    .dashboard-page-root table,
    .dashboard-container table {
        font-size: 0.8125rem;
    }

    .pmts-dashboard-page .h-64,
    .dashboard-page-root .h-64,
    .dashboard-container .h-64 {
        min-height: 14rem;
    }

    .reports-charts-grid,
    .geo-charts-grid,
    .dashboard-charts-row {
        grid-template-columns: 1fr !important;
    }

    .pmts-chart-shell,
    .pmts-chart-shell--lg,
    .chart-container,
    .pd-chart-shell {
        min-height: 13rem;
        max-width: 100%;
    }

    .pmts-chart-shell canvas,
    .chart-container canvas,
    .pd-chart-shell canvas {
        max-width: 100%;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    /* Bulk edit — hide low-priority financial columns on tablet */
    .bulk-grid-table th:nth-child(8),
    .bulk-grid-table td:nth-child(8),
    .bulk-grid-table th:nth-child(9),
    .bulk-grid-table td:nth-child(9),
    .bulk-grid-table th:nth-child(10),
    .bulk-grid-table td:nth-child(10) {
        display: none;
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    .dashboard-status-grid-lg-5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ── Staff shell overflow safety ── */
@media (max-width: 1023px) {
    body.pmts-has-sidebar #page-scroll-shell {
        overflow-x: clip;
    }

    body.pmts-has-sidebar .pmts-dashboard-page,
    body.pmts-has-sidebar .dashboard-page-root {
        min-width: 0;
    }

    body.pmts-has-sidebar .dashboard-page-root img,
    body.pmts-has-sidebar .dashboard-page-root video,
    body.pmts-has-sidebar .dashboard-page-root iframe {
        max-width: 100%;
        height: auto;
    }
}
