/**
 * Base data table – display only. No sort, search, or pagination.
 * Use for simple tables that only need to show data (blogs, docs, static lists).
 * For tables that need sorting, search, or pagination, use the DataTables library.
 * Theme-aware; uses CSS variables from base_style.css.
 */

/* Wrapper – use for horizontal scroll on small screens */
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
}

/* Base table */
.data-table,
.dataTables_wrapper .dataTable {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 15px;
  border-radius: 0;
}

.data-table thead,
body.theme-dark .data-table thead,
body.theme-dark .data-table-wrap .data-table thead,
.dataTables_wrapper .dataTable thead,
body.theme-dark .dataTables_wrapper .dataTable thead,
body.theme-dark .dataTables_wrapper .dataTable thead {
  border-radius: 0;
  background:
    linear-gradient(
      180deg,
      rgba(84, 100, 138, 0.98) 0%,
      rgba(44, 56, 84, 0.98) 100%
    ),
    radial-gradient(
      140% 140% at 10% 0%,
      rgba(148, 163, 184, 0.28) 0%,
      rgba(15, 23, 42, 0) 55%
    ) !important;
  color: var(--heading-color);
  box-shadow:
    inset 0 1px 0 rgba(148, 163, 184, 0.22),
    inset 0 -1px 0 rgba(148, 163, 184, 0.32) !important;
}

body.theme-dark .data-table thead th,
body.theme-dark .dataTables_wrapper .dataTable thead th {
  background: rgba(56, 70, 102, 0.98) !important;
}

.data-table thead th,
.dataTables_wrapper .dataTable thead th {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(226, 232, 240, 0.85);
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  text-align: left;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

table.dataTable thead > tr > th div.dt-column-header,
table.dataTable thead > tr > td div.dt-column-header {
  align-items: center;
}

.data-table thead th:first-child,
.dataTables_wrapper .dataTable thead th:first-child {
  padding-left: 20px;
  border-radius: 0;
}

.data-table thead th:last-child,
.dataTables_wrapper .dataTable thead th:last-child {
  padding-right: 20px;
  border-radius: 0;
}

body.theme-light .data-table thead,
body.theme-light .data-table.data-table-sortable thead,
body.theme-light .data-table-wrap .data-table thead,
body.theme-light .dataTables_wrapper .dataTable thead {
  background:
    linear-gradient(
      180deg,
      rgba(190, 214, 245, 1) 0%,
      rgba(164, 192, 232, 1) 100%
    ),
    radial-gradient(
      140% 140% at 10% 0%,
      rgba(99, 102, 241, 0.28) 0%,
      rgba(255, 255, 255, 0) 55%
    ) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 rgba(30, 41, 59, 0.65),
    0 1px 0 rgba(71, 85, 105, 0.35) !important;
}

body.theme-light .data-table thead th,
body.theme-light .dataTables_wrapper .dataTable thead th {
  background: rgba(186, 204, 232, 1) !important;
  color: #1f2937;
}

/* DataTables quick order toggle (timesheet) */
table.dataTable thead .dt-order-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 4px 8px;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--text-color) !important;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 4px;
  box-shadow: none;
  height: 22px;
  position: relative;
  top: 4px;
}

table.dataTable thead .dt-order-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

table.dataTable thead .dt-order-toggle.is-asc,
table.dataTable thead .dt-order-toggle.is-desc {
  border-color: rgba(99, 102, 241, 0.75) !important;
  background: rgba(99, 102, 241, 0.2) !important;
  color: var(--heading-color) !important;
}

table.dataTable thead .dt-order-toggle:hover {
  border-color: rgba(99, 102, 241, 0.55) !important;
  background: transparent !important;
  color: var(--heading-color) !important;
}

body.theme-light table.dataTable thead .dt-order-toggle.is-asc,
body.theme-light table.dataTable thead .dt-order-toggle.is-desc {
  border-color: rgba(59, 130, 246, 0.75) !important;
  background: rgba(59, 130, 246, 0.18) !important;
  color: #111827 !important;
}

