/* ============================================================
   RosterDive — Page: Roster Users
   Page-specific styles not covered by DS components.
   DS components used: inline-header, filters-bar, toolbar, datatable,
   badge, modal, form-field, alert, button, toast
   Tokens: css/tokens.css

   Responsive (responsive.md §10 Option B): on mobile the 7-column users
   table and the 4-column organizations table of the details modal become
   stacks of cards, one per row. Each cell shows its column header from the
   `data-label` attribute set by roster_users_table.js / roster_users_modals.js
   (i18n keys), so no data is hidden and no horizontal scroll is required.
   ============================================================ */

/* Keep DS vertical rhythm between the warning alert and the confirmation
   field of the delete-user modal. */
#delete-user-modal .form-field {
  margin-top: var(--space-4);
}

@media (max-width: 599px) {
  /* Drop the DS 600px min-width: the tables are no longer grids. */
  #users-table .datatable__table,
  #details-organizations .datatable__table {
    min-width: 0;
  }

  #users-table .datatable__table thead,
  #details-organizations .datatable__table thead {
    display: none;
  }

  #users-table .datatable__table,
  #users-table .datatable__table tbody,
  #users-table .datatable__table tr,
  #users-table .datatable__table td,
  #details-organizations .datatable__table,
  #details-organizations .datatable__table tbody,
  #details-organizations .datatable__table tr,
  #details-organizations .datatable__table td {
    display: block;
    width: 100%;
  }

  #users-table .datatable__table tr,
  #details-organizations .datatable__table tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);
    background: var(--color-surface);
    margin-bottom: var(--space-3);
    padding: var(--space-2) var(--space-3);
  }

  #users-table .datatable__table td,
  #details-organizations .datatable__table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-2) 0;
    text-align: right;
  }

  #users-table .datatable__table tr td:last-child,
  #details-organizations .datatable__table tr td:last-child {
    border-bottom: none;
  }

  #users-table .datatable__table td::before,
  #details-organizations .datatable__table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
    text-align: left;
  }

  /* Long names/organization lists must not force the card wider than the row. */
  #users-table .datatable__table td.datatable__cell--orgs {
    max-width: none;
    overflow-wrap: anywhere;
  }

  /* State rows (loading/empty/error) are not cards: keep the message
     centered and full width, without a column header. */
  #users-table .datatable__table td.datatable__loading,
  #users-table .datatable__table td.datatable__empty,
  #users-table .datatable__table td.datatable__error {
    display: block;
    text-align: center;
    border-bottom: none;
  }

  #users-table .datatable__table td.datatable__loading::before,
  #users-table .datatable__table td.datatable__empty::before,
  #users-table .datatable__table td.datatable__error::before {
    content: none;
  }
}
