/* --- Desktop & General Table Styling --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 25px 0;
  font-family: inherit;
  font-size: 0.95em;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  background-color: var(--th-card);
  color: var(--th-text-main);
}

table thead tr {
  background-color: var(--th-primary); /* Uses your dynamic admin primary color */
  color: #ffffff; /* White text ensures contrast against the primary color */
  text-align: left;
  font-weight: bold;
}

table th,
table td {
  padding: 12px 15px;
  border: 1px solid var(--th-border);
}

table tbody tr {
  border-bottom: 1px solid var(--th-border);
  background-color: var(--th-card);
  transition: background-color 0.2s ease;
}

/* Zebra striping for readability (uses agnostic alpha transparency to work with any admin bg color) */
table tbody tr:nth-of-type(even) {
  background-color: rgba(128, 128, 128, 0.05);
}

/* Hover effect */
table tbody tr:hover {
  background-color: rgba(128, 128, 128, 0.1);
}

/* Bottom border highlight */
table tbody tr:last-of-type {
  border-bottom: 3px solid var(--th-primary); 
}

/* ========================================= */
/* 🌙 BULLETPROOF DARK MODE OVERRIDES        */
/* ========================================= */
html[data-bs-theme="dark"] table, 
body.dark-mode table {
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  color: #f8f9fa;
  background-color: #1a1d20;
}

html[data-bs-theme="dark"] table thead tr, 
body.dark-mode table thead tr {
  background-color: #0b1120;
  color: #f8f9fa;
  border-bottom: 2px solid var(--th-primary);
}

html[data-bs-theme="dark"] table th,
html[data-bs-theme="dark"] table td,
body.dark-mode table th,
body.dark-mode table td {
  border-color: #374151;
}

html[data-bs-theme="dark"] table tbody tr,
body.dark-mode table tbody tr {
  background-color: #1a1d20;
  border-bottom-color: #374151;
}

/* Subtle dark mode zebra striping */
html[data-bs-theme="dark"] table tbody tr:nth-of-type(even),
body.dark-mode table tbody tr:nth-of-type(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Subtle dark mode hover */
html[data-bs-theme="dark"] table tbody tr:hover,
body.dark-mode table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* --- Mobile Responsive Magic --- */
@media screen and (max-width: 768px) {
  table {
    display: block; /* Forces the table to act like a block container */
    overflow-x: auto; /* Enables horizontal swiping */
    white-space: nowrap; /* Prevents text from breaking layout */
    -webkit-overflow-scrolling: touch; /* Smooth swiping on iPhones */
    border: 1px solid var(--th-border);
  }
  
  html[data-bs-theme="dark"] table, 
  body.dark-mode table {
    border-color: #374151;
  }
  
  table th, 
  table td {
    white-space: nowrap; /* Keeps data on one line so it scrolls cleanly */
  }
}