/* RC56Y Android Edition - solo ottimizzazione visuale mobile.
   Non modifica PDF/rapportini, database o logiche applicative. */

@media (max-width: 860px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    padding-bottom: 76px;
  }

  main, .main, .content, .container, .wrap, .page, .app-content {
    max-width: 100% !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .card, .panel, section.card {
    margin: 8px 0 !important;
    padding: 10px !important;
    border-radius: 14px !important;
  }

  h1 { font-size: 1.35rem !important; line-height: 1.15 !important; margin: 8px 0 10px !important; }
  h2 { font-size: 1.10rem !important; line-height: 1.2 !important; margin: 8px 0 !important; }
  h3 { font-size: 1rem !important; margin: 6px 0 !important; }

  .toolbar, .actions, .filters, form.filters, .filterbar, .searchbar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    align-items: stretch !important;
    margin-bottom: 8px !important;
  }

  input, select, textarea, button, .btn, a.btn {
    font-size: 14px !important;
    min-height: 38px !important;
    border-radius: 10px !important;
  }

  input[type="search"], input[type="text"], select {
    max-width: 100% !important;
  }

  .toolbar input, .toolbar select,
  .filters input, .filters select,
  form.filters input, form.filters select,
  .filterbar input, .filterbar select,
  .searchbar input, .searchbar select {
    flex: 1 1 145px !important;
    width: auto !important;
  }

  .toolbar button, .toolbar .btn,
  .actions button, .actions .btn,
  .filters button, .filters .btn {
    flex: 0 0 auto !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  /* Tabelle più compatte e scorrevoli su Android */
  table {
    width: 100% !important;
    min-width: 620px;
    border-collapse: collapse !important;
    font-size: 12px !important;
  }

  .card:has(table), .panel:has(table), section:has(table), .table-wrap, .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  table th, table td {
    padding: 6px 7px !important;
    line-height: 1.18 !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
  }

  table td {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  table td:nth-child(1), table th:nth-child(1) { max-width: 95px; }
  table td:nth-child(2), table th:nth-child(2) { max-width: 155px; }
  table td:nth-child(3), table th:nth-child(3) { max-width: 145px; }
  table td:last-child, table th:last-child { max-width: none; }

  table a, table .btn, table button {
    min-height: 30px !important;
    padding: 5px 7px !important;
    font-size: 12px !important;
  }

  .badge, .pill, .status, .tag {
    font-size: 11px !important;
    padding: 3px 6px !important;
    white-space: nowrap !important;
  }

  .calls-table .urgency-dot {
    width: 10px !important;
    height: 10px !important;
    margin-right: 4px !important;
  }

  /* Tabelle molto grandi: più righe visibili */
  .machines table, table.machines, .calls-table, .maintenance table, .warehouse table {
    font-size: 11.5px !important;
  }

  .machines table th, .machines table td,
  table.machines th, table.machines td,
  .calls-table th, .calls-table td,
  .maintenance table th, .maintenance table td,
  .warehouse table th, .warehouse table td {
    padding: 5px 6px !important;
  }

  /* Menu inferiore/azioni: tocco più semplice */
  nav.bottom-nav, .bottom-nav, .mobile-bottom-nav {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 2000 !important;
  }

  /* Evita che i rapportini di stampa/PDF vengano alterati */
  .rapportino-print, .workorder-print, .pdf-page, .a4-page {
    font-size: inherit !important;
  }
}
