/* ================================================
   TABLES - Professional Data Display
   ================================================ */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-card);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 0.9375rem;
}

/* === TABLE HEADER === */
thead {
  background: var(--bg-subtle);
}

th {
  padding: 1rem 1.125rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-base);
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}

html[data-theme="dark"] thead {
  background: var(--bg-muted);
}

/* === TABLE BODY === */
tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--surface-hover);
}

td {
  padding: 0.875rem 1.125rem;
  color: var(--text-base);
  border-bottom: 1px solid var(--border-base);
}

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

/* === WINNER/HIGHLIGHT CELLS === */
.winner-cell,
td.winner,
.highlight {
  background: var(--success-bg);
  color: var(--success-text);
  font-weight: 600;
}

html[data-theme="dark"] .winner-cell,
html[data-theme="dark"] td.winner,
html[data-theme="dark"] .highlight {
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary-light);
}

/* === COMPARISON TABLES & RESPONSIVE WRAPPERS === */
.table-wrap,
.table-responsive,
.results-table-wrap,
.post-table-wrap,
.data-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
  display: block;
}

.results-table {
  min-width: 600px;
}

.results-table th:first-child,
.results-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface-card);
  z-index: 1;
}

.results-table thead th:first-child {
  background: var(--bg-subtle);
  z-index: 2;
}

html[data-theme="dark"] .results-table th:first-child,
html[data-theme="dark"] .results-table td:first-child {
  background: var(--surface-card);
}

html[data-theme="dark"] .results-table thead th:first-child {
  background: var(--bg-muted);
}

/* === NUTRITIONAL DATA TABLES === */
.nutrition-table {
  margin: 2rem 0;
}

.nutrition-table th {
  text-align: left;
}

.nutrition-table td:nth-child(2),
.nutrition-table td:nth-child(3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 768px) {
  .results-table-wrap {
    margin: 1rem -1.5rem;
    padding: 0 1.5rem;
  }
  
  th, td {
    padding: 0.75rem 0.875rem;
    font-size: 0.875rem;
  }
  
  .nutrition-table th:first-child {
    min-width: 140px;
  }
}

/* === STRIPED TABLES === */
.table-striped tbody tr:nth-child(even) {
  background: var(--bg-subtle);
}

html[data-theme="dark"] .table-striped tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

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

/* === COMPACT TABLES === */
.table-compact th,
.table-compact td {
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
}

/* === DATA ALIGNMENT === */
.text-right {
  text-align: right;
}

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

.numeric {
  font-variant-numeric: tabular-nums;
}
