/* ──────────────────────────────────────────────────────────────
   Bookings mobile layout — turns the RC/AT tables into stacked
   cards under 700px. We keep the existing table markup untouched
   and rely on CSS only (display changes + generated data-labels
   from the <th> order through ::before pseudo-content).

   Because the exact <th> labels differ per page, we set a custom
   property per column in JS would be noisy; instead we target
   nth-child() and hand-label each cell. Pages we style here:

     - Rent-a-Car (columns: [bulk] Ref / Cliente / Carro / Pick-up /
       Drop-off / Valor / Parceiro / Estado / Acções)
     - Activities (columns: [bulk] Ref / Cliente / Atividade / Data /
       Pax / Valor / Parceiro / Estado / Acções)

   The leading [bulk] cell is optional (only when the bulk actions
   component is attached). We stretch the label column wide enough
   to handle both.
   ────────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table td,
  .data-table th {
    display: block;
    width: 100%;
  }

  .data-table thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .data-table tbody tr {
    background: var(--surface-raised, #fff);
    border: 1px solid var(--border-subtle, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(15, 23, 42, .05));
    margin-bottom: 12px;
    padding: 14px 14px 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 6px;
    column-gap: 12px;
    align-items: start;
  }

  .data-table tbody td {
    border: none;
    padding: 2px 0;
    font-size: .85rem;
    text-align: left;
  }

  .data-table tbody td::before {
    content: attr(data-label);
    display: block;
    color: var(--text-secondary, #64748b);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    margin-bottom: 2px;
  }

  /* Remove the per-row cursor:pointer inline style visual noise. */
  .data-table tbody tr[data-row-click] { cursor: default; }

  /* Make the actions cell occupy the full row and flex nicely. */
  .data-table tbody tr td:last-child {
    grid-column: 1 / -1;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-subtle, #e2e8f0);
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px !important;
    justify-content: flex-start;
  }
  .data-table tbody tr td:last-child::before { display: none; }
  .data-table tbody tr td:last-child button {
    font-size: .7rem !important;
    padding: .25rem .5rem !important;
  }

  /* Bulk-checkbox cell (when present) sits top-right. */
  .data-table tbody tr td:first-child:has(.bm-bulk-cb) {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
    padding: 0;
  }
  .data-table tbody tr td:first-child:has(.bm-bulk-cb)::before { display: none; }
  .data-table tbody tr td:first-child:has(.bm-bulk-cb) .bm-unread-dot {
    left: -6px !important;
    height: 22px !important;
  }

  /* Hide the "client telephone" <br><small>…</small> duplication on tiny
     screens — the phone is already in its own chip-row via the action
     buttons (WhatsApp). */
  .data-table tbody tr td small { display: block; color: var(--text-secondary, #64748b); }

  /* Floating bulk toolbar must not overlap the bottom tab bar on iOS. */
  #bmBulkBar {
    bottom: max(22px, env(safe-area-inset-bottom, 22px)) !important;
    width: calc(100% - 32px);
    max-width: 420px;
    justify-content: space-between;
    font-size: .8rem !important;
  }
}

/* ── Mobile-friendly tweaks for the sb-cards layout (already responsive
   but we tighten padding on small screens). ──────────────────────── */
@media (max-width: 560px) {
  .sb-card { padding: 12px 14px; }
  .sb-card-info { grid-template-columns: 1fr !important; }
}
