/*
 * Phones (up to 640 px): list tables as cards (marked by includes/layout/js/ama-mobile.js), the paging that wraps,
 * the top bar on one line. Nothing changes on wider screens.
 */
@media (max-width: 640px) {
  /* top bar: the logout link keeps its icon only, so the bar stays on one line */
  header a[href$="admin/logout.php"] > span { display: none; }

  /* paging and the length / search of DataTables: wrap instead of widening the page */
  .dataTables_paginate .pagination, div.dt-paging nav, .dt-paging .pagination { flex-wrap: wrap; justify-content: center; }
  .dataTables_wrapper .row > [class*="col-"] { width: 100%; }
  .dataTables_filter input, .dt-search input { width: 100% !important; max-width: 100%; margin-left: 0 !important; }

  /* cards */
  table.ama-cards { border: 0 !important; width: 100% !important; }
  table.ama-cards thead { display: none; }
  table.ama-cards, table.ama-cards tbody, table.ama-cards tr, table.ama-cards td { display: block; width: auto !important; }
  table.ama-cards tbody tr {
    border: 1px solid var(--m-border, #e2e8f0); border-radius: 10px; margin: 0 0 10px; padding: 6px 12px;
    background: var(--m-surface, #fff); box-shadow: var(--m-shadow-sm, 0 1px 2px rgba(0, 0, 0, .06));
  }
  table.ama-cards tbody td {
    display: flex !important; justify-content: flex-end; align-items: center; gap: 8px;
    border: 0 !important; padding: 5px 0 !important; text-align: right !important; white-space: normal !important; min-height: 30px;
  }
  table.ama-cards tbody td + td { border-top: 1px dashed var(--m-border, #e2e8f0) !important; }
  table.ama-cards tbody td::before {
    content: attr(data-label); flex: 0 0 42%; text-align: left; font-weight: 600; font-size: .82rem; color: var(--m-muted, #64748b);
    /* the arrow of the DataTables "responsive" column is replaced by the label */
    position: static !important; top: auto !important; left: auto !important; height: auto !important; width: auto !important;
    margin: 0 auto 0 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: none !important; line-height: 1.3 !important;
  }
  table.ama-cards tbody td[data-label=""]::before { display: none; }
  table.ama-cards tbody td[data-label=""] { justify-content: flex-end; }
  table.ama-cards tbody td.dtr-hidden, table.ama-cards tbody th.dtr-hidden { display: flex !important; }   /* "responsive" hid them */
  table.ama-cards tbody tr.child { display: none !important; }                                          /* its copy of them */
  table.ama-cards tbody td .btn { min-width: 38px; min-height: 34px; }                                 /* a finger, not a mouse */
  table.ama-cards tbody td.dataTables_empty { justify-content: center; }
  table.ama-cards tbody td.dataTables_empty::before { display: none; }
  table.ama-cards tfoot { display: block; }
  table.ama-cards tfoot tr { display: flex; flex-wrap: wrap; gap: 8px; }
}
