/* ==========================================================================
   Tables - Clean, readable data tables
   ========================================================================== */

.table-container {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.table-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: var(--space-4) var(--space-6);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  text-align: left;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
}

.table th:first-child {
  padding-left: var(--space-6);
}

.table th:last-child {
  padding-right: var(--space-6);
}

.table td {
  padding: var(--space-4) var(--space-6);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.table td:first-child {
  padding-left: var(--space-6);
}

.table td:last-child {
  padding-right: var(--space-6);
}

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

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--color-background);
}

/* Sortable Headers */
.table th.sortable {
  cursor: pointer;
  user-select: none;
}

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

.table th.sortable::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: var(--space-2);
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.3;
}

.table th.sortable.asc::after {
  opacity: 1;
  border-top: none;
  border-bottom: 4px solid currentColor;
}

.table th.sortable.desc::after {
  opacity: 1;
}

/* Cell Variants */
.table-cell-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-cell-center {
  text-align: center;
}

.table-cell-nowrap {
  white-space: nowrap;
}

/* Performance Indicators */
.performance-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.performance-indicator-excellent {
  background: var(--color-green-light);
  color: var(--color-green);
}

.performance-indicator-good {
  background: var(--color-info-bg);
  color: var(--color-blue);
}

.performance-indicator-average {
  background: var(--color-orange-light);
  color: var(--color-orange);
}

.performance-indicator-poor {
  background: var(--color-red-light);
  color: var(--color-red);
}

/* Row Highlighting */
.table-row-highlight {
  background: var(--color-info-bg);
}

.table-row-success {
  background: var(--color-green-light);
}

.table-row-warning {
  background: var(--color-orange-light);
}

.table-row-danger {
  background: var(--color-red-light);
}

/* Compact Table */
.table-compact th,
.table-compact td {
  padding: var(--space-3) var(--space-4);
}

/* Striped Table */
.table-striped tbody tr:nth-child(even) {
  background: var(--color-background);
}

.table-striped tbody tr:nth-child(even):hover {
  background: var(--color-border-light);
}

/* Table Footer */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-light);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.pagination-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.pagination-item:hover {
  background: var(--color-background);
  color: var(--color-text-primary);
}

.pagination-item.active {
  background: var(--color-blue);
  color: var(--color-text-inverse);
}

/* Expandable Row */
.table-row-expandable {
  cursor: pointer;
}

.table-row-expanded {
  background: var(--color-background);
}

.table-row-details {
  padding: var(--space-4) var(--space-6);
  background: var(--color-background);
}

/* Metrics Table (for monthly data) */
.metrics-table .table-cell-value {
  font-variant-numeric: tabular-nums;
  font-weight: var(--font-weight-medium);
}

.metrics-table .table-cell-change {
  font-size: var(--font-size-xs);
}

.metrics-table .table-cell-change-positive {
  color: var(--color-green);
}

.metrics-table .table-cell-change-negative {
  color: var(--color-red);
}
