/* ═══════════════════════════════════════════════════════════════════════════
   Unified App Table Styles
   Use class="app-table" (optionally inside .app-table-wrap) on any <table>
   to get the consistent look across the whole app.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Optional wrapper: adds border-radius + card-like shadow ── */
.app-table-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  overflow-x: auto;
}

/* ── Base table ── */
.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  margin: 0;
  background: #fff;
}

/* ── Header cells ── */
.app-table thead th,
.app-table thead td {
  background: #f8f9fa !important;
  border-top: none !important;
  border-bottom: 2px solid #dee2e6 !important;
  border-left: none !important;
  border-right: none !important;
  padding: 9px 12px !important;
  text-align: left;
  font-weight: 700 !important;
  font-size: .72rem !important;
  text-transform: uppercase !important;
  letter-spacing: .06em !important;
  color: #555 !important;
  white-space: nowrap;
  user-select: none;
  vertical-align: middle !important;
}

/* ── Body rows ── */
.app-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
}
.app-table tbody tr:last-child {
  border-bottom: none;
}
.app-table tbody tr:hover {
  background: #eef2ff !important;
}

/* ── Body cells ── */
.app-table tbody td {
  padding: 9px 12px;
  vertical-align: middle;
  text-align: left;
  border: none !important;
  border-bottom: 1px solid #f0f0f0 !important;
  color: #2d3748;
}
.app-table tbody tr:last-child td {
  border-bottom: none !important;
}

/* ── Strip Bootstrap's td:first-of-type override for app-table ── */
.app-table td:first-of-type {
  text-align: left;
  display: table-cell;
  vertical-align: middle;
}

/* ── Center-aligned columns (opt-in) ── */
.app-table .col-center,
.app-table th.col-center {
  text-align: center !important;
}
.app-table td.col-center {
  text-align: center !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   DataTables overrides — when DataTables initialises on an .app-table the
   jQuery DataTables plugin wraps the table and adds its own classes;
   these rules ensure everything still matches.
   ───────────────────────────────────────────────────────────────────────── */
table.dataTable.app-table {
  border: none !important;
  border-collapse: collapse !important;
  width: 100% !important;
}
table.dataTable.app-table thead th,
table.dataTable.app-table thead td {
  background: #f8f9fa !important;
  border-bottom: 2px solid #dee2e6 !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  font-weight: 700 !important;
  font-size: .72rem !important;
  text-transform: uppercase !important;
  letter-spacing: .06em !important;
  color: #555 !important;
  padding: 9px 12px !important;
  white-space: nowrap;
}

/* ── DataTables sort indicators — inline ⇅/▲/▼ appended after the label ── */
table.dataTable.app-table thead th.sorting::before,
table.dataTable.app-table thead th.sorting_asc::before,
table.dataTable.app-table thead th.sorting_desc::before {
  display: none !important;
}

/* Unsorted: ⇅ in grey */
table.dataTable.app-table thead th.sorting::after {
  content: ' ⇅' !important;
  font-size: 0.65rem;
  color: #595959;
  opacity: 1 !important;
  position: static !important;
  vertical-align: middle;
}

/* Sorted ascending: ▲ in blue */
table.dataTable.app-table thead th.sorting_asc::after {
  content: ' ▲' !important;
  font-size: 0.6rem;
  color: #1a73e8;
  opacity: 1 !important;
  position: static !important;
  vertical-align: middle;
}

/* Sorted descending: ▼ in blue */
table.dataTable.app-table thead th.sorting_desc::after {
  content: ' ▼' !important;
  font-size: 0.6rem;
  color: #1a73e8;
  opacity: 1 !important;
  position: static !important;
  vertical-align: middle;
}

/* ── Separator: right border between Student column and first data column ── */
table.dataTable.app-table thead th:first-child {
  border-right: 2px solid #dee2e6 !important;
}
table.dataTable.app-table tbody td:first-child {
  border-right: 2px solid #f0f0f0 !important;
  white-space: nowrap;
}

/* ── Body cell borders ── */
table.dataTable.app-table tbody td,
table.dataTable.app-table tbody th {
  border: none !important;
  border-bottom: 1px solid #f0f0f0 !important;
  padding: 9px 12px;
}
table.dataTable.app-table tbody tr:last-child td {
  border-bottom: none !important;
}

/* ── Consistent alternating row colours ──
   DataTables applies stripe to cells (tr.odd > td), not the row element,
   so we must target cells directly.  We also neutralise the order-column
   highlight (sorting_1/2/3) so it doesn't make individual cells darker
   than their neighbours, breaking the visual stripe. ── */
table.dataTable.app-table tbody tr.odd  > td,
table.dataTable.app-table tbody tr.odd  > th {
  background-color: #f5f7fa !important;
}
table.dataTable.app-table tbody tr.even > td,
table.dataTable.app-table tbody tr.even > th {
  background-color: #ffffff !important;
}

/* Neutralise DataTables order-column per-cell highlight so the stripe
   stays consistent across all columns, including the sorted one. */
table.dataTable.app-table.order-column tbody tr.odd  > .sorting_1,
table.dataTable.app-table.order-column tbody tr.odd  > .sorting_2,
table.dataTable.app-table.order-column tbody tr.odd  > .sorting_3 {
  background-color: #f5f7fa !important;
}
table.dataTable.app-table.order-column tbody tr.even > .sorting_1,
table.dataTable.app-table.order-column tbody tr.even > .sorting_2,
table.dataTable.app-table.order-column tbody tr.even > .sorting_3 {
  background-color: #ffffff !important;
}

/* Hover: override both odd and even so neither stripe colour bleeds through */
table.dataTable.app-table tbody tr:hover > td,
table.dataTable.app-table tbody tr:hover > th {
  background-color: #eef2ff !important;
}

/* ── DataTables wrapper: allow horizontal scroll when many columns visible ── */
.dataTables_wrapper {
  overflow-x: auto;
}
.dataTables_wrapper.app-table-wrap {
  padding: 0;
}
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .88rem;
  margin-left: 6px;
}
.dataTables_wrapper .dataTables_length select {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: .88rem;
}

/* ─────────────────────────────────────────────────────────────────────────
   Sort arrows — used in column headers (both DataTable and plain tables).
   ───────────────────────────────────────────────────────────────────────── */
.sort-group,
.th-sort-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.sort-arrows,
.th-sort-arrows {
  display: inline-flex;
  flex-direction: column;
  margin-left: 3px;
  gap: 0;
}
.sort-arrows span,
.th-sort-arrows span {
  line-height: .85;
  font-size: .6rem;
  color: #595959;
  cursor: pointer;
  user-select: none;
}
.sort-arrows span:hover,
.sort-arrows span.active,
.th-sort-arrows span:hover,
.th-sort-arrows span.active {
  color: #1a73e8;
}

/* Disable DataTables' own click-to-sort on the Name column when we handle
   it ourselves — the th gets data-dt-no-sort in table-head.ejs */
table.dataTable thead th[data-dt-no-sort] {
  cursor: default;
}
table.dataTable thead th[data-dt-no-sort]:after {
  display: none !important;
}
