/*
 * OsFluxo — ajustes de responsividade (mobile-first)
 * Criado em 12/10/2026. Arquivo SOMENTE de overrides: nenhuma regra existente foi alterada.
 * Rollback: remover o <link> deste arquivo dos layouts (app, auth, guest) e da landing (public/home).
 */

/* ---------- Desktop (>= 992px): texto longo quebra linha em vez de alargar a tabela ---------- */
@media (min-width: 992px) {
    table.rt-cards td.rt-title,
    table.rt-cards td.rt-wide {
        white-space: normal;
        overflow-wrap: anywhere;
        min-width: 12rem;
    }
}

/* ---------- Celular, inclusive deitado (< 768px) ---------- */
@media (max-width: 767.98px) {
    /* iOS dá zoom automático ao focar campos com fonte < 16px */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Grade de formulário: 1 coluna que não pode crescer além da tela (texto longo, e-mail etc.) */
    .orca-workflow .form-grid,
    .auth-form .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .orca-workflow .form-grid > *,
    .auth-form .form-grid > * {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    /* Alvos de toque mínimos (WCAG 2.2 — 24x24). O tema usa !important, por isso aqui também. */
    .orca-workflow .checkbox input[type="checkbox"],
    .orca-workflow :not(.form-switch) > .form-check-input[type="checkbox"] {
        width: 24px !important;
        height: 24px !important;
        min-height: 24px !important;
    }
    .orca-workflow .form-switch .form-check-input {
        width: 44px !important;
        height: 24px !important;
    }
    .register-consent input[type="checkbox"] {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
    }
    /* Link "Esqueci minha senha" (21px de altura) e links do rodapé da landing (14px) */
    .auth-form a.small-text {
        padding-top: 2px;
        padding-bottom: 2px;
    }
    .footer-grid > div > a {
        padding-top: 6px;
        padding-bottom: 6px;
    }
}

/* ---------- Celular e tablet (< 992px): tabelas viram cartões (classe aplicada por responsive-fixes.js) ---------- */
@media (max-width: 991.98px) {
    table.rt-cards,
    table.rt-cards tbody,
    table.rt-cards tr,
    table.rt-cards td {
        display: block;
        width: 100%;
    }
    table.rt-cards {
        min-width: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }
    table.rt-cards thead {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        overflow: hidden !important;
        clip: rect(0 0 0 0) !important;
        clip-path: inset(50%) !important;
        white-space: nowrap !important;
    }
    table.rt-cards tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 14px;
        margin: 0 0 12px;
        padding: 14px 16px;
        border: 1px solid #e6e8f0 !important;
        border-radius: 12px;
        background: #fff !important;
        box-shadow: 0 1px 2px rgba(20, 24, 40, .04);
    }
    /* Modo escuro: usa os tons do próprio tema (painel #252832, borda #383b48).
       O card fica um passo mais claro que o painel para continuar visível.
       O documento do orçamento (.quote-items) é "papel" e segue branco, como no tema. */
    body.dark-only table.rt-cards:not(.quote-items) tbody tr,
    body.dark-only .orca-workflow table.rt-cards:not(.quote-items) tbody tr {
        border-color: #3a3d4b !important;
        background: #2b2e3a !important;
        color: #e4e5e9;
        box-shadow: none;
    }
    body.dark-only .orca-workflow table.rt-cards:not(.quote-items) tbody tr:hover {
        background: #30323d !important;
    }
    body.dark-only table.rt-cards td[data-label]:not([data-label=""])::before,
    body.dark-only .orca-workflow table.rt-cards td[data-label]:not([data-label=""])::before {
        color: #9a9db0;
    }
    table.rt-cards tbody tr:last-child {
        margin-bottom: 0;
    }
    table.rt-cards td,
    body.dark-only .orca-workflow table.rt-cards td {
        min-width: 0;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        text-align: left !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }
    /* Largura de coluna da tabela não vale no cartão (17/10/2026): com o ".quote-items .center {width:9%}"
       do tema, quantidade, unidade e valores ficavam com ~13px e quebravam letra por letra */
    table.rt-cards td,
    table.rt-cards th {
        width: auto !important;
        max-width: none !important;
    }
    table.rt-cards.quote-items td.center,
    table.rt-cards.quote-items td.money {
        overflow-wrap: normal;
        word-break: normal;
    }
    table.rt-cards td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        font-size: 11px;
        font-weight: 600;
        line-height: 1.3;
        letter-spacing: .3px;
        text-transform: uppercase;
        color: #8a90a2;
    }
    /* Primeira coluna = título do cartão */
    table.rt-cards td.rt-title {
        grid-column: 1 / -1;
        font-size: 15px;
        font-weight: 700;
    }
    table.rt-cards td.rt-title::before {
        content: none !important;
    }
    /* Conteúdo longo ocupa a linha toda */
    table.rt-cards td.rt-wide,
    table.rt-cards td.rt-full {
        grid-column: 1 / -1;
    }
    /* Linha de estado vazio ("Nenhum registro") */
    table.rt-cards td.rt-full {
        text-align: center !important;
        color: #8a90a2;
    }
    table.rt-cards td.rt-full::before {
        content: none !important;
    }
    /* Coluna de ações (cabeçalho vazio) */
    table.rt-cards td.rt-actions {
        grid-column: 1 / -1;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 8px;
        padding-top: 4px !important;
    }
    table.rt-cards td.rt-actions::before {
        content: none !important;
    }
    table.rt-cards td.rt-actions > a,
    table.rt-cards td.rt-actions > button,
    table.rt-cards td.rt-actions > form > button,
    table.rt-cards td.rt-actions .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }
    /* Itens do orçamento (documento interno e link público) */
    table.rt-cards.quote-items td.code.rt-title {
        font-size: 12px;
        font-weight: 600;
        color: #8a90a2;
    }
    table.rt-cards.quote-items td.code.rt-title::before {
        content: "Item " !important;
        display: inline;
        font-size: inherit;
        text-transform: none;
        letter-spacing: 0;
        color: inherit;
    }
    /* O wrapper deixa de precisar de rolagem */
    .table-wrap:has(> table.rt-cards) {
        overflow-x: visible;
        border: 0;
    }
}

