/* ============================================================
   IPCLUB — DataTables Custom CSS (docs/design.md §3.3, Rule #4)
   Outer padding + Desktop table / Mobile card transformation.
   Opt-in per listing page: wrap the table in .ip-dt-wrapper-card
   and give the <table> class .ip-datatable (data-label attributes
   are injected automatically by datatable-init.js).
   Requires tokens.css.
   ============================================================ */

/* 1. Outer Padded Shell */
.ip-dt-wrapper-card {
  background: var(--ip-bg-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-card);
  padding: 16px;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.04);
  margin-bottom: 24px;
}

.ip-dt-wrapper-card .table-responsive {
  padding: 0 !important;
  overflow-x: auto;
}

/* DataTables Top Controls (Length & Search) */
.ip-dt-wrapper-card .dataTables_wrapper .dataTables_filter input,
.ip-dt-wrapper-card .dataTables_wrapper .dataTables_length select {
  height: var(--ip-control-height);
  border: 1px solid var(--ip-border-input);
  border-radius: var(--ip-radius-control);
  padding: 0 14px;
  background-color: var(--ip-bg-surface);
  font-size: 0.875rem;
}

/* Desktop Table Polish */
table.ip-datatable {
  width: 100% !important;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 16px !important;
}

table.ip-datatable thead th {
  background: var(--ip-bg-elevated);
  color: #475569;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ip-border);
}

table.ip-datatable tbody td {
  padding: 16px;
  vertical-align: middle;
  border-bottom: 1px solid #F1F5F9;
  color: #1E293B;
  font-size: 0.9rem;
}

/* 2. Mobile Card View Transformation (< 768px) */
@media screen and (max-width: 767.98px) {
  .ip-dt-wrapper-card {
    padding: 16px; /* Outer padding preserved on mobile container */
    background: transparent;
    border: none;
    box-shadow: none;
  }

  table.ip-datatable thead {
    display: none; /* Hide table headers on mobile */
  }

  table.ip-datatable,
  table.ip-datatable tbody {
    display: block;
    width: 100%;
  }

  table.ip-datatable tbody tr {
    display: block;
    background: var(--ip-bg-surface);
    border: 1px solid var(--ip-border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  }

  table.ip-datatable tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed #E2E8F0;
    text-align: right;
    gap: 12px;
  }

  table.ip-datatable tbody td:last-child {
    border-bottom: none;
    padding-top: 14px;
    justify-content: flex-end;
  }

  /* Inject column header label on the left side of each card row */
  table.ip-datatable tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748B;
    text-align: left;
    flex-shrink: 0;
  }
}
