/* ==========================================================================
   OMRCheck Web — responsivo global (todas as páginas)
   Breakpoints: 1280 | 1080 | 900 | 640 | 560
   ========================================================================== */

.keepedu-app-page .ke-page-content,
.keepedu-app-page .page-historico,
.keepedu-app-page .page-historico-detalhe,
.keepedu-app-page .page-processando,
.keepedu-app-page .page-kanban,
.keepedu-auth-page {
    min-width: 0;
    overflow-x: clip;
}

/* ---- Barras de ação ---- */
@media (max-width: 900px) {
    .keepedu-app-page .ke-action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .keepedu-app-page .ke-action-bar .ke-action-btn,
    .keepedu-app-page .ke-action-bar > a.ke-action-btn,
    .keepedu-app-page .ke-action-bar > button.ke-action-btn {
        width: 100%;
        min-width: 0 !important;
        white-space: normal;
        line-height: 1.35;
        justify-content: center;
    }
}

/* ---- Stats em linha (processamento, hero, etc.) ---- */
@media (max-width: 900px) {
    .keepedu-app-page .hero-stats-row,
    .keepedu-app-page .processamento-stats-inline,
    .keepedu-app-page .page-processando .hero-stats {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 640px) {
    .keepedu-app-page .historico-stats-compact {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .keepedu-app-page .historico-lote-card-stats,
    .keepedu-app-page .historico-processamento-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .keepedu-app-page .historico-lote-card-stats,
    .keepedu-app-page .historico-processamento-stats {
        grid-template-columns: 1fr;
    }
}

/* ---- Toolbars de tabela / busca ---- */
@media (max-width: 900px) {
    .keepedu-app-page .table-toolbar,
    .keepedu-app-page .historico-lista-toolbar,
    .keepedu-app-page .historico-table-toolbar,
    .keepedu-app-page .validacao-table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .keepedu-app-page .table-toolbar-search,
    .keepedu-app-page .historico-lista-toolbar .table-toolbar-search {
        width: 100%;
        min-width: 0;
    }

    .keepedu-app-page .historico-lista-toolbar-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .keepedu-app-page .historico-lista-toolbar-actions .ke-action-btn,
    .keepedu-app-page .historico-lista-toolbar-actions .btn-light {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        justify-content: center;
    }
}

/* ---- Tabelas largas no desktop: rolagem interna ---- */
@media (min-width: 901px) {
    .keepedu-app-page .historico-table-wrapper,
    .keepedu-app-page .validacao-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ---- Tabelas → cards no mobile ---- */
@media (max-width: 900px) {
    .ke-table-mobile-cards {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    .ke-table-mobile-cards .data-table {
        display: block;
        min-width: 0 !important;
        width: 100%;
        border: 0;
        background: transparent;
        table-layout: auto;
    }

    .ke-table-mobile-cards .data-table thead {
        display: none;
    }

    .ke-table-mobile-cards .data-table tbody {
        display: grid;
        gap: 14px;
    }

    .ke-table-mobile-cards .data-table tbody tr {
        display: block;
        border: 1px solid #d7dce3;
        border-radius: 12px;
        background: #ffffff;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
        overflow: hidden;
    }

    .ke-table-mobile-cards .data-table tbody tr.linha-pendente {
        border-color: #f0c9c4;
        background: #fff8f7;
    }

    .ke-table-mobile-cards .data-table td {
        display: grid;
        grid-template-columns: minmax(108px, 34%) minmax(0, 1fr);
        gap: 8px 12px;
        align-items: start;
        width: 100%;
        padding: 12px 14px;
        border-bottom: 1px solid #e8edf2;
        white-space: normal;
        word-break: break-word;
        vertical-align: top;
    }

    .ke-table-mobile-cards .data-table td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #64748b;
        line-height: 1.35;
    }

    .ke-table-mobile-cards .data-table td:last-child {
        border-bottom: 0;
    }

    .ke-table-mobile-cards .manual-form {
        justify-content: flex-start;
        width: 100%;
    }

    .ke-table-mobile-cards .manual-form input {
        flex: 1 1 120px;
        width: auto;
        max-width: none;
    }

    .ke-table-mobile-cards .historico-btn-ver-cartao {
        width: 100%;
        justify-content: center;
    }
}

/* ---- Cabeçalhos de seção ---- */
@media (max-width: 640px) {
    .keepedu-app-page .section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .keepedu-app-page .section-head .section-badge {
        align-self: flex-start;
    }
}

/* ---- Paginação ---- */
@media (max-width: 640px) {
    .keepedu-app-page .table-pagination,
    .keepedu-app-page .historico-lista-pagination,
    .keepedu-app-page .historico-registros-pagination,
    .keepedu-app-page .lote-imagens-pagination {
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 10px;
    }

    .keepedu-app-page .table-pagination .btn-light,
    .keepedu-app-page .table-pagination a.btn-light,
    .keepedu-app-page .historico-lista-pagination .btn-light,
    .keepedu-app-page .historico-lista-pagination a.btn-light {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .keepedu-app-page .table-pagination-info {
        text-align: center;
    }
}

/* ---- Processando ---- */
@media (max-width: 900px) {
    .keepedu-app-page .page-processando .hero-shell.compact-hero,
    .keepedu-app-page .page-processando .processando-hero {
        grid-template-columns: 1fr !important;
    }

    .keepedu-app-page .progress-message,
    .keepedu-app-page #arquivo-atual,
    .keepedu-app-page #linha-log {
        word-break: break-word;
        overflow-wrap: break-word;
    }
}

/* ---- Upload / painel ---- */
@media (max-width: 900px) {
    .keepedu-app-page .upload-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .keepedu-app-page .job-stats-grid {
        width: 100%;
        max-width: 100%;
    }
}

/* ---- Modais ---- */
@media (max-width: 640px) {
    .keepedu-app-page .app-modal-dialog,
    .keepedu-app-page .app-modal-image-dialog {
        margin: 12px;
        max-width: calc(100vw - 24px);
    }

    .keepedu-app-page .app-modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .keepedu-app-page .app-modal-actions .btn-light,
    .keepedu-app-page .app-modal-actions .btn-danger,
    .keepedu-app-page .app-modal-actions .btn-info,
    .keepedu-app-page .app-modal-actions .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

/* ---- Login ---- */
@media (max-width: 640px) {
    .ke-auth-header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        padding: 12px 16px !important;
    }

    .ke-auth-header img {
        max-height: 52px !important;
        width: auto !important;
    }

    .ke-auth-brand img {
        max-height: 44px !important;
    }

    .ke-auth-main {
        padding: 16px;
    }

    .ke-auth-card {
        padding: 20px 16px;
        width: 100%;
        box-sizing: border-box;
    }

    .ke-auth-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .ke-auth-meta {
        grid-template-columns: 1fr;
    }
}

/* ---- Bernoulli (reforço) ---- */
@media (max-width: 900px) {
    .keepedu-app-page .bernoulli-mini-grid {
        grid-template-columns: 1fr;
    }

    .keepedu-app-page .bernoulli-form-card .bernoulli-form-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ---- Kanban (reforço) ---- */
@media (max-width: 640px) {
    .keepedu-app-page .kanban-board-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .keepedu-app-page .kanban-board-filtros {
        grid-template-columns: 1fr;
    }
}