/* Tablet e celular deitado: mais campos por linha dentro do cartão */
@media (min-width: 576px) and (max-width: 991.98px) {
    table.rt-cards tbody tr {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    /* Itens do orçamento: Qtd. | Un. | Valor unit. | Total lado a lado (17/10/2026) */
    table.rt-cards.quote-items tbody tr {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ---------- Celular em pé (< 576px) ---------- */
@media (max-width: 575.98px) {
    /* Faixa do título: a margem negativa do tema (-27px) passava do padding do container (12px) */
    .page-wrapper .page-body-wrapper .page-body > .container-fluid > .page-title {
        margin-left: calc(var(--bs-gutter-x, 1.5rem) * -.5);
        margin-right: calc(var(--bs-gutter-x, 1.5rem) * -.5);
    }

    /* Gráfico do dashboard/relatórios: barras do último mês ficavam cortadas */
    .chart {
        gap: 6px;
    }
    .chart-group {
        min-width: 0;
        gap: 3px;
    }

    /* Formulário de orçamento: itens com 5 colunas ficavam espremidos e cortados */
    .orca-workflow .item-top {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .orca-workflow .item-top .catalog-select {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    .orca-workflow .item-top .btn.danger {
        min-width: 44px;
        min-height: 44px;
    }
    .orca-workflow .item-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* Qtd | Un · Preço | Desconto · Total do item na linha toda */
    .orca-workflow .item-grid > .field:last-child {
        grid-column: 1 / -1;
    }

    /* Admin → detalhe da empresa: 5 blocos fixos estouravam a tela em 320px */
    .orca-workflow .record-summary {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
    .orca-workflow .record-summary > div {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

/* Alvo de toque: links soltos no cabeçalho de painel (ex. "Ver pagamentos", 21px de altura) */
@media (max-width: 767.98px) {
    .orca-workflow .panel-header > a,
    .orca-workflow .panel-header a:not(.btn) {
        display: inline-block;
        padding-top: 3px;
        padding-bottom: 3px;
    }

    /* Textos sem espaço (URL de webhook, token, e-mail) quebram em vez de furar a tela */
    .orca-workflow .panel-body strong,
    .orca-workflow .panel-body code,
    .orca-workflow .small-text,
    .orca-workflow .table-sub {
        overflow-wrap: anywhere;
    }
}

/* ---------- Cabeçalho das páginas no celular (16/10/2026) ---------- */
/* Título em cima e ações embaixo, na largura toda: evita botão espremido em várias linhas */
@media (max-width: 575.98px) {
    .orca-workflow > .page-heading {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 14px;
    }
    .orca-workflow > .page-heading > :first-child {
        flex: 1 1 100%;
        min-width: 0;
    }
    .orca-workflow > .page-heading > :not(:first-child) {
        flex: 1 1 auto;
    }
    .orca-workflow > .page-heading > .btn,
    .orca-workflow > .page-heading > form .btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }
}

/* Fim da página (17/10/2026): o último botão (ex.: "Salvar landing page") não encosta no rodapé nem fica
   embaixo do botão flutuante de voltar ao topo (40 px de altura, a 30 px da borda) */
.page-wrapper .page-body-wrapper .page-body > .container-fluid:last-child {
    padding-bottom: 40px;
}

/* Landing: contraste mínimo 4,5:1 (WCAG AA) nos 3 pontos apontados pelo Lighthouse (17/10/2026).
   Só escurece um pouco o roxo/cinza sobre os fundos claros; o resto da paleta segue igual. */
.workflow-copy ol li > span,
#planos > .container > .eyebrow {
    color: #5a4ae8;
}
#planos > .container > p {
    color: #5f6878;
}
/* Termos e privacidade: texto e links com contraste AA sobre o branco (17/10/2026) */
main.legal p,
main.legal li {
    color: #5d6377;
}
main.legal a {
    color: #2a6f97 !important; /* os links têm style="color:var(--brand)" (3,66:1) */
}
