/* =========================
   TABLE STYLES
   ========================= */

/* Container for tables with horizontal scroll on mobile */
.table-container {
  width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Main table styling */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.5s ease-out;
}

/* Table header */
table thead {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
}

table thead th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--primary-dark);
}

/* Table body */
table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: all 0.2s ease;
}

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

table tbody tr:hover {
  background: var(--surface-hover);
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

table tbody td {
  padding: 1rem 1.25rem;
  color: var(--text-primary);
  vertical-align: middle;
}

/* Zebra striping for better readability */
table tbody tr:nth-child(even) {
  background: var(--surface);
}

table tbody tr:nth-child(odd) {
  background: var(--background);
}

/* Numeric column alignment */
table td[align="right"],
table th[align="right"],
table td.number,
table th.number {
  text-align: right;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}

/* Center aligned columns */
table td[align="center"],
table th[align="center"] {
  text-align: center;
}

/* Responsive table wrapper */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
}

/* Table caption */
table caption {
  padding: 1rem;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-align: left;
  caption-side: top;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Sticky header for long tables */
table.sticky-header thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Special styling for boolean/checkbox columns */
table td:has(input[type="checkbox"]),
table th:has(input[type="checkbox"]) {
  text-align: center;
  width: 60px;
}

/* Code in tables */
table code {
  background: var(--surface-light);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.875em;
  font-family: 'JetBrains Mono', monospace;
}

/* Links in tables */
table a {
  color: var(--primary-color) !important;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

table a:hover {
  color: var(--primary-dark) !important;
  text-decoration: underline;
}

/* Table footer */
table tfoot {
  background: var(--surface);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

table tfoot td {
  padding: 1rem 1.25rem;
}

/* Small tables */
table.compact {
  font-size: 0.875rem;
}

table.compact td,
table.compact th {
  padding: 0.5rem 0.75rem;
}

/* Table with borders */
table.bordered {
  border: 1px solid var(--border);
}

table.bordered td,
table.bordered th {
  border: 1px solid var(--border);
}

/* Sortable table headers */
table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 2rem;
}

table th.sortable::after {
  content: "⇅";
  position: absolute;
  right: 0.5rem;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

table th.sortable:hover::after {
  opacity: 1;
}

/* Responsive design for tables */
@media (max-width: 768px) {
  table {
    font-size: 0.875rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  table thead {
    display: table-header-group;
  }
  
  table tbody {
    display: table-row-group;
  }
  
  table th,
  table td {
    padding: 0.75rem;
    min-width: 100px;
  }
}

/* Print styles for tables */
@media print {
  table {
    page-break-inside: avoid;
    border: 1px solid black;
  }
  
  table thead {
    background: #f0f0f0 !important;
    color: black !important;
  }
}
