/* ==========================================================================
   Component: Table
   .table, .table__row, .table__cell — dark-themed data table.
   ========================================================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */
.table__head {
  position: sticky;
  top: 0;
  z-index: var(--z-base);
}

.table__head .table__row {
  background-color: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
}

.table__head .table__cell {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  user-select: none;
}

/* Sortable header */
.table__cell--sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

.table__cell--sortable:hover {
  color: var(--text-primary);
}

.table__cell--sorted {
  color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Body
   --------------------------------------------------------------------------- */
.table__body .table__row {
  border-bottom: 1px solid var(--border-muted);
  transition: background-color var(--transition-fast);
}

.table__body .table__row:hover {
  background-color: var(--bg-elevated);
}

.table__body .table__row:last-child {
  border-bottom: none;
}

/* ---------------------------------------------------------------------------
   Cell
   --------------------------------------------------------------------------- */
.table__cell {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  vertical-align: middle;
  color: var(--text-secondary);
}

.table__cell:first-child {
  padding-left: var(--space-4);
}

.table__cell:last-child {
  padding-right: var(--space-4);
}

/* Right-aligned (numbers, prices) */
.table__cell--right {
  text-align: right;
}

/* Center-aligned */
.table__cell--center {
  text-align: center;
}

/* Mono font for numeric values */
.table__cell--mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Compact density */
.table--compact .table__cell {
  padding: var(--space-1) var(--space-2);
}

.table--compact .table__cell:first-child {
  padding-left: var(--space-3);
}

.table--compact .table__cell:last-child {
  padding-right: var(--space-3);
}

/* ---------------------------------------------------------------------------
   Row variants
   --------------------------------------------------------------------------- */
.table__row--success {
  background-color: var(--color-success-bg);
}

.table__row--error {
  background-color: var(--color-error-bg);
}

.table__row--selected {
  background-color: var(--accent-subtle);
}

.table__row--clickable {
  cursor: pointer;
}

/* ---------------------------------------------------------------------------
   Empty state
   --------------------------------------------------------------------------- */
.table__empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------------------------
   Reduced motion
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .table__body .table__row {
    transition: none;
  }
}
