/**
 * Custom Tabulator Theme for Tailwind + Dark Mode
 * Matches existing Tailwind design system and dark mode colors
 */

/* Override Tabulator defaults to match Tailwind styling */
.tabulator {
  font-size: 0.875rem;
  background-color: white;
  border: 1px solid rgb(229, 231, 235);
  border-radius: 0.5rem;
}

/* Dark mode */
.dark .tabulator {
  background-color: rgb(31, 41, 55);
  border-color: rgb(55, 65, 81);
}

/* Table header styling */
.tabulator .tabulator-header {
  background-color: rgb(241, 245, 249); 
  /* old grey-- background-color: rgb(249, 250, 251); */
  border-bottom: 1px solid rgb(226, 232, 240); 
  /* old grey-- border-bottom: 1px solid rgb(229, 231, 235) */
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.dark .tabulator .tabulator-header {
  background-color: rgb(15, 23, 42) !important;
  border-bottom-color: rgb(30, 41, 59) !important;
}

.dark .tabulator .tabulator-header-contents {
  background-color: rgb(15, 23, 42) !important;
}

/* Column headers */
.tabulator .tabulator-col {
  background-color: rgb(241, 245, 249); 
  /* old grey-- background-color: transparent; */
  border-right: none !important;
}

.tabulator .tabulator-col-content {
  background-color: rgb(241, 245, 249); 
  /* old grey-- background-color: transparent; */
  border-right: none !important;
}

.dark .tabulator .tabulator-col {
  background-color: rgb(15, 23, 42) !important;
}

.dark .tabulator .tabulator-col-content {
  background-color: rgb(15, 23, 42) !important;
  border-right: none !important;
}

.tabulator .tabulator-col-title {
  color: rgb(71, 85, 105); 
  /* old grey-- color: rgb(107, 114, 128) */
  font-weight: 500;
  padding-left: 1rem;
  background-color: rgb(241, 245, 249); 
  /* old grey-- background-color: transparent; */
}

.dark .tabulator .tabulator-col-title {
  color: rgb(148, 163, 184) !important;
  background-color: rgb(15, 23, 42) !important;
}

/* Column resize handle */
/* Expand clickable area while keeping visual border thin and subtle */
.tabulator .tabulator-col-resize-handle {
  position: relative;
  width: 14px !important;
  margin-left: -6px;
  margin-right: -6px;
  cursor: col-resize;
  background-color: transparent;
  z-index: 10;
}

/* Visual border using pseudo-element - centered 2px line, very subtle by default */
.tabulator .tabulator-col-resize-handle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background-color: rgba(156, 163, 175, 0.1);
  transition: background-color 0.2s ease;
  pointer-events: none;
}

.tabulator .tabulator-col-resize-handle:hover::before {
  background-color: rgba(59, 130, 246, 0.7);
}

.dark .tabulator .tabulator-col-resize-handle::before {
  background-color: rgba(75, 85, 99, 0.15);
}

.dark .tabulator .tabulator-col-resize-handle:hover::before {
  background-color: rgba(96, 165, 250, 0.7);
}

/* Sort arrows */
.tabulator-col-sorter {
  color: rgb(156, 163, 175);
}

.tabulator-col-sorter.tabulator-arrow-active {
  color: rgb(59, 130, 246);
}

.dark .tabulator-col-sorter {
  color: rgb(107, 114, 128);
}

.dark .tabulator-col-sorter.tabulator-arrow-active {
  color: rgb(96, 165, 250);
}

/* Table body */
.tabulator .tabulator-tableholder {
  background-color: white;
}

.dark .tabulator .tabulator-tableholder {
  background-color: rgb(31, 41, 55);
}

/* Rows */
.tabulator .tabulator-row {
  background-color: white;
  border-bottom: 1px solid rgb(229, 231, 235);
  color: rgb(17, 24, 39);
}

.dark .tabulator .tabulator-row {
  background-color: rgb(31, 41, 55);
  border-bottom-color: rgb(55, 65, 81);
  color: rgb(243, 244, 246);
}

/* Row hover - apply to all rows, not just selectable ones */
.tabulator .tabulator-row:hover {
  background-color: rgb(249, 250, 251) !important;
}

.dark .tabulator .tabulator-row:hover {
  background-color: rgba(55, 65, 81) !important;
}



/* Cells */
.tabulator .tabulator-cell {
  border-right: none;
  padding: 1rem 1.5rem;
  cursor: default !important;
}

/* Remove pointer cursor from selectable rows unless they're actually clickable */
.tabulator .tabulator-row.tabulator-selectable {
  cursor: default !important;
}

/* Keep pointer cursor only for actual interactive elements */
.tabulator .tabulator-cell a,
.tabulator .tabulator-cell button,
.tabulator .tabulator-cell form button,
.tabulator .tabulator-cell input[type="submit"],
.tabulator .tabulator-cell input[type="button"] {
  cursor: pointer !important;
}

/* Alternating rows (optional) */
.tabulator .tabulator-row.tabulator-row-even {
  background-color: white;
}

.dark .tabulator .tabulator-row.tabulator-row-even {
  background-color: rgb(31, 41, 55);
}

/* Selected rows */
.tabulator .tabulator-row.tabulator-selected {
  background-color: rgb(239, 246, 255);
}

