/**
 * GawangPinas Seller Portal — tables.css
 *
 * Data tables: headers, cells, numeric alignment, row actions,
 * horizontal scrolling on small screens, and pagination.
 */

/* ==========================================================================
   1. TABLE CONTAINER
   Wrapped in .table-wrap so wide tables scroll sideways on phones
   instead of squashing their columns.
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--gp-border);
  border-radius: var(--gp-radius-sm);
  background-color: var(--gp-surface);
}

.table-wrap-flush {
  border: none;
  border-radius: 0 0 var(--gp-radius-sm) var(--gp-radius-sm);
}

/* A table that lives inside a panel card needs no outer box at all. */
.panel-body-flush > .table-wrap {
  border: none;
}

/* ==========================================================================
   2. TABLE STRUCTURE
   ========================================================================== */

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.data-table--wide {
  width: max-content;
  min-width: 100%;
}

.data-table--wide td {
  white-space: nowrap;
  overflow-wrap: normal;
}

.data-table--wide :is(th, td).table-cell-wrap {
  white-space: nowrap;
  overflow-wrap: normal;
}

.data-table--wide .badge {
  white-space: nowrap;
  overflow-wrap: normal;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gp-border);
  vertical-align: middle;
}

/* ModularAdmin/Bootstrap header: no fill, just a heavier rule under the head. */
.data-table thead th {
  padding-top: 11px;
  padding-bottom: 11px;
  border-bottom: 2px solid var(--gp-border-strong);
  background-color: transparent;
  color: var(--gp-text-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover th,
.data-table tbody tr:hover td {
  background-color: var(--gp-surface-2);
}

/* Row headers and plain cells */
.data-table tbody th {
  font-weight: 600;
  color: var(--gp-text-main);
  text-align: left;
}

/* Dates and other short muted values stay on one line */
.data-table td.text-muted {
  white-space: nowrap;
}

/* Numbers line up under each other, always right aligned */
.data-table .num,
.data-table td.num,
.data-table th.num {
  text-align: right;
  white-space: nowrap;
  font-feature-settings: var(--gp-tabular-nums);
  font-variant-numeric: tabular-nums;
}

/* Cells that combine a title and a smaller second line */
.cell-main {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--gp-text-main);
}

.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--gp-text-muted);
}

.cell-note {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gp-text-muted);
}

/* Thumbnail + name cell */
.cell-product {
  display: flex;
  align-items: center;
  gap: var(--gp-space-3);
  min-width: 240px;
}

.thumb {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 1px solid var(--gp-border);
  border-radius: var(--gp-radius-sm);
  background-color: var(--gp-surface-2);
  object-fit: cover;
}

.thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gp-text-faint);
}

.thumb-empty .material-symbols-outlined {
  font-size: 20px;
}

/* Buttons at the end of a row */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--gp-space-2);
}

/* Stock level cell: dot plus quantity */
.stock-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--gp-space-2);
  white-space: nowrap;
}

/* ==========================================================================
   3. PAGINATION
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gp-space-3);
  margin-top: var(--gp-space-4);
  font-size: 0.875rem;
  color: var(--gp-text-muted);
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: var(--gp-space-1);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--gp-space-2);
  border: 1px solid var(--gp-border);
  border-radius: var(--gp-radius-sm);
  background-color: var(--gp-surface);
  color: var(--gp-text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
}

.page-btn:hover:not(:disabled) {
  background-color: var(--gp-surface-2);
  color: var(--gp-text-main);
}

.page-btn.is-active {
  background-color: var(--gp-primary);
  border-color: var(--gp-primary);
  color: #ffffff;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-gap {
  padding: 0 var(--gp-space-1);
  color: var(--gp-text-faint);
}

@media (max-width: 640px) {
  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-pages {
    justify-content: center;
  }
}

/* Each field stays in its own column; the wrapper handles narrow screens. */
.data-table :is(th, td) { white-space: nowrap; overflow-wrap: normal; }
