/* Table Components */
/* Reusable table styles and enhancements */

/* --- Enhanced Table Hover Effects --- */
.table-hover > tbody > tr {
  position: relative;
  transition: background-color 0.2s ease;
  border-left: 2px solid transparent;
}

.table-hover > tbody > tr:hover {
  background-color: rgba(0, 0, 0, 0.015);
  border-left-color: var(--bs-primary);
}

/* Subtle highlight effect */
.table-hover > tbody > tr::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background-color: var(--bs-primary);
  opacity: 0.1;
  transition: width 0.2s ease;
  pointer-events: none;
}

.table-hover > tbody > tr:hover::after {
  width: 100%;
}

/* --- Table Bordered Enhancement --- */
.table-bordered {
  border-color: rgba(0, 0, 0, 0.1);
}

.table-bordered > :not(caption) > * {
  border-color: rgba(0, 0, 0, 0.1);
}

/* --- Table Striped Enhancement --- */
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(0, 0, 0, 0.02);
}

/* --- Compact Table --- */
.table-sm > :not(caption) > * > * {
  padding: 0.4rem;
}

/* --- Responsive Table Enhancement --- */
.table-responsive {
  border-radius: 0.375rem;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* --- Table Actions Column --- */
.table-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* --- Table Status Column --- */
.table-status {
  width: 120px;
}

/* --- Table Priority Column --- */
.table-priority {
  width: 100px;
}

/* --- Table Date Column --- */
.table-date {
  width: 150px;
  white-space: nowrap;
}

/* --- Table Cell Ellipsis --- */
.table-cell-ellipsis {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Table Header Sorting --- */
.table-sortable th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.5rem;
}

.table-sortable th:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.table-sortable th.sorted-asc::after {
  content: '▲';
  position: absolute;
  right: 0.5rem;
  font-size: 0.75rem;
  color: var(--bs-primary);
}

.table-sortable th.sorted-desc::after {
  content: '▼';
  position: absolute;
  right: 0.5rem;
  font-size: 0.75rem;
  color: var(--bs-primary);
}

/* --- Fixed Header Table --- */
.table-fixed-header {
  overflow-y: auto;
  max-height: 500px;
}

.table-fixed-header thead th {
  position: sticky;
  top: 0;
  background-color: var(--bs-body-bg);
  z-index: 10;
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

/* --- Table Loading State --- */
.table-loading {
  position: relative;
  min-height: 200px;
}

.table-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: table-spinner 0.8s linear infinite;
}

@keyframes table-spinner {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* --- Table Empty State --- */
.table-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--bs-secondary);
}

.table-empty i,
.table-empty .bi {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* --- Table Card Style --- */
.table-card {
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0.5rem;
  overflow: hidden;
}

.table-card .table {
  margin-bottom: 0;
}

.table-card .table thead {
  background-color: rgba(0, 0, 0, 0.02);
}

/* --- Table Checkbox Column --- */
.table-checkbox {
  width: 40px;
  text-align: center;
}

.table-checkbox input[type="checkbox"] {
  cursor: pointer;
}

/* --- Table Row Selected State --- */
.table-row-selected {
  background-color: rgba(13, 110, 253, 0.08) !important;
  border-left-color: var(--bs-primary) !important;
}

/* --- Table Footer --- */
.table tfoot {
  background-color: rgba(0, 0, 0, 0.02);
  font-weight: 500;
}

/* --- Table Badges in Cells --- */
.table td .badge {
  font-size: 0.75rem;
}

/* --- Table Avatar in Cells --- */
.table td .avatar-sm {
  vertical-align: middle;
}

/* --- Responsive Table Scroll Hint --- */
.table-responsive::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.05));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.table-responsive:not(.scrolled-end)::after {
  opacity: 1;
}

/* --- Table Pagination Integration --- */
.table-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.table-wrapper .pagination {
  margin: 0;
  justify-content: center;
}

/* --- Dark Mode Support for Tables --- */
[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .table-hover > tbody > tr::after {
  background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table-bordered {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table-bordered > :not(caption) > * {
  border-color: rgba(255, 255, 255, 0.1);
}