body.theme-light table.dataTable thead .dt-order-toggle:hover {
  border-color: rgba(59, 130, 246, 0.5) !important;
  color: #111827 !important;
}

.data-table tbody td,
.dataTables_wrapper .dataTable tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  display: table-cell;
  color: var(--text-color);
}

.data-table tbody tr:nth-child(even),
.dataTables_wrapper .dataTable tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Alignment helpers */
.data-table-align-left thead th,
.data-table-align-left tbody td {
  text-align: left;
}

.data-table-align-center thead th,
.data-table-align-center tbody td {
  text-align: center;
}

.data-table-align-right thead th,
.data-table-align-right tbody td {
  text-align: right;
}

.data-table tbody td:first-child,
.dataTables_wrapper .dataTable tbody td:first-child {
  padding-left: 20px;
}

.data-table tbody td:last-child,
.dataTables_wrapper .dataTable tbody td:last-child {
  padding-right: 20px;
}

.data-table tbody tr:last-child td,
.dataTables_wrapper .dataTable tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover,
.dataTables_wrapper .dataTable tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table tbody tr:hover td,
.dataTables_wrapper .dataTable tbody tr:hover td {
  background: rgba(255, 255, 255, 0.05);
}

body.theme-light .data-table tbody tr:hover,
body.theme-light .dataTables_wrapper .dataTable tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

body.theme-light .data-table tbody tr:nth-child(even),
body.theme-light .dataTables_wrapper .dataTable tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.03);
}

body.theme-light .data-table tbody tr:hover td,
body.theme-light .dataTables_wrapper .dataTable tbody tr:hover td {
  background: rgba(0, 0, 0, 0.04);
}

/* Sortable header */
.data-table.data-table-sortable thead th[data-sort] {
  cursor: pointer;
  padding-right: 16px;
  padding-left: 16px;
}

.data-table.data-table-sortable thead th[data-sort]:hover {
  color: #ffffff;
}

.data-table-sort-icon {
  position: static;
  margin-left: 6px;
  vertical-align: middle;
  color: rgba(148, 163, 184, 0.9);
  opacity: 1;
  display: inline-block;
  position: relative;
  width: 12px;
  height: 14px;
  top: -1px;
}

.data-table-sort-icon::before,
.data-table-sort-icon::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
}

.data-table-sort-icon::before {
  top: 0;
  border-bottom: 6px solid currentColor;
}

.data-table-sort-icon::after {
  bottom: 0;
  border-top: 6px solid currentColor;
}

.data-table
  thead
  th[data-sort]:not([data-sort='asc']):not([data-sort='desc'])
  .data-table-sort-icon::before {
  opacity: 0.5;
}

.data-table
  thead
  th[data-sort]:not([data-sort='asc']):not([data-sort='desc'])
  .data-table-sort-icon::after {
  opacity: 0.5;
}

.data-table thead th[data-sort='asc'] .data-table-sort-icon::before {
  opacity: 1;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.data-table thead th[data-sort='asc'] .data-table-sort-icon::after {
  opacity: 0;
}

.data-table thead th[data-sort='desc'] .data-table-sort-icon::before {
  opacity: 0;
}

.data-table thead th[data-sort='desc'] .data-table-sort-icon::after {
  opacity: 1;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

body.theme-dark .data-table thead th[data-sort='asc'] .data-table-sort-icon,
body.theme-dark .data-table thead th[data-sort='desc'] .data-table-sort-icon {
  color: #ffffff;
}

body.theme-light .data-table thead th[data-sort='asc'] .data-table-sort-icon,
body.theme-light .data-table thead th[data-sort='desc'] .data-table-sort-icon {
  color: #1e293b;
}

body.theme-light
  .data-table
  thead
  th[data-sort]:not([data-sort='asc']):not([data-sort='desc'])
  .data-table-sort-icon {
  color: rgba(71, 85, 105, 0.7);
}

/* Cell typography */
.data-table-cell-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-color);
}