.dark .tabulator .tabulator-row.tabulator-selected {
  background-color: rgba(59, 130, 246, 0.1);
}

/* Pagination */
.tabulator .tabulator-footer {
  background-color: rgb(249, 250, 251);
  border-top: 1px solid rgb(229, 231, 235);
  padding: 1rem;
}

.dark .tabulator .tabulator-footer {
  background-color: rgb(17, 24, 39);
  border-top-color: rgb(55, 65, 81);
}

.tabulator .tabulator-page {
  color: rgb(75, 85, 99);
  background-color: white;
  border: 1px solid rgb(209, 213, 219);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  margin: 0 0.25rem;
  font-size: 0.875rem;
}

.dark .tabulator .tabulator-page {
  color: rgb(209, 213, 219);
  background-color: rgb(55, 65, 81);
  border-color: rgb(75, 85, 99);
}

.tabulator .tabulator-page:hover {
  background-color: rgb(243, 244, 246);
  border-color: rgb(156, 163, 175);
}

.dark .tabulator .tabulator-page:hover {
  background-color: rgb(75, 85, 99);
  border-color: rgb(107, 114, 128);
}

.tabulator .tabulator-page.active {
  background-color: rgb(59, 130, 246);
  color: white;
  border-color: rgb(59, 130, 246);
}

.dark .tabulator .tabulator-page.active {
  background-color: rgb(37, 99, 235);
  border-color: rgb(37, 99, 235);
}

/* Loading overlay */
.tabulator .tabulator-loader {
  background-color: rgba(255, 255, 255, 0.8);
}

.dark .tabulator .tabulator-loader {
  background-color: rgba(17, 24, 39, 0.8);
}

.tabulator .tabulator-loader-msg {
  color: rgb(75, 85, 99);
  font-weight: 500;
}

.dark .tabulator .tabulator-loader-msg {
  color: rgb(209, 213, 219);
}

/* Empty table message */
.tabulator .tabulator-placeholder span {
  color: rgb(107, 114, 128);
  font-size: 1rem;
}

.dark .tabulator .tabulator-placeholder span {
  color: rgb(156, 163, 175);
}

/* Header filters */
.tabulator .tabulator-header-filter input {
  background-color: white;
  border: 1px solid rgb(209, 213, 219);
  border-radius: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: rgb(17, 24, 39);
}

.dark .tabulator .tabulator-header-filter input {
  background-color: rgb(55, 65, 81);
  border-color: rgb(75, 85, 99);
  color: rgb(243, 244, 246);
}

.tabulator .tabulator-header-filter input:focus {
  outline: none;
  border-color: rgb(59, 130, 246);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dark .tabulator .tabulator-header-filter input:focus {
  border-color: rgb(96, 165, 250);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Buttons in cells */
.tabulator .tabulator-cell button,
.tabulator .tabulator-cell a.button {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Scrollbar styling for dark mode */
.dark .tabulator .tabulator-tableholder::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.dark .tabulator .tabulator-tableholder::-webkit-scrollbar-track {
  background: rgb(17, 24, 39);
}

.dark .tabulator .tabulator-tableholder::-webkit-scrollbar-thumb {
  background: rgb(75, 85, 99);
  border-radius: 4px;
}

.dark .tabulator .tabulator-tableholder::-webkit-scrollbar-thumb:hover {
  background: rgb(107, 114, 128);
}

/* Export buttons container (custom addition) */
.tabulator-export-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tabulator-export-buttons button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: rgb(59, 130, 246);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.tabulator-export-buttons button:hover {
  background-color: rgb(37, 99, 235);
}

.dark .tabulator-export-buttons button {
  background-color: rgb(37, 99, 235);
}

.dark .tabulator-export-buttons button:hover {
  background-color: rgb(29, 78, 216);
}

/* ========================================
 * Table-Specific Styles
 * Remove borders and radius for embedded tables
 * ======================================== */
#units-table .tabulator,
#programs-table .tabulator,
#repositories-table .tabulator {
  border-left: none !important;
  border-right: none !important;
  border-radius: 0 !important;
}

/* Center Actions column content for all tables */
#units-table .tabulator-cell[data-field="actions"],
#programs-table .tabulator-cell[data-field="actions"],
#repositories-table .tabulator-cell[data-field="actions"] {
  text-align: center !important;
}

/* ========================================
 * Custom Field Color Utilities
 * Used for company/program custom fields in unit tables
 * ======================================== */

/* Company fields styling - gray text */
.company-field {
  color: rgb(75, 85, 99) !important; /* gray-600 */
}
.dark .company-field {
  color: rgb(156, 163, 175) !important; /* gray-400 */
}

/* Program fields styling - purple text */
.program-field {
  color: rgb(147, 51, 234) !important; /* purple-600 */
}
.dark .program-field {
  color: rgb(192, 132, 252) !important; /* purple-400 */
}

/* Tabulator cell color overrides for custom fields */
.dark .tabulator .text-gray-400 {
  color: rgb(156, 163, 175) !important;
}
.dark .tabulator .text-purple-400 {
  color: rgb(192, 132, 252) !important;
}

/* Responsive table adjustments */
@media (max-width: 768px) {
  .tabulator .tabulator-cell {
    padding: 0.75rem 1rem;
  }
}

