/* ============================================
   MODERN BOOTSTRAP TABLE TRANSFORMATION
   ============================================ */

/* --- Base Table Styles --- */
.table {
  --table-border-radius: 12px;
  --table-header-bg: linear-gradient(135deg, #f8fafc, #f1f5f9);
  --table-row-hover: rgba(59, 130, 246, 0.04);
  --table-row-active: rgba(59, 130, 246, 0.08);
  --table-stripe: rgba(248, 250, 252, 0.6);
  --table-border-color: rgba(226, 232, 240, 0.6);
  --table-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  color: #475569;
}

/* Table wrapper for rounded corners and shadow */
.table-responsive {
  border-radius: var(--table-border-radius);
  box-shadow: var(--table-shadow);
  background: #ffffff;
  border: 1px solid var(--table-border-color);
  /* overflow: hidden; */
}

.table-responsive .table {
  box-shadow: none;
  border: none;
}

/* --- Table Header --- */
.table thead th {
  background: var(--table-header-bg);
  color: #334155;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--table-border-color);
  border-top: none;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.table thead th:first-child {
  border-top-left-radius: var(--table-border-radius);
}

.table thead th:last-child {
  border-top-right-radius: var(--table-border-radius);
}

/* Sortable header indicator */
.table thead th.sortable,
.table thead th[onclick] {
  cursor: pointer;
  transition: background 0.2s ease;
}

.table thead th.sortable:hover,
.table thead th[onclick]:hover {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  color: #1e293b;
}

.table thead th.sortable::after,
.table thead th[onclick]::after {
  content: '↕';
  margin-left: 0.5rem;
  opacity: 0.3;
  font-size: 0.75rem;
  font-weight: 400;
}

.table thead th.sort-asc::after {
  content: '↑';
  opacity: 1;
  color: #3b82f6;
}

.table thead th.sort-desc::after {
  content: '↓';
  opacity: 1;
  color: #3b82f6;
}

/* --- Table Body --- */
.table tbody td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--table-border-color);
  transition: all 0.2s ease;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--table-border-radius);
}

.table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--table-border-radius);
}

/* Row hover effect */
.table tbody tr:hover {
  background: var(--table-row-hover);
  transform: scale(1.002);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  z-index: 1;
  position: relative;
}

/* Row active/selected */
.table tbody tr.active,
.table tbody tr.selected {
  background: var(--table-row-active);
  box-shadow: inset 3px 0 0 #3b82f6;
}

/* Striped rows */
.table-striped tbody tr:nth-of-type(odd) {
  background: var(--table-stripe);
}

.table-striped tbody tr:nth-of-type(odd):hover {
  background: var(--table-row-hover);
}

/* --- Table Footer --- */
.table tfoot td,
.table tfoot th {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  font-weight: 600;
  color: #334155;
  padding: 0.875rem 1.25rem;
  border-top: 2px solid var(--table-border-color);
  border-bottom: none;
}

/* --- Table Variants --- */

/* Bordered table */
.table-bordered {
  border: 1px solid var(--table-border-color);
}

.table-bordered thead th,
.table-bordered tbody td {
  border: 1px solid var(--table-border-color);
}

/* Borderless table */
.table-borderless thead th,
.table-borderless tbody td {
  border: none;
}

.table-borderless tbody tr:hover {
  box-shadow: none;
  transform: none;
}

/* Small table */
.table-sm thead th {
  padding: 0.625rem 1rem;
  font-size: 0.75rem;
}

.table-sm tbody td {
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
}

/* Large table */
.table-lg thead th {
  padding: 1.25rem 1.5rem;
  font-size: 0.85rem;
}

.table-lg tbody td {
  padding: 1.25rem 1.5rem;
  font-size: 0.9375rem;
}