.data-table-cell-muted {
  font-size: 14px;
  color: var(--muted-text);
}

.data-table-cell-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.data-table-cell-icon .fa,
.data-table-cell-icon .fas,
.data-table-cell-icon .far,
.data-table-cell-icon .fab {
  width: 18px;
  text-align: center;
  color: var(--primary-blue);
  flex-shrink: 0;
}

.data-table-cell-image {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.data-table-cell-image img {
  width: 32px;
  height: 32px;
  border-radius: 0;
  object-fit: cover;
  flex-shrink: 0;
}

/* Empty / loading state */
.data-table-empty td,
.data-table-loading td {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted-text);
  font-size: 15px;
}

.data-table-empty td .data-table-empty-icon,
.data-table-loading td .data-table-loading-icon {
  display: block;
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.6;
}

/* Mobile: card layout */
@media (max-width: 767px) {
  .data-table-mobile-cards.data-table-wrap {
    overflow-x: auto;
    min-width: 0;
  }

  .data-table-mobile-cards .data-table {
    min-width: 720px;
  }
}

/* Section title above table (reusable) */
.data-table-section {
  margin-bottom: 24px;
}

.data-table-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--heading-color);
  margin: 0 0 16px 0;
}

.data-table-section-title .fa,
.data-table-section-title .fas {
  color: var(--primary-blue);
  font-size: 20px;
}

/* DataTables UI chrome (search, length, paging, info). */
.dataTables_wrapper,
.dt-container {
  width: 100%;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate,
.dt-length,
.dt-search,
.dt-info,
.dt-paging {
  font-size: 14px;
  color: var(--text-color);
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label,
.dt-length label,
.dt-search label {
  font-weight: 600;
  color: var(--heading-color);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dt-length,
.dt-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.dataTables_wrapper .dataTables_filter,
.dt-search {
  justify-content: flex-end;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input,
.dt-length select,
.dt-search input {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 6px 10px;
  border-radius: 0;
  font-size: 14px;
  outline: none;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus,
.dt-length select:focus,
.dt-search input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.dataTables_wrapper .dataTables_info,
.dt-info {
  margin: 0.75em 0;
  color: var(--muted-text);
}

.dataTables_wrapper .dataTables_paginate,
.dt-paging {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0.75em 0;
  justify-content: flex-end;
}

/* DataTables 2.x layout row (match default layout) */
.dataTables_wrapper .dt-container .dt-layout-row,
.dt-container .dt-layout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 0.75em 0;
  padding: 0 36px;
}

.dataTables_wrapper .dt-container .dt-layout-row .dt-layout-cell,
.dt-container .dt-layout-row .dt-layout-cell {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dataTables_wrapper
  .dt-container
  .dt-layout-row
  .dt-layout-cell.dt-layout-start,
.dt-container .dt-layout-row .dt-layout-cell.dt-layout-start {
  justify-content: flex-start;
  margin-right: auto;
}

.dataTables_wrapper .dt-container .dt-layout-row .dt-layout-cell.dt-layout-end,
.dt-container .dt-layout-row .dt-layout-cell.dt-layout-end {
  justify-content: flex-end;
  margin-left: auto;
}

.dataTables_wrapper .dt-container .dt-layout-row .dt-layout-cell:empty,
.dt-container .dt-layout-row .dt-layout-cell:empty {
  display: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button,
.dataTables_wrapper .dataTables_paginate a.paginate_button,
.dataTables_wrapper .dataTables_paginate button.paginate_button,
.dataTables_wrapper .dataTables_paginate span.paginate_button,
.dataTables_wrapper .dataTables_paginate a,
.dataTables_wrapper .dataTables_paginate button,
.dataTables_wrapper .dataTables_paginate span,
.dt-paging-button {
  padding: 6px 10px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--text-color) !important;
  cursor: pointer;
  font-size: 13px !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover,
.dataTables_wrapper .dataTables_paginate a.paginate_button:hover,
.dataTables_wrapper .dataTables_paginate button.paginate_button:hover,
.dataTables_wrapper .dataTables_paginate span.paginate_button:hover,
.dataTables_wrapper .dataTables_paginate a:hover,
.dataTables_wrapper .dataTables_paginate button:hover,
.dataTables_wrapper .dataTables_paginate span:hover,
.dt-paging-button:hover {
  border-color: var(--primary-blue) !important;
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--heading-color) !important;
}

/* DataTables 2.x paging (nav + dt-paging-button) */
.dataTables_wrapper .dt-paging nav,
.dt-paging nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dataTables_wrapper .dt-paging-button,
.dt-paging .dt-paging-button {
  padding: 4px 8px !important;
  margin: 0 !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--text-color) !important;
  cursor: pointer;
  font-size: 13px !important;
  line-height: 1.2 !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  width: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transform: none !important;
}

.dataTables_wrapper .dt-paging-button:hover,
.dt-paging .dt-paging-button:hover {
  border-color: var(--primary-blue) !important;
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--heading-color) !important;
}

.dataTables_wrapper .dt-paging-button.current,
.dt-paging .dt-paging-button.current {
  border-color: var(--primary-blue) !important;
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--heading-color) !important;
  font-weight: 600;
}

.dataTables_wrapper .dt-paging-button.disabled,
.dt-paging .dt-paging-button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: transparent !important;
  background: transparent !important;
  color: var(--muted-text) !important;
  box-shadow: none !important;
}

/* DataTables header sort icons (asc/desc) */

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate a.paginate_button.current,
.dataTables_wrapper .dataTables_paginate button.paginate_button.current,
.dataTables_wrapper .dataTables_paginate span.paginate_button.current,
.dataTables_wrapper .dataTables_paginate a.current,
.dataTables_wrapper .dataTables_paginate button.current,
.dataTables_wrapper .dataTables_paginate span.current,
.dt-paging-button.current {
  border-color: var(--primary-blue) !important;
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--heading-color) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate a.paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate button.paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate span.paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate a.disabled,
.dataTables_wrapper .dataTables_paginate button.disabled,
.dataTables_wrapper .dataTables_paginate span.disabled,
.dt-paging-button:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: transparent !important;
  background: transparent !important;
  color: var(--muted-text) !important;
  box-shadow: none !important;
}

