/*
 * VERSÃO CELULAR do Integra-têxtil — ver includes/mobile.php.
 *
 * Esta folha é carregada com media="(max-width: 767.98px)" e TODA regra repete
 * o mesmo @media: se alguém a incluir sem o atributo, computador e tablet
 * continuam intocados. O mobile.js põe a classe .m-cel no <html> quando a
 * tela é de celular, e os ajustes de tela específica usam o id/classe dela.
 */
@media (max-width: 767.98px) {

/* ───────────────────────── Base ───────────────────────── */
html.m-cel { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.m-cel body { overflow-x: hidden !important; min-width: 0 !important; width: auto !important; }
html.m-cel img, html.m-cel video, html.m-cel iframe { max-width: 100%; }
html.m-cel img { height: auto; }
html.m-cel canvas { max-width: 100% !important; }
/* iOS dá zoom em campo com fonte < 16px */
html.m-cel input:not([type=checkbox]):not([type=radio]):not([type=range]),
html.m-cel select, html.m-cel textarea { font-size: 16px !important; max-width: 100%; }
html.m-cel .form-control, html.m-cel .form-select { min-height: 40px; }
html.m-cel .btn { min-height: 38px; }
html.m-cel .btn-sm { min-height: 32px; }
html.m-cel pre { white-space: pre-wrap; word-break: break-word; }
html.m-cel h1 { font-size: 1.45rem; } html.m-cel h2 { font-size: 1.3rem; }
html.m-cel h3 { font-size: 1.15rem; } html.m-cel h4 { font-size: 1.05rem; }
html.m-cel .display-4, html.m-cel .display-5, html.m-cel .display-6 { font-size: 1.6rem; }

/* Containers: menos respiro nas bordas */
html.m-cel .container, html.m-cel .container-fluid, html.m-cel .dashboard-container,
html.m-cel .container-lg, html.m-cel .container-xl, html.m-cel .container-xxl {
    padding-left: 10px !important; padding-right: 10px !important;
    max-width: 100% !important; width: 100% !important;
}
html.m-cel .row { --bs-gutter-x: 0.75rem; }
html.m-cel .card-body { padding: 12px; }
html.m-cel .card-header { padding: 10px 12px; }

/* ───────────────────────── Tabelas ───────────────────────── */
/* Toda tabela larga ganha rolagem lateral própria (o mobile.js embrulha as
   que estouram a tela num .m-scroll-x). */
html.m-cel .table-responsive, html.m-cel .m-scroll-x {
    overflow-x: auto !important; -webkit-overflow-scrolling: touch; max-width: 100%;
}
html.m-cel .m-scroll-x { display: block; width: 100%; position: relative; }
html.m-cel .m-scroll-x > table { margin-bottom: 0; }
html.m-cel table { font-size: 12.5px; }
html.m-cel .table > :not(caption) > * > * { padding: 6px 7px; }
html.m-cel .m-scroll-x.m-sombra { box-shadow: inset -12px 0 10px -10px rgba(0,0,0,.25); }

/* Tabela em cartões (opt-in pelo mobile.js, tabelas simples e pequenas) */
html.m-cel table.m-cartoes, html.m-cel table.m-cartoes tbody,
html.m-cel table.m-cartoes tr, html.m-cel table.m-cartoes td { display: block; width: 100% !important; }
html.m-cel table.m-cartoes thead { display: none; }
html.m-cel table.m-cartoes tr {
    border: 1px solid #dfe5e1; border-radius: 10px; margin-bottom: 8px; padding: 6px 10px;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
html.m-cel table.m-cartoes td {
    border: 0 !important; padding: 3px 0 !important; text-align: right !important;
    display: flex; justify-content: space-between; gap: 10px; min-height: 0;
}
html.m-cel table.m-cartoes td::before {
    content: attr(data-m-rotulo); font-weight: 600; color: #4a5a50; text-align: left;
    flex: 0 0 auto; max-width: 48%;
}
html.m-cel table.m-cartoes td[data-m-rotulo=""]::before { display: none; }
html.m-cel table.m-cartoes td[data-m-rotulo=""] { justify-content: flex-end; }

/* ───────────────────────── Modais ───────────────────────── */
html.m-cel .modal-dialog { margin: 6px auto; max-width: calc(100vw - 12px) !important; width: auto !important; }
html.m-cel .modal-dialog.modal-xl, html.m-cel .modal-dialog.modal-lg,
html.m-cel .modal-dialog.modal-fullscreen-md-down { margin: 0; max-width: 100vw !important; min-height: 100%; }
html.m-cel .modal-dialog.modal-xl .modal-content, html.m-cel .modal-dialog.modal-lg .modal-content { border-radius: 0; min-height: 100vh; }
html.m-cel .modal-body { padding: 12px; }
html.m-cel .modal-footer { flex-wrap: wrap; gap: 6px; }
html.m-cel .modal-footer > .btn { flex: 1 1 auto; }
html.m-cel .swal2-popup { width: calc(100vw - 20px) !important; }

/* Grupos de botões e barras de ferramentas quebram linha em vez de estourar */
html.m-cel .btn-toolbar, html.m-cel .d-flex.gap-1, html.m-cel .d-flex.gap-2,
html.m-cel .d-flex.gap-3, html.m-cel .nav-tabs, html.m-cel .nav-pills { flex-wrap: wrap; }
html.m-cel .nav-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
html.m-cel .nav-tabs::-webkit-scrollbar { display: none; }
html.m-cel .nav-tabs .nav-link { white-space: nowrap; }
html.m-cel .input-group { flex-wrap: wrap; }
html.m-cel .input-group > .form-control, html.m-cel .input-group > .form-select { min-width: 0; }

/* ───────────────────────── Barra superior (includes/header.php) ───────────────────────── */
html.m-cel .navbar-top {
    left: 0 !important; height: 54px !important; padding: 0 8px 0 4px !important; gap: 6px;
}
html.m-cel .navbar-top .navbar-title { min-width: 0; flex: 1 1 auto; gap: 8px !important; }
html.m-cel .navbar-top .navbar-title > span {
    font-size: .98rem !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
html.m-cel .navbar-top .navbar-title > i { display: none; }
html.m-cel .navbar-top .navbar-right { gap: 6px !important; flex: 0 0 auto; }
html.m-cel .navbar-top .navbar-right > span { display: none !important; }       /* nome, data, Admin */
html.m-cel .navbar-top .navbar-right > .btn,
html.m-cel .navbar-top .navbar-right > a,
html.m-cel .navbar-top .navbar-right > button:not(.btn-sidebar-mobile) { font-size: .8rem; padding: 4px 8px; }
html.m-cel .navbar-top .btn-sidebar-mobile.m-movido {
    display: inline-flex !important; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0 !important; font-size: 1.5rem !important;
    background: transparent !important; flex: 0 0 auto;
}
html.m-cel .container, html.m-cel .container-fluid, html.m-cel .dashboard-container { margin-top: 54px; }
html.m-cel .m-tem-navbar .m-extra-escondido { display: none !important; }
/* Âncora e scrollIntoView param abaixo da barra fixa, não por baixo dela */
html.m-cel.m-tem-navbar [id] { scroll-margin-top: 62px; }

/* ───────────────────────── Menu lateral (includes/sidebar.php) ───────────────────────── */
html.m-cel .sidebar-magic { width: min(86vw, 320px) !important; box-shadow: 4px 0 24px rgba(0,0,0,.35); }
html.m-cel .sidebar-magic:not(.expanded) { transform: translateX(-105%) !important; }
html.m-cel .sidebar-magic .sidebar-link,
html.m-cel .sidebar-magic .sidebar-group-header { min-height: 44px; }
html.m-cel .sidebar-magic .sidebar-toggle { display: none; }
html.m-cel body.has-sidebar, html.m-cel body.has-sidebar.sidebar-open { margin-left: 0 !important; padding-left: 0 !important; }
html.m-cel body.m-menu-aberto { overflow: hidden !important; }

/* Botão flutuante de menu — telas sem a barra do header.php */
.m-fab-menu {
    position: fixed; left: 12px; bottom: 14px; z-index: 99990;
    width: 52px; height: 52px; border-radius: 50%; border: 0;
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 100%); color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,.35); font-size: 1.6rem;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.m-fab-menu:active { transform: scale(.94); }
html.m-cel body.m-menu-aberto .m-fab-menu { display: none; }
@media print { .m-fab-menu, .m-gaveta, .m-gaveta-fundo { display: none !important; } }

/* Gaveta própria (telas sem sidebar): lista os módulos do usuário */
.m-gaveta-fundo { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99996; }
.m-gaveta {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); z-index: 99997;
    background: linear-gradient(180deg, #0d2818 0%, #1a4d2e 100%); color: #fff;
    overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 24px;
    box-shadow: 4px 0 24px rgba(0,0,0,.35); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.m-gaveta-topo { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.m-gaveta-topo b { font-size: 1.05rem; }
.m-gaveta-topo button { background: transparent; border: 0; color: #fff; font-size: 1.6rem; width: 44px; height: 44px; }
.m-gaveta-busca { margin: 10px 12px; }
.m-gaveta-busca input { width: 100%; border-radius: 10px; border: 0; padding: 10px 12px; font-size: 16px; }
.m-gaveta-grupo { padding: 12px 16px 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.55); }
.m-gaveta a {
    display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 46px;
    color: #fff; text-decoration: none; font-size: .95rem;
}
.m-gaveta a:active, .m-gaveta a.ativo { background: rgba(255,255,255,.12); }
.m-gaveta a i { font-size: 1.15rem; width: 22px; text-align: center; opacity: .9; }
.m-gaveta-rodape { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.12); margin-top: 8px; }
.m-gaveta-rodape a { padding: 10px 0; }

/* Folga no pé da página para o botão flutuante não cobrir o último botão */
html.m-cel body.m-tem-fab { padding-bottom: 76px !important; }

/* ───────────────────────── Grades comuns de indicadores ───────────────────────── */
html.m-cel .kpi-grid, html.m-cel .kpis, html.m-cel .stats-grid, html.m-cel .cards-grid,
html.m-cel .kpi-container, html.m-cel .stats-container, html.m-cel .summary-cards, html.m-cel .resumo-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important;
}
/* Elementos corrigidos pelo mobile.js (largura fixa maior que a tela) */
html.m-cel .m-encolhe { max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; overflow-wrap: anywhere; }
html.m-cel a.m-encolhe, html.m-cel span.m-encolhe, html.m-cel label.m-encolhe, html.m-cel b.m-encolhe, html.m-cel strong.m-encolhe { display: inline-block; white-space: normal !important; }
html.m-cel .m-quebra { flex-wrap: wrap !important; }
html.m-cel .m-grade-1 { grid-template-columns: minmax(0, 1fr) !important; }
html.m-cel .m-grade-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

/* Bootstrap: colunas fixas pequenas (col-3, col-4…) ficam apertadas; os
   formulários de filtro (row g-*) em linha viram duas colunas. */
html.m-cel form .row > [class*="col-md-"], html.m-cel form .row > [class*="col-lg-"] { margin-bottom: 4px; }
html.m-cel .row-cols-md-2 > *, html.m-cel .row-cols-lg-3 > *, html.m-cel .row-cols-lg-4 > * { flex: 0 0 auto; width: 100%; }

/* DataTables */
html.m-cel .dataTables_wrapper .row > div { width: 100%; text-align: left !important; }
html.m-cel .dataTables_wrapper .dataTables_filter input { width: 100% !important; margin-left: 0 !important; }
html.m-cel .dataTables_wrapper .dataTables_length,
html.m-cel .dataTables_wrapper .dataTables_filter,
html.m-cel .dataTables_wrapper .dataTables_info,
html.m-cel .dataTables_wrapper .dataTables_paginate { text-align: left !important; float: none !important; margin-bottom: 6px; }
html.m-cel .dataTables_wrapper .dataTables_paginate .pagination { flex-wrap: wrap; justify-content: flex-start !important; }

/* Widgets globais que flutuam no canto */
html.m-cel .ramais-panel-sidebar { width: calc(100vw - 20px) !important; left: 10px !important; }


/* ───────────────────────── Navegação pelo toque (26/11/2026) ─────────────────────────
   Alvo de toque com no mínimo ~40-44 px (dedo), botão Voltar, e modal com o × e os
   botões do rodapé sempre à vista. O comportamento (voltar do aparelho fecha a janela)
   está no mobile.js, seção 4. */

/* Botão Voltar — na barra do header, ao lado do ☰ */
html.m-cel .navbar-top .m-voltar-barra {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 40px; height: 44px; padding: 0; margin-left: -4px; border: 0; background: transparent;
    color: inherit; font-size: 1.35rem; -webkit-tap-highlight-color: transparent;
}
/* …ou flutuante, acima do botão de menu (telas sem a barra) */
.m-voltar-fab {
    position: fixed; left: 16px; bottom: 76px; z-index: 99989;
    width: 44px; height: 44px; border-radius: 50%; border: 1px solid #c8e6c9;
    background: #fff; color: #1B5E20; font-size: 1.35rem;
    box-shadow: 0 3px 10px rgba(0,0,0,.25);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.m-voltar-fab:active, html.m-cel .m-voltar-barra:active { transform: scale(.92); }
html.m-cel body.m-menu-aberto .m-voltar-fab, html.m-cel body.modal-open .m-voltar-fab { display: none; }
html.m-cel body.m-tem-fab { padding-bottom: 128px !important; }
@media print { .m-voltar-fab { display: none !important; } }

/* Alvos de toque */
html.m-cel .btn-close {
    width: 44px; height: 44px; padding: 0; box-sizing: border-box;
    background-size: 14px; background-position: center; opacity: .75;
}
html.m-cel .modal-header .btn-close { margin: -6px -8px -6px auto; }
/* título longo no cabeçalho espremia o × (23-32 px de largura): ele não encolhe */
html.m-cel .btn-close { flex: 0 0 44px; }
html.m-cel .btn-sm, html.m-cel .btn-group-sm > .btn { min-height: 36px; min-width: 36px; }
html.m-cel .btn { min-width: 38px; }
html.m-cel .nav-tabs .nav-link, html.m-cel .nav-pills .nav-link { min-height: 42px; display: flex; align-items: center; }
html.m-cel .page-link { min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
html.m-cel .dataTables_wrapper .paginate_button { min-width: 38px; min-height: 38px; }
html.m-cel .form-check-input { width: 1.3em; height: 1.3em; }
html.m-cel .form-check { min-height: 32px; display: flex; align-items: center; gap: .4em; }
html.m-cel .form-check .form-check-input { margin-top: 0; flex: 0 0 auto; }
html.m-cel .form-switch .form-check-input { width: 2.4em; }
html.m-cel .dropdown-item { padding-top: 10px; padding-bottom: 10px; }
html.m-cel .dropdown-menu { max-width: calc(100vw - 16px); overflow-x: hidden; }
html.m-cel .list-group-item-action { min-height: 44px; }
html.m-cel .accordion-button { min-height: 48px; }

/* Modal: cabeçalho (com o ×) e rodapé presos ao rolar — mobile.js põe .m-preso e o fundo */
html.m-cel .modal-header.m-preso { position: sticky; top: 0; z-index: 6; }
html.m-cel .modal-footer.m-preso { position: sticky; bottom: 0; z-index: 6; box-shadow: 0 -4px 10px rgba(0,0,0,.06); }
html.m-cel .modal-footer > .btn { min-height: 44px; }
/* modal pequeno: centralizado com folga, sem colar no topo */
html.m-cel .modal-dialog:not(.modal-xl):not(.modal-lg):not(.modal-fullscreen) { margin-top: 12px; }

/* Contêiner de avisos (toasts) fixo no canto: mesmo vazio, o espaçamento dele cobria o ×
   dos modais (relatorio_partidas_aberto: z-index 9999 no canto superior direito).
   O contêiner deixa o toque passar; os avisos dentro dele continuam clicáveis. */
html.m-cel .toast-container, html.m-cel div.position-fixed.top-0.end-0 { pointer-events: none; }
html.m-cel .toast-container > *, html.m-cel div.position-fixed.top-0.end-0 > * { pointer-events: auto; }

/* Aviso de "Carregando…" das telas começa ABAIXO da barra: enquanto a tela carrega
   (algumas levam 10-15 s), o ☰ e a seta de voltar continuam ao alcance. */
html.m-cel.m-tem-navbar #loadingOverlay, html.m-cel.m-tem-navbar #modalLoading,
html.m-cel.m-tem-navbar #overlayCarregando, html.m-cel.m-tem-navbar .loading-overlay { top: 54px !important; }

/* Botões de ajuda "?" e atalhos pequenos das telas (Vendas, Relógio, RCS, Necessidade de Fio…) */
html.m-cel button[class*="-ajuda"] {
    min-width: 32px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center;
}
html.m-cel .chip, html.m-cel .btn-mini, html.m-cel .qm-atalho, html.m-cel .rcs-atalho,
html.m-cel .rlg-hist-item, html.m-cel .btn-check + .btn, html.m-cel .btn-nav { min-height: 36px; }
html.m-cel .chip, html.m-cel .btn-mini, html.m-cel .qm-atalho, html.m-cel .rcs-atalho { display: inline-flex; align-items: center; }

/* Links Curtos (encurtador.php): sem o host no prefixo do código e a
   lista vira cartões. A tabela fica num .table-responsive para o
   mobile.js não lhe dar largura mínima (m-larga). */
html.m-cel .ec-wrap { padding: 72px 12px 32px; }
html.m-cel .ec-card { padding: 16px 14px; }
html.m-cel .ec-host { display: none; }
html.m-cel .ec-barra-ferr .ec-h { width: 100%; }
html.m-cel .ec-busca { flex: 1; width: auto; }
html.m-cel .ec-tabela thead { display: none; }
html.m-cel .ec-tabela, html.m-cel .ec-tabela tbody, html.m-cel .ec-tabela tr, html.m-cel .ec-tabela td { display: block; width: 100%; }
html.m-cel .ec-tabela tr { border: 1px solid var(--ec-borda); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
html.m-cel .ec-tabela > :not(caption) > * > * { padding: 3px 0 !important; border: 0; }
html.m-cel .ec-tabela td[data-rot] { display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; text-align: right; }
html.m-cel .ec-tabela td[data-rot]::before { content: attr(data-rot); color: var(--ec-mudo); font-size: .75rem; font-weight: 400; text-align: left; flex-shrink: 0; }
html.m-cel .ec-tabela td.ec-col-destino { min-width: 0; padding-bottom: 6px !important; }
html.m-cel .ec-destino { max-width: 100%; }
html.m-cel .ec-tabela .ec-sub { display: inline; margin-left: 4px; }
html.m-cel .ec-tabela td.ec-acoes { text-align: left; padding-top: 8px !important; margin-top: 6px; border-top: 1px solid #eef0f2; }
html.m-cel .ec-tabela tr.ec-linha-vazia { border: 0; }
html.m-cel .ec-abas { flex-wrap: nowrap; overflow-x: auto; }
html.m-cel .ec-abas .nav-link { white-space: nowrap; padding: 8px 10px; }
html.m-cel .ec-usuario { flex: 1; width: auto; }


/* Relógio 2027 (diretoria/Relogio2027, R3 N4 — 06/11/2026): as tabelas 2026 × 2027 (.rlg-t27: cartão "2026 × 2027"
   quadro "Total do pedido" e custo para o cliente, na consulta e no simulador) tinham 4 colunas e a do 2027 ficava fora da tela, sem aviso.
   No celular cada linha vira duas: o rótulo em cima, ocupando a largura toda, e 2026 | 2027 | diferença embaixo,
   alinhados com o cabeçalho. Nada rola de lado e nenhuma coluna some. Classe só do Relógio 2027. */
html.m-cel .rlg-t27, html.m-cel .rlg-t27 > thead, html.m-cel .rlg-t27 > tbody { display: block; width: 100%; }
html.m-cel .rlg-t27.m-larga { min-width: 0 !important; }
html.m-cel .rlg-t27 tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 6px; border-bottom: 1px solid #eceff1; padding: 3px 0; }
html.m-cel .rlg-t27 > :not(caption) > * > * { border-bottom-width: 0; padding: 1px 2px; }
html.m-cel .rlg-t27 td:first-child { grid-column: 1 / -1; white-space: normal !important; min-width: 0 !important; padding-left: 2px !important; font-weight: 600; }
html.m-cel .rlg-t27 .rlg-t27-dentro td:first-child { font-weight: 400; padding-left: 10px !important; }
html.m-cel .rlg-t27 thead th:first-child { display: none; }
html.m-cel .rlg-t27 thead tr { border-bottom: 2px solid #cfd8dc; }
html.m-cel .rlg-t27 td:not(:first-child), html.m-cel .rlg-t27 th:not(:first-child) { white-space: nowrap; font-size: .78rem; text-align: right; overflow: hidden; text-overflow: ellipsis; }
html.m-cel .rlg-scroll:has(> .rlg-t27) { overflow-x: visible; }
html.m-cel .rlg-t27 td:not(:first-child):has(.text-muted) { white-space: normal; overflow: visible; }

}
