/**
 * Table Styles - Table layout, headers, and rows
 */

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

.table thead {
  background: var(--gray-50);
}

.table th {
  text-align: left;
  padding: 0.875rem 1rem;
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
}

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

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

/* ========== Column Widths ========== */
.table th:first-child,
.table td:first-child {
  width: auto;
}

.table th:last-child,
.table td:last-child {
  width: auto;
  text-align: right;
}

/* ========== Sortable Headers ========== */
.sort-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.sort-button:hover {
  color: var(--primary-color);
}

.sort-indicator {
  font-size: 0.75rem;
}

.sort-indicator.active {
  color: var(--primary-color);
}

/* ========== Responsive Tables ========== */

/* Tablet: Allow horizontal scroll */
@media (max-width: 1024px) {
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
  }

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

/* Mobile: Card-based layout for better readability */
@media (max-width: 768px) {
  /* Hide standard table on very small screens, show cards instead */
  .table-responsive-cards {
    display: block;
  }

  .table-responsive-cards thead {
    display: none;
  }

  .table-responsive-cards tbody {
    display: block;
  }

  .table-responsive-cards tr {
    display: block;
    margin-bottom: 1rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  .table-responsive-cards tr:hover {
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }

  .table-responsive-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
  }

  .table-responsive-cards td:last-child {
    border-bottom: none;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
  }

  .table-responsive-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .table-responsive-cards td:last-child::before {
    content: "";
  }

  /* Actions should be full width on mobile */
  .table-responsive-cards .table-actions {
    width: 100%;
  }
}

/* Small mobile: Optimize for very small screens */
@media (max-width: 480px) {
  .table-responsive-cards tr {
    padding: 0.75rem;
  }

  .table-responsive-cards td {
    font-size: 0.875rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .table-responsive-cards td::before {
    font-size: 0.75rem;
  }
}