.dataTables_wrapper .dataTables_processing,
.dt-processing {
  color: var(--muted-text);
  font-size: 14px;
}

@media (max-width: 767px) {
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dt-length,
  .dt-search {
    flex-direction: column;
    align-items: flex-start;
  }

  .dataTables_wrapper .dataTables_paginate,
  .dt-paging {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media screen and (max-width: 767px) {
  .dataTables_wrapper .dt-container .dt-layout-row:not(.dt-layout-table),
  .dt-container .dt-layout-row:not(.dt-layout-table) {
    display: block;
  }

  .dataTables_wrapper
    .dt-container
    .dt-layout-row:not(.dt-layout-table)
    .dt-layout-cell,
  .dt-container .dt-layout-row:not(.dt-layout-table) .dt-layout-cell {
    display: block;
    text-align: center;
  }

  .dataTables_wrapper
    .dt-container
    .dt-layout-row:not(.dt-layout-table)
    .dt-layout-cell
    > *,
  .dt-container .dt-layout-row:not(.dt-layout-table) .dt-layout-cell > * {
    margin: 0.5em 0;
  }

  .dataTables_wrapper
    .dt-container
    .dt-layout-row:not(.dt-layout-table)
    .dt-layout-cell.dt-layout-start,
  .dt-container
    .dt-layout-row:not(.dt-layout-table)
    .dt-layout-cell.dt-layout-start {
    margin-right: 0;
  }

  .dataTables_wrapper
    .dt-container
    .dt-layout-row:not(.dt-layout-table)
    .dt-layout-cell.dt-layout-end,
  .dt-container
    .dt-layout-row:not(.dt-layout-table)
    .dt-layout-cell.dt-layout-end {
    margin-left: 0;
  }
}
