/* Carnicerias Vilcy — capa táctil y rendimiento (PC táctil, tablet, celular) */
html {
  -webkit-tap-highlight-color: rgba(122, 31, 31, 0.16);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
html.is-touch,
html.is-touch body {
  touch-action: manipulation;
}

/* ── Controles grandes: táctil o pantallas ≤ 1024px ── */
@media (pointer: coarse), (hover: none), (max-width: 1024px) {
  html { --tap: 48px; }

  a, button, summary, label, [role="button"] {
    touch-action: manipulation;
  }

  .btn, .btn-sm, .btn-lg, .btn-ghost, .btn-primary, .btn-danger,
  button.btn, a.btn {
    min-height: var(--tap);
    min-width: 44px;
    padding: 0.7rem 1.05rem;
    font-size: 0.95rem;
  }
  .btn-sm { padding: 0.55rem 0.85rem; }

  input, select, textarea,
  .login-select, .login-input {
    min-height: var(--tap);
    font-size: 16px; /* evita zoom iOS */
  }
  textarea { min-height: 96px; }

  .cat-tab {
    min-height: 34px;
    padding: 0.28rem 0.75rem;
    font-size: 0.8rem;
    flex-shrink: 0;
  }
  .cat-tabs {
    gap: 0.3rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .prod-card {
    min-height: 240px;
    grid-template-rows: 160px auto;
  }
  .prod-card-media {
    height: 160px;
    min-height: 160px;
  }
  .prod-card-img {
    height: 160px;
    object-fit: contain;
  }
  .catalogo {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 0.7rem;
  }
  .item-edit, .item-del, .captura-close {
    width: 48px;
    height: 48px;
    min-width: 48px;
    font-size: 1.15rem;
  }

  .sidebar-link,
  .sidebar-group > summary,
  .sidebar-logout-btn,
  .sidebar-close-btn {
    min-height: var(--tap);
  }
  .sidebar-sub a {
    min-height: 44px;
    padding: 0.6rem 0.8rem 0.6rem 1.4rem;
  }

  .app-atajo {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 0.75rem;
  }
  .app-atajo-card {
    min-height: 88px;
    padding: 0.9rem 0.85rem;
  }

  .bnav-item {
    min-height: 56px;
  }

  .tabla th, .tabla td {
    padding: 0.85rem 0.65rem;
  }
  .tabla .btn, .tabla button, .home-ped-actions .btn {
    min-height: 44px;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .page-header {
    gap: 0.75rem;
  }
  .header-actions, .page-header > div:last-child {
    gap: 0.5rem;
  }

  .chip, .estado-tag {
    min-height: 32px;
    padding: 0.25rem 0.65rem;
  }

  .home-ped-tab {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }

  .kpi-dash-card {
    min-height: 108px;
  }

  .sticky-actions {
    bottom: 0;
    padding: 0.75rem 0 calc(0.5rem + env(safe-area-inset-bottom, 0));
    z-index: 30;
  }

  .modal-form .btn,
  dialog .btn,
  .captura-pad button,
  .precio-ref-btn {
    min-height: 52px;
  }

  .merma-radio, .merma-alcance label {
    min-height: 48px;
  }

  .field-label, label.field-label {
    font-size: 0.88rem;
  }
}

/* Híbridos (Surface / PC táctil) aunque el mouse sea fino */
html.is-touch .btn,
html.is-touch .btn-sm,
html.is-touch .btn-lg,
html.is-touch a.btn {
  min-height: 48px;
}
html.is-touch input,
html.is-touch select,
html.is-touch textarea {
  min-height: 48px;
  font-size: 16px;
}
html.is-touch .sidebar-link,
html.is-touch .sidebar-group > summary {
  min-height: 48px;
}
html.is-touch .app-atajo {
  min-height: 44px;
}
html.is-touch .prod-card {
  min-height: 240px;
}

@media (pointer: coarse), (hover: none) {
  .btn:hover, .prod-card:hover, .cat-tab:hover,
  .app-atajo:hover, .sidebar-link:hover, .kpi-dash-card:hover {
    transform: none;
  }
  .tabla tr:hover td {
    background: inherit;
  }
}

/* Acciones fijas no quedan bajo la barra inferior */
@media (max-width: 900px) {
  .sticky-actions {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0));
  }
  .content {
    padding-left: max(0.85rem, env(safe-area-inset-left, 0));
    padding-right: max(0.85rem, env(safe-area-inset-right, 0));
  }
  .bottom-nav {
    height: auto;
    min-height: 62px;
  }
  .bnav-item {
    padding-top: 0.45rem;
    padding-bottom: 0.35rem;
  }
}

@media print {
  .bottom-nav, .app-atajos-bar, .mobile-topbar, .sticky-actions {
    display: none !important;
  }
}