/* --- Status/Pill Badges in Tables --- */
.table .badge,
.table .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.table .badge::before,
.table .status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Status colors */
.status-active,
.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.status-active::before,
.badge-success::before {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.status-pending,
.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.status-pending::before,
.badge-warning::before {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.status-inactive,
.badge-secondary {
  background: rgba(148, 163, 184, 0.1);
  color: #64748b;
}

.status-inactive::before,
.badge-secondary::before {
  background: #94a3b8;
}

.status-danger,
.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.status-danger::before,
.badge-danger::before {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.status-info,
.badge-info {
  background: rgba(6, 182, 212, 0.1);
  color: #0891b2;
}

.status-info::before,
.badge-info::before {
  background: #06b6d4;
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.4);
}

/* --- Action Buttons in Tables --- */
.table .btn-action {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #64748b;
  transition: all 0.2s ease;
  cursor: pointer;
}

.table .btn-action:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  transform: translateY(-2px);
}

.table .btn-action.btn-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.table .btn-action.btn-edit:hover {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.table .btn-action.btn-view:hover {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

/* Action group */
.table .action-group {
  display: flex;
  gap: 0.25rem;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.table tbody tr:hover .action-group {
  opacity: 1;
}

/* --- Avatar/Images in Tables --- */
.table .avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table .avatar-group {
  display: flex;
  align-items: center;
}

.table .avatar-group .avatar {
  margin-left: -8px;
  border: 2px solid #ffffff;
  transition: transform 0.2s ease;
}

.table .avatar-group .avatar:first-child {
  margin-left: 0;
}

.table .avatar-group:hover .avatar {
  margin-left: 2px;
}

.table .avatar-group:hover .avatar:first-child {
  margin-left: 0;
}

/* --- Progress Bars in Tables --- */
.table .progress {
  height: 6px;
  border-radius: 100px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.table .progress-bar {
  border-radius: 100px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  transition: width 0.6s ease;
}

/* --- Checkbox Column --- */
.table .checkbox-col {
  width: 48px;
  text-align: center;
}

.table .form-check-input {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.table .form-check-input:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* --- Empty State --- */
.table-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: #94a3b8;
}

.table-empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.table-empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.5rem;
}

/* --- Loading State --- */
.table-loading {
  position: relative;
  min-height: 200px;
}

.table-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: table-spin 0.8s linear infinite;
}

@keyframes table-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Skeleton loading rows */
.table-skeleton tbody tr td {
  position: relative;
  overflow: hidden;
}

.table-skeleton tbody tr td::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 1.25rem;
  right: 1.25rem;
  height: 12px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  transform: translateY(-50%);
  animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   DARK THEME OVERRIDES
   ============================================ */

[data-pc-theme="dark"] .table {
  --table-header-bg: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  --table-row-hover: rgba(96, 165, 250, 0.06);
  --table-row-active: rgba(96, 165, 250, 0.1);
  --table-stripe: rgba(255, 255, 255, 0.02);
  --table-border-color: rgba(255, 255, 255, 0.06);
  --table-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.03);
  color: #bfbfbf;
}

[data-pc-theme="dark"] .table-responsive {
  background: rgba(17, 26, 49, 0.6);
  border-color: var(--table-border-color);
}

[data-pc-theme="dark"] .table thead th {
  color: #e2e8f0;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-pc-theme="dark"] .table thead th.sortable:hover,
[data-pc-theme="dark"] .table thead th[onclick]:hover {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(51, 65, 85, 0.8));
  color: #f1f5f9;
}

[data-pc-theme="dark"] .table thead th.sort-asc::after,
[data-pc-theme="dark"] .table thead th.sort-desc::after {
  color: #60a5fa;
}

[data-pc-theme="dark"] .table tbody td {
  border-bottom-color: var(--table-border-color);
}

[data-pc-theme="dark"] .table tbody tr:hover {
  background: var(--table-row-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-pc-theme="dark"] .table tbody tr.active,
[data-pc-theme="dark"] .table tbody tr.selected {
  background: var(--table-row-active);
  box-shadow: inset 3px 0 0 #60a5fa;
}

[data-pc-theme="dark"] .table tfoot td,
[data-pc-theme="dark"] .table tfoot th {
  background: var(--table-header-bg);
  color: #e2e8f0;
  border-top-color: rgba(255, 255, 255, 0.08);
}

/* Dark theme status badges */
[data-pc-theme="dark"] .status-active,
[data-pc-theme="dark"] .badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

[data-pc-theme="dark"] .status-active::before,
[data-pc-theme="dark"] .badge-success::before {
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

[data-pc-theme="dark"] .status-pending,
[data-pc-theme="dark"] .badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

[data-pc-theme="dark"] .status-pending::before,
[data-pc-theme="dark"] .badge-warning::before {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

[data-pc-theme="dark"] .status-inactive,
[data-pc-theme="dark"] .badge-secondary {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

[data-pc-theme="dark"] .status-danger,
[data-pc-theme="dark"] .badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

[data-pc-theme="dark"] .status-danger::before,
[data-pc-theme="dark"] .badge-danger::before {
  background: #f87171;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
}

[data-pc-theme="dark"] .status-info,
[data-pc-theme="dark"] .badge-info {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

[data-pc-theme="dark"] .status-info::before,
[data-pc-theme="dark"] .badge-info::before {
  background: #22d3ee;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}

/* Dark theme action buttons */
[data-pc-theme="dark"] .table .btn-action {
  color: #64748b;
}

[data-pc-theme="dark"] .table .btn-action:hover {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

[data-pc-theme="dark"] .table .btn-action.btn-delete:hover {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

[data-pc-theme="dark"] .table .btn-action.btn-edit:hover {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

[data-pc-theme="dark"] .table .btn-action.btn-view:hover {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

/* Dark theme avatars */
[data-pc-theme="dark"] .table .avatar {
  border-color: rgba(17, 26, 49, 0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Dark theme progress */
[data-pc-theme="dark"] .table .progress {
  background: rgba(255, 255, 255, 0.06);
}

[data-pc-theme="dark"] .table .progress-bar {
  background: linear-gradient(90deg, #60a5fa, #a78bfa);
}

/* Dark theme checkboxes */
[data-pc-theme="dark"] .table .form-check-input {
  border-color: #475569;
  background-color: rgba(15, 23, 42, 0.5);
}

[data-pc-theme="dark"] .table .form-check-input:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Dark theme empty state */
[data-pc-theme="dark"] .table-empty {
  color: #475569;
}

[data-pc-theme="dark"] .table-empty-icon {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(51, 65, 85, 0.6));
}

[data-pc-theme="dark"] .table-empty-title {
  color: #94a3b8;
}

/* Dark theme loading */
[data-pc-theme="dark"] .table-loading::after {
  border-color: rgba(255, 255, 255, 0.1);
  border-top-color: #60a5fa;
}

[data-pc-theme="dark"] .table-skeleton tbody tr td::after {
  background: linear-gradient(90deg, rgba(30, 41, 59, 0.8) 25%, rgba(51, 65, 85, 0.6) 50%, rgba(30, 41, 59, 0.8) 75%);
}

/* ============================================
   TABLE CARD LAYOUT (Alternative)
   ============================================ */

.table-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.table-card .table-card-item {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid var(--table-border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
}

.table-card .table-card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}

.table-card .table-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3b82f6;
  font-size: 1.25rem;
}

.table-card .table-card-content {
  min-width: 0;
}

.table-card .table-card-title {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
  font-size: 0.9375rem;
}

.table-card .table-card-meta {
  color: #64748b;
  font-size: 0.8125rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.table-card .table-card-actions {
  display: flex;
  gap: 0.25rem;
}

[data-pc-theme="dark"] .table-card .table-card-item {
  background: rgba(17, 26, 49, 0.6);
  border-color: rgba(255, 255, 255, 0.06);
}

[data-pc-theme="dark"] .table-card .table-card-item:hover {
  border-color: rgba(96, 165, 250, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

[data-pc-theme="dark"] .table-card .table-card-icon {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(99, 102, 241, 0.15));
  color: #60a5fa;
}

[data-pc-theme="dark"] .table-card .table-card-title {
  color: #e2e8f0;
}

[data-pc-theme="dark"] .table-card .table-card-meta {
  color: #64748b;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 767.98px) {
  .table-responsive {
    border-radius: 12px;
  }
  
  .table thead th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
  }
  
  .table tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.8125rem;
  }
  
  .table .badge,
  .table .status-pill {
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
  }
  
  .table .avatar {
    width: 32px;
    height: 32px;
  }
  
  .table .btn-action {
    width: 28px;
    height: 28px;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .table tbody tr,
  .table tbody td,
  .table .btn-action,
  .table-card .table-card-item {
    transition: none;
  }
  
  .table tbody tr:hover {
    transform: none;
  }
  
  .table-loading::after {
    animation: none;
  }
  
  .table-skeleton tbody tr td::after {
    animation: none;
  }
}