/* ═══════════════════════════════════════════════════
   PRECIVO — TABLET
   Só vale em tela > 768px COM toque como entrada principal (sem mouse).
   - Celular (<= 768px): não entra aqui, continua no mobile.css
   - Desktop / notebook (tem mouse): não entra aqui
   Carregado em todas as páginas pelo index.php.
═══════════════════════════════════════════════════ */

/* Fora do tablet: os elementos criados pelo tablet.js ficam "invisíveis" pro layout */
.tab-short, .tab-rail-btn, .tab-rail-ov { display: none; }
.tab-chips, .tab-alerts { display: contents; }
@media (max-width: 768px) { .tab-chips { display: none !important; } }

@media (min-width: 769px) and (hover: none) and (pointer: coarse) {

  /* ── 1. MENU LATERAL EM "TRILHO" (só ícones + nome curto) ── */
  .sidebar {
    display: flex !important;
    width: 84px !important;
    height: 100vh !important; height: 100dvh !important;
    min-height: 0 !important; bottom: 0;
    overflow-x: hidden;
    overscroll-behavior: contain;
    overflow-y: auto;
    transition: width .2s ease, box-shadow .2s ease;
    -webkit-overflow-scrolling: touch;
  }
  .main { margin-left: 84px !important; }

  .slogo { justify-content: center; padding: 12px 0 10px !important; }
  .slogo-wm { content: url(/assets/precivo-mark-white.png); height: 42px !important; width: 42px !important; }

  .snav { padding: 8px 8px 4px !important; }
  .snav-label { display: none !important; }

  .sidebar .nav-a {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 10px 2px !important;
    min-height: 58px;
    margin-bottom: 2px;
    text-align: center;
    border-radius: 10px;
  }
  .sidebar .nav-a svg { width: 22px; height: 22px; }
  .sidebar .nav-a.active::before { top: 18%; bottom: 18%; }
  .sidebar .tab-lbl { display: none; }
  .sidebar .tab-short { display: block; font-size: 10.5px; line-height: 1.15; font-weight: 500; white-space: nowrap; max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
  .sidebar .nav-a > span:not(.tab-lbl):not(.tab-short) { display: none !important; } /* selo "Em breve" */
  .sidebar .nav-group > div > button { display: none !important; }                   /* setinha do submenu */
  .sidebar .nav-submenu { display: none !important; }

  .sfooter { padding: 10px 6px !important; }
  .user-card { justify-content: center; padding: 6px 0 !important; }
  .user-card > :not(.uavatar) { display: none !important; }
  .sidebar > *, .snav > *, .tab-rail-btn { flex-shrink: 0; }

  /* Botão ☰ que abre o menu completo (criado pelo tablet.js) */
  .tab-rail-btn {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 44px; margin: 8px auto 0;
    background: rgba(255,255,255,.06); border: none; border-radius: 10px;
    color: rgba(255,255,255,.75); cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .tab-rail-btn svg { width: 22px; height: 22px; }
  .tab-rail-ov { display: block; position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; }

  /* Menu aberto: volta a largura normal por cima da tela */
  body.tab-rail-open .tab-rail-ov { opacity: 1; pointer-events: auto; }
  body.tab-rail-open .sidebar { width: 260px !important; box-shadow: 8px 0 30px rgba(0,0,0,.3); }
  body.tab-rail-open .slogo { justify-content: flex-start; padding: 12px 20px 10px 22px !important; }
  body.tab-rail-open .slogo-wm { content: normal; width: auto !important; height: 52px !important; }
  body.tab-rail-open .tab-rail-btn { margin: 8px 12px 0 auto; }
  body.tab-rail-open .sidebar .nav-a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 12px !important; min-height: 48px; text-align: left; font-size: 15px; }
  body.tab-rail-open .sidebar .tab-lbl { display: inline; }
  body.tab-rail-open .sidebar .tab-short { display: none; }
  body.tab-rail-open .sidebar .nav-a > span:not(.tab-lbl):not(.tab-short) { display: inline-block !important; }
  body.tab-rail-open .sidebar .nav-group > div > button { display: flex !important; padding: 12px 12px !important; }
  body.tab-rail-open .sidebar .nav-submenu[style*="block"] { display: block !important; }
  body.tab-rail-open .user-card { justify-content: flex-start; padding: 8px 10px !important; }
  body.tab-rail-open .user-card > :not(.uavatar) { display: revert !important; }
  body.tab-rail-open .user-card .logout-btn { font-size: 14px; padding: 10px 12px; }

  /* ── 2. ÁREAS DE TOQUE MAIORES (mín. ~44px) ── */
  .btn-primary, .btn-secondary, .btn-tutorial { min-height: 44px; font-size: 14px !important; }
  .search-box, .rc-search input { min-height: 44px; }
  .search-box input { font-size: 15px !important; }
  select.fsort { min-height: 44px; font-size: 14px !important; }
  .chip { min-height: 40px; padding: 8px 16px !important; font-size: 13.5px !important; }
  .vt-btn { width: 46px !important; height: 44px !important; }
  .btn-icon, .icon-btn, .ft-del-btn, .ft-dup-btn { width: 42px !important; height: 42px !important; border-radius: 10px !important; }
  .btn-icon svg, .icon-btn svg, .ft-del-btn svg, .ft-dup-btn svg { width: 18px !important; height: 18px !important; }
  .row-actions, .ft-acoes { gap: 8px !important; }
  .rc-btn { min-height: 46px; font-size: 14.5px !important; }
  .rc-uso-btn { min-height: 40px; font-size: 14px !important; }
  .uso-toggle { padding: 8px 14px !important; font-size: 12.5px !important; }
  .page-btns button, .page-btns a, .page-btn { min-width: 42px; min-height: 42px; }
  .alert-strip button, .drawer-close, .modal-close { min-width: 40px; min-height: 40px; }

  .filter-row .search-box, .filter-bar .search-box { flex: 1 1 280px; max-width: 440px; }
  .card-actions { gap: 6px !important; }
  .card-actions .icon-btn { width: 38px !important; height: 38px !important; }
  .code-tag { white-space: nowrap; }

  /* Coisas que só apareciam com o mouse em cima: no toque ficam sempre visíveis */
  .card-actions { opacity: 1 !important; }
  .chip .chip-del { opacity: .7 !important; width: 16px; height: 16px; }

  /* ── 3. FILTROS DE CATEGORIA NUMA LINHA SÓ, COM ROLAGEM PRO LADO ── */
  .tab-chips {
    display: flex; flex: 1 1 100%; order: 99; gap: 8px; min-width: 0;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 2px 0 4px;
    mask-image: linear-gradient(to right, #000 92%, transparent);
    -webkit-mask-image: linear-gradient(to right, #000 92%, transparent);
  }
  .tab-chips::-webkit-scrollbar { display: none; }
  .tab-chips > *, .tab-chips #chips-cat > *, .tab-chips #chips-categorias > * { flex-shrink: 0; }
  .tab-chips #chips-cat, .tab-chips #chips-categorias { display: contents !important; }

  /* ── 4. TABELA DE INSUMOS MAIS ENXUTA (sai Medida e Fornecedor) ── */
  table:has(#ing-tbody) > thead th:nth-child(3), table:has(#ing-tbody) > thead th:nth-child(4),
  #ing-tbody tr:not(.ing-bloq) > td:nth-child(3), #ing-tbody tr:not(.ing-bloq) > td:nth-child(4) { display: none; }
  .table-wrap th { font-size: 12px !important; padding: 12px 14px !important; }
  .table-wrap td { font-size: 14.5px; padding: 12px 14px !important; }

  /* ── 5. CARDS DE RESUMO DE INSUMOS: OS 5 NA MESMA LINHA ── */
  #ing-stats { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; gap: 12px !important; }
  #ing-stats .stat-card { padding: 14px !important; gap: 10px !important; min-width: 0; }
  #ing-stats .stat-card > div:last-child { min-width: 0; }
  #ing-stats .slabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ── 6. AVISOS AMARELOS COMPACTOS (lado a lado, numa linha) ── */
  .tab-alerts { display: flex; gap: 10px; margin-bottom: 14px; }
  .tab-alerts .alert-strip { flex: 1 1 0; min-width: 0; margin-bottom: 0 !important; padding: 6px 8px 6px 14px !important; }
  .alert-strip { padding: 6px 8px 6px 14px !important; margin-bottom: 12px; }
  .alert-strip > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

  /* ── 7. FONTES UM POUCO MAIORES ── */
  .ftable { font-size: 14.5px !important; }
  .ftable thead th { font-size: 12px !important; padding: 12px 14px !important; }
  .ftable tbody td { padding: 13px 14px !important; }
  .ft-cod { font-size: 12.5px !important; }
  .slabel, .rsm-label, .rsm-sub { font-size: 12.5px !important; }
  .rc-meta { font-size: 13.5px !important; }
  .rc-nome { font-size: 16px !important; }
  .rc-uso-item { font-size: 13.5px !important; }
  .code-tag { font-size: 12px !important; }
  .content { padding: 22px 22px !important; }

  /* ── FICHAS EM LISTA: TUDO CABE NA TELA, SEM ROLAGEM PRO LADO ── */
  .ftable { width: 100%; table-layout: auto; }
  .ftable thead th { padding: 11px 8px !important; font-size: 11.5px !important; }
  .ftable tbody td { padding: 11px 8px !important; }
  .ftable thead th:first-child, .ftable tbody td:first-child { padding-left: 14px !important; }
  .ftable thead th:last-child, .ftable tbody td:last-child { padding-right: 12px !important; }
  .ftable tbody td:first-child { white-space: normal !important; min-width: 170px; }
  .ftable .ft-nome { line-height: 1.3; overflow-wrap: anywhere; }
  .ftable .cat-tag { white-space: normal; max-width: 120px; line-height: 1.25; font-size: 11.5px !important; }
  .ftable .ft-acoes { gap: 6px !important; }
  .ftable .ft-del-btn, .ftable .ft-dup-btn { width: 38px !important; height: 38px !important; }
  .ftable .uso-toggle { padding: 7px 10px !important; }

  /* ── RECEITAS (lista e aviso vêm do receitas.php): tamanhos pro toque ── */
  .rc-vt button { width: 46px !important; height: 44px !important; }
  .rc-vt button svg { width: 18px !important; height: 18px !important; }
  .rl-table { font-size: 14.5px !important; }
  .rl-table th { font-size: 12px !important; padding: 12px 12px !important; }
  .rl-table td { padding: 12px 12px !important; }
  .rl-meta { font-size: 12.5px !important; }
  .rl-uso { min-height: 38px; padding: 0 12px !important; font-size: 13.5px !important; }
  .rl-btn { width: 42px !important; height: 42px !important; border-radius: 10px !important; }
  .rl-btn svg { width: 18px !important; height: 18px !important; }
  .rl-acoes { gap: 8px !important; }
  .rl-row:active { background: var(--brand-light); }
  .cf-bar { min-height: 52px; font-size: 14.5px !important; }
  .cf-bar-acao { padding: 8px 14px !important; font-size: 13.5px !important; }

  /* ── INSUMOS "EM USO" (janela vem do ingredientes.php): tamanhos pro toque ── */
  #ing-tbody .uso-badge.uf-click { min-height: 36px; padding: 0 12px !important; font-size: 13px !important; }
  .uf-box { width: min(560px, 90vw) !important; }
  .uf-x { width: 42px !important; height: 42px !important; font-size: 24px !important; }
  .uf-item { padding: 12px 10px !important; font-size: 15px !important; }
}
