/* ==========================================================================
   AIRH Data Table — Futuristic Neumorphism
   ========================================================================== */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-bg-primary);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--neu-raised);
  scrollbar-width: thin;
}

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

/* Header */
.table thead {
  border-bottom: none;
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  position: relative;
  user-select: none;
  background: none;
}

.table th.is-sortable { cursor: pointer; transition: color 0.15s; }
.table th.is-sortable:hover { color: var(--color-text-primary); }

.table__sort-icon {
  display: inline-flex;
  margin-left: var(--space-1);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  vertical-align: middle;
  width: 12px;
  height: 12px;
}

.table th.is-sortable:hover .table__sort-icon { opacity: 0.3; }
.table th.is-sorted .table__sort-icon { opacity: 1; color: var(--color-accent); }
.table th.is-sorted-desc .table__sort-icon { transform: rotate(180deg); }

/* Body */
.table td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
  line-height: var(--leading-normal);
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: all 0.15s; }

.table tbody tr:hover {
  box-shadow: var(--neu-inset-sm);
}

.table tbody tr.is-selected {
  background: rgba(35, 131, 226, 0.06);
}

.table tbody tr.is-clickable { cursor: pointer; }

.table tbody tr.is-clickable:active {
  box-shadow: var(--neu-pressed);
}

/* Checkbox */
.table__checkbox-cell { width: 40px; text-align: center; }

.table__checkbox {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--neu-inset-sm);
  transition: all 0.15s;
  position: relative;
  vertical-align: middle;
  background: var(--color-bg-primary);
}

.table__checkbox:hover { box-shadow: var(--neu-inset); }

.table__checkbox:checked {
  background: linear-gradient(135deg, var(--color-accent), #6366f1);
  box-shadow: var(--neu-flat);
}

.table__checkbox:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* Status */
.table__status { display: inline-flex; align-items: center; gap: var(--space-2); }

/* Cell variants */
.table__cell--numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table__cell--actions { text-align: right; white-space: nowrap; }
.table__cell--truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.data-table__cell-avatar { display: flex; align-items: center; gap: var(--space-3); }
.data-table__cell-avatar .avatar { flex-shrink: 0; }
.data-table__cell-avatar span { font-weight: 600; }

/* Density */
.table--compact th, .table--compact td { padding: 6px var(--space-3); }
.table--compact { font-size: var(--text-xs); }
.table--spacious th, .table--spacious td { padding: var(--space-4) var(--space-5); }

/* Pagination — Neumorphic */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  gap: var(--space-4);
}

.table-pagination__info { white-space: nowrap; }
.table-pagination__controls { display: flex; align-items: center; gap: 4px; }

.table-pagination__btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--neu-flat);
  transition: all 0.2s;
}

.table-pagination__btn:hover:not(:disabled) {
  box-shadow: var(--neu-raised-sm);
  color: var(--color-text-primary);
}

.table-pagination__btn:disabled { opacity: 0.3; cursor: not-allowed; }

.table-pagination__btn.is-active {
  background: linear-gradient(135deg, var(--color-accent), #6366f1);
  color: #fff;
  box-shadow: var(--neu-raised-sm);
}

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

.table-pagination__select {
  height: 30px;
  padding: 0 var(--space-6) 0 var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-bg-primary);
  box-shadow: var(--neu-inset-sm);
  font-size: var(--text-xs);
  color: var(--color-text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236B6B6B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

/* Empty State */
.table__empty { text-align: center; padding: var(--space-12) var(--space-4); color: var(--color-text-tertiary); }
.table__empty-icon { width: 40px; height: 40px; margin: 0 auto var(--space-3); opacity: 0.3; }
.table__empty-text { font-size: var(--text-sm); }

/* Responsive */
@media (max-width: 639px) {
  .table-pagination { flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
  .table-pagination__per-page { display: none; }
}
